调整新增奖励
This commit is contained in:
@ -13,6 +13,7 @@ import (
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
"server/utility/gamelife"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -76,6 +77,9 @@ func (s *sReward) Create(ctx context.Context, in *model.RewardCreateIn) (out *mo
|
||||
}
|
||||
}
|
||||
|
||||
// 券ID-根据时间戳生成
|
||||
id := "Q" + strconv.FormatInt(time.Now().Unix(), 10)
|
||||
|
||||
// 创建奖励
|
||||
_, err = dao.Rewards.Ctx(ctx).Data(do.Rewards{
|
||||
StoreId: in.StoreId,
|
||||
@ -94,6 +98,8 @@ func (s *sReward) Create(ctx context.Context, in *model.RewardCreateIn) (out *mo
|
||||
GameId: in.GameId,
|
||||
UserDailyLimit: in.UserDailyLimit,
|
||||
UserTotalLimit: in.UserTotalLimit,
|
||||
PrizeId: id,
|
||||
Source: in.Source,
|
||||
}).OmitEmptyData().Insert()
|
||||
|
||||
if err != nil {
|
||||
@ -700,15 +706,14 @@ func (s *sReward) CallBack(ctx context.Context, in *model.RewardCallbackIn) (out
|
||||
func (s *sReward) GetUserClaimList(ctx context.Context, in *model.GetUserClaimListIn) (out *model.GetUserClaimListOut, err error) {
|
||||
|
||||
// Initialize result slice
|
||||
rewards := make([]model.Reward, 0)
|
||||
rewards := make([]model.UserClaimReward, 0)
|
||||
var totalCount int
|
||||
|
||||
var userTaskId int64
|
||||
if in.UserTaskId == 0 {
|
||||
value, err := dao.UserTasks.Ctx(ctx).
|
||||
Where(do.UserTasks{UserId: in.UserId, TaskId: in.TaskId}).
|
||||
Fields(dao.UserTasks.Columns().Id).
|
||||
Value()
|
||||
Fields(dao.UserTasks.Columns().Id).Value()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询用户任务失败")
|
||||
}
|
||||
@ -744,7 +749,7 @@ func (s *sReward) GetUserClaimList(ctx context.Context, in *model.GetUserClaimLi
|
||||
}
|
||||
|
||||
// Scan rewards
|
||||
if err = query.Fields(fmt.Sprintf("%s.*", dao.Rewards.Table())).Scan(&rewards); err != nil {
|
||||
if err = query.Fields(fmt.Sprintf("user_task_rewards.reward_id,reward_id, user_task_rewards.status reward_status,user_task_rewards.reward_name reward_name, rewards.*")).WithAll().Scan(&rewards); err != nil {
|
||||
return nil, ecode.Fail.Sub("任务奖励获取失败")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user