调整回调,奖励领取
This commit is contained in:
@ -222,12 +222,15 @@ type GetLiftReq struct {
|
|||||||
AreaId int `json:"areaId" dc:"大区Id"`
|
AreaId int `json:"areaId" dc:"大区Id"`
|
||||||
RoleIdx string `json:"roleIdx" dc:"角色索引"`
|
RoleIdx string `json:"roleIdx" dc:"角色索引"`
|
||||||
UserTaskId int `json:"userTaskId" v:"required#用户任务记录id不能为空" dc:"用户任务记录"`
|
UserTaskId int `json:"userTaskId" v:"required#用户任务记录id不能为空" dc:"用户任务记录"`
|
||||||
|
GameCode string `json:"gameCode" v:"required#游戏code不能为空" dc:"游戏Code"`
|
||||||
|
Id int64 `in:"path" json:"id" v:"required#ID不能为空" dc:"ID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetLiftRes struct {
|
type GetLiftRes struct {
|
||||||
List interface{} `json:"list" dc:"物品列表"`
|
//List interface{} `json:"list" dc:"物品列表"`
|
||||||
//Result int64 `json:"result" dc:"1-奖励发放成功,2-奖励兑换失败(礼包发放背包环节成功,需要重新引导领奖)3-针对只需要发背包,然后引导用户到人生应用背包领奖的奖励类型,发奖成功了,4-water错误(一般是orderid),不做兑换操作"`
|
Result int64 `json:"result" dc:"1-奖励发放成功,2-奖励兑换失败(礼包发放背包环节成功,需要重新引导领奖)3-针对只需要发背包,然后引导用户到人生应用背包领奖的奖励类型,发奖成功了,4-water错误(一般是orderid),不做兑换操作"`
|
||||||
//Water Water `json:"water" dc:"礼包列表"`
|
//Water Water `json:"water" dc:"礼包列表"`
|
||||||
|
Url string `json:"url" dc:"不为空时需要打开物品背包链接"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetLiftNewRes struct {
|
type GetLiftNewRes struct {
|
||||||
|
|||||||
@ -13,6 +13,7 @@ func (c *ControllerV1) GetLift(ctx context.Context, req *v1.GetLiftReq) (res *v1
|
|||||||
userId := g.RequestFromCtx(ctx).Get("id")
|
userId := g.RequestFromCtx(ctx).Get("id")
|
||||||
out, err := service.Reward().GetLift(ctx, &model.GetRewardIn{
|
out, err := service.Reward().GetLift(ctx, &model.GetRewardIn{
|
||||||
GameId: req.GameId,
|
GameId: req.GameId,
|
||||||
|
GameCode: req.GameCode,
|
||||||
TaskId: req.TaskId,
|
TaskId: req.TaskId,
|
||||||
PopenId: req.PopenId,
|
PopenId: req.PopenId,
|
||||||
RewradTypeId: req.RewardType,
|
RewradTypeId: req.RewardType,
|
||||||
@ -23,12 +24,14 @@ func (c *ControllerV1) GetLift(ctx context.Context, req *v1.GetLiftReq) (res *v1
|
|||||||
UserTaskId: req.UserTaskId,
|
UserTaskId: req.UserTaskId,
|
||||||
UserId: userId.Int(),
|
UserId: userId.Int(),
|
||||||
RewardId: req.RewardId,
|
RewardId: req.RewardId,
|
||||||
|
Id: int(req.Id),
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &v1.GetLiftRes{
|
return &v1.GetLiftRes{
|
||||||
List: out.List,
|
Result: out.Result,
|
||||||
|
Url: out.Url,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,14 +21,18 @@ type TaskRewardsDao struct {
|
|||||||
|
|
||||||
// TaskRewardsColumns defines and stores column names for the table task_rewards.
|
// TaskRewardsColumns defines and stores column names for the table task_rewards.
|
||||||
type TaskRewardsColumns struct {
|
type TaskRewardsColumns struct {
|
||||||
TaskId string // 任务ID
|
TaskId string // 任务ID
|
||||||
RewardId string // 奖励ID
|
RewardId string // 奖励ID
|
||||||
|
NetbarAccount string // 门店网关账号
|
||||||
|
StoreId string // 门店 id
|
||||||
}
|
}
|
||||||
|
|
||||||
// taskRewardsColumns holds the columns for the table task_rewards.
|
// taskRewardsColumns holds the columns for the table task_rewards.
|
||||||
var taskRewardsColumns = TaskRewardsColumns{
|
var taskRewardsColumns = TaskRewardsColumns{
|
||||||
TaskId: "task_id",
|
TaskId: "task_id",
|
||||||
RewardId: "reward_id",
|
RewardId: "reward_id",
|
||||||
|
NetbarAccount: "netbar_account",
|
||||||
|
StoreId: "store_id",
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTaskRewardsDao creates and returns a new DAO object for table data access.
|
// NewTaskRewardsDao creates and returns a new DAO object for table data access.
|
||||||
|
|||||||
@ -33,6 +33,9 @@ type UserTaskRewardsColumns struct {
|
|||||||
UpdatedAt string // 更新时间
|
UpdatedAt string // 更新时间
|
||||||
DeletedAt string // 软删除时间
|
DeletedAt string // 软删除时间
|
||||||
ExpiredAt string // 奖励过期时间
|
ExpiredAt string // 奖励过期时间
|
||||||
|
IssueQuantity string //
|
||||||
|
Source string // 来源 1:系统 2:门店
|
||||||
|
RewardTypeId string // 奖励类型 id
|
||||||
}
|
}
|
||||||
|
|
||||||
// userTaskRewardsColumns holds the columns for the table user_task_rewards.
|
// userTaskRewardsColumns holds the columns for the table user_task_rewards.
|
||||||
@ -49,6 +52,9 @@ var userTaskRewardsColumns = UserTaskRewardsColumns{
|
|||||||
UpdatedAt: "updated_at",
|
UpdatedAt: "updated_at",
|
||||||
DeletedAt: "deleted_at",
|
DeletedAt: "deleted_at",
|
||||||
ExpiredAt: "expired_at",
|
ExpiredAt: "expired_at",
|
||||||
|
IssueQuantity: "issue_quantity",
|
||||||
|
Source: "source",
|
||||||
|
RewardTypeId: "reward_type_id",
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewUserTaskRewardsDao creates and returns a new DAO object for table data access.
|
// NewUserTaskRewardsDao creates and returns a new DAO object for table data access.
|
||||||
|
|||||||
@ -349,14 +349,162 @@ func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetLift 领取奖励
|
// GetLift 领取奖励
|
||||||
|
// func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *model.GetRewardOut, err error) {
|
||||||
|
//
|
||||||
|
// giftParam := model.GiftParam{}
|
||||||
|
// var needUrl bool
|
||||||
|
// // 判断奖励类型
|
||||||
|
// if in.Source == 1 {
|
||||||
|
// // 系统奖励处理
|
||||||
|
// if in.RewradTypeId == 16 {
|
||||||
|
// // 需要大区角色
|
||||||
|
// giftParam.AreaId = in.AreaId
|
||||||
|
// giftParam.Gid = in.GameId
|
||||||
|
// giftParam.RoleIdx = in.RoleIdx
|
||||||
|
// giftParam.TaskId = in.TaskId
|
||||||
|
// } else {
|
||||||
|
// // 不需要
|
||||||
|
// giftParam.TaskId = in.TaskId
|
||||||
|
// giftParam.Gid = in.GameId
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// if in.RewardId != 16 && in.RewardId != 37 {
|
||||||
|
// needUrl = true
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// // 门店奖励处理
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// glog.Info(ctx, "调用 tencent开始")
|
||||||
|
// activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{PopenId: in.PopenId, ServiceName: consts.GetGift, GiftParam: giftParam})
|
||||||
|
//
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// glog.Info(ctx, "调用 tencent结束")
|
||||||
|
// fmt.Print(activity)
|
||||||
|
//
|
||||||
|
// result, ok := activity.(*model.GiftResponse)
|
||||||
|
// if !ok {
|
||||||
|
// return nil, ecode.Fail.Sub("数据类型转换失败")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if len(result.GiftItem) == 0 {
|
||||||
|
// return nil, ecode.Fail.Sub("奖励领取异常")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 存储数据库记录
|
||||||
|
// var data model.GetRewardOut
|
||||||
|
// if err = dao.RewardWaters.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||||
|
// for _, item := range result.GiftItem {
|
||||||
|
// marshal, err := json.Marshal(item.Water)
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("序列化 json 数据出现异常")
|
||||||
|
// }
|
||||||
|
// _, err = dao.RewardWaters.Ctx(ctx).Insert(model.RewardWaters{
|
||||||
|
// OrderId: item.Water.OrderId,
|
||||||
|
// Status: int64(item.Result),
|
||||||
|
// Uid: item.Water.Uid,
|
||||||
|
// Water: string(marshal),
|
||||||
|
// TaskId: in.TaskId,
|
||||||
|
// GameId: int64(in.GameId),
|
||||||
|
// })
|
||||||
|
//
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("添加奖励领取记录异常")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 根据 result判断
|
||||||
|
// data.Result = int64(item.Result)
|
||||||
|
// if item.Result == 1 {
|
||||||
|
// //// 奖励发放成功,修改状态,扣除数量
|
||||||
|
// glog.Infof(ctx, "奖励发放成功1,修改状态,扣除数量")
|
||||||
|
// // 查询当前奖励是否为最后一个, 如果是则更新任务状态为2 完成
|
||||||
|
// count, err := dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: in.UserTaskId}).WhereIn(dao.UserTaskRewards.Columns().Status, []int{2, 3, 5}).Count()
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("查询用户任务奖励失败")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if count == 1 {
|
||||||
|
// // 修改任务记录状态2
|
||||||
|
// _, err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{Id: in.UserTaskId}).Data(do.UserTasks{
|
||||||
|
// Status: 2,
|
||||||
|
// }).Update()
|
||||||
|
//
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("修改用户任务状态失败")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 增加奖励已领取数量
|
||||||
|
// _, err = dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.RewardId}).Increment(dao.Rewards.Columns().ReceivedNum, 1)
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("获取奖励领取记录异常")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 修改用户任务奖励记录状态
|
||||||
|
// _, err = dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: in.UserTaskId, RewardId: in.RewardId}).Data(do.UserTaskRewards{
|
||||||
|
// Status: consts.RewardSuccessStatus,
|
||||||
|
// }).Update()
|
||||||
|
//
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("修改用户任务奖励记录状态异常")
|
||||||
|
// }
|
||||||
|
// } else if item.Result == 2 || item.Result == 3 {
|
||||||
|
// // 发放背包成功,修改状态
|
||||||
|
// glog.Infof(ctx, "奖励发放成功2,修改状态")
|
||||||
|
// _, err = dao.UserTaskRewards.Ctx(ctx).Data(do.UserTaskRewards{
|
||||||
|
// Status: consts.RewardExchangeStatus,
|
||||||
|
// }).Where(do.UserTaskRewards{
|
||||||
|
// Id: in.UserTaskId,
|
||||||
|
// RewardId: in.RewardId,
|
||||||
|
// }).Update()
|
||||||
|
//
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("修改用户任务奖励记录状态异常")
|
||||||
|
// }
|
||||||
|
// } else if item.Result == 4 {
|
||||||
|
// // 奖励领取失败,不做操作,直接返回
|
||||||
|
// glog.Infof(ctx, "领取奖励失败")
|
||||||
|
// return ecode.Fail.Sub("领取奖励失败")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //data.List = append(data.List, model.GetRewardNewOut{
|
||||||
|
// // Result: int64(item.Result),
|
||||||
|
// // Water: item.Water,
|
||||||
|
// //})
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return
|
||||||
|
//
|
||||||
|
// }); err != nil {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if needUrl {
|
||||||
|
// data.Url, err = gamelife.GetGamelifeClient(ctx).GetGamelifePackageUrl(ctx, in.PopenId, in.GameCode, in.GameId, in.BindType)
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, ecode.Fail.Sub("获取绑定链接失败")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //return &model.GetRewardOut{
|
||||||
|
// // List: data.List,
|
||||||
|
// //}, err
|
||||||
|
// return &data, err
|
||||||
|
// }
|
||||||
func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *model.GetRewardOut, err error) {
|
func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *model.GetRewardOut, err error) {
|
||||||
|
out = &model.GetRewardOut{}
|
||||||
giftParam := model.GiftParam{}
|
|
||||||
// 判断奖励类型
|
// 判断奖励类型
|
||||||
if in.Source == 1 {
|
if in.Source == 1 {
|
||||||
// 系统奖励处理
|
var needUrl bool
|
||||||
|
giftParam := model.GiftParam{}
|
||||||
if in.RewradTypeId == 16 {
|
if in.RewradTypeId == 16 {
|
||||||
// 需要大区角色
|
// 需要大区角色
|
||||||
|
if in.AreaId == 0 || in.RoleIdx == "" {
|
||||||
|
return nil, ecode.Params.Sub("获取角色信息失败")
|
||||||
|
}
|
||||||
giftParam.AreaId = in.AreaId
|
giftParam.AreaId = in.AreaId
|
||||||
giftParam.Gid = in.GameId
|
giftParam.Gid = in.GameId
|
||||||
giftParam.RoleIdx = in.RoleIdx
|
giftParam.RoleIdx = in.RoleIdx
|
||||||
@ -366,119 +514,120 @@ func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *mode
|
|||||||
giftParam.TaskId = in.TaskId
|
giftParam.TaskId = in.TaskId
|
||||||
giftParam.Gid = in.GameId
|
giftParam.Gid = in.GameId
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// 门店奖励处理
|
|
||||||
|
|
||||||
}
|
if in.RewradTypeId != 37 && in.RewradTypeId != 16 {
|
||||||
|
needUrl = true
|
||||||
|
}
|
||||||
|
|
||||||
glog.Info(ctx, "调用 tencent开始")
|
glog.Info(ctx, "调用 tencent开始")
|
||||||
activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{PopenId: in.PopenId, ServiceName: consts.GetGift, GiftParam: giftParam})
|
activity, err2 := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{PopenId: in.PopenId, ServiceName: consts.GetGift, GiftParam: giftParam})
|
||||||
|
|
||||||
if err != nil {
|
if err2 != nil {
|
||||||
return nil, err
|
return nil, err2
|
||||||
}
|
}
|
||||||
glog.Info(ctx, "调用 tencent结束")
|
glog.Info(ctx, "调用 tencent结束")
|
||||||
fmt.Print(activity)
|
fmt.Print(activity)
|
||||||
|
|
||||||
result, ok := activity.(*model.GiftResponse)
|
result, ok := activity.(*model.GiftResponse)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, ecode.Fail.Sub("数据类型转换失败")
|
return nil, ecode.Fail.Sub("数据类型转换失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(result.GiftItem) == 0 {
|
if len(result.GiftItem) == 0 {
|
||||||
return nil, ecode.Fail.Sub("奖励领取异常")
|
return nil, ecode.Fail.Sub("奖励领取异常")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 存储数据库记录
|
// 存储数据库记录
|
||||||
var data model.GetRewardOut
|
if err = dao.RewardWaters.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||||
if err = dao.RewardWaters.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
for _, item := range result.GiftItem {
|
||||||
for _, item := range result.GiftItem {
|
marshal, err := json.Marshal(item.Water)
|
||||||
marshal, err := json.Marshal(item.Water)
|
|
||||||
if err != nil {
|
|
||||||
return ecode.Fail.Sub("序列化 json 数据出现异常")
|
|
||||||
}
|
|
||||||
_, err = dao.RewardWaters.Ctx(ctx).Insert(model.RewardWaters{
|
|
||||||
OrderId: item.Water.OrderId,
|
|
||||||
Status: int64(item.Result),
|
|
||||||
Uid: item.Water.Uid,
|
|
||||||
Water: string(marshal),
|
|
||||||
TaskId: in.TaskId,
|
|
||||||
GameId: int64(in.GameId),
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return ecode.Fail.Sub("添加奖励领取记录异常")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据 result判断
|
|
||||||
if item.Result == 1 {
|
|
||||||
//// 奖励发放成功,修改状态,扣除数量
|
|
||||||
glog.Infof(ctx, "奖励发放成功1,修改状态,扣除数量")
|
|
||||||
// 查询当前奖励是否为最后一个, 如果是则更新任务状态为2 完成
|
|
||||||
count, err := dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: in.UserTaskId}).Where(do.UserTaskRewards{Status: 2}).Count()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ecode.Fail.Sub("查询用户任务奖励失败")
|
return ecode.Fail.Sub("序列化 json 数据出现异常")
|
||||||
|
}
|
||||||
|
_, err = dao.RewardWaters.Ctx(ctx).Insert(model.RewardWaters{
|
||||||
|
OrderId: item.Water.OrderId,
|
||||||
|
Status: int64(item.Result),
|
||||||
|
Uid: item.Water.Uid,
|
||||||
|
Water: string(marshal),
|
||||||
|
TaskId: in.TaskId,
|
||||||
|
GameId: int64(in.GameId),
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ecode.Fail.Sub("添加奖励领取记录异常")
|
||||||
}
|
}
|
||||||
|
|
||||||
if count <= 1 {
|
// 根据 result判断
|
||||||
// 修改任务记录状态2
|
out.Result = int64(item.Result)
|
||||||
_, err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{Id: in.UserTaskId}).Data(do.UserTasks{
|
if item.Result == 1 {
|
||||||
Status: 2,
|
//// 奖励发放成功,修改状态,扣除数量
|
||||||
|
glog.Infof(ctx, "奖励发放成功1,修改状态,扣除数量")
|
||||||
|
// 查询当前奖励是否为最后一个, 如果是则更新任务状态为2 完成
|
||||||
|
count, err := dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: in.UserTaskId}).WhereIn(dao.UserTaskRewards.Columns().Status, []int{2, 3, 5}).Count()
|
||||||
|
if err != nil {
|
||||||
|
return ecode.Fail.Sub("查询用户任务奖励失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
if count == 1 {
|
||||||
|
// 修改任务记录状态2
|
||||||
|
_, err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{Id: in.UserTaskId}).Data(do.UserTasks{
|
||||||
|
Status: 2,
|
||||||
|
}).Update()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ecode.Fail.Sub("修改用户任务状态失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if in.Source == 1 && in.RewradTypeId == 37 || in.Source == 2 {
|
||||||
|
// 增加奖励已领取数量
|
||||||
|
_, err = dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.RewardId}).Increment(dao.Rewards.Columns().ReceivedNum, 1)
|
||||||
|
if err != nil {
|
||||||
|
return ecode.Fail.Sub("获取奖励领取记录异常")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改用户任务奖励记录状态
|
||||||
|
_, err = dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{Id: in.Id}).Data(do.UserTaskRewards{
|
||||||
|
Status: consts.RewardSuccessStatus,
|
||||||
|
}).Update()
|
||||||
|
if err != nil {
|
||||||
|
return ecode.Fail.Sub("修改用户任务奖励记录状态异常")
|
||||||
|
}
|
||||||
|
} else if item.Result == 2 || item.Result == 3 {
|
||||||
|
// 发放背包成功,修改状态
|
||||||
|
glog.Infof(ctx, "奖励发放成功2,修改状态")
|
||||||
|
_, err = dao.UserTaskRewards.Ctx(ctx).Data(do.UserTaskRewards{
|
||||||
|
Status: consts.RewardExchangeStatus,
|
||||||
|
}).Where(do.UserTaskRewards{
|
||||||
|
Id: in.Id,
|
||||||
}).Update()
|
}).Update()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ecode.Fail.Sub("修改用户任务状态失败")
|
return ecode.Fail.Sub("修改用户任务奖励记录状态异常")
|
||||||
}
|
}
|
||||||
|
needUrl = true
|
||||||
|
} else if item.Result == 4 {
|
||||||
|
// 奖励领取失败,不做操作,直接返回
|
||||||
|
glog.Infof(ctx, "领取奖励失败")
|
||||||
|
return ecode.Fail.Sub("领取奖励失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 增加奖励已领取数量
|
|
||||||
_, err = dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.RewardId}).Increment(dao.Rewards.Columns().ReceivedNum, 1)
|
|
||||||
if err != nil {
|
|
||||||
return ecode.Fail.Sub("获取奖励领取记录异常")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改用户任务奖励记录状态
|
|
||||||
_, err = dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: in.UserTaskId, RewardId: in.RewardId}).Data(do.UserTaskRewards{
|
|
||||||
Status: consts.RewardSuccessStatus,
|
|
||||||
}).Update()
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return ecode.Fail.Sub("修改用户任务奖励记录状态异常")
|
|
||||||
}
|
|
||||||
} else if item.Result == 2 || item.Result == 3 {
|
|
||||||
// 发放背包成功,修改状态
|
|
||||||
glog.Infof(ctx, "奖励发放成功2,修改状态")
|
|
||||||
_, err = dao.UserTaskRewards.Ctx(ctx).Data(do.UserTaskRewards{
|
|
||||||
Status: consts.RewardExchangeStatus,
|
|
||||||
}).Where(do.UserTaskRewards{
|
|
||||||
Id: in.UserTaskId,
|
|
||||||
RewardId: in.RewardId,
|
|
||||||
}).Update()
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return ecode.Fail.Sub("修改用户任务奖励记录状态异常")
|
|
||||||
}
|
|
||||||
} else if item.Result == 4 {
|
|
||||||
// 奖励领取失败,不做操作,直接返回
|
|
||||||
glog.Infof(ctx, "领取奖励失败")
|
|
||||||
return ecode.Fail.Sub("领取奖励失败")
|
|
||||||
}
|
}
|
||||||
|
return
|
||||||
data.List = append(data.List, model.GetRewardNewOut{
|
}); err != nil {
|
||||||
Result: int64(item.Result),
|
return
|
||||||
Water: item.Water,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
if needUrl {
|
||||||
return
|
out.Url, err = gamelife.GetGamelifeClient(ctx).GetGamelifePackageUrl(ctx, in.PopenId, in.GameCode, in.GameId, in.BindType)
|
||||||
|
if err != nil {
|
||||||
}); err != nil {
|
return nil, ecode.Fail.Sub("获取绑定链接失败")
|
||||||
return
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 门店奖励处理
|
||||||
}
|
}
|
||||||
|
return out, err
|
||||||
return &model.GetRewardOut{
|
|
||||||
List: data.List,
|
|
||||||
}, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetGoodsList 调用外部获取物品列表
|
// GetGoodsList 调用外部获取物品列表
|
||||||
@ -850,12 +999,11 @@ func (s *sReward) CallBack(ctx context.Context, in *model.RewardCallbackIn) (out
|
|||||||
}
|
}
|
||||||
|
|
||||||
//// 回调成功,组装响应参数
|
//// 回调成功,组装响应参数
|
||||||
//var userTaskReward []*model.UserTaskRewards
|
var rewardCallback []model.RewardCallback
|
||||||
//if err = dao.Rewards.Ctx(ctx).Where(dao.Rewards.Columns().PrizeId, in.PrizeId).InnerJoin(dao.UserTaskRewards.Table(), fmt.Sprintf("%s.%s = %s.%s",
|
if err = dao.RewardCallback.Ctx(ctx).Where(dao.RewardCallback.Columns().PrizeId, in.PrizeId).Scan(&rewardCallback); err != nil {
|
||||||
// dao.Rewards.Table(), dao.Rewards.Columns().Id, dao.UserTaskRewards.Table(), dao.UserTaskRewards.Columns().RewardId)).Scan(&userTaskReward); err != nil {
|
return nil, ecode.Fail.Sub("获取用户奖励记录异常")
|
||||||
// return nil, ecode.Fail.Sub("获取用户奖励记录异常")
|
}
|
||||||
//}
|
|
||||||
//
|
|
||||||
//if userTaskReward == nil {
|
//if userTaskReward == nil {
|
||||||
// res.Errcode = -1
|
// res.Errcode = -1
|
||||||
// res.Errmsg = "用户奖励记录为空"
|
// res.Errmsg = "用户奖励记录为空"
|
||||||
@ -864,11 +1012,11 @@ func (s *sReward) CallBack(ctx context.Context, in *model.RewardCallbackIn) (out
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
callbackData := make([]model.CallbackData, 0)
|
callbackData := make([]model.CallbackData, 0)
|
||||||
//for _, v := range userTaskReward {
|
for _, v := range rewardCallback {
|
||||||
callbackData = append(callbackData, model.CallbackData{
|
callbackData = append(callbackData, model.CallbackData{
|
||||||
PrizeCode: "rewardlsseew0rt70db0lhtazmicw50082uudq",
|
PrizeCode: v.InnerOrderId,
|
||||||
})
|
})
|
||||||
//}
|
}
|
||||||
|
|
||||||
res.Datas = callbackData
|
res.Datas = callbackData
|
||||||
|
|
||||||
@ -878,55 +1026,13 @@ 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) {
|
func (s *sReward) GetUserClaimList(ctx context.Context, in *model.GetUserClaimListIn) (out *model.GetUserClaimListOut, err error) {
|
||||||
|
|
||||||
// Initialize result slice
|
// Initialize result slice
|
||||||
rewards := make([]model.UserClaimReward, 0)
|
rewards := make([]model.UserTaskRewards, 0)
|
||||||
var totalCount int
|
var total int
|
||||||
|
if err = dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: in.UserTaskId}).ScanAndCount(&rewards, &total, false); err != nil {
|
||||||
var userTaskId int64
|
return nil, ecode.Fail.Sub("查询用户领取列表异常")
|
||||||
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()
|
|
||||||
if err != nil {
|
|
||||||
return nil, ecode.Fail.Sub("查询用户任务失败")
|
|
||||||
}
|
|
||||||
if value.IsEmpty() {
|
|
||||||
return nil, ecode.Fail.Sub("用户任务不存在")
|
|
||||||
}
|
|
||||||
userTaskId = value.Int64()
|
|
||||||
} else {
|
|
||||||
exist, err := dao.UserTasks.Ctx(ctx).WherePri(in.UserTaskId).Exist()
|
|
||||||
if err != nil || !exist {
|
|
||||||
return nil, ecode.Fail.Sub("用户任务不存在")
|
|
||||||
}
|
|
||||||
userTaskId = in.UserTaskId
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build base query for rewards
|
|
||||||
query := dao.UserTaskRewards.Ctx(ctx).
|
|
||||||
LeftJoin(dao.Rewards.Table(), fmt.Sprintf("%s.%s = %s.%s",
|
|
||||||
dao.Rewards.Table(),
|
|
||||||
dao.Rewards.Columns().Id,
|
|
||||||
dao.UserTaskRewards.Table(),
|
|
||||||
dao.UserTaskRewards.Columns().RewardId)).
|
|
||||||
Where(fmt.Sprintf("%s.%s = ?",
|
|
||||||
dao.UserTaskRewards.Table(),
|
|
||||||
dao.UserTaskRewards.Columns().UserTaskId),
|
|
||||||
userTaskId).
|
|
||||||
Where(dao.UserTaskRewards.Columns().DeletedAt, nil).
|
|
||||||
Where(dao.Rewards.Columns().DeletedAt, nil)
|
|
||||||
|
|
||||||
// Count rewards
|
|
||||||
if totalCount, err = query.Count(); err != nil {
|
|
||||||
return nil, ecode.Fail.Sub("任务奖励获取失败")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scan rewards
|
|
||||||
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("任务奖励获取失败")
|
|
||||||
}
|
|
||||||
|
|
||||||
return &model.GetUserClaimListOut{
|
return &model.GetUserClaimListOut{
|
||||||
List: rewards,
|
List: rewards,
|
||||||
Total: totalCount,
|
Total: total,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gogf/gf/v2/database/gdb"
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
"github.com/gogf/gf/v2/os/glog"
|
"github.com/gogf/gf/v2/os/glog"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
"github.com/gogf/gf/v2/util/gconv"
|
"github.com/gogf/gf/v2/util/gconv"
|
||||||
"github.com/gogf/gf/v2/util/guid"
|
"github.com/gogf/gf/v2/util/guid"
|
||||||
"server/internal/consts"
|
"server/internal/consts"
|
||||||
@ -454,12 +455,353 @@ func (s *sTask) GetUserTaskRecordsList(ctx context.Context, in *model.UserTaskRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetTaskList PC-WEB获取任务列表
|
// GetTaskList PC-WEB获取任务列表
|
||||||
|
//func (s *sTask) GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out *model.GetTaskListV2Out, err error) {
|
||||||
|
// var tasks []model.Task
|
||||||
|
// var pageIdx string
|
||||||
|
// var data []model.GameTask
|
||||||
|
// if in.IsBound == 0 {
|
||||||
|
// // 未绑定游戏查询自己数据库
|
||||||
|
// err := dao.Tasks.Ctx(ctx).Where(do.Tasks{GameId: in.Gid, NetbarAcconut: in.NetBarAccount}).WithAll().WithAll().Scan(&tasks)
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, ecode.Fail.Sub("获取任务列表失败")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// for i, v := range tasks {
|
||||||
|
// err := json.Unmarshal([]byte(v.Task), &tasks[i].GameTask)
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, ecode.Fail.Sub("解析任务信息失败")
|
||||||
|
// }
|
||||||
|
// tasks[i].Task = ""
|
||||||
|
// for _, i3 := range tasks[i].TaskRewards {
|
||||||
|
// tasks[i].GameTask.Reward = append(tasks[i].GameTask.Reward, i3.Rewards)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// for _, prize := range tasks[i].GameTask.PrizeList {
|
||||||
|
// for _, goods := range prize.GoodsList {
|
||||||
|
// if goods.GoodsType != 37 {
|
||||||
|
// tasks[i].GameTask.Reward = append(tasks[i].GameTask.Reward, model.SimpleReward{
|
||||||
|
// Source: 1,
|
||||||
|
// RewardTypeId: int64(goods.GoodsType),
|
||||||
|
// Name: goods.GoodsName,
|
||||||
|
// ImageUrl: goods.GoodsIcon,
|
||||||
|
// TotalLimit: uint64(v.GameTask.LimitNum),
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// data = append(data, tasks[i].GameTask)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return &model.GetTaskListV2Out{
|
||||||
|
// Data: data,
|
||||||
|
// }, nil
|
||||||
|
// } else {
|
||||||
|
// // 已绑定
|
||||||
|
// // 调用外部接口
|
||||||
|
// activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{ServiceName: consts.GetTaskList, PopenId: in.PopenId, BindType: in.BindType, TaskParam: model.TaskParam{Gid: in.Gid, NetBarAccount: in.NetBarAccount, Num: in.Num, Pageidx: in.Pageidx}})
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// result, ok := activity.(*model.GameTaskResponse)
|
||||||
|
// if !ok {
|
||||||
|
// return nil, ecode.Fail.Sub("数据类型转换失败")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// pageIdx = result.PageIdx
|
||||||
|
// // 剔除不需要的任务数据
|
||||||
|
// for i, task := range result.TaskList {
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// // 组装门店奖励数据
|
||||||
|
// err := dao.TaskRewards.Ctx(ctx).
|
||||||
|
// LeftJoin(dao.Rewards.Table(),
|
||||||
|
// fmt.Sprintf("`%s`.`%s` = `%s`.`%s`",
|
||||||
|
// dao.Rewards.Table(), dao.Rewards.Columns().Id,
|
||||||
|
// dao.TaskRewards.Table(), dao.TaskRewards.Columns().RewardId)).
|
||||||
|
// LeftJoin(dao.RewardTypes.Table(),
|
||||||
|
// fmt.Sprintf("`%s`.`%s` = `%s`.`%s`",
|
||||||
|
// dao.RewardTypes.Table(), dao.RewardTypes.Columns().Id,
|
||||||
|
// dao.Rewards.Table(), dao.Rewards.Columns().RewardTypeId)).
|
||||||
|
// Fields(
|
||||||
|
// fmt.Sprintf("%s.*, `%s`.`%s` AS %s",
|
||||||
|
// dao.Rewards.Table(),
|
||||||
|
// dao.RewardTypes.Table(), dao.RewardTypes.Columns().Name,
|
||||||
|
// "reward_type_name",
|
||||||
|
// ),
|
||||||
|
// ).Where(dao.TaskRewards.Columns().TaskId, task.TaskID).Scan(&result.TaskList[i].Reward)
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 尝试转换q 币结构体
|
||||||
|
// //for _, prize := range task.PrizeList {
|
||||||
|
// // for _, goods := range prize.GoodsList {
|
||||||
|
// // if goods.GoodsType != 37 {
|
||||||
|
// // task.Reward = append(task.Reward, model.SimpleReward{
|
||||||
|
// // Source: 1,
|
||||||
|
// // RewardTypeId: int64(goods.GoodsType),
|
||||||
|
// // Name: goods.GoodsName,
|
||||||
|
// // ImageUrl: goods.GoodsIcon,
|
||||||
|
// // TotalLimit: uint64(task.LimitNum),
|
||||||
|
// // })
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
// //}
|
||||||
|
//
|
||||||
|
// //任务状态=1或者2不做操作,其他查询门店奖励是否全部领取
|
||||||
|
// if task.Status != 1 && task.Status != 2 {
|
||||||
|
// count, err := dao.UserTasks.Ctx(ctx).Where(dao.UserTasks.Columns().TaskId, task.TaskID).Where(dao.UserTasks.Columns().UserId, in.UserId).LeftJoin(dao.UserTaskRewards.Table(),
|
||||||
|
// fmt.Sprintf("%s.user_task_id = %s.id", dao.UserTaskRewards.Table(), dao.UserTasks.Table())).LeftJoin(dao.Rewards.Table(), fmt.Sprintf("%s.id = %s.reward_id",
|
||||||
|
// dao.Rewards.Table(), dao.UserTaskRewards.Table())).Where("rewards.source", 2).Where(dao.UserTaskRewards.Columns().Status, 2).Count()
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, ecode.Fail.Sub("查询用户门店任务奖励失败")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if count > 0 {
|
||||||
|
// result.TaskList[i].Status = 2
|
||||||
|
// //tasks[i].Status = 2
|
||||||
|
// } else {
|
||||||
|
// result.TaskList[i].Status = 3
|
||||||
|
// //tasks[i].Status = 3
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //else {
|
||||||
|
// // data.Status = task.Status
|
||||||
|
// //}
|
||||||
|
// //tasks = append(tasks, data)
|
||||||
|
//
|
||||||
|
// // 根据用户完成次数和任务指标次数判任务是否完成,修改任务记录状态为 3
|
||||||
|
// if int(task.UserTimes) >= task.TargetTimes {
|
||||||
|
// if err = dao.UserTasks.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
|
||||||
|
// orm := dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: task.TaskID})
|
||||||
|
// if task.GameTaskConfig.TimeType == 1 {
|
||||||
|
// // 每日任务
|
||||||
|
// start := gtime.Now().StartOfDay()
|
||||||
|
// end := gtime.Now().EndOfDay()
|
||||||
|
// orm = orm.WhereBetween(dao.UserTasks.Columns().CreatedAt, start, end)
|
||||||
|
// }
|
||||||
|
// value, err := orm.Fields(dao.UserTasks.Columns().Id).Value()
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("获取用户任务失败")
|
||||||
|
// }
|
||||||
|
// if value.IsEmpty() {
|
||||||
|
// glog.Info(ctx, "用户任务不存在")
|
||||||
|
// v, err := dao.Stores.Ctx(ctx).Fields(dao.Stores.Columns().Id).Where(do.Stores{NetbarAccount: in.NetBarAccount}).Value()
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("获取门店信息失败")
|
||||||
|
// }
|
||||||
|
// serialNumber, err := snowid.GetSnowClient().GenerateSerialNumber()
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("生成流水号异常")
|
||||||
|
// }
|
||||||
|
// id, err := dao.UserTasks.Ctx(ctx).InsertAndGetId(do.UserTasks{
|
||||||
|
// UserId: in.UserId,
|
||||||
|
// TaskId: task.TaskID,
|
||||||
|
// StoreId: v.Int64(),
|
||||||
|
// Status: 3,
|
||||||
|
// SerialNumber: serialNumber,
|
||||||
|
// TaskName: task.Title,
|
||||||
|
// GameId: in.Gid,
|
||||||
|
// TaskType: task.GameTaskConfig.TimeType,
|
||||||
|
// })
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("创建用户任务记录失败")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 查询该任务相关联的奖励, 创建对应奖励下发记录id
|
||||||
|
// array, err := dao.TaskRewards.Ctx(ctx).LeftJoin(dao.Rewards.Table(), "rewards.id = task_rewards.reward_id").Where(do.TaskRewards{TaskId: task.TaskID}).Fields(dao.TaskRewards.Columns().RewardId).Fields(dao.Rewards.Columns().Name).All()
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("获取任务关联奖励列表失败")
|
||||||
|
// }
|
||||||
|
// for _, v := range array {
|
||||||
|
// _, err = dao.UserTaskRewards.Ctx(ctx).Data(do.UserTaskRewards{
|
||||||
|
// UserTaskId: id,
|
||||||
|
// RewardId: v["reward_id"].Int64(),
|
||||||
|
// RewardName: v["name"].String(),
|
||||||
|
// Status: consts.RewardPendingStatus,
|
||||||
|
// InnerOrderId: fmt.Sprintf("reward%s", guid.S()),
|
||||||
|
// }).Insert()
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("创建用户任务奖励记录失败")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// glog.Info(ctx, "用户任务存在")
|
||||||
|
// _, err = dao.UserTasks.Ctx(ctx).WherePri(value.Int64()).Where(dao.UserTasks.Columns().Status).WhereNot(dao.UserTasks.Columns().Status, 2).Update(do.UserTasks{
|
||||||
|
// Status: 3,
|
||||||
|
// })
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("修改用户任务状态失败")
|
||||||
|
// }
|
||||||
|
// _, err = dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: value.Int()}).Where(dao.UserTaskRewards.Columns().Status, 1).Update(do.UserTaskRewards{
|
||||||
|
// Status: 2,
|
||||||
|
// })
|
||||||
|
// if err != nil {
|
||||||
|
// return ecode.Fail.Sub("修改用户任务奖励状态失败")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return nil
|
||||||
|
// }); err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// data = result.TaskList
|
||||||
|
// return &model.GetTaskListV2Out{
|
||||||
|
// Data: data,
|
||||||
|
// PageIdx: pageIdx,
|
||||||
|
// }, nil
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
func (s *sTask) GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out *model.GetTaskListV2Out, err error) {
|
func (s *sTask) GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out *model.GetTaskListV2Out, err error) {
|
||||||
var tasks []model.Task
|
out = &model.GetTaskListV2Out{}
|
||||||
var pageIdx string
|
if in.IsBound == 1 {
|
||||||
var data []model.GameTask
|
// 查询实时任务数据
|
||||||
if in.IsBound == 0 {
|
activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{ServiceName: consts.GetTaskList, PopenId: in.PopenId, BindType: in.BindType, TaskParam: model.TaskParam{Gid: in.Gid, NetBarAccount: in.NetBarAccount, Num: in.Num, Pageidx: in.Pageidx}})
|
||||||
// 未绑定游戏查询自己数据库
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result, ok := activity.(*model.GameTaskResponse)
|
||||||
|
if !ok {
|
||||||
|
return nil, ecode.Fail.Sub("数据类型转换失败")
|
||||||
|
}
|
||||||
|
for i, v := range result.TaskList {
|
||||||
|
// 获取任务奖励列表
|
||||||
|
err := dao.TaskRewards.Ctx(ctx).Where(do.TaskRewards{TaskId: v.TaskID}).WhereOr(do.TaskRewards{TaskId: v.TaskID, NetbarAccount: in.NetBarAccount}).
|
||||||
|
LeftJoin(dao.Rewards.Table(), "rewards.id = task_rewards.reward_id").Fields("rewards.*").Scan(&result.TaskList[i].Rewards)
|
||||||
|
if err != nil {
|
||||||
|
return nil, ecode.Fail.Sub("获取任务奖励列表失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
if int(v.UserTimes) >= v.TargetTimes {
|
||||||
|
// 判断当前用户完成情况,已完成根据任务、用户,任务类型检查是否存在用户任务记录
|
||||||
|
orm := dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: v.TaskID})
|
||||||
|
if v.GameTaskConfig.TimeType == 1 {
|
||||||
|
// 每日任务
|
||||||
|
start := gtime.Now().StartOfDay()
|
||||||
|
end := gtime.Now().EndOfDay()
|
||||||
|
orm = orm.WhereBetween(dao.UserTasks.Columns().CreatedAt, start, end)
|
||||||
|
}
|
||||||
|
value, err := orm.Fields(dao.UserTasks.Columns().Id).Value()
|
||||||
|
if err != nil {
|
||||||
|
return nil, ecode.Fail.Sub("获取用户任务失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
if value.IsEmpty() {
|
||||||
|
// 不存在创建用户任务完成记录,同时组装用户可领取奖励数据,
|
||||||
|
glog.Info(ctx, "用户不存在创建用户任务完成记录,同时组装用户可领取奖励数据")
|
||||||
|
if err = dao.UserTaskRewards.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||||
|
storeId, err := dao.Stores.Ctx(ctx).Fields(dao.Stores.Columns().Id).Where(do.Stores{NetbarAccount: in.NetBarAccount}).Value()
|
||||||
|
if err != nil {
|
||||||
|
return ecode.Fail.Sub("获取门店信息失败")
|
||||||
|
}
|
||||||
|
if storeId.IsEmpty() {
|
||||||
|
return ecode.Fail.Sub("获取门店信息失败")
|
||||||
|
}
|
||||||
|
serialNumber, err := snowid.GetSnowClient().GenerateSerialNumber()
|
||||||
|
if err != nil {
|
||||||
|
return ecode.Fail.Sub("生成流水号异常")
|
||||||
|
}
|
||||||
|
id, err := dao.UserTasks.Ctx(ctx).Data(do.UserTasks{
|
||||||
|
UserId: in.UserId,
|
||||||
|
TaskId: v.TaskID,
|
||||||
|
StoreId: storeId.Int(),
|
||||||
|
Status: 3,
|
||||||
|
SerialNumber: serialNumber,
|
||||||
|
TaskName: v.Title,
|
||||||
|
GameId: in.Gid,
|
||||||
|
TaskType: v.GameTaskConfig.TimeType,
|
||||||
|
}).InsertAndGetId()
|
||||||
|
if err != nil {
|
||||||
|
return ecode.Fail.Sub("创建用户任务记录失败")
|
||||||
|
}
|
||||||
|
result.TaskList[i].UserTaskId = id
|
||||||
|
insertData := make([]do.UserTaskRewards, 0)
|
||||||
|
// 首先拼装平台奖励
|
||||||
|
for _, prize := range v.PrizeList {
|
||||||
|
for _, goods := range prize.GoodsList {
|
||||||
|
if goods.GoodsType == 37 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
insertData = append(insertData, do.UserTaskRewards{
|
||||||
|
UserTaskId: id,
|
||||||
|
RewardName: goods.GoodsName,
|
||||||
|
Status: consts.RewardPendingStatus,
|
||||||
|
IssueQuantity: goods.Num,
|
||||||
|
Source: 1,
|
||||||
|
RewardTypeId: goods.GoodsType,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 拼装门店奖励数据
|
||||||
|
if len(result.TaskList[i].Rewards) > 0 {
|
||||||
|
for _, reward := range result.TaskList[i].Rewards {
|
||||||
|
in := do.UserTaskRewards{
|
||||||
|
RewardId: reward.Id,
|
||||||
|
UserTaskId: id,
|
||||||
|
RewardName: reward.Name,
|
||||||
|
Status: consts.RewardPendingStatus,
|
||||||
|
IssueQuantity: reward.GrantQuantity,
|
||||||
|
Source: 2,
|
||||||
|
RewardTypeId: reward.RewardTypeId,
|
||||||
|
}
|
||||||
|
if reward.RewardTypeId == 37 {
|
||||||
|
in.Source = 1
|
||||||
|
}
|
||||||
|
insertData = append(insertData, in)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, err = dao.UserTaskRewards.Ctx(ctx).Data(insertData).Insert(); err != nil {
|
||||||
|
return ecode.Fail.Sub("创建用户任务奖励记录失败")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.TaskList[i].UserTaskId = value.Int64()
|
||||||
|
// 存在该任务记录,则判断该任务记录对应的奖励是否都已领取,需要修改任务状态
|
||||||
|
glog.Info(ctx, "用户存在该任务记录,则判断该任务记录对应的奖励是否都已领取,需要修改任务状态")
|
||||||
|
if v.Status != 1 && v.Status != 2 {
|
||||||
|
count, err := dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: value.Int()}).WhereIn(dao.UserTasks.Columns().Status, []int{2, 3, 5}).Count()
|
||||||
|
if err != nil {
|
||||||
|
return nil, ecode.Fail.Sub("查询用户门店任务奖励失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
if count > 0 {
|
||||||
|
result.TaskList[i].Status = 2
|
||||||
|
} else {
|
||||||
|
result.TaskList[i].Status = 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err = dao.UserTaskRewards.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||||
|
_, err = dao.UserTasks.Ctx(ctx).WherePri(value.Int64()).Where(dao.UserTasks.Columns().Status).WhereNot(dao.UserTasks.Columns().Status, 2).Update(do.UserTasks{
|
||||||
|
Status: 3,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return ecode.Fail.Sub("修改用户任务状态失败")
|
||||||
|
}
|
||||||
|
_, err = dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: value.Int()}).Where(dao.UserTaskRewards.Columns().Status, 1).Update(do.UserTaskRewards{
|
||||||
|
Status: 2,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return ecode.Fail.Sub("修改用户任务奖励状态失败")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.PageIdx = result.PageIdx
|
||||||
|
out.Data = result.TaskList
|
||||||
|
} else {
|
||||||
|
// 从数据库获取数据
|
||||||
|
tasks := make([]model.Task, 0)
|
||||||
err := dao.Tasks.Ctx(ctx).Where(do.Tasks{GameId: in.Gid, NetbarAcconut: in.NetBarAccount}).WithAll().WithAll().Scan(&tasks)
|
err := dao.Tasks.Ctx(ctx).Where(do.Tasks{GameId: in.Gid, NetbarAcconut: in.NetBarAccount}).WithAll().WithAll().Scan(&tasks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ecode.Fail.Sub("获取任务列表失败")
|
return nil, ecode.Fail.Sub("获取任务列表失败")
|
||||||
@ -470,101 +812,37 @@ func (s *sTask) GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ecode.Fail.Sub("解析任务信息失败")
|
return nil, ecode.Fail.Sub("解析任务信息失败")
|
||||||
}
|
}
|
||||||
tasks[i].Task = ""
|
if err = dao.TaskRewards.Ctx(ctx).Where(do.TaskRewards{TaskId: v.TaskId, StoreId: in.StoreId, NetbarAccount: in.NetBarAccount}).OmitEmptyWhere().
|
||||||
for _, i3 := range tasks[i].TaskRewards {
|
LeftJoin(dao.Rewards.Table(), "rewards.id = task_rewards.reward_id").Fields("rewards.*").Scan(&tasks[i].GameTask.Rewards); err != nil {
|
||||||
tasks[i].GameTask.Reward = append(tasks[i].GameTask.Reward, i3.Rewards)
|
|
||||||
}
|
|
||||||
data = append(data, tasks[i].GameTask)
|
|
||||||
}
|
|
||||||
return &model.GetTaskListV2Out{
|
|
||||||
Data: data,
|
|
||||||
}, nil
|
|
||||||
} else {
|
|
||||||
// 已绑定
|
|
||||||
// 调用外部接口
|
|
||||||
activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{ServiceName: consts.GetTaskList, PopenId: in.PopenId, BindType: in.BindType, TaskParam: model.TaskParam{Gid: in.Gid, NetBarAccount: in.NetBarAccount, Num: in.Num, Pageidx: in.Pageidx}})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
result, ok := activity.(*model.GameTaskResponse)
|
|
||||||
if !ok {
|
|
||||||
return nil, ecode.Fail.Sub("数据类型转换失败")
|
|
||||||
}
|
|
||||||
|
|
||||||
pageIdx = result.PageIdx
|
return nil, ecode.Fail.Sub("获取任务奖励列表失败")
|
||||||
// 剔除不需要的任务数据
|
|
||||||
for i, task := range result.TaskList {
|
|
||||||
//data := model.Task{
|
|
||||||
// QqNetbarTaskId: task.TaskID,
|
|
||||||
// QqNetbarTaskName: task.Title,
|
|
||||||
// QqNetbarTaskMemo: task.TaskDesc,
|
|
||||||
// QqNetbarTaskRules: task.RuleDesc,
|
|
||||||
// QqNetbarTargetName: task.TargetName,
|
|
||||||
// QqNetbarTargetTime: task.TargetTimes,
|
|
||||||
// StartTime: task.CycleStart,
|
|
||||||
// EndTime: task.CycleEnd,
|
|
||||||
// //Status: task.Status,
|
|
||||||
//}
|
|
||||||
//data.UserTaskResult.Usertimes = task.UserTimes
|
|
||||||
// 组装门店奖励数据
|
|
||||||
err := dao.TaskRewards.Ctx(ctx).
|
|
||||||
LeftJoin(dao.Rewards.Table(),
|
|
||||||
fmt.Sprintf("`%s`.`%s` = `%s`.`%s`",
|
|
||||||
dao.Rewards.Table(), dao.Rewards.Columns().Id,
|
|
||||||
dao.TaskRewards.Table(), dao.TaskRewards.Columns().RewardId)).
|
|
||||||
LeftJoin(dao.RewardTypes.Table(),
|
|
||||||
fmt.Sprintf("`%s`.`%s` = `%s`.`%s`",
|
|
||||||
dao.RewardTypes.Table(), dao.RewardTypes.Columns().Id,
|
|
||||||
dao.Rewards.Table(), dao.Rewards.Columns().RewardTypeId)).
|
|
||||||
Fields(
|
|
||||||
fmt.Sprintf("%s.*, `%s`.`%s` AS %s",
|
|
||||||
dao.Rewards.Table(),
|
|
||||||
dao.RewardTypes.Table(), dao.RewardTypes.Columns().Name,
|
|
||||||
"reward_type_name",
|
|
||||||
),
|
|
||||||
).Where(dao.TaskRewards.Columns().TaskId, task.TaskID).Scan(&result.TaskList[i].Reward)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
//任务状态=1或者2不做操作,其他查询门店奖励是否全部领取
|
|
||||||
if task.Status != 1 && task.Status != 2 {
|
|
||||||
count, err := dao.UserTasks.Ctx(ctx).Where(dao.UserTasks.Columns().TaskId, task.TaskID).Where(dao.UserTasks.Columns().UserId, in.UserId).LeftJoin(dao.UserTaskRewards.Table(),
|
|
||||||
fmt.Sprintf("%s.user_task_id = %s.id", dao.UserTaskRewards.Table(), dao.UserTasks.Table())).LeftJoin(dao.Rewards.Table(), fmt.Sprintf("%s.id = %s.reward_id",
|
|
||||||
dao.Rewards.Table(), dao.UserTaskRewards.Table())).Where("rewards.source", 2).Where(dao.UserTaskRewards.Columns().Status, 2).Count()
|
|
||||||
if err != nil {
|
|
||||||
return nil, ecode.Fail.Sub("查询用户门店任务奖励失败")
|
|
||||||
}
|
|
||||||
|
|
||||||
if count > 0 {
|
|
||||||
result.TaskList[i].Status = 2
|
|
||||||
//tasks[i].Status = 2
|
|
||||||
} else {
|
|
||||||
result.TaskList[i].Status = 3
|
|
||||||
//tasks[i].Status = 3
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//else {
|
|
||||||
// data.Status = task.Status
|
|
||||||
//}
|
|
||||||
//tasks = append(tasks, data)
|
|
||||||
|
|
||||||
// 根据用户完成次数和任务指标次数判任务是否完成,修改任务记录状态为 3
|
|
||||||
if int(task.UserTimes) >= task.TargetTimes {
|
|
||||||
_, err := dao.UserTasks.Ctx(ctx).Where(do.UserTasks{TaskId: task.TaskID}).Where(do.UserTasks{UserId: in.UserId}).Data(do.UserTasks{Status: 3}).Update()
|
|
||||||
if err != nil {
|
|
||||||
return nil, ecode.Fail.Sub("更新用户任务记录状态异常")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// 根据任务 id 查询门店奖励追加记录
|
||||||
|
out.Data = append(out.Data, tasks[i].GameTask)
|
||||||
}
|
}
|
||||||
data = result.TaskList
|
|
||||||
return &model.GetTaskListV2Out{
|
|
||||||
Data: data,
|
|
||||||
PageIdx: pageIdx,
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// 遍历任务列表数据,进行处理
|
||||||
|
// 根据门店查询出当前门店追加的奖励
|
||||||
|
for i, v := range out.Data {
|
||||||
|
for _, prize := range v.PrizeList {
|
||||||
|
for _, goods := range prize.GoodsList {
|
||||||
|
if goods.GoodsType == 37 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
out.Data[i].Rewards = append(out.Data[i].Rewards, model.SimpleReward{
|
||||||
|
Source: 1,
|
||||||
|
RewardTypeId: int64(goods.GoodsType),
|
||||||
|
Name: goods.GoodsName,
|
||||||
|
ImageUrl: goods.GoodsIcon,
|
||||||
|
GrantQuantity: uint64(goods.Num),
|
||||||
|
TotalLimit: uint64(v.LimitNum),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
func (s *sTask) SyncTaskFromGamelife(ctx context.Context) (out *model.SyncTaskOut, err error) {
|
func (s *sTask) SyncTaskFromGamelife(ctx context.Context) (out *model.SyncTaskOut, err error) {
|
||||||
stores, err := dao.Stores.Ctx(ctx).Fields(dao.Stores.Columns().Id, dao.Stores.Columns().NetbarAccount).All()
|
stores, err := dao.Stores.Ctx(ctx).Fields(dao.Stores.Columns().Id, dao.Stores.Columns().NetbarAccount).All()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -628,8 +906,8 @@ func (s *sTask) SyncTaskFromGamelife(ctx context.Context) (out *model.SyncTaskOu
|
|||||||
}
|
}
|
||||||
|
|
||||||
taskMap := gconv.Map(task)
|
taskMap := gconv.Map(task)
|
||||||
delete(taskMap, "PrizeList")
|
//delete(taskMap, "PrizeList")
|
||||||
delete(taskMap, "prize_list")
|
//delete(taskMap, "prize_list")
|
||||||
delete(taskMap, "reward")
|
delete(taskMap, "reward")
|
||||||
|
|
||||||
_, err = dao.Tasks.Ctx(ctx).Data(do.Tasks{
|
_, err = dao.Tasks.Ctx(ctx).Data(do.Tasks{
|
||||||
|
|||||||
@ -10,7 +10,9 @@ import (
|
|||||||
|
|
||||||
// TaskRewards is the golang structure of table task_rewards for DAO operations like Where/Data.
|
// TaskRewards is the golang structure of table task_rewards for DAO operations like Where/Data.
|
||||||
type TaskRewards struct {
|
type TaskRewards struct {
|
||||||
g.Meta `orm:"table:task_rewards, do:true"`
|
g.Meta `orm:"table:task_rewards, do:true"`
|
||||||
TaskId interface{} // 任务ID
|
TaskId interface{} // 任务ID
|
||||||
RewardId interface{} // 奖励ID
|
RewardId interface{} // 奖励ID
|
||||||
|
NetbarAccount interface{} // 门店网关账号
|
||||||
|
StoreId interface{} // 门店 id
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,4 +24,7 @@ type UserTaskRewards struct {
|
|||||||
UpdatedAt *gtime.Time // 更新时间
|
UpdatedAt *gtime.Time // 更新时间
|
||||||
DeletedAt *gtime.Time // 软删除时间
|
DeletedAt *gtime.Time // 软删除时间
|
||||||
ExpiredAt *gtime.Time // 奖励过期时间
|
ExpiredAt *gtime.Time // 奖励过期时间
|
||||||
|
IssueQuantity interface{} //
|
||||||
|
Source interface{} // 来源 1:系统 2:门店
|
||||||
|
RewardTypeId interface{} // 奖励类型 id
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,8 @@ package entity
|
|||||||
|
|
||||||
// TaskRewards is the golang structure for table task_rewards.
|
// TaskRewards is the golang structure for table task_rewards.
|
||||||
type TaskRewards struct {
|
type TaskRewards struct {
|
||||||
TaskId string `json:"taskId" orm:"task_id" description:"任务ID"` // 任务ID
|
TaskId string `json:"taskId" orm:"task_id" description:"任务ID"` // 任务ID
|
||||||
RewardId int64 `json:"rewardId" orm:"reward_id" description:"奖励ID"` // 奖励ID
|
RewardId int64 `json:"rewardId" orm:"reward_id" description:"奖励ID"` // 奖励ID
|
||||||
|
NetbarAccount string `json:"netbarAccount" orm:"netbar_account" description:"门店网关账号"` // 门店网关账号
|
||||||
|
StoreId int `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,4 +22,7 @@ type UserTaskRewards struct {
|
|||||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
|
||||||
ExpiredAt *gtime.Time `json:"expiredAt" orm:"expired_at" description:"奖励过期时间"` // 奖励过期时间
|
ExpiredAt *gtime.Time `json:"expiredAt" orm:"expired_at" description:"奖励过期时间"` // 奖励过期时间
|
||||||
|
IssueQuantity int `json:"issueQuantity" orm:"issue_quantity" description:""` //
|
||||||
|
Source int64 `json:"source" orm:"source" description:"来源 1:系统 2:门店"` // 来源 1:系统 2:门店
|
||||||
|
RewardTypeId int64 `json:"rewardTypeId" orm:"reward_type_id" description:"奖励类型 id"` // 奖励类型 id
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,11 +27,11 @@ type GameTaskConfigParse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GameTask struct {
|
type GameTask struct {
|
||||||
RuleDesc string `json:"rule_desc"`
|
RuleDesc string `json:"rule_desc"`
|
||||||
TaskDesc string `json:"task_desc"`
|
TaskDesc string `json:"task_desc"`
|
||||||
LimitPrize int `json:"-"`
|
LimitPrize int `json:"-"`
|
||||||
LimitNum int `json:"-"`
|
LimitNum int `json:"-"`
|
||||||
//PrizeList []Prize `json:"prize_list"`
|
PrizeList []Prize `json:"prize_list,omitempty"`
|
||||||
TaskID string `json:"task_id"`
|
TaskID string `json:"task_id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
CycleStart int64 `json:"cycle_start"`
|
CycleStart int64 `json:"cycle_start"`
|
||||||
@ -42,7 +42,8 @@ type GameTask struct {
|
|||||||
UserTimes int64 `json:"user_times"`
|
UserTimes int64 `json:"user_times"`
|
||||||
GameTaskConfig GameTaskConfig `json:"game_task_config"`
|
GameTaskConfig GameTaskConfig `json:"game_task_config"`
|
||||||
GameTaskConfigParse GameTaskConfigParse `json:"game_task_config_parse"`
|
GameTaskConfigParse GameTaskConfigParse `json:"game_task_config_parse"`
|
||||||
Reward []SimpleReward `json:"reward"`
|
Rewards []SimpleReward `json:"rewards"`
|
||||||
|
UserTaskId int64 `json:"userTaskId" orm:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GameTaskResponse struct {
|
type GameTaskResponse struct {
|
||||||
@ -164,9 +165,7 @@ type premiumPrivInfo struct {
|
|||||||
|
|
||||||
type goodsType int64
|
type goodsType int64
|
||||||
|
|
||||||
type goodsDisplayType struct {
|
type goodsDisplayType int64
|
||||||
// FIXME
|
|
||||||
}
|
|
||||||
|
|
||||||
type merchantInfo struct {
|
type merchantInfo struct {
|
||||||
// FIXME
|
// FIXME
|
||||||
@ -201,14 +200,17 @@ type privCoupon struct {
|
|||||||
Url string `json:"url"`
|
Url string `json:"url"`
|
||||||
}
|
}
|
||||||
type goodsExtraInfo struct {
|
type goodsExtraInfo struct {
|
||||||
OlCouponCfg olCouponCfg `json:"olcoupon_cfg"`
|
OlCouponCfg olCouponCfg `json:"olcoupon_cfg"`
|
||||||
GoodsBrandInfo goodsBrandInfo `json:"goods_brand_info"`
|
GoodsBrandInfo goodsBrandInfo `json:"goods_brand_info"`
|
||||||
ExpireType int `json:"expire_type"`
|
ExpireType int `json:"expire_type"`
|
||||||
ExpireConfig expireConfig `json:"expire_config"`
|
ExpireConfig expireConfig `json:"expire_config"`
|
||||||
MprocJmpCfg map[string]any `json:"mproc_jmp_cfg"` // 空对象可用 map[string]any 表示
|
MprocJmpCfg map[string]any `json:"mproc_jmp_cfg"` // 空对象可用 map[string]any 表示
|
||||||
ApplyGoods string `json:"apply_goods"`
|
ApplyGoods string `json:"apply_goods"`
|
||||||
NewlyBuilt bool `json:"newly_built"`
|
NewlyBuilt bool `json:"newly_built"`
|
||||||
PrivCoupon privCoupon `json:"priv_coupon"`
|
PrivCoupon privCoupon `json:"priv_coupon"`
|
||||||
|
SpecialStatement string `json:"special_statement"`
|
||||||
|
MoneyScoreInfo map[string]any `json:"money_score_info"`
|
||||||
|
GoodsPrice string `json:"goods_price"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type water struct {
|
type water struct {
|
||||||
|
|||||||
@ -50,7 +50,21 @@ type SimpleReward struct {
|
|||||||
UserDailyLimit uint64 `json:"userDailyLimit" orm:"user_daily_limit" description:"用户每日领取限制(NULL表示不限制)"` // 用户每日领取限制(NULL表示不限制)
|
UserDailyLimit uint64 `json:"userDailyLimit" orm:"user_daily_limit" description:"用户每日领取限制(NULL表示不限制)"` // 用户每日领取限制(NULL表示不限制)
|
||||||
UserTotalLimit uint64 `json:"userTotalLimit" orm:"user_total_limit" description:"用户领取总次数限制(NULL表示不限制)"` // 用户领取总次数限制(NULL表示不限制)
|
UserTotalLimit uint64 `json:"userTotalLimit" orm:"user_total_limit" description:"用户领取总次数限制(NULL表示不限制)"` // 用户领取总次数限制(NULL表示不限制)
|
||||||
ReceivedNum uint64 `json:"receivedNum" orm:"received_num" description:"已领取数量"` // 已领取数量
|
ReceivedNum uint64 `json:"receivedNum" orm:"received_num" description:"已领取数量"` // 已领取数量
|
||||||
//GrantQuantity uint64 `json:"grantQuantity" orm:"grant_quantity" description:"每次发放个数"` // 每次发放个数
|
GrantQuantity uint64 `json:"grantQuantity" orm:"grant_quantity" description:"每次发放个数"` // 每次发放个数
|
||||||
|
}
|
||||||
|
|
||||||
|
type RewardCallback struct {
|
||||||
|
Id int64 `json:"id" orm:"id" description:""` //
|
||||||
|
Uid string `json:"uid" orm:"uid" description:"用户账号"` // 用户账号
|
||||||
|
OrderId string `json:"orderId" orm:"order_id" description:"订单号必须保证全局唯一(保证接口幂等)"` // 订单号必须保证全局唯一(保证接口幂等)
|
||||||
|
PrizeChannelId string `json:"prizeChannelId" orm:"prize_channel_id" description:"券渠道 ID"` // 券渠道 ID
|
||||||
|
PrizeId string `json:"prizeId" orm:"prize_id" description:"券 ID"` // 券 ID
|
||||||
|
PrizeType int `json:"prizeType" orm:"prize_type" description:"奖励类型,1 网鱼积分,2 网鱼经验值,3 网鱼兑换码"` // 奖励类型,1 网鱼积分,2 网鱼经验值,3 网鱼兑换码
|
||||||
|
PrizeSubType int `json:"prizeSubType" orm:"prize_sub_type" description:"奖励子类型,默认为 0,有多种子类型时可用,如 1,5 元网费充值券,2、满 30-5 满减券等"` // 奖励子类型,默认为 0,有多种子类型时可用,如 1,5 元网费充值券,2、满 30-5 满减券等
|
||||||
|
Num int `json:"num" orm:"num" description:"奖励个数,默认 1,比如经验值 10"` // 奖励个数,默认 1,比如经验值 10
|
||||||
|
CustomInfo string `json:"customInfo" orm:"custom_info" description:"透传字段 (json串)"` // 透传字段 (json串)
|
||||||
|
AppId string `json:"appId" orm:"app_id" description:"业务 id(标识业务方,由游戏人生提供)"` // 业务 id(标识业务方,由游戏人生提供)
|
||||||
|
InnerOrderId string `json:"innerOrderId" orm:"inner_order_id" description:"系统内部订单ID"` // 系统内部订单ID
|
||||||
}
|
}
|
||||||
|
|
||||||
// RewardCreateIn 创建奖励入参
|
// RewardCreateIn 创建奖励入参
|
||||||
@ -169,8 +183,10 @@ type CallbackData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetRewardIn struct {
|
type GetRewardIn struct {
|
||||||
|
Id int
|
||||||
AreaId int
|
AreaId int
|
||||||
GameId int
|
GameId int
|
||||||
|
GameCode string
|
||||||
RewradTypeId int
|
RewradTypeId int
|
||||||
RewardId int
|
RewardId int
|
||||||
RoleIdx string
|
RoleIdx string
|
||||||
@ -182,7 +198,9 @@ type GetRewardIn struct {
|
|||||||
UserId int
|
UserId int
|
||||||
}
|
}
|
||||||
type GetRewardOut struct {
|
type GetRewardOut struct {
|
||||||
List []GetRewardNewOut `json:"list"`
|
//List []GetRewardNewOut `json:"list"`
|
||||||
|
Result int64 `json:"result"`
|
||||||
|
Url string `json:"url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetRewardNewOut struct {
|
type GetRewardNewOut struct {
|
||||||
|
|||||||
@ -140,6 +140,6 @@ type GetTaskListV2In struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetTaskListV2Out struct {
|
type GetTaskListV2Out struct {
|
||||||
PageIdx string `json:"pageidx"`
|
PageIdx string `json:"pageidx"`
|
||||||
Data interface{} `json:"taskList"`
|
Data []GameTask `json:"taskList"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ type GetUserClaimListIn struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetUserClaimListOut struct {
|
type GetUserClaimListOut struct {
|
||||||
List []UserClaimReward
|
List []UserTaskRewards
|
||||||
Total int
|
Total int
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +31,9 @@ type UserTaskRewards struct {
|
|||||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
|
||||||
ExpiredAt *gtime.Time `json:"expiredAt" orm:"expired_at" description:"奖励过期时间"` // 奖励过期时间
|
ExpiredAt *gtime.Time `json:"expiredAt" orm:"expired_at" description:"奖励过期时间"` // 奖励过期时间
|
||||||
|
IssueQuantity int `json:"issueQuantity" orm:"issue_quantity" description:""` //
|
||||||
|
Source int64 `json:"source" orm:"source" description:"来源 1:系统 2:门店"` // 来源 1:系统 2:门店
|
||||||
|
RewardTypeId int64 `json:"rewardTypeId" orm:"reward_type_id" description:"奖励类型 id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserClaimReward struct {
|
type UserClaimReward struct {
|
||||||
|
|||||||
@ -150,6 +150,8 @@ func init() {
|
|||||||
// admin
|
// admin
|
||||||
enforcer.AddPolicy("admin", "/x/admin/info", "GET", "获取管理员用户信息")
|
enforcer.AddPolicy("admin", "/x/admin/info", "GET", "获取管理员用户信息")
|
||||||
enforcer.AddPolicy("admin", "/x/upload/game", "POST", "管理员上传游戏图标")
|
enforcer.AddPolicy("admin", "/x/upload/game", "POST", "管理员上传游戏图标")
|
||||||
|
//
|
||||||
|
enforcer.AddPolicy("store", "/x/user/list", "GET", "获取用户列表信息")
|
||||||
|
|
||||||
// role
|
// role
|
||||||
enforcer.AddPolicy("admin", "/x/role", "GET", "管理员获取角色列表")
|
enforcer.AddPolicy("admin", "/x/role", "GET", "管理员获取角色列表")
|
||||||
|
|||||||
Reference in New Issue
Block a user