nft质押任务逻辑
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"nova_task/internal/consts"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ NhSystemConfigModel = (*customNhSystemConfigModel)(nil)
|
||||
@@ -12,6 +16,8 @@ type (
|
||||
// and implement the added methods in customNhSystemConfigModel.
|
||||
NhSystemConfigModel interface {
|
||||
nhSystemConfigModel
|
||||
GetNftStakeTaskOpenDate(ctx context.Context) (start, end time.Time, err error)
|
||||
GetNftStakeTaskConf(ctx context.Context) (conf NftStakeTaskConf, err error)
|
||||
}
|
||||
|
||||
customNhSystemConfigModel struct {
|
||||
@@ -25,3 +31,41 @@ func NewNhSystemConfigModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.
|
||||
defaultNhSystemConfigModel: newNhSystemConfigModel(conn, c, opts...),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *customNhSystemConfigModel) GetNftStakeTaskOpenDate(ctx context.Context) (start, end time.Time, err error) {
|
||||
cf, err := m.FindOneByName(ctx, consts.NftStakeTaskDate)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
dateConf := struct {
|
||||
Start string `json:"start"`
|
||||
End string `json:"end"`
|
||||
}{}
|
||||
err = json.Unmarshal([]byte(cf.Value), &dateConf)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
start, err = time.ParseInLocation(time.DateOnly, dateConf.Start, time.Local)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
end, err = time.ParseInLocation(time.DateOnly, dateConf.End, time.Local)
|
||||
return
|
||||
}
|
||||
|
||||
type NftStakeTaskConf struct {
|
||||
OccupyPercent int `json:"occupy_percent"`
|
||||
LittleTarot int `json:"little_tarot"`
|
||||
GreatTarot int `json:"great_tarot"`
|
||||
MinCoefficient float64 `json:"min_coefficient"`
|
||||
MaxCoefficient float64 `json:"max_coefficient"`
|
||||
}
|
||||
|
||||
func (m *customNhSystemConfigModel) GetNftStakeTaskConf(ctx context.Context) (conf NftStakeTaskConf, err error) {
|
||||
cf, err := m.FindOneByName(ctx, consts.NftStakeTaskConf)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal([]byte(cf.Value), &conf)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user