diff --git a/api/task/v1/task.go b/api/task/v1/task.go index b4bdd19..96c2c7e 100644 --- a/api/task/v1/task.go +++ b/api/task/v1/task.go @@ -87,6 +87,7 @@ type GetTaskReq struct { TaskName string `json:"taskName" v:"required#任务名称不能为空" dc:"任务名称"` TaskType int `json:"taskType" v:"required#任务类型不能为空" dc:"任务类型1:每日 3:周期"` UserTimes int `json:"userTimes" v:"required#完成次数不能为空" dc:"用户完成次数"` + BindType int `json:"bindType" v:"required#不能为空" dc:"绑定类型 1: QQ 2:微信"` } type GetTaskRes struct { @@ -102,6 +103,7 @@ type GetUserTaskRecordsListReq struct { Page int `json:"page" dc:"页数"` Size int `json:"size" dc:"条数"` TimeType int `json:"timeType" dc:"时间类型,1:一周,2:一月,3:一年, 不传就是不加时间限制"` //TODO + BindType int `json:"bindType" v:"required#不能为空" dc:"绑定类型 1: QQ 2:微信"` } type GetUserTaskRecordsListRes struct { List interface{} `json:"list"` diff --git a/internal/controller/task/task_v1_get_task.go b/internal/controller/task/task_v1_get_task.go index 6c74888..bbf5299 100644 --- a/internal/controller/task/task_v1_get_task.go +++ b/internal/controller/task/task_v1_get_task.go @@ -21,6 +21,7 @@ func (c *ControllerV1) GetTask(ctx context.Context, req *v1.GetTaskReq) (res *v1 TaskName: req.TaskName, TaskType: req.TaskType, UserTimes: req.UserTimes, + BindType: req.BindType, }) if err != nil { return nil, err diff --git a/internal/controller/task/task_v1_get_user_task_records_list.go b/internal/controller/task/task_v1_get_user_task_records_list.go index c481a3d..b37ed57 100644 --- a/internal/controller/task/task_v1_get_user_task_records_list.go +++ b/internal/controller/task/task_v1_get_user_task_records_list.go @@ -12,7 +12,10 @@ import ( func (c *ControllerV1) GetUserTaskRecordsList(ctx context.Context, req *v1.GetUserTaskRecordsListReq) (res *v1.GetUserTaskRecordsListRes, err error) { fromCtx := g.RequestFromCtx(ctx) userId := fromCtx.GetCtxVar("id").Int() - out, err := service.Task().GetUserTaskRecordsList(ctx, &model.UserTaskRecordsListIn{UserId: userId, StoreId: req.StoreId, Page: req.Page, Size: req.Size, TimeType: req.TimeType, RewardTypeId: req.RewardTypeId, GameId: req.GameId, NetBarAccount: req.NetbarAccount}) + out, err := service.Task().GetUserTaskRecordsList(ctx, &model.UserTaskRecordsListIn{ + UserId: userId, StoreId: req.StoreId, Page: req.Page, Size: req.Size, TimeType: req.TimeType, + RewardTypeId: req.RewardTypeId, GameId: req.GameId, NetBarAccount: req.NetbarAccount, BindType: req.BindType, + }) if err != nil { return nil, err } diff --git a/internal/dao/internal/user_tasks.go b/internal/dao/internal/user_tasks.go index d3423a5..ee045d0 100644 --- a/internal/dao/internal/user_tasks.go +++ b/internal/dao/internal/user_tasks.go @@ -34,6 +34,7 @@ type UserTasksColumns struct { GameId string // 游戏 id TaskType string // 1: 每日任务 3: 周期任务 UserTimes string // 用户完成次数 + BindType string // 当前账号类型 } // userTasksColumns holds the columns for the table user_tasks. @@ -52,6 +53,7 @@ var userTasksColumns = UserTasksColumns{ GameId: "game_id", TaskType: "task_type", UserTimes: "user_times", + BindType: "bind_type", } // NewUserTasksDao creates and returns a new DAO object for table data access. diff --git a/internal/logic/task/task.go b/internal/logic/task/task.go index 70c7605..252bf54 100644 --- a/internal/logic/task/task.go +++ b/internal/logic/task/task.go @@ -371,10 +371,10 @@ func (s *sTask) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.Ge start := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()) // 当天结束时间 end := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 0, now.Location()) - err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: in.TaskId, StoreId: storeId, GameId: in.GameId}). + err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: in.TaskId, StoreId: storeId, GameId: in.GameId, BindType: in.BindType}). WhereBetween(dao.UserTasks.Columns().CreatedAt, start, end).Scan(&userTask) } else { - err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: in.TaskId, StoreId: storeId, GameId: in.GameId}).Scan(&userTask) + err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: in.TaskId, StoreId: storeId, GameId: in.GameId, BindType: in.BindType}).Scan(&userTask) } if err != nil { @@ -403,6 +403,7 @@ func (s *sTask) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.Ge GameId: in.GameId, TaskType: in.TaskType, UserTimes: in.UserTimes, + BindType: in.BindType, }) if err != nil { return ecode.Fail.Sub("创建用户任务记录失败") @@ -445,7 +446,7 @@ func (s *sTask) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.Ge func (s *sTask) GetUserTaskRecordsList(ctx context.Context, in *model.UserTaskRecordsListIn) (out *model.UserTaskRecordsListOut, err error) { list := make([]model.UserTask2, 0) var total int - orm := dao.UserTasks.Ctx(ctx).Where(dao.UserTasks.Columns().UserId, in.UserId) + orm := dao.UserTasks.Ctx(ctx).Where(dao.UserTasks.Columns().UserId, in.UserId, dao.UserTasks.Columns().BindType, in.BindType) if in.StoreId != 0 && in.NetBarAccount == "" { orm = orm.Where(dao.UserTasks.Columns().StoreId, in.StoreId) @@ -503,7 +504,7 @@ func (s *sTask) GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out if err != nil { return nil, ecode.Fail.Sub("获取任务奖励列表失败") } - orm := dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: v.TaskID}) + orm := dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: v.TaskID, BindType: in.BindType}) if v.GameTaskConfig.TimeType == 1 { // 每日任务 start := gtime.Now().StartOfDay() diff --git a/internal/model/do/user_tasks.go b/internal/model/do/user_tasks.go index 95fa16a..e929af4 100644 --- a/internal/model/do/user_tasks.go +++ b/internal/model/do/user_tasks.go @@ -26,4 +26,5 @@ type UserTasks struct { GameId interface{} // 游戏 id TaskType interface{} // 1: 每日任务 3: 周期任务 UserTimes interface{} // 用户完成次数 + BindType interface{} // 当前账号类型 } diff --git a/internal/model/entity/user_tasks.go b/internal/model/entity/user_tasks.go index 6d44095..3511a40 100644 --- a/internal/model/entity/user_tasks.go +++ b/internal/model/entity/user_tasks.go @@ -24,4 +24,5 @@ type UserTasks struct { GameId int64 `json:"gameId" orm:"game_id" description:"游戏 id"` // 游戏 id TaskType int64 `json:"taskType" orm:"task_type" description:"1: 每日任务 3: 周期任务"` // 1: 每日任务 3: 周期任务 UserTimes int64 `json:"userTimes" orm:"user_times" description:"用户完成次数"` // 用户完成次数 + BindType int `json:"bindType" orm:"bind_type" description:"当前账号类型"` // 当前账号类型 } diff --git a/internal/model/userTask.go b/internal/model/userTask.go index f9616df..c8335fe 100644 --- a/internal/model/userTask.go +++ b/internal/model/userTask.go @@ -125,6 +125,7 @@ type GetTaskIn struct { GameId int `json:"gid"` TaskType int `json:"taskType"` UserTimes int `json:"userTimes"` + BindType int `json:"bindType"` } type GetTaskOut struct { @@ -140,6 +141,7 @@ type UserTaskRecordsListIn struct { RewardTypeId int TimeType int GameId int + BindType int } type UserTaskRecordsListOut struct { diff --git a/utility/gamelife/gamelife.go b/utility/gamelife/gamelife.go index cb6a42d..58f7f23 100644 --- a/utility/gamelife/gamelife.go +++ b/utility/gamelife/gamelife.go @@ -170,7 +170,7 @@ func (s *gamelifeClient) GetUserKeyIV(ctx context.Context, popenID string) (*mod Token: result.Key, } cacheKey := fmt.Sprintf(consts.GameLifeUserKey, popenID) - if err := g.Redis().SetEX(ctx, cacheKey, cache, int64(consts.GameLifeUserExpire+grand.Intn(1000))); err != nil { + if err := g.Redis().SetEX(ctx, cacheKey, cache, int64(consts.GameLifeUserExpire-grand.Intn(1000))); err != nil { return nil, ecode.Fail.Sub("设置用户信息失败") }