From 2791322a769e80d5a7cb3b103f93860a60afe45e Mon Sep 17 00:00:00 2001 From: chy <2463300564@qq.com> Date: Tue, 1 Jul 2025 09:57:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BB=BB=E5=8A=A1=E5=AD=98?= =?UTF-8?q?=E5=82=A8=EF=BC=8C=E4=BB=BB=E5=8A=A1=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/reward/v1/reward.go | 6 +-- api/task/v1/task.go | 14 ++++++ .../controller/reward/reward_v1_get_lift.go | 4 +- internal/dao/internal/tasks.go | 48 +++++++------------ internal/dao/internal/user_tasks.go | 2 +- internal/logic/reward/reward.go | 6 ++- internal/model/do/tasks.go | 26 ++++------ internal/model/do/user_tasks.go | 2 +- internal/model/entity/tasks.go | 24 ++++------ internal/model/entity/user_tasks.go | 24 +++++----- utility/gamelife/gamelife.go | 7 ++- utility/myCasbin/casbin.go | 2 +- 12 files changed, 81 insertions(+), 84 deletions(-) diff --git a/api/reward/v1/reward.go b/api/reward/v1/reward.go index 5be348f..3dfbc72 100644 --- a/api/reward/v1/reward.go +++ b/api/reward/v1/reward.go @@ -212,9 +212,9 @@ type CallbackRes struct { type GetLiftReq struct { g.Meta `path:"/reward/getLift" method:"post" tags:"PC/Reward" summary:"(PC)奖励领取"` - RewradType int `json:"rewardType" v:"required#奖励类型不能为空" dc:"奖励类型"` - RewradId int `json:"rewardId" v:"required#奖励id不能为空" dc:"奖励id"` - PopenId string `json:"popenid" v:"required#popenId不能为空" dc:"popenId不能为空"` + RewardType int `json:"rewardType" dc:"奖励类型"` + RewardId int `json:"rewardId" v:"required#奖励id不能为空" dc:"奖励id"` + PopenId string `json:"popenId" v:"required#popenId不能为空" dc:"popenId不能为空"` Source int `json:"source" v:"required#来源不能为空" dc:"来源" d:"1:系统 2:门店"` TaskId string `json:"taskId" v:"required#任务id不能为空" dc:"任务Id"` GameId int `json:"gameId" v:"required#游戏id不能为空" dc:"游戏Id"` diff --git a/api/task/v1/task.go b/api/task/v1/task.go index ef48026..1f5955b 100644 --- a/api/task/v1/task.go +++ b/api/task/v1/task.go @@ -100,3 +100,17 @@ type GetUserTaskRecordsListRes struct { List interface{} `json:"list"` Total int `json:"total"` } + +type GetTaskListReq struct { + g.Meta `path:"/task/list" method:"get" tags:"Backend-PC/Task" summary:"任务列表"` +} +type GetTaskListRes struct { + List interface{} `json:"list"` + Total int `json:"total"` +} + +type SyncTaskReq struct { + g.Meta `path:"/task/sync" method:"post" tags:"Backend/Task" summary:"同步任务"` +} +type SyncTaskRes struct { +} diff --git a/internal/controller/reward/reward_v1_get_lift.go b/internal/controller/reward/reward_v1_get_lift.go index cd0b432..2c0fa37 100644 --- a/internal/controller/reward/reward_v1_get_lift.go +++ b/internal/controller/reward/reward_v1_get_lift.go @@ -15,14 +15,14 @@ func (c *ControllerV1) GetLift(ctx context.Context, req *v1.GetLiftReq) (res *v1 GameId: req.GameId, TaskId: req.TaskId, PopenId: req.PopenId, - RewradTypeId: req.RewradType, + RewradTypeId: req.RewardType, RoleIdx: req.RoleIdx, AreaId: req.AreaId, Source: req.Source, BindType: req.BindType, UserTaskId: req.UserTaskId, UserId: userId.Int(), - RewardId: req.RewradId, + RewardId: req.RewardId, }) if err != nil { diff --git a/internal/dao/internal/tasks.go b/internal/dao/internal/tasks.go index dfd5153..72333ac 100644 --- a/internal/dao/internal/tasks.go +++ b/internal/dao/internal/tasks.go @@ -21,40 +21,28 @@ type TasksDao struct { // TasksColumns defines and stores column names for the table tasks. type TasksColumns struct { - Id string // 任务唯一标识符 - CreatedAt string // 创建时间 - UpdatedAt string // 更新时间 - DeletedAt string // 软删除时间戳 - GameId string // 游戏唯一id - StoreId string // 门店 id - Status string // 1:启用 2:禁用 - QqNetbarTaskId string // QQ网吧任务ID - QqNetbarTaskRules string // 任务规则 - QqNetbarTaskMemo string // 任务描述 - QqNetbarTaskName string // QQ网吧任务名称 - QqNetbarReward string // qq 网吧奖励名称 - QqNetbarTargetTime string // qq 网吧任务指标 - StartTime string // 任务开始时间 - EndTime string // 任务结束时间 + Id string // 任务唯一标识符 + CreatedAt string // 创建时间 + UpdatedAt string // 更新时间 + DeletedAt string // 软删除时间戳 + GameId string // 游戏唯一id + StoreId string // 门店 id + NetbarAcconut string // 网关 + TaskId string // 任务 id + Task string // 任务 } // tasksColumns holds the columns for the table tasks. var tasksColumns = TasksColumns{ - Id: "id", - CreatedAt: "created_at", - UpdatedAt: "updated_at", - DeletedAt: "deleted_at", - GameId: "game_id", - StoreId: "store_id", - Status: "status", - QqNetbarTaskId: "qq_netbar_task_id", - QqNetbarTaskRules: "qq_netbar_task_rules", - QqNetbarTaskMemo: "qq_netbar_task_memo", - QqNetbarTaskName: "qq_netbar_task_name", - QqNetbarReward: "qq_netbar_reward", - QqNetbarTargetTime: "qq_netbar_target_time", - StartTime: "start_time", - EndTime: "end_time", + Id: "id", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", + GameId: "game_id", + StoreId: "store_id", + NetbarAcconut: "netbar_acconut", + TaskId: "task_id", + Task: "task", } // NewTasksDao creates and returns a new DAO object for table data access. diff --git a/internal/dao/internal/user_tasks.go b/internal/dao/internal/user_tasks.go index 257329e..0adced4 100644 --- a/internal/dao/internal/user_tasks.go +++ b/internal/dao/internal/user_tasks.go @@ -24,7 +24,7 @@ type UserTasksColumns struct { Id string // 用户任务唯一标识符 UserId string // 用户ID TaskId string // 腾讯任务ID - Status string // 任务状态:1=进行中,2=已完成中,3=未完成 + Status string // 任务状态:1=进行中,2=已完成,3=待领取奖励 SerialNumber string // 流水号,确保用户任务唯一性 CreatedAt string // 创建时间 UpdatedAt string // 更新时间 diff --git a/internal/logic/reward/reward.go b/internal/logic/reward/reward.go index ed4310e..2572661 100644 --- a/internal/logic/reward/reward.go +++ b/internal/logic/reward/reward.go @@ -353,7 +353,7 @@ func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *mode // 判断奖励类型 if in.Source == 1 { // 系统奖励处理 - if in.RewradTypeId != 16 { + if in.RewradTypeId == 16 { // 需要大区角色 giftParam.AreaId = in.AreaId giftParam.Gid = in.GameId @@ -380,6 +380,10 @@ func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *mode return nil, ecode.Fail.Sub("数据类型转换失败") } + if len(result.GiftItem) == 0 { + return nil, ecode.Fail.Sub("奖励领取异常") + } + // 存储数据库记录 if err = dao.RewardWaters.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) { for _, item := range result.GiftItem { diff --git a/internal/model/do/tasks.go b/internal/model/do/tasks.go index 38a33fc..988f42a 100644 --- a/internal/model/do/tasks.go +++ b/internal/model/do/tasks.go @@ -11,20 +11,14 @@ import ( // Tasks is the golang structure of table tasks for DAO operations like Where/Data. type Tasks struct { - g.Meta `orm:"table:tasks, do:true"` - Id interface{} // 任务唯一标识符 - CreatedAt *gtime.Time // 创建时间 - UpdatedAt *gtime.Time // 更新时间 - DeletedAt *gtime.Time // 软删除时间戳 - GameId interface{} // 游戏唯一id - StoreId interface{} // 门店 id - Status interface{} // 1:启用 2:禁用 - QqNetbarTaskId interface{} // QQ网吧任务ID - QqNetbarTaskRules interface{} // 任务规则 - QqNetbarTaskMemo interface{} // 任务描述 - QqNetbarTaskName interface{} // QQ网吧任务名称 - QqNetbarReward interface{} // qq 网吧奖励名称 - QqNetbarTargetTime interface{} // qq 网吧任务指标 - StartTime interface{} // 任务开始时间 - EndTime interface{} // 任务结束时间 + g.Meta `orm:"table:tasks, do:true"` + Id interface{} // 任务唯一标识符 + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 更新时间 + DeletedAt *gtime.Time // 软删除时间戳 + GameId interface{} // 游戏唯一id + StoreId interface{} // 门店 id + NetbarAcconut interface{} // 网关 + TaskId interface{} // 任务 id + Task interface{} // 任务 } diff --git a/internal/model/do/user_tasks.go b/internal/model/do/user_tasks.go index da69e39..817511c 100644 --- a/internal/model/do/user_tasks.go +++ b/internal/model/do/user_tasks.go @@ -15,7 +15,7 @@ type UserTasks struct { Id interface{} // 用户任务唯一标识符 UserId interface{} // 用户ID TaskId interface{} // 腾讯任务ID - Status interface{} // 任务状态:1=进行中,2=已完成中,3=未完成 + Status interface{} // 任务状态:1=进行中,2=已完成,3=待领取奖励 SerialNumber interface{} // 流水号,确保用户任务唯一性 CreatedAt *gtime.Time // 创建时间 UpdatedAt *gtime.Time // 更新时间 diff --git a/internal/model/entity/tasks.go b/internal/model/entity/tasks.go index f871104..d1aed50 100644 --- a/internal/model/entity/tasks.go +++ b/internal/model/entity/tasks.go @@ -10,19 +10,13 @@ import ( // Tasks is the golang structure for table tasks. type Tasks struct { - Id int64 `json:"id" orm:"id" description:"任务唯一标识符"` // 任务唯一标识符 - CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间 - UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间 - DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳 - GameId int64 `json:"gameId" orm:"game_id" description:"游戏唯一id"` // 游戏唯一id - StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id - Status int `json:"status" orm:"status" description:"1:启用 2:禁用"` // 1:启用 2:禁用 - QqNetbarTaskId string `json:"qqNetbarTaskId" orm:"qq_netbar_task_id" description:"QQ网吧任务ID"` // QQ网吧任务ID - QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则 - QqNetbarTaskMemo string `json:"qqNetbarTaskMemo" orm:"qq_netbar_task_memo" description:"任务描述"` // 任务描述 - QqNetbarTaskName string `json:"qqNetbarTaskName" orm:"qq_netbar_task_name" description:"QQ网吧任务名称"` // QQ网吧任务名称 - QqNetbarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:"qq 网吧奖励名称"` // qq 网吧奖励名称 - QqNetbarTargetTime int `json:"qqNetbarTargetTime" orm:"qq_netbar_target_time" description:"qq 网吧任务指标"` // qq 网吧任务指标 - StartTime int64 `json:"startTime" orm:"start_time" description:"任务开始时间"` // 任务开始时间 - EndTime int64 `json:"endTime" orm:"end_time" description:"任务结束时间"` // 任务结束时间 + Id int64 `json:"id" orm:"id" description:"任务唯一标识符"` // 任务唯一标识符 + CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间 + UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间 + DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳 + GameId int64 `json:"gameId" orm:"game_id" description:"游戏唯一id"` // 游戏唯一id + StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id + NetbarAcconut string `json:"netbarAcconut" orm:"netbar_acconut" description:"网关"` // 网关 + TaskId string `json:"taskId" orm:"task_id" description:"任务 id"` // 任务 id + Task string `json:"task" orm:"task" description:"任务"` // 任务 } diff --git a/internal/model/entity/user_tasks.go b/internal/model/entity/user_tasks.go index 3d4575d..5847ce4 100644 --- a/internal/model/entity/user_tasks.go +++ b/internal/model/entity/user_tasks.go @@ -10,16 +10,16 @@ import ( // UserTasks is the golang structure for table user_tasks. type UserTasks struct { - Id int64 `json:"id" orm:"id" description:"用户任务唯一标识符"` // 用户任务唯一标识符 - UserId int64 `json:"userId" orm:"user_id" description:"用户ID"` // 用户ID - TaskId string `json:"taskId" orm:"task_id" description:"腾讯任务ID"` // 腾讯任务ID - Status int `json:"status" orm:"status" description:"任务状态:1=进行中,2=已完成中,3=未完成"` // 任务状态:1=进行中,2=已完成中,3=未完成 - SerialNumber string `json:"serialNumber" orm:"serial_number" description:"流水号,确保用户任务唯一性"` // 流水号,确保用户任务唯一性 - CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间 - UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间 - CompletedAt *gtime.Time `json:"completedAt" orm:"completed_at" description:"任务完成时间"` // 任务完成时间 - DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳 - StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id - TaskName string `json:"taskName" orm:"task_name" description:"任务名称"` // 任务名称 - GameId int64 `json:"gameId" orm:"game_id" description:"游戏 id"` // 游戏 id + Id int64 `json:"id" orm:"id" description:"用户任务唯一标识符"` // 用户任务唯一标识符 + UserId int64 `json:"userId" orm:"user_id" description:"用户ID"` // 用户ID + TaskId string `json:"taskId" orm:"task_id" description:"腾讯任务ID"` // 腾讯任务ID + Status int `json:"status" orm:"status" description:"任务状态:1=进行中,2=已完成,3=待领取奖励"` // 任务状态:1=进行中,2=已完成,3=待领取奖励 + SerialNumber string `json:"serialNumber" orm:"serial_number" description:"流水号,确保用户任务唯一性"` // 流水号,确保用户任务唯一性 + CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间 + UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间 + CompletedAt *gtime.Time `json:"completedAt" orm:"completed_at" description:"任务完成时间"` // 任务完成时间 + DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳 + StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id + TaskName string `json:"taskName" orm:"task_name" description:"任务名称"` // 任务名称 + GameId int64 `json:"gameId" orm:"game_id" description:"游戏 id"` // 游戏 id } diff --git a/utility/gamelife/gamelife.go b/utility/gamelife/gamelife.go index d0e5441..44cfaec 100644 --- a/utility/gamelife/gamelife.go +++ b/utility/gamelife/gamelife.go @@ -414,7 +414,7 @@ func (s *gamelifeClient) RequestActivity(ctx context.Context, in *model.QQNetbar if err != nil { return nil, err } - var result model.GiftResponse + var result *model.GiftResponse resp, err := client.R(). SetContext(ctx). SetBody(in.GiftParam). @@ -423,7 +423,10 @@ func (s *gamelifeClient) RequestActivity(ctx context.Context, in *model.QQNetbar if err != nil || resp.IsError() { return nil, ecode.Fail.Sub("请求出现异常") } - return &result, nil + if result == nil { + return nil, ecode.Fail.Sub("请求结果为空") + } + return result, nil case consts.QueryUserGoodsList: value, err := dao.Games.Ctx(ctx).Where(do.Games{GameId: in.GoodsParam.Gid}).Fields(dao.Games.Columns().GameCode).Value() if err != nil { diff --git a/utility/myCasbin/casbin.go b/utility/myCasbin/casbin.go index 59f68cf..717a9ed 100644 --- a/utility/myCasbin/casbin.go +++ b/utility/myCasbin/casbin.go @@ -48,7 +48,7 @@ func init() { // 游戏列表 enforcer.AddPolicy("guest", "/x/game", "GET", "获取游戏列表") enforcer.AddPolicy("guest", "/x/reward/callback", "POST", "tencent奖励回调") - enforcer.AddPolicy("guest", "/x/reward/getLift", "POST", "tencent奖励领取") + enforcer.AddPolicy("user", "/x/reward/getLift", "POST", "tencent奖励领取") enforcer.AddPolicy("guest", "/x/reward/goodsDetails", "POST", "获取物品详情") } // 用户