Merge remote-tracking branch 'origin/master'
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
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,8 +29,7 @@ func (c *ControllerV1) WeChatEvent(ctx context.Context, req *v1.WeChatEventReq)
|
|||||||
switch req.Event {
|
switch req.Event {
|
||||||
case "subscribe":
|
case "subscribe":
|
||||||
key := strings.TrimPrefix(req.EventKey, "qrscene_")
|
key := strings.TrimPrefix(req.EventKey, "qrscene_")
|
||||||
split := strings.Split(req.EventKey, "_")
|
out, err := service.User().Login(ctx, &model.UserLoginIn{OpenId: unionid, SceneId: key})
|
||||||
out, err := service.User().Login(ctx, &model.UserLoginIn{OpenId: unionid, StoreCode: split[0]})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -39,8 +38,7 @@ func (c *ControllerV1) WeChatEvent(ctx context.Context, req *v1.WeChatEventReq)
|
|||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
case "SCAN":
|
case "SCAN":
|
||||||
split := strings.Split(req.EventKey, "_")
|
out, err := service.User().Login(ctx, &model.UserLoginIn{OpenId: unionid, SceneId: req.EventKey})
|
||||||
out, err := service.User().Login(ctx, &model.UserLoginIn{OpenId: unionid, StoreCode: split[0]})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,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.
|
||||||
@ -53,6 +54,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()
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
"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/os/gtime"
|
||||||
|
"github.com/gogf/gf/v2/util/gconv"
|
||||||
"github.com/gogf/gf/v2/util/grand"
|
"github.com/gogf/gf/v2/util/grand"
|
||||||
"server/internal/consts"
|
"server/internal/consts"
|
||||||
"server/internal/dao"
|
"server/internal/dao"
|
||||||
@ -19,6 +20,7 @@ import (
|
|||||||
"server/utility/gamelife"
|
"server/utility/gamelife"
|
||||||
"server/utility/jwt"
|
"server/utility/jwt"
|
||||||
"server/utility/sms"
|
"server/utility/sms"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type sUser struct{}
|
type sUser struct{}
|
||||||
@ -53,74 +55,114 @@ func New() service.IUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *sUser) Login(ctx context.Context, in *model.UserLoginIn) (out *model.UserLoginOut, err error) {
|
func (s *sUser) Login(ctx context.Context, in *model.UserLoginIn) (out *model.UserLoginOut, err error) {
|
||||||
|
// Fetch role information
|
||||||
value, err := dao.Roles.Ctx(ctx).Where(do.Roles{Code: consts.UserRoleCode}).Fields(dao.Roles.Columns().Code, dao.Roles.Columns().Id).One()
|
value, err := dao.Roles.Ctx(ctx).Where(do.Roles{Code: consts.UserRoleCode}).Fields(dao.Roles.Columns().Code, dao.Roles.Columns().Id).One()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ecode.Fail.Sub("查找角色失败")
|
return nil, ecode.Fail.Sub("查找角色失败")
|
||||||
}
|
}
|
||||||
// 根据 OpenId 查找用户
|
|
||||||
exist, err := dao.Users.Ctx(ctx).Where(do.Users{WxOpenId: in.OpenId}).Exist()
|
split := strings.Split(in.SceneId, "_")
|
||||||
if err != nil {
|
if len(split) < 3 {
|
||||||
return nil, ecode.Fail.Sub("查找用户失败")
|
return nil, ecode.Fail.Sub("SceneId格式错误")
|
||||||
}
|
}
|
||||||
|
storeId := gconv.Int64(split[0])
|
||||||
|
var xyUserId string
|
||||||
var userId int64
|
var userId int64
|
||||||
v, err := dao.Stores.Ctx(ctx).Where(do.Stores{StoreCode: in.StoreCode}).Fields(dao.Stores.Columns().Id).Value()
|
|
||||||
if err != nil {
|
if split[1] == "0" {
|
||||||
return nil, ecode.Fail.Sub("查找门店失败")
|
// Case 1: split[1] == "0", use in.OpenId to find or create user
|
||||||
}
|
exist, err := dao.Users.Ctx(ctx).Where(do.Users{WxOpenId: in.OpenId}).Exist()
|
||||||
if !exist {
|
if err != nil {
|
||||||
// 用户不存在,创建新用户
|
return nil, ecode.Fail.Sub("查找用户失败")
|
||||||
// 生成 username: qy_ + 8位随机字母数字
|
}
|
||||||
var username string
|
|
||||||
for {
|
if !exist {
|
||||||
randomStr := grand.Str("abcdefghijklmnopqrstuvwxyz0123456789", 8)
|
// User does not exist, create new user
|
||||||
username = "qy_" + randomStr
|
var username string
|
||||||
// 检查 username 是否唯一
|
for {
|
||||||
count, err := dao.Users.Ctx(ctx).Where(do.Users{Username: username}).Count()
|
randomStr := grand.Str("abcdefghijklmnopqrstuvwxyz0123456789", 8)
|
||||||
|
username = "qy_" + randomStr
|
||||||
|
count, err := dao.Users.Ctx(ctx).Where(do.Users{Username: username}).Count()
|
||||||
|
if err != nil {
|
||||||
|
return nil, ecode.Fail.Sub("检查用户名失败")
|
||||||
|
}
|
||||||
|
if count == 0 {
|
||||||
|
break // Username is unique
|
||||||
|
}
|
||||||
|
}
|
||||||
|
password, err := encrypt.EncryptPassword(consts.DefaultPassword)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ecode.Fail.Sub("检查用户名失败")
|
return nil, ecode.Fail.Sub("加密密码失败")
|
||||||
}
|
}
|
||||||
if count == 0 {
|
user := &entity.Users{
|
||||||
break // username 唯一,退出循环
|
WxOpenId: in.OpenId,
|
||||||
|
Username: username,
|
||||||
|
Nickname: username,
|
||||||
|
PasswordHash: password,
|
||||||
|
Avatar: consts.DefaultUserAvatar,
|
||||||
|
FirstVisitAt: gtime.Now(),
|
||||||
|
LastLoginAt: gtime.Now(),
|
||||||
|
WxPopenId: utility.GenerateUserID("WX"),
|
||||||
|
QqPopenId: utility.GenerateUserID("QQ"),
|
||||||
|
RoleId: value[dao.Roles.Columns().Id].Int64(),
|
||||||
|
LastLoginStoreId: storeId,
|
||||||
|
}
|
||||||
|
result, err := dao.Users.Ctx(ctx).Insert(user)
|
||||||
|
if err != nil {
|
||||||
|
return nil, ecode.Fail.Sub("创建用户失败")
|
||||||
|
}
|
||||||
|
userId, err = result.LastInsertId()
|
||||||
|
if err != nil {
|
||||||
|
return nil, ecode.Fail.Sub("获取用户ID失败")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// User exists, update last login store ID and time
|
||||||
|
var user entity.Users
|
||||||
|
if err := dao.Users.Ctx(ctx).Where(do.Users{WxOpenId: in.OpenId}).Scan(&user); err != nil {
|
||||||
|
return nil, ecode.Fail.Sub("查找用户失败")
|
||||||
|
}
|
||||||
|
userId = user.Id
|
||||||
|
if _, err := dao.Users.Ctx(ctx).Where(do.Users{Id: userId}).Update(do.Users{
|
||||||
|
LastLoginAt: gtime.Now(),
|
||||||
|
LastLoginStoreId: storeId,
|
||||||
|
}); err != nil {
|
||||||
|
return nil, ecode.Fail.Sub("更新登录时间失败")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
password, err := encrypt.EncryptPassword(consts.DefaultPassword)
|
} else if split[1] == "1" {
|
||||||
if err != nil {
|
// Case 2: split[1] == "1", use xyUserId to find user and bind in.OpenId
|
||||||
return nil, ecode.Fail.Sub("加密密码失败")
|
xyUserId = split[2]
|
||||||
}
|
|
||||||
user := &entity.Users{
|
|
||||||
WxOpenId: in.OpenId,
|
|
||||||
Username: username,
|
|
||||||
Nickname: username,
|
|
||||||
PasswordHash: password,
|
|
||||||
Avatar: consts.DefaultUserAvatar,
|
|
||||||
FirstVisitAt: gtime.Now(),
|
|
||||||
LastLoginAt: gtime.Now(),
|
|
||||||
WxPopenId: utility.GenerateUserID("WX"),
|
|
||||||
QqPopenId: utility.GenerateUserID("QQ"),
|
|
||||||
RoleId: value[dao.Roles.Columns().Id].Int64(),
|
|
||||||
LastLoginStoreId: v.Int64(),
|
|
||||||
}
|
|
||||||
result, err := dao.Users.Ctx(ctx).Insert(user)
|
|
||||||
if err != nil {
|
|
||||||
return nil, ecode.Fail.Sub("创建用户失败")
|
|
||||||
}
|
|
||||||
userId, err = result.LastInsertId()
|
|
||||||
if err != nil {
|
|
||||||
return nil, ecode.Fail.Sub("获取用户ID失败")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 用户存在,更新最后登录时间
|
|
||||||
var user entity.Users
|
var user entity.Users
|
||||||
if err := dao.Users.Ctx(ctx).Where(do.Users{WxOpenId: in.OpenId}).Scan(&user); err != nil {
|
exist, err := dao.Users.Ctx(ctx).Where(do.Users{XyUserId: xyUserId}).Exist()
|
||||||
|
if err != nil {
|
||||||
|
return nil, ecode.Fail.Sub("查找用户失败")
|
||||||
|
}
|
||||||
|
if !exist {
|
||||||
|
return nil, ecode.Fail.Sub("参数错误:用户不存在")
|
||||||
|
}
|
||||||
|
|
||||||
|
// User exists, check WxOpenId
|
||||||
|
if err := dao.Users.Ctx(ctx).Where(do.Users{XyUserId: xyUserId}).Scan(&user); err != nil {
|
||||||
return nil, ecode.Fail.Sub("查找用户失败")
|
return nil, ecode.Fail.Sub("查找用户失败")
|
||||||
}
|
}
|
||||||
userId = user.Id
|
userId = user.Id
|
||||||
if _, err := dao.Users.Ctx(ctx).Where(do.Users{Id: userId}).Update(do.Users{LastLoginAt: gtime.Now(), LastLoginStoreId: v.Int64()}); err != nil {
|
if user.WxOpenId != "" && user.WxOpenId != in.OpenId {
|
||||||
return nil, ecode.Fail.Sub("更新登录时间失败")
|
return nil, ecode.Fail.Sub("当前微信已绑定其他微信号")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bind in.OpenId and update last login store ID
|
||||||
|
if _, err := dao.Users.Ctx(ctx).Where(do.Users{Id: userId}).Update(do.Users{
|
||||||
|
WxOpenId: in.OpenId,
|
||||||
|
LastLoginAt: gtime.Now(),
|
||||||
|
LastLoginStoreId: storeId,
|
||||||
|
}); err != nil {
|
||||||
|
return nil, ecode.Fail.Sub("绑定OpenId失败")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil, ecode.Fail.Sub("无效的SceneId类型")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成 token
|
// Generate token
|
||||||
token, err := jwt.GenerateToken(&jwt.TokenIn{
|
token, err := jwt.GenerateToken(&jwt.TokenIn{
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
Role: value[dao.Roles.Columns().Code].String(),
|
Role: value[dao.Roles.Columns().Code].String(),
|
||||||
@ -132,7 +174,7 @@ func (s *sUser) Login(ctx context.Context, in *model.UserLoginIn) (out *model.Us
|
|||||||
out = &model.UserLoginOut{
|
out = &model.UserLoginOut{
|
||||||
Token: token,
|
Token: token,
|
||||||
}
|
}
|
||||||
return
|
return out, nil
|
||||||
}
|
}
|
||||||
func (s *sUser) WeChatLogin(ctx context.Context, in *model.WeChatLogin) (out *model.WeChatLoginOut, err error) {
|
func (s *sUser) WeChatLogin(ctx context.Context, in *model.WeChatLogin) (out *model.WeChatLoginOut, err error) {
|
||||||
return
|
return
|
||||||
|
|||||||
@ -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:"当前账号类型"` // 当前账号类型
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,8 +59,8 @@ type LoginCache struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UserLoginIn struct {
|
type UserLoginIn struct {
|
||||||
OpenId string
|
OpenId string
|
||||||
StoreCode string // 门店编码,登录时根据门店编码查询,填写最近一次登录门店 id
|
SceneId string
|
||||||
}
|
}
|
||||||
type WeChatLogin struct {
|
type WeChatLogin struct {
|
||||||
UUID string // 使用的是微信的唯一 id,而不是openid,保证微信服务号,小程序绑定的系统用户为同一个
|
UUID string // 使用的是微信的唯一 id,而不是openid,保证微信服务号,小程序绑定的系统用户为同一个
|
||||||
|
|||||||
@ -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