nft stake task logic
This commit is contained in:
@@ -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