调整新增和编辑奖励
This commit is contained in:
@ -53,7 +53,7 @@ type CreateReq struct {
|
||||
TotalLimit int `json:"totalLimit" v:"required#奖励总限不能为空" dc:"领取总次数限制"`
|
||||
UserDailyLimit int `json:"userDailyLimit" v:"required#用户每日领取总次数限制" dc:"用户每日领取总次数限制"`
|
||||
UserTotalLimit int `json:"userTotalLimit" v:"required#用户领取总次数限制" dc:"用户领取总次数限制"`
|
||||
GrantQuantify int `json:"grantQuantify" dc:"发放数量"`
|
||||
GrantQuantity int `json:"grantQuantity" dc:"发放数量"`
|
||||
Source int `json:"source" v:"required#来源不能为空" dc:"来源" d:"1"`
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ type UpdateReq struct {
|
||||
TotalLimit int `json:"totalLimit" dc:"领取总次数限制"`
|
||||
UserDailyLimit int `json:"userDailyLimit" dc:"用户每日领取总次数限制"`
|
||||
UserTotalLimit int `json:"userTotalLimit" dc:"用户领取总次数限制"`
|
||||
GrantQuantify int `json:"grantQuantify" dc:"发放数量"`
|
||||
GrantQuantity int `json:"grantQuantity" dc:"发放数量"`
|
||||
Source int `json:"source" v:"required#来源不能为空" dc:"来源" d:"1"`
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.C
|
||||
TotalLimit: int64(req.TotalLimit),
|
||||
UserDailyLimit: int64(req.UserDailyLimit),
|
||||
UserTotalLimit: int64(req.UserTotalLimit),
|
||||
GrantQuantity: int64(req.GrantQuantify),
|
||||
GrantQuantity: int64(req.GrantQuantity),
|
||||
Source: req.Source,
|
||||
})
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ func (c *ControllerV1) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.U
|
||||
TotalLimit: int64(req.TotalLimit),
|
||||
UserDailyLimit: int64(req.UserDailyLimit),
|
||||
UserTotalLimit: int64(req.UserTotalLimit),
|
||||
GrantQuantity: int64(req.GrantQuantify),
|
||||
GrantQuantity: int64(req.GrantQuantity),
|
||||
Source: req.Source,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -105,6 +105,7 @@ func init() {
|
||||
enforcer.AddPolicy("store", "/x/rewardType", "POST", "添加奖励类型")
|
||||
enforcer.AddPolicy("store", "/x/rewardType", "PUT", "更新奖励类型")
|
||||
enforcer.AddPolicy("store", "/x/rewardType/*", "DELETE", "删除奖励类型")
|
||||
enforcer.AddPolicy("store", "/x/reward/netfeeCallback", "POST", "网点充值回调")
|
||||
|
||||
enforcer.AddPolicy("store", "/x/reward", "GET", "获取奖励列表")
|
||||
enforcer.AddPolicy("store", "/x/reward/internetCharge", "GET", "获取网费奖励列表")
|
||||
|
||||
Reference in New Issue
Block a user