修改奖励列表接口返回奖励类型名称
This commit is contained in:
@ -306,7 +306,7 @@ func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model.
|
||||
}
|
||||
|
||||
//
|
||||
array, err := dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Source: 1}).Fields(rewardTypeCols.Id).Array()
|
||||
array, err := dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Source: 2, StoreId: in.StoreId}).Fields(rewardTypeCols.Id).Array()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("获取奖励类型列表失败")
|
||||
}
|
||||
@ -317,7 +317,15 @@ func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model.
|
||||
return nil, ecode.Params.Sub("无效的角色")
|
||||
}
|
||||
|
||||
orm := dao.Rewards.Ctx(ctx).WhereIn(dao.Rewards.Columns().RewardTypeId, rewardTypeIds)
|
||||
orm := dao.Rewards.Ctx(ctx).LeftJoin(
|
||||
dao.RewardTypes.Table(),
|
||||
fmt.Sprintf(
|
||||
"%s.%s = %s.%s",
|
||||
dao.Rewards.Table(), dao.Rewards.Columns().RewardTypeId,
|
||||
dao.RewardTypes.Table(), dao.RewardTypes.Columns().Id,
|
||||
),
|
||||
).Fields(fmt.Sprintf("%s.*,%s.name as reward_type_name", dao.Rewards.Table(), dao.RewardTypes.Table())).
|
||||
WhereIn(dao.Rewards.Columns().RewardTypeId, rewardTypeIds)
|
||||
// ==== 其他查询条件 ====
|
||||
if in.Status != 0 {
|
||||
orm = orm.Where(fmt.Sprintf("%s.%s = ?", dao.Rewards.Table(), rewardCols.Status), in.Status)
|
||||
@ -465,3 +473,31 @@ func (s *sReward) GetGoodsDetails(ctx context.Context, in *model.GetGoodsDetails
|
||||
Water: result.Water,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sReward) OperateTaskReward(ctx context.Context, in *model.OperateTaskRewardIn) (out *model.OperateTaskRewardOut, err error) {
|
||||
// 如果是系统管理员给任务添加奖励,需要校验奖励的来源
|
||||
exist, err := dao.Tasks.Ctx(ctx).Where(do.Tasks{Id: in.TaskId}).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("任务不存在")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("任务不存在")
|
||||
}
|
||||
|
||||
exist, err = dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.RewardId}).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("奖励不存在")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("奖励不存在")
|
||||
}
|
||||
|
||||
opiton := dao.TaskRewards.Ctx(ctx).Data(do.TaskRewards{TaskId: in.TaskId, RewardId: in.RewardId})
|
||||
if in.Type == 1 {
|
||||
_, err := opiton.Insert()
|
||||
return &model.OperateTaskRewardOut{Success: true}, err
|
||||
} else {
|
||||
_, err := opiton.Delete()
|
||||
return &model.OperateTaskRewardOut{Success: true}, err
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ type Reward struct {
|
||||
StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID,系统奖励为NULL"` // 门店ID,系统奖励为NULL
|
||||
Name string `json:"name" orm:"name" description:"奖励名称"` // 奖励名称
|
||||
RewardTypeId int64 `json:"rewardTypeId" orm:"reward_type_id" description:"奖励类型ID,关联 reward_types 表"` // 奖励类型ID,关联 reward_types 表
|
||||
RewardTypeName string `json:"rewardTypeName" orm:"reward_type_name" description:"奖励类型名称"` // 奖励类型名称
|
||||
GameId int64 `json:"gameId" orm:"game_id" description:"游戏ID"` // 游戏ID
|
||||
ImageUrl string `json:"imageUrl" orm:"image_url" description:"奖励图片链接"` // 奖励图片链接
|
||||
QqGoodsId string `json:"qqGoodsId" orm:"qq_goods_id" description:"QQ网吧物品ID"` // QQ网吧物品ID
|
||||
@ -193,3 +194,15 @@ type GetGoodsDetailsIn struct {
|
||||
type GetGoodsDetailsOut struct {
|
||||
Goods Water `json:"goods" dc:"物品详情"`
|
||||
}
|
||||
|
||||
type OperateTaskRewardIn struct {
|
||||
OperatorId int64
|
||||
OperatorRole string
|
||||
TaskId int64
|
||||
RewardId int64
|
||||
Type int // 1: 任务添加奖励 2: 任务删除奖励
|
||||
StoreId int64 // 当前操作门店, 当操作为门店或者是商户时
|
||||
}
|
||||
type OperateTaskRewardOut struct {
|
||||
Success bool
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user