fix: 质押占领矿洞占比

This commit is contained in:
lianghuanjie
2025-01-09 16:33:25 +08:00
parent 6acad51ebd
commit 84d23a295d
2 changed files with 7 additions and 2 deletions

View File

@@ -75,7 +75,7 @@ CREATE TABLE `nh_task_nft_stake_reward`
`award_seq` int NOT NULL COMMENT '派奖序列号',
`pledge_output` decimal(18, 6) NOT NULL DEFAULT 0 COMMENT '质押产出代币',
`random_coefficient` float NOT NULL COMMENT '随机系数',
`occupy_percent` int NOT NULL DEFAULT 100 COMMENT '占领百分比',
`occupy_percent` int NOT NULL DEFAULT 0 COMMENT '占领百分比',
`reward` decimal(18, 6) NOT NULL DEFAULT 0 COMMENT '奖励金额',
`sent` bool NOT NULL DEFAULT false COMMENT '是否已发放',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',

View File

@@ -101,7 +101,12 @@ func (l *StakeSettleLogic) StakeSettle() {
}
tokensDecimal := decimal.NewFromFloat(tokens)
reward := tokensDecimal.Mul(decimal.NewFromFloat(coefficient))
err = l.svcCtx.StakeRewardModel.SetReward(l.ctx, uid, awardSeq, taskConf.OccupyPercent, tokensDecimal, reward)
var gameBonus int
if l.svcCtx.GamePitModel.UserExist(l.ctx, uid) {
gameBonus = taskConf.OccupyPercent
reward = reward.Mul(decimal.NewFromFloat(float64(100+gameBonus) / 100))
}
err = l.svcCtx.StakeRewardModel.SetReward(l.ctx, uid, awardSeq, gameBonus, tokensDecimal, reward)
if err != nil {
logx.Errorw("set reward failed", logx.Field("err", err), logx.Field("uid", uid), logx.Field("awardSeq", awardSeq), logx.Field("coefficient", coefficient), logx.Field("tokens", tokens), logx.Field("reward", reward))
continue