调整新增和编辑奖励
This commit is contained in:
@ -105,6 +105,7 @@ func (s *sReward) Create(ctx context.Context, in *model.RewardCreateIn) (out *mo
|
||||
UserTotalLimit: in.UserTotalLimit,
|
||||
PrizeId: id,
|
||||
Source: in.Source,
|
||||
GrantQuantity: in.GrantQuantity,
|
||||
}).OmitEmptyData().Insert()
|
||||
|
||||
if err != nil {
|
||||
@ -725,6 +726,14 @@ func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *mode
|
||||
return ecode.Params.Sub("该用户暂未绑定8圈账号,无法发放网费奖励")
|
||||
}
|
||||
|
||||
storeId, err := dao.Rewards.Ctx(ctx).WherePri(in.RewardId).Fields(dao.Rewards.Columns().StoreId).Value()
|
||||
if err != nil {
|
||||
return ecode.Fail.Sub("查询奖励信息失败")
|
||||
}
|
||||
if storeId.IsEmpty() {
|
||||
return ecode.Params.Sub("奖励信息有误")
|
||||
}
|
||||
|
||||
// 增加奖励已领取数量
|
||||
_, err = dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.RewardId}).Increment(dao.Rewards.Columns().ReceivedNum, 1)
|
||||
if err != nil {
|
||||
@ -743,7 +752,7 @@ func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *mode
|
||||
if !b {
|
||||
return ecode.Fail.Sub("获取mqtt客户端异常")
|
||||
}
|
||||
downData := emqx.DownData{CMD: consts.CmdUserFee, Data: struct {
|
||||
downData := emqx.DownData{CMD: consts.CmdUserFee, StoreId: storeId.Int(), Data: struct {
|
||||
XyUserId string `json:"xy_user_id"`
|
||||
Money int `json:"money"`
|
||||
Note string `json:"note"`
|
||||
@ -758,7 +767,7 @@ func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *mode
|
||||
if err != nil {
|
||||
return ecode.Fail.Sub("json.Marshal异常")
|
||||
}
|
||||
if err = client.Publish(fmt.Sprintf(consts.DOWNDataTopic, in.StoreId), marshal); err != nil {
|
||||
if err = client.Publish(fmt.Sprintf(consts.DOWNDataTopic, storeId.Int()), marshal); err != nil {
|
||||
return ecode.Fail.Sub("Publish异常")
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user