用户任务记录新增字段记录领取任务账号 id
This commit is contained in:
@ -87,6 +87,7 @@ type GetTaskReq struct {
|
|||||||
TaskName string `json:"taskName" v:"required#任务名称不能为空" dc:"任务名称"`
|
TaskName string `json:"taskName" v:"required#任务名称不能为空" dc:"任务名称"`
|
||||||
TaskType int `json:"taskType" v:"required#任务类型不能为空" dc:"任务类型1:每日 3:周期"`
|
TaskType int `json:"taskType" v:"required#任务类型不能为空" dc:"任务类型1:每日 3:周期"`
|
||||||
UserTimes int `json:"userTimes" v:"required#完成次数不能为空" dc:"用户完成次数"`
|
UserTimes int `json:"userTimes" v:"required#完成次数不能为空" dc:"用户完成次数"`
|
||||||
|
BindType int `json:"bindType" v:"required#不能为空" dc:"绑定类型 1: QQ 2:微信"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetTaskRes struct {
|
type GetTaskRes struct {
|
||||||
@ -102,6 +103,7 @@ type GetUserTaskRecordsListReq struct {
|
|||||||
Page int `json:"page" dc:"页数"`
|
Page int `json:"page" dc:"页数"`
|
||||||
Size int `json:"size" dc:"条数"`
|
Size int `json:"size" dc:"条数"`
|
||||||
TimeType int `json:"timeType" dc:"时间类型,1:一周,2:一月,3:一年, 不传就是不加时间限制"` //TODO
|
TimeType int `json:"timeType" dc:"时间类型,1:一周,2:一月,3:一年, 不传就是不加时间限制"` //TODO
|
||||||
|
BindType int `json:"bindType" v:"required#不能为空" dc:"绑定类型 1: QQ 2:微信"`
|
||||||
}
|
}
|
||||||
type GetUserTaskRecordsListRes struct {
|
type GetUserTaskRecordsListRes struct {
|
||||||
List interface{} `json:"list"`
|
List interface{} `json:"list"`
|
||||||
|
|||||||
@ -21,6 +21,7 @@ func (c *ControllerV1) GetTask(ctx context.Context, req *v1.GetTaskReq) (res *v1
|
|||||||
TaskName: req.TaskName,
|
TaskName: req.TaskName,
|
||||||
TaskType: req.TaskType,
|
TaskType: req.TaskType,
|
||||||
UserTimes: req.UserTimes,
|
UserTimes: req.UserTimes,
|
||||||
|
BindType: req.BindType,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@ -12,7 +12,10 @@ import (
|
|||||||
func (c *ControllerV1) GetUserTaskRecordsList(ctx context.Context, req *v1.GetUserTaskRecordsListReq) (res *v1.GetUserTaskRecordsListRes, err error) {
|
func (c *ControllerV1) GetUserTaskRecordsList(ctx context.Context, req *v1.GetUserTaskRecordsListReq) (res *v1.GetUserTaskRecordsListRes, err error) {
|
||||||
fromCtx := g.RequestFromCtx(ctx)
|
fromCtx := g.RequestFromCtx(ctx)
|
||||||
userId := fromCtx.GetCtxVar("id").Int()
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,7 @@ type UserTasksColumns struct {
|
|||||||
GameId string // 游戏 id
|
GameId string // 游戏 id
|
||||||
TaskType string // 1: 每日任务 3: 周期任务
|
TaskType string // 1: 每日任务 3: 周期任务
|
||||||
UserTimes string // 用户完成次数
|
UserTimes string // 用户完成次数
|
||||||
|
BindType string // 当前账号类型
|
||||||
}
|
}
|
||||||
|
|
||||||
// userTasksColumns holds the columns for the table user_tasks.
|
// userTasksColumns holds the columns for the table user_tasks.
|
||||||
@ -52,6 +53,7 @@ var userTasksColumns = UserTasksColumns{
|
|||||||
GameId: "game_id",
|
GameId: "game_id",
|
||||||
TaskType: "task_type",
|
TaskType: "task_type",
|
||||||
UserTimes: "user_times",
|
UserTimes: "user_times",
|
||||||
|
BindType: "bind_type",
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewUserTasksDao creates and returns a new DAO object for table data access.
|
// NewUserTasksDao creates and returns a new DAO object for table data access.
|
||||||
|
|||||||
@ -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())
|
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())
|
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)
|
WhereBetween(dao.UserTasks.Columns().CreatedAt, start, end).Scan(&userTask)
|
||||||
} else {
|
} 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 {
|
if err != nil {
|
||||||
@ -403,6 +403,7 @@ func (s *sTask) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.Ge
|
|||||||
GameId: in.GameId,
|
GameId: in.GameId,
|
||||||
TaskType: in.TaskType,
|
TaskType: in.TaskType,
|
||||||
UserTimes: in.UserTimes,
|
UserTimes: in.UserTimes,
|
||||||
|
BindType: in.BindType,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ecode.Fail.Sub("创建用户任务记录失败")
|
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) {
|
func (s *sTask) GetUserTaskRecordsList(ctx context.Context, in *model.UserTaskRecordsListIn) (out *model.UserTaskRecordsListOut, err error) {
|
||||||
list := make([]model.UserTask2, 0)
|
list := make([]model.UserTask2, 0)
|
||||||
var total int
|
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 == "" {
|
if in.StoreId != 0 && in.NetBarAccount == "" {
|
||||||
orm = orm.Where(dao.UserTasks.Columns().StoreId, in.StoreId)
|
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 {
|
if err != nil {
|
||||||
return nil, ecode.Fail.Sub("获取任务奖励列表失败")
|
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 {
|
if v.GameTaskConfig.TimeType == 1 {
|
||||||
// 每日任务
|
// 每日任务
|
||||||
start := gtime.Now().StartOfDay()
|
start := gtime.Now().StartOfDay()
|
||||||
|
|||||||
@ -26,4 +26,5 @@ type UserTasks struct {
|
|||||||
GameId interface{} // 游戏 id
|
GameId interface{} // 游戏 id
|
||||||
TaskType interface{} // 1: 每日任务 3: 周期任务
|
TaskType interface{} // 1: 每日任务 3: 周期任务
|
||||||
UserTimes interface{} // 用户完成次数
|
UserTimes interface{} // 用户完成次数
|
||||||
|
BindType interface{} // 当前账号类型
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,4 +24,5 @@ type UserTasks struct {
|
|||||||
GameId int64 `json:"gameId" orm:"game_id" description:"游戏 id"` // 游戏 id
|
GameId int64 `json:"gameId" orm:"game_id" description:"游戏 id"` // 游戏 id
|
||||||
TaskType int64 `json:"taskType" orm:"task_type" description:"1: 每日任务 3: 周期任务"` // 1: 每日任务 3: 周期任务
|
TaskType int64 `json:"taskType" orm:"task_type" description:"1: 每日任务 3: 周期任务"` // 1: 每日任务 3: 周期任务
|
||||||
UserTimes int64 `json:"userTimes" orm:"user_times" description:"用户完成次数"` // 用户完成次数
|
UserTimes int64 `json:"userTimes" orm:"user_times" description:"用户完成次数"` // 用户完成次数
|
||||||
|
BindType int `json:"bindType" orm:"bind_type" description:"当前账号类型"` // 当前账号类型
|
||||||
}
|
}
|
||||||
|
|||||||
@ -125,6 +125,7 @@ type GetTaskIn struct {
|
|||||||
GameId int `json:"gid"`
|
GameId int `json:"gid"`
|
||||||
TaskType int `json:"taskType"`
|
TaskType int `json:"taskType"`
|
||||||
UserTimes int `json:"userTimes"`
|
UserTimes int `json:"userTimes"`
|
||||||
|
BindType int `json:"bindType"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetTaskOut struct {
|
type GetTaskOut struct {
|
||||||
@ -140,6 +141,7 @@ type UserTaskRecordsListIn struct {
|
|||||||
RewardTypeId int
|
RewardTypeId int
|
||||||
TimeType int
|
TimeType int
|
||||||
GameId int
|
GameId int
|
||||||
|
BindType int
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserTaskRecordsListOut struct {
|
type UserTaskRecordsListOut struct {
|
||||||
|
|||||||
@ -170,7 +170,7 @@ func (s *gamelifeClient) GetUserKeyIV(ctx context.Context, popenID string) (*mod
|
|||||||
Token: result.Key,
|
Token: result.Key,
|
||||||
}
|
}
|
||||||
cacheKey := fmt.Sprintf(consts.GameLifeUserKey, popenID)
|
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("设置用户信息失败")
|
return nil, ecode.Fail.Sub("设置用户信息失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user