软质押增加奖励发放记录
This commit is contained in:
@@ -86,6 +86,11 @@ func (l *GetStakeTaskDetailLogic) GetStakeTaskDetail() (*types.StakeTaskDetail,
|
||||
|
||||
canReceiveTokens *= coefficient
|
||||
|
||||
totalIncomeReward, err := l.svcCtx.StakeRewardModel.CountReward(l.ctx, uid)
|
||||
if err != nil {
|
||||
l.Errorw("count reward failed", logx.Field("err", err), logx.Field("uid", uid))
|
||||
}
|
||||
|
||||
return &types.StakeTaskDetail{
|
||||
StartDate: start.Format(time.DateOnly),
|
||||
EndDate: end.Format(time.DateOnly),
|
||||
@@ -93,5 +98,6 @@ func (l *GetStakeTaskDetailLogic) GetStakeTaskDetail() (*types.StakeTaskDetail,
|
||||
ProduceTokensToday: produceTokensToday,
|
||||
GameBonus: gameBonus,
|
||||
CanReceiveTokens: canReceiveTokens,
|
||||
TotalIncomeTokens: totalIncomeReward,
|
||||
}, nil
|
||||
}
|
||||
|
||||
52
internal/logic/task/stake_reward_list_logic.go
Normal file
52
internal/logic/task/stake_reward_list_logic.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/spf13/cast"
|
||||
"nova_task/internal/pkg/errs"
|
||||
"nova_task/internal/pkg/utils"
|
||||
"time"
|
||||
|
||||
"nova_task/internal/svc"
|
||||
"nova_task/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type StakeRewardListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 质押奖励发放列表
|
||||
func NewStakeRewardListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StakeRewardListLogic {
|
||||
return &StakeRewardListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *StakeRewardListLogic) StakeRewardList() (*types.StakeRewardList, error) {
|
||||
uid := utils.GetUidUint(l.ctx)
|
||||
rws, err := l.svcCtx.StakeRewardModel.FindRewardsByUid(l.ctx, uid)
|
||||
if err != nil {
|
||||
l.Errorw("find rewards by uid failed", logx.Field("err", err))
|
||||
return nil, errs.New(errs.ErrDatabaseOperate, err)
|
||||
}
|
||||
var rs []types.StakeReward
|
||||
for _, rw := range rws {
|
||||
date, err := time.Parse("20060102", cast.ToString(rw.AwardSeq))
|
||||
if err != nil {
|
||||
l.Errorw("parse date failed", logx.Field("err", err), logx.Field("awardSeq", rw.AwardSeq))
|
||||
continue
|
||||
}
|
||||
rs = append(rs, types.StakeReward{
|
||||
Date: date.Format(time.DateOnly),
|
||||
Reward: rw.Reward.InexactFloat64(),
|
||||
})
|
||||
}
|
||||
|
||||
return &types.StakeRewardList{RewardList: rs}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user