nft stake task logic
This commit is contained in:
@@ -6,10 +6,9 @@ import (
|
||||
"nova_task/internal/model"
|
||||
"nova_task/internal/pkg/errs"
|
||||
"nova_task/internal/pkg/utils"
|
||||
"time"
|
||||
|
||||
"nova_task/internal/svc"
|
||||
"nova_task/internal/types"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -53,7 +52,9 @@ func (l *GetNftListLogic) GetNftList() (*types.UserNftList, error) {
|
||||
nft, err := l.svcCtx.StakeNftModel.FindOneByUidTokenId(l.ctx, uid, token)
|
||||
if err == nil {
|
||||
hasStake = nft.State == 1
|
||||
stakeAt = nft.UpdatedAt.Format(time.DateOnly)
|
||||
if hasStake {
|
||||
stakeAt = nft.UpdatedAt.Format(time.DateOnly)
|
||||
}
|
||||
}
|
||||
nftList = append(nftList, types.UserNft{
|
||||
TokenId: token,
|
||||
|
||||
@@ -53,12 +53,35 @@ func (l *GetStakeTaskDetailLogic) GetStakeTaskDetail() (*types.StakeTaskDetail,
|
||||
gameBonus = taskConf.OccupyPercent
|
||||
}
|
||||
|
||||
stakeNfts, err := l.svcCtx.StakeNftModel.FindByUid(l.ctx, uid)
|
||||
if err != nil {
|
||||
l.Errorw("get user stake nft failed", logx.Field("err", err))
|
||||
return nil, errs.New(errs.ErrDatabaseOperate, err)
|
||||
}
|
||||
var produceTokensToday float64
|
||||
for _, sn := range stakeNfts {
|
||||
if sn.State != 1 {
|
||||
continue
|
||||
}
|
||||
if utils.IsBigTarot(sn.TokenId) {
|
||||
produceTokensToday += float64(taskConf.GreatTarot)
|
||||
} else {
|
||||
produceTokensToday += float64(taskConf.LittleTarot)
|
||||
}
|
||||
}
|
||||
var canReceiveTokens float64
|
||||
if gameBonus > 0 {
|
||||
canReceiveTokens = produceTokensToday * float64(100+gameBonus) / 100
|
||||
} else {
|
||||
canReceiveTokens = produceTokensToday
|
||||
}
|
||||
|
||||
return &types.StakeTaskDetail{
|
||||
StartDate: start.Format(time.DateOnly),
|
||||
EndDate: end.Format(time.DateOnly),
|
||||
CountDown: utils.TodayRemainSeconds(),
|
||||
ProduceTokensToday: 0,
|
||||
ProduceTokensToday: produceTokensToday,
|
||||
GameBonus: gameBonus,
|
||||
CanReceiveTokens: 0,
|
||||
CanReceiveTokens: canReceiveTokens,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user