Compare commits

..

18 Commits

54 changed files with 686 additions and 345 deletions

View File

@ -49,7 +49,7 @@ type MerchantRegisterRes struct {
}
type StoreLoginReq struct {
g.Meta `path:"/store/login" method:"post" tags:"Backend/Store" summary:"(商户门店后台)门店登录"`
g.Meta `path:"/store/login" method:"post" tags:"PC-Server" summary:"(商户门店后台)门店登录"`
Username string `json:"username" v:"required" dc:"用户名"`
Password string `json:"password" v:"required" dc:"密码"`
}
@ -63,9 +63,9 @@ type StoreLoginRes struct {
}
type Quan8AutologinReq struct {
g.Meta `path:"/quan8/autologin" method:"post" tags:"PC/Auth" summary:"8圈用户自动登录该系统"`
g.Meta `path:"/quan8/autologin" method:"post" tags:"PC-Server" summary:"8圈用户自动登录该系统"`
UUID string `json:"uuid" v:"required#UUID不能为空" dc:"UUID"`
StoreId int64
StoreId int64 `json:"storeId" v:"required#门店ID不能为空" dc:"门店ID"`
}
type Quan8AutologinRes struct {
Token string `json:"token"`

View File

@ -3,7 +3,7 @@ package v1
import "github.com/gogf/gf/v2/frame/g"
type GetReq struct {
g.Meta `path:"/desktop" method:"get" tags:"PC/Desktop" summary:"(PC)获取桌面信息"`
g.Meta `path:"/desktop" method:"get" tags:"PC-Server" summary:"(PC)获取桌面信息"`
StoreId int64 `json:"storeId" v:"required#请选择店铺" dc:"门店id"`
}
type GetRes struct {

View File

@ -87,11 +87,12 @@ type GetIpListRes struct {
Total int64 `json:"total" dc:"总数"`
}
type DetailReq struct {
g.Meta `path:"/store/detail" method:"get" tags:"Backend/Store" summary:"(系统、商户门店后台)门店详情"`
NetbarAccount string `json:"netbarAccount" v:"required" dc:"门店账号"`
g.Meta `path:"/store/detail" method:"get" tags:"Backend/Store" summary:"(系统、商户门店后台)门店详情"`
StoreId int64 `json:"storeId" v:"required" dc:"门店ID"`
}
type DetailRes struct {
Id int64 `json:"id" dc:"门店ID"`
Id int64 `json:"id" dc:"门店ID"`
NetbarAccount string `json:"netbarAccount" dc:"门店账号"`
}
type StoreMemberLevelReq struct {

View File

@ -7,8 +7,11 @@ type InfoReq struct {
}
type InfoRes struct {
Id int64 `json:"id"`
Username string `json:"username"`
Id int64 `json:"id"`
StoreId int64 `json:"storeId"`
Username string `json:"username"`
Realname string `json:"realname"`
IsPrimary bool `json:"isPrimary"`
}
type ListReq struct {
g.Meta `path:"/store/admin" method:"get" tags:"Backend/StoreAdmin" summary:"(系统、商户门店后台)门店管理员列表"`

View File

@ -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" dc:"绑定类型 1: QQ 2:微信"`
}
type GetUserTaskRecordsListRes struct {
List interface{} `json:"list"`

View File

@ -54,6 +54,8 @@ func (c *ControllerV1) Callback(ctx context.Context, req *v1.CallbackReq) (res *
return nil, nil
}
glog.Infof(ctx, "回调响应:%s", marshal)
g.RequestFromCtx(ctx).Response.Write(marshal)
return nil, nil
}

View File

@ -9,9 +9,9 @@ import (
)
func (c *ControllerV1) Detail(ctx context.Context, req *v1.DetailReq) (res *v1.DetailRes, err error) {
out, err := service.Store().Detail(ctx, &model.StoreDetailIn{NetbarAccount: req.NetbarAccount})
out, err := service.Store().Detail(ctx, &model.StoreDetailIn{StoreId: req.StoreId})
if err != nil {
return nil, err
}
return &v1.DetailRes{Id: out.Id}, nil
return &v1.DetailRes{Id: out.Id, NetbarAccount: out.NetbarAccount}, nil
}

View File

@ -3,14 +3,17 @@ package storeAdmin
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"server/internal/model"
"server/internal/service"
"server/api/storeAdmin/v1"
)
func (c *ControllerV1) Info(ctx context.Context, req *v1.InfoReq) (res *v1.InfoRes, err error) {
g.RequestFromCtx(ctx)
return nil, gerror.NewCode(gcode.CodeNotImplemented)
storeAdminId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
out, err := service.StoreAdmin().Info(ctx, &model.StoreAdminInfoIn{StoreAdminId: storeAdminId})
if err != nil {
return nil, err
}
return &v1.InfoRes{Id: out.Id, StoreId: out.StoreId, Username: out.Username, Realname: out.RealName, IsPrimary: out.IsPrimary}, nil
}

View File

@ -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

View File

@ -3,6 +3,7 @@ package task
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/glog"
"server/internal/model"
"server/internal/service"
@ -11,6 +12,8 @@ import (
func (c *ControllerV1) GetTaskList(ctx context.Context, req *v1.GetTaskListReq) (res *v1.GetTaskListRes, err error) {
glog.Info(ctx, req)
userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
list, err := service.Task().GetTaskList(ctx, &model.GetTaskListV2In{
Gid: req.Gid,
@ -26,6 +29,8 @@ func (c *ControllerV1) GetTaskList(ctx context.Context, req *v1.GetTaskListReq)
if err != nil {
return nil, err
}
glog.Infof(ctx, "The return task length of Game %d: %d", req.Gid, len(list.Data))
glog.Info(ctx, list)
return &v1.GetTaskListRes{
List: list,
}, nil

View File

@ -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
}

View File

@ -29,8 +29,7 @@ func (c *ControllerV1) WeChatEvent(ctx context.Context, req *v1.WeChatEventReq)
switch req.Event {
case "subscribe":
key := strings.TrimPrefix(req.EventKey, "qrscene_")
split := strings.Split(req.EventKey, "_")
out, err := service.User().Login(ctx, &model.UserLoginIn{OpenId: unionid, StoreCode: split[0]})
out, err := service.User().Login(ctx, &model.UserLoginIn{OpenId: unionid, SceneId: key})
if err != nil {
return nil, err
}
@ -39,8 +38,7 @@ func (c *ControllerV1) WeChatEvent(ctx context.Context, req *v1.WeChatEventReq)
}
return nil, nil
case "SCAN":
split := strings.Split(req.EventKey, "_")
out, err := service.User().Login(ctx, &model.UserLoginIn{OpenId: unionid, StoreCode: split[0]})
out, err := service.User().Login(ctx, &model.UserLoginIn{OpenId: unionid, SceneId: req.EventKey})
if err != nil {
return nil, err
}

View File

@ -13,9 +13,10 @@ import (
// AdminsDao is the data access object for the table admins.
type AdminsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns AdminsColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns AdminsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// AdminsColumns defines and stores column names for the table admins.
@ -49,11 +50,12 @@ var adminsColumns = AdminsColumns{
}
// NewAdminsDao creates and returns a new DAO object for table data access.
func NewAdminsDao() *AdminsDao {
func NewAdminsDao(handlers ...gdb.ModelHandler) *AdminsDao {
return &AdminsDao{
group: "default",
table: "admins",
columns: adminsColumns,
group: "default",
table: "admins",
columns: adminsColumns,
handlers: handlers,
}
}
@ -79,7 +81,11 @@ func (dao *AdminsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *AdminsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// FeedbacksDao is the data access object for the table feedbacks.
type FeedbacksDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns FeedbacksColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns FeedbacksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// FeedbacksColumns defines and stores column names for the table feedbacks.
@ -51,11 +52,12 @@ var feedbacksColumns = FeedbacksColumns{
}
// NewFeedbacksDao creates and returns a new DAO object for table data access.
func NewFeedbacksDao() *FeedbacksDao {
func NewFeedbacksDao(handlers ...gdb.ModelHandler) *FeedbacksDao {
return &FeedbacksDao{
group: "default",
table: "feedbacks",
columns: feedbacksColumns,
group: "default",
table: "feedbacks",
columns: feedbacksColumns,
handlers: handlers,
}
}
@ -81,7 +83,11 @@ func (dao *FeedbacksDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *FeedbacksDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// GamesDao is the data access object for the table games.
type GamesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns GamesColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns GamesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// GamesColumns defines and stores column names for the table games.
@ -45,11 +46,12 @@ var gamesColumns = GamesColumns{
}
// NewGamesDao creates and returns a new DAO object for table data access.
func NewGamesDao() *GamesDao {
func NewGamesDao(handlers ...gdb.ModelHandler) *GamesDao {
return &GamesDao{
group: "default",
table: "games",
columns: gamesColumns,
group: "default",
table: "games",
columns: gamesColumns,
handlers: handlers,
}
}
@ -75,7 +77,11 @@ func (dao *GamesDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *GamesDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// MerchantAdminsDao is the data access object for the table merchant_admins.
type MerchantAdminsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns MerchantAdminsColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns MerchantAdminsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// MerchantAdminsColumns defines and stores column names for the table merchant_admins.
@ -57,11 +58,12 @@ var merchantAdminsColumns = MerchantAdminsColumns{
}
// NewMerchantAdminsDao creates and returns a new DAO object for table data access.
func NewMerchantAdminsDao() *MerchantAdminsDao {
func NewMerchantAdminsDao(handlers ...gdb.ModelHandler) *MerchantAdminsDao {
return &MerchantAdminsDao{
group: "default",
table: "merchant_admins",
columns: merchantAdminsColumns,
group: "default",
table: "merchant_admins",
columns: merchantAdminsColumns,
handlers: handlers,
}
}
@ -87,7 +89,11 @@ func (dao *MerchantAdminsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *MerchantAdminsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// MerchantsDao is the data access object for the table merchants.
type MerchantsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns MerchantsColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns MerchantsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// MerchantsColumns defines and stores column names for the table merchants.
@ -71,11 +72,12 @@ var merchantsColumns = MerchantsColumns{
}
// NewMerchantsDao creates and returns a new DAO object for table data access.
func NewMerchantsDao() *MerchantsDao {
func NewMerchantsDao(handlers ...gdb.ModelHandler) *MerchantsDao {
return &MerchantsDao{
group: "default",
table: "merchants",
columns: merchantsColumns,
group: "default",
table: "merchants",
columns: merchantsColumns,
handlers: handlers,
}
}
@ -101,7 +103,11 @@ func (dao *MerchantsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *MerchantsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// NoticesDao is the data access object for the table notices.
type NoticesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns NoticesColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns NoticesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// NoticesColumns defines and stores column names for the table notices.
@ -49,11 +50,12 @@ var noticesColumns = NoticesColumns{
}
// NewNoticesDao creates and returns a new DAO object for table data access.
func NewNoticesDao() *NoticesDao {
func NewNoticesDao(handlers ...gdb.ModelHandler) *NoticesDao {
return &NoticesDao{
group: "default",
table: "notices",
columns: noticesColumns,
group: "default",
table: "notices",
columns: noticesColumns,
handlers: handlers,
}
}
@ -79,7 +81,11 @@ func (dao *NoticesDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *NoticesDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// RewardCallbackDao is the data access object for the table reward_callback.
type RewardCallbackDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RewardCallbackColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RewardCallbackColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// RewardCallbackColumns defines and stores column names for the table reward_callback.
@ -31,6 +32,9 @@ type RewardCallbackColumns struct {
CustomInfo string // 透传字段 (json串)
AppId string // 业务 id标识业务方由游戏人生提供
InnerOrderId string // 系统内部订单ID
CreatedAt string //
UpdatedAt string //
DeletedAt string //
}
// rewardCallbackColumns holds the columns for the table reward_callback.
@ -46,14 +50,18 @@ var rewardCallbackColumns = RewardCallbackColumns{
CustomInfo: "custom_info",
AppId: "app_id",
InnerOrderId: "inner_order_id",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewRewardCallbackDao creates and returns a new DAO object for table data access.
func NewRewardCallbackDao() *RewardCallbackDao {
func NewRewardCallbackDao(handlers ...gdb.ModelHandler) *RewardCallbackDao {
return &RewardCallbackDao{
group: "default",
table: "reward_callback",
columns: rewardCallbackColumns,
group: "default",
table: "reward_callback",
columns: rewardCallbackColumns,
handlers: handlers,
}
}
@ -79,7 +87,11 @@ func (dao *RewardCallbackDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *RewardCallbackDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// RewardTypesDao is the data access object for the table reward_types.
type RewardTypesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RewardTypesColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RewardTypesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// RewardTypesColumns defines and stores column names for the table reward_types.
@ -45,11 +46,12 @@ var rewardTypesColumns = RewardTypesColumns{
}
// NewRewardTypesDao creates and returns a new DAO object for table data access.
func NewRewardTypesDao() *RewardTypesDao {
func NewRewardTypesDao(handlers ...gdb.ModelHandler) *RewardTypesDao {
return &RewardTypesDao{
group: "default",
table: "reward_types",
columns: rewardTypesColumns,
group: "default",
table: "reward_types",
columns: rewardTypesColumns,
handlers: handlers,
}
}
@ -75,7 +77,11 @@ func (dao *RewardTypesDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *RewardTypesDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// RewardWatersDao is the data access object for the table reward_waters.
type RewardWatersDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RewardWatersColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RewardWatersColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// RewardWatersColumns defines and stores column names for the table reward_waters.
@ -47,11 +48,12 @@ var rewardWatersColumns = RewardWatersColumns{
}
// NewRewardWatersDao creates and returns a new DAO object for table data access.
func NewRewardWatersDao() *RewardWatersDao {
func NewRewardWatersDao(handlers ...gdb.ModelHandler) *RewardWatersDao {
return &RewardWatersDao{
group: "default",
table: "reward_waters",
columns: rewardWatersColumns,
group: "default",
table: "reward_waters",
columns: rewardWatersColumns,
handlers: handlers,
}
}
@ -77,7 +79,11 @@ func (dao *RewardWatersDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *RewardWatersDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// RewardsDao is the data access object for the table rewards.
type RewardsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RewardsColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RewardsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// RewardsColumns defines and stores column names for the table rewards.
@ -75,11 +76,12 @@ var rewardsColumns = RewardsColumns{
}
// NewRewardsDao creates and returns a new DAO object for table data access.
func NewRewardsDao() *RewardsDao {
func NewRewardsDao(handlers ...gdb.ModelHandler) *RewardsDao {
return &RewardsDao{
group: "default",
table: "rewards",
columns: rewardsColumns,
group: "default",
table: "rewards",
columns: rewardsColumns,
handlers: handlers,
}
}
@ -105,7 +107,11 @@ func (dao *RewardsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *RewardsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// RolesDao is the data access object for the table roles.
type RolesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RolesColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RolesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// RolesColumns defines and stores column names for the table roles.
@ -47,11 +48,12 @@ var rolesColumns = RolesColumns{
}
// NewRolesDao creates and returns a new DAO object for table data access.
func NewRolesDao() *RolesDao {
func NewRolesDao(handlers ...gdb.ModelHandler) *RolesDao {
return &RolesDao{
group: "default",
table: "roles",
columns: rolesColumns,
group: "default",
table: "roles",
columns: rolesColumns,
handlers: handlers,
}
}
@ -77,7 +79,11 @@ func (dao *RolesDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *RolesDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoreAdminsDao is the data access object for the table store_admins.
type StoreAdminsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreAdminsColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreAdminsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreAdminsColumns defines and stores column names for the table store_admins.
@ -57,11 +58,12 @@ var storeAdminsColumns = StoreAdminsColumns{
}
// NewStoreAdminsDao creates and returns a new DAO object for table data access.
func NewStoreAdminsDao() *StoreAdminsDao {
func NewStoreAdminsDao(handlers ...gdb.ModelHandler) *StoreAdminsDao {
return &StoreAdminsDao{
group: "default",
table: "store_admins",
columns: storeAdminsColumns,
group: "default",
table: "store_admins",
columns: storeAdminsColumns,
handlers: handlers,
}
}
@ -87,7 +89,11 @@ func (dao *StoreAdminsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreAdminsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoreAreasDao is the data access object for the table store_areas.
type StoreAreasDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreAreasColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreAreasColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreAreasColumns defines and stores column names for the table store_areas.
@ -39,11 +40,12 @@ var storeAreasColumns = StoreAreasColumns{
}
// NewStoreAreasDao creates and returns a new DAO object for table data access.
func NewStoreAreasDao() *StoreAreasDao {
func NewStoreAreasDao(handlers ...gdb.ModelHandler) *StoreAreasDao {
return &StoreAreasDao{
group: "default",
table: "store_areas",
columns: storeAreasColumns,
group: "default",
table: "store_areas",
columns: storeAreasColumns,
handlers: handlers,
}
}
@ -69,7 +71,11 @@ func (dao *StoreAreasDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreAreasDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoreClientSessionsDao is the data access object for the table store_client_sessions.
type StoreClientSessionsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreClientSessionsColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreClientSessionsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreClientSessionsColumns defines and stores column names for the table store_client_sessions.
@ -57,11 +58,12 @@ var storeClientSessionsColumns = StoreClientSessionsColumns{
}
// NewStoreClientSessionsDao creates and returns a new DAO object for table data access.
func NewStoreClientSessionsDao() *StoreClientSessionsDao {
func NewStoreClientSessionsDao(handlers ...gdb.ModelHandler) *StoreClientSessionsDao {
return &StoreClientSessionsDao{
group: "default",
table: "store_client_sessions",
columns: storeClientSessionsColumns,
group: "default",
table: "store_client_sessions",
columns: storeClientSessionsColumns,
handlers: handlers,
}
}
@ -87,7 +89,11 @@ func (dao *StoreClientSessionsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreClientSessionsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoreClientsDao is the data access object for the table store_clients.
type StoreClientsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreClientsColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreClientsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreClientsColumns defines and stores column names for the table store_clients.
@ -43,11 +44,12 @@ var storeClientsColumns = StoreClientsColumns{
}
// NewStoreClientsDao creates and returns a new DAO object for table data access.
func NewStoreClientsDao() *StoreClientsDao {
func NewStoreClientsDao(handlers ...gdb.ModelHandler) *StoreClientsDao {
return &StoreClientsDao{
group: "default",
table: "store_clients",
columns: storeClientsColumns,
group: "default",
table: "store_clients",
columns: storeClientsColumns,
handlers: handlers,
}
}
@ -73,7 +75,11 @@ func (dao *StoreClientsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreClientsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoreDesktopSettingsDao is the data access object for the table store_desktop_settings.
type StoreDesktopSettingsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreDesktopSettingsColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreDesktopSettingsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreDesktopSettingsColumns defines and stores column names for the table store_desktop_settings.
@ -33,11 +34,12 @@ var storeDesktopSettingsColumns = StoreDesktopSettingsColumns{
}
// NewStoreDesktopSettingsDao creates and returns a new DAO object for table data access.
func NewStoreDesktopSettingsDao() *StoreDesktopSettingsDao {
func NewStoreDesktopSettingsDao(handlers ...gdb.ModelHandler) *StoreDesktopSettingsDao {
return &StoreDesktopSettingsDao{
group: "default",
table: "store_desktop_settings",
columns: storeDesktopSettingsColumns,
group: "default",
table: "store_desktop_settings",
columns: storeDesktopSettingsColumns,
handlers: handlers,
}
}
@ -63,7 +65,11 @@ func (dao *StoreDesktopSettingsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreDesktopSettingsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoreIpsDao is the data access object for the table store_ips.
type StoreIpsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreIpsColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreIpsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreIpsColumns defines and stores column names for the table store_ips.
@ -41,11 +42,12 @@ var storeIpsColumns = StoreIpsColumns{
}
// NewStoreIpsDao creates and returns a new DAO object for table data access.
func NewStoreIpsDao() *StoreIpsDao {
func NewStoreIpsDao(handlers ...gdb.ModelHandler) *StoreIpsDao {
return &StoreIpsDao{
group: "default",
table: "store_ips",
columns: storeIpsColumns,
group: "default",
table: "store_ips",
columns: storeIpsColumns,
handlers: handlers,
}
}
@ -71,7 +73,11 @@ func (dao *StoreIpsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreIpsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoreMemberLevelsDao is the data access object for the table store_member_levels.
type StoreMemberLevelsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreMemberLevelsColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreMemberLevelsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreMemberLevelsColumns defines and stores column names for the table store_member_levels.
@ -47,11 +48,12 @@ var storeMemberLevelsColumns = StoreMemberLevelsColumns{
}
// NewStoreMemberLevelsDao creates and returns a new DAO object for table data access.
func NewStoreMemberLevelsDao() *StoreMemberLevelsDao {
func NewStoreMemberLevelsDao(handlers ...gdb.ModelHandler) *StoreMemberLevelsDao {
return &StoreMemberLevelsDao{
group: "default",
table: "store_member_levels",
columns: storeMemberLevelsColumns,
group: "default",
table: "store_member_levels",
columns: storeMemberLevelsColumns,
handlers: handlers,
}
}
@ -77,7 +79,11 @@ func (dao *StoreMemberLevelsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreMemberLevelsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoreNetfeeAreaLevelDao is the data access object for the table store_netfee_area_level.
type StoreNetfeeAreaLevelDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreNetfeeAreaLevelColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreNetfeeAreaLevelColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreNetfeeAreaLevelColumns defines and stores column names for the table store_netfee_area_level.
@ -45,11 +46,12 @@ var storeNetfeeAreaLevelColumns = StoreNetfeeAreaLevelColumns{
}
// NewStoreNetfeeAreaLevelDao creates and returns a new DAO object for table data access.
func NewStoreNetfeeAreaLevelDao() *StoreNetfeeAreaLevelDao {
func NewStoreNetfeeAreaLevelDao(handlers ...gdb.ModelHandler) *StoreNetfeeAreaLevelDao {
return &StoreNetfeeAreaLevelDao{
group: "default",
table: "store_netfee_area_level",
columns: storeNetfeeAreaLevelColumns,
group: "default",
table: "store_netfee_area_level",
columns: storeNetfeeAreaLevelColumns,
handlers: handlers,
}
}
@ -75,7 +77,11 @@ func (dao *StoreNetfeeAreaLevelDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreNetfeeAreaLevelDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoreRolesDao is the data access object for the table store_roles.
type StoreRolesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreRolesColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreRolesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreRolesColumns defines and stores column names for the table store_roles.
@ -39,11 +40,12 @@ var storeRolesColumns = StoreRolesColumns{
}
// NewStoreRolesDao creates and returns a new DAO object for table data access.
func NewStoreRolesDao() *StoreRolesDao {
func NewStoreRolesDao(handlers ...gdb.ModelHandler) *StoreRolesDao {
return &StoreRolesDao{
group: "default",
table: "store_roles",
columns: storeRolesColumns,
group: "default",
table: "store_roles",
columns: storeRolesColumns,
handlers: handlers,
}
}
@ -69,7 +71,11 @@ func (dao *StoreRolesDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreRolesDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoresDao is the data access object for the table stores.
type StoresDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoresColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoresColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoresColumns defines and stores column names for the table stores.
@ -51,11 +52,12 @@ var storesColumns = StoresColumns{
}
// NewStoresDao creates and returns a new DAO object for table data access.
func NewStoresDao() *StoresDao {
func NewStoresDao(handlers ...gdb.ModelHandler) *StoresDao {
return &StoresDao{
group: "default",
table: "stores",
columns: storesColumns,
group: "default",
table: "stores",
columns: storesColumns,
handlers: handlers,
}
}
@ -81,7 +83,11 @@ func (dao *StoresDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoresDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// TaskRewardsDao is the data access object for the table task_rewards.
type TaskRewardsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns TaskRewardsColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns TaskRewardsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// TaskRewardsColumns defines and stores column names for the table task_rewards.
@ -35,11 +36,12 @@ var taskRewardsColumns = TaskRewardsColumns{
}
// NewTaskRewardsDao creates and returns a new DAO object for table data access.
func NewTaskRewardsDao() *TaskRewardsDao {
func NewTaskRewardsDao(handlers ...gdb.ModelHandler) *TaskRewardsDao {
return &TaskRewardsDao{
group: "default",
table: "task_rewards",
columns: taskRewardsColumns,
group: "default",
table: "task_rewards",
columns: taskRewardsColumns,
handlers: handlers,
}
}
@ -65,7 +67,11 @@ func (dao *TaskRewardsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *TaskRewardsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// TasksDao is the data access object for the table tasks.
type TasksDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns TasksColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns TasksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// TasksColumns defines and stores column names for the table tasks.
@ -45,11 +46,12 @@ var tasksColumns = TasksColumns{
}
// NewTasksDao creates and returns a new DAO object for table data access.
func NewTasksDao() *TasksDao {
func NewTasksDao(handlers ...gdb.ModelHandler) *TasksDao {
return &TasksDao{
group: "default",
table: "tasks",
columns: tasksColumns,
group: "default",
table: "tasks",
columns: tasksColumns,
handlers: handlers,
}
}
@ -75,7 +77,11 @@ func (dao *TasksDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *TasksDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// UserTaskRewardsDao is the data access object for the table user_task_rewards.
type UserTaskRewardsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns UserTaskRewardsColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns UserTaskRewardsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// UserTaskRewardsColumns defines and stores column names for the table user_task_rewards.
@ -57,11 +58,12 @@ var userTaskRewardsColumns = UserTaskRewardsColumns{
}
// NewUserTaskRewardsDao creates and returns a new DAO object for table data access.
func NewUserTaskRewardsDao() *UserTaskRewardsDao {
func NewUserTaskRewardsDao(handlers ...gdb.ModelHandler) *UserTaskRewardsDao {
return &UserTaskRewardsDao{
group: "default",
table: "user_task_rewards",
columns: userTaskRewardsColumns,
group: "default",
table: "user_task_rewards",
columns: userTaskRewardsColumns,
handlers: handlers,
}
}
@ -87,7 +89,11 @@ func (dao *UserTaskRewardsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *UserTaskRewardsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// UserTasksDao is the data access object for the table user_tasks.
type UserTasksDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns UserTasksColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns UserTasksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// UserTasksColumns defines and stores column names for the table user_tasks.
@ -34,6 +35,7 @@ type UserTasksColumns struct {
GameId string // 游戏 id
TaskType string // 1: 每日任务 3: 周期任务
UserTimes string // 用户完成次数
BindType string // 1:qq 2:wx
}
// userTasksColumns holds the columns for the table user_tasks.
@ -52,14 +54,16 @@ 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.
func NewUserTasksDao() *UserTasksDao {
func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao {
return &UserTasksDao{
group: "default",
table: "user_tasks",
columns: userTasksColumns,
group: "default",
table: "user_tasks",
columns: userTasksColumns,
handlers: handlers,
}
}
@ -85,7 +89,11 @@ func (dao *UserTasksDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// UsersDao is the data access object for the table users.
type UsersDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns UsersColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns UsersColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// UsersColumns defines and stores column names for the table users.
@ -61,11 +62,12 @@ var usersColumns = UsersColumns{
}
// NewUsersDao creates and returns a new DAO object for table data access.
func NewUsersDao() *UsersDao {
func NewUsersDao(handlers ...gdb.ModelHandler) *UsersDao {
return &UsersDao{
group: "default",
table: "users",
columns: usersColumns,
group: "default",
table: "users",
columns: usersColumns,
handlers: handlers,
}
}
@ -91,7 +93,11 @@ func (dao *UsersDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *UsersDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -605,9 +605,40 @@ func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *mode
glog.Info(ctx, "调用 tencent开始")
activity, err2 := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{PopenId: in.PopenId, ServiceName: consts.GetGift, GiftParam: giftParam})
if err2 != nil {
//if err2 != nil {
if err2 != nil && err2.Error() == "奖励领取超出限制,-1" {
// 修改奖励领取状态为5
//_, err2 = dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{Id: in.Id}).Data(do.UserTaskRewards{
// Status: consts.RewardFailedStatus,
//}).Update()
//
//if err2 != nil {
// return nil, ecode.Fail.Sub("修改用奖励领取状态失败")
//}
//
//// 判断奖励是否领完,修改用户任务记录为 2
//exist, err2 := dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: in.UserTaskId}).WhereIn(dao.UserTaskRewards.Columns().Status, []int{2, 3}).Exist()
//if err2 != nil {
// return nil, ecode.Fail.Sub("查询用户任务奖励失败")
//}
//
//if !exist {
// // 修改用户任务记录为 2
// _, err2 = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{Id: in.UserTaskId}).Data(do.UserTasks{
// Status: 2,
// }).Update()
//
// if err2 != nil {
// return nil, ecode.Fail.Sub("修改用户任务状态失败")
// }
//}
return nil, ecode.RewardExceedLimited
} else if err2 != nil {
return nil, err2
}
//return nil, err2
//}
glog.Info(ctx, "调用 tencent结束")
fmt.Print(activity)
@ -627,6 +658,16 @@ func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *mode
if err != nil {
return ecode.Fail.Sub("序列化 json 数据出现异常")
}
exist, err := dao.RewardWaters.Ctx(ctx).Where(do.RewardWaters{OrderId: item.Water.OrderId}).Exist()
if exist {
_, err := dao.RewardWaters.Ctx(ctx).Where(do.RewardWaters{OrderId: item.Water.OrderId}).Delete()
if err != nil {
return ecode.Fail.Sub("删除奖励领取记录异常")
}
}
_, err = dao.RewardWaters.Ctx(ctx).Insert(model.RewardWaters{
OrderId: item.Water.OrderId,
Status: int64(item.Result),
@ -1142,17 +1183,37 @@ func (s *sReward) CallBack(ctx context.Context, in *model.RewardCallbackIn) (out
res.Errcode = consts.BatchTotalLimit
res.Errmsg = consts.BatchTotalLimitMSG
}
_, err = dao.RewardCallback.Ctx(ctx).OmitEmptyData().Insert(do.RewardCallback{
OrderId: in.OrderId,
PrizeId: in.PrizeId,
PrizeType: in.PrizeType,
PrizeSubType: in.PrizeSubType,
Uid: in.Uid,
Num: in.Num,
CustomInfo: in.CustomInfo,
AppId: in.AppId,
InnerOrderId: fmt.Sprintf("reward%s", guid.S()),
})
if err = dao.RewardWaters.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
exist, err := dao.RewardCallback.Ctx(ctx).Where(do.RewardCallback{OrderId: in.OrderId}).Exist()
if err != nil {
return ecode.Fail.Sub("查询回调记录异常")
}
if exist {
_, err = dao.RewardCallback.Ctx(ctx).Where(do.RewardCallback{OrderId: in.OrderId}).Delete()
if err != nil {
return ecode.Fail.Sub("删除回调记录异常")
}
}
_, err = dao.RewardCallback.Ctx(ctx).OmitEmptyData().Insert(do.RewardCallback{
OrderId: in.OrderId,
PrizeId: in.PrizeId,
PrizeType: in.PrizeType,
PrizeSubType: in.PrizeSubType,
Uid: in.Uid,
Num: in.Num,
CustomInfo: in.CustomInfo,
AppId: in.AppId,
InnerOrderId: fmt.Sprintf("reward%s", guid.S()),
})
return err
}); err != nil {
res.Errcode = -1
res.Errmsg = "存储奖励回调数据异常"
res.Datas = nil
return &res, ecode.Fail.Sub("存储奖励回调数据异常")
}
if err != nil {
res.Errcode = -1

View File

@ -266,7 +266,7 @@ func (s *sStore) DeleteIP(ctx context.Context, in *model.IPDeleteIn) (*model.IPD
}
func (s *sStore) Detail(ctx context.Context, in *model.StoreDetailIn) (out *model.StoreDetailOut, err error) {
one, err := dao.Stores.Ctx(ctx).Where(do.Stores{NetbarAccount: in.NetbarAccount}).One()
one, err := dao.Stores.Ctx(ctx).Where(do.Stores{Id: in.StoreId}).One()
if err != nil {
return nil, ecode.Fail.Sub("查询门店出现异常")
}
@ -274,7 +274,8 @@ func (s *sStore) Detail(ctx context.Context, in *model.StoreDetailIn) (out *mode
return nil, ecode.Params.Sub("门店不存在")
}
return &model.StoreDetailOut{
Id: one[dao.Stores.Columns().Id].Int64(),
Id: one[dao.Stores.Columns().Id].Int64(),
NetbarAccount: one[dao.Stores.Columns().NetbarAccount].String(),
}, nil
}

View File

@ -97,7 +97,11 @@ func (s *sStoreAdmin) Info(ctx context.Context, in *model.StoreAdminInfoIn) (out
return nil, ecode.Fail.Sub("查询门店管理员失败")
}
out = &model.StoreAdminInfoOut{
Username: storeAdmin.Username,
Id: storeAdmin.Id,
StoreId: storeAdmin.StoreId,
Username: storeAdmin.Username,
RealName: storeAdmin.RealName,
IsPrimary: storeAdmin.IsPrimary,
}
return
}

View File

@ -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("创建用户任务记录失败")
@ -447,6 +448,9 @@ func (s *sTask) GetUserTaskRecordsList(ctx context.Context, in *model.UserTaskRe
var total int
orm := dao.UserTasks.Ctx(ctx).Where(dao.UserTasks.Columns().UserId, in.UserId)
if in.BindType != 0 {
orm = orm.Where(dao.UserTasks.Columns().BindType, in.BindType)
}
if in.StoreId != 0 && in.NetBarAccount == "" {
orm = orm.Where(dao.UserTasks.Columns().StoreId, in.StoreId)
}
@ -496,6 +500,7 @@ func (s *sTask) GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out
if !ok {
return nil, ecode.Fail.Sub("数据类型转换失败")
}
glog.Infof(ctx, "The tencent task length of Game %d: %d", in.Gid, len(result.TaskList))
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}).
@ -503,7 +508,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()
@ -519,17 +524,18 @@ func (s *sTask) GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out
result.TaskList[i].Status = 1
} else {
// 存在用户记录,自行判断用户是否完成任务
if v.UserTimes-one["user_times"].Int64() >= v.TargetTimes {
completeTime := gtime.Now()
userTaskStatus := one["status"].Int64()
// 用户任务完成修改任务记录完成时间
_, err := dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: v.TaskID}).Data(do.UserTasks{CompletedAt: completeTime}).Update()
if err != nil {
return nil, ecode.Fail.Sub("修改用户任务完成时间失败")
}
userTaskStatus := one["status"].Int64()
if userTaskStatus == 1 {
if userTaskStatus == 1 {
if v.UserTimes-one["user_times"].Int64() >= v.TargetTimes {
completeTime := gtime.Now()
if err := dao.UserTasks.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
// 用户任务完成修改任务记录完成时间
_, err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: v.TaskID}).Data(do.UserTasks{CompletedAt: completeTime}).Update()
if err != nil {
return ecode.Fail.Sub("修改用户任务完成时间失败")
}
if _, err := dao.UserTasks.Ctx(ctx).WherePri(one["id"].Int64()).Where(do.UserTasks{Status: 1}).Data(do.UserTasks{Status: 3}).Update(); err != nil {
return ecode.Fail.Sub("修改用户任务状态失败")
}
@ -556,7 +562,7 @@ func (s *sTask) GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out
updateData.IssueQuantity = quantity
}
}
if _, err := dao.UserTaskRewards.Ctx(ctx).Data(updateData).Update(); err != nil {
if _, err := dao.UserTaskRewards.Ctx(ctx).Data(updateData).Where(do.UserTaskRewards{Id: record["id"].Int64()}).Update(); err != nil {
return ecode.Fail.Sub("修改用户任务奖励失败")
}
}
@ -565,16 +571,17 @@ func (s *sTask) GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out
return nil, err
}
result.TaskList[i].Status = 2
} else if userTaskStatus == 3 {
result.TaskList[i].Status = 2
} else {
result.TaskList[i].Status = 3
result.TaskList[i].UserTimes -= one["user_times"].Int64()
result.TaskList[i].Status = 1
}
} else if userTaskStatus == 3 {
result.TaskList[i].Status = 2
} else {
result.TaskList[i].UserTimes -= one["user_times"].Int64()
result.TaskList[i].Status = 1
result.TaskList[i].Status = 3
}
result.TaskList[i].UserTaskId = one["id"].Int64()
}
}
out.PageIdx = result.PageIdx

View File

@ -6,6 +6,7 @@ import (
"github.com/gogf/gf/v2/frame/g"
"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/grand"
"server/internal/consts"
"server/internal/dao"
@ -19,6 +20,7 @@ import (
"server/utility/gamelife"
"server/utility/jwt"
"server/utility/sms"
"strings"
)
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) {
// 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()
if err != nil {
return nil, ecode.Fail.Sub("查找角色失败")
}
// 根据 OpenId 查找用户
exist, err := dao.Users.Ctx(ctx).Where(do.Users{WxOpenId: in.OpenId}).Exist()
if err != nil {
return nil, ecode.Fail.Sub("查找用户失败")
split := strings.Split(in.SceneId, "_")
if len(split) < 3 {
return nil, ecode.Fail.Sub("SceneId格式错误")
}
storeId := gconv.Int64(split[0])
var xyUserId string
var userId int64
v, err := dao.Stores.Ctx(ctx).Where(do.Stores{StoreCode: in.StoreCode}).Fields(dao.Stores.Columns().Id).Value()
if err != nil {
return nil, ecode.Fail.Sub("查找门店失败")
}
if !exist {
// 用户不存在,创建新用户
// 生成 username: qy_ + 8位随机字母数字
var username string
for {
randomStr := grand.Str("abcdefghijklmnopqrstuvwxyz0123456789", 8)
username = "qy_" + randomStr
// 检查 username 是否唯一
count, err := dao.Users.Ctx(ctx).Where(do.Users{Username: username}).Count()
if split[1] == "0" {
// 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 err != nil {
return nil, ecode.Fail.Sub("查找用户失败")
}
if !exist {
// User does not exist, create new user
var username string
for {
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 {
return nil, ecode.Fail.Sub("检查用户名失败")
return nil, ecode.Fail.Sub("加密密码失败")
}
if count == 0 {
break // username 唯一,退出循环
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: 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)
if err != nil {
return nil, ecode.Fail.Sub("加密密码失败")
}
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 {
// 用户存在,更新最后登录时间
} else if split[1] == "1" {
// Case 2: split[1] == "1", use xyUserId to find user and bind in.OpenId
xyUserId = split[2]
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("查找用户失败")
}
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 {
return nil, ecode.Fail.Sub("更新登录时间失败")
if user.WxOpenId != "" && user.WxOpenId != in.OpenId {
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{
UserId: userId,
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{
Token: token,
}
return
return out, nil
}
func (s *sUser) WeChatLogin(ctx context.Context, in *model.WeChatLogin) (out *model.WeChatLoginOut, err error) {
return
@ -254,6 +296,9 @@ func (s *sUser) BindPhone(ctx context.Context, in *model.UserBindPhoneIn) (out *
if err != nil {
return nil, ecode.Fail.Sub("绑定手机号失败")
}
if _, err := g.Redis().Del(ctx, fmt.Sprintf(consts.UserBindPhoneKey, in.Phone)); err != nil {
return nil, ecode.Fail.Sub("删除验证码失败")
}
return &model.UserBindPhoneOut{
Success: true,
}, nil

View File

@ -6,6 +6,7 @@ package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// RewardCallback is the golang structure of table reward_callback for DAO operations like Where/Data.
@ -22,4 +23,7 @@ type RewardCallback struct {
CustomInfo interface{} // 透传字段 (json串)
AppId interface{} // 业务 id标识业务方由游戏人生提供
InnerOrderId interface{} // 系统内部订单ID
CreatedAt *gtime.Time //
UpdatedAt *gtime.Time //
DeletedAt *gtime.Time //
}

View File

@ -26,4 +26,5 @@ type UserTasks struct {
GameId interface{} // 游戏 id
TaskType interface{} // 1: 每日任务 3: 周期任务
UserTimes interface{} // 用户完成次数
BindType interface{} // 1:qq 2:wx
}

View File

@ -4,17 +4,24 @@
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// RewardCallback is the golang structure for table reward_callback.
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
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
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:""` //
}

View File

@ -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:"1:qq 2:wx"` // 1:qq 2:wx
}

View File

@ -112,9 +112,11 @@ type IPCreateOut struct {
}
type StoreDetailIn struct {
NetbarAccount string
StoreId int64
}
type StoreDetailOut struct {
Id int64 `json:"id"`
Id int64 `json:"id"`
NetbarAccount string `json:"netbarAccount"`
}
type StoreByNetbarAccountIn struct {

View File

@ -5,7 +5,11 @@ type StoreAdminInfoIn struct {
}
type StoreAdminInfoOut struct {
Username string
Id int64
StoreId int64
Username string
RealName string
IsPrimary bool
}
type StoreAdminLoginIn struct {

View File

@ -59,8 +59,8 @@ type LoginCache struct {
}
type UserLoginIn struct {
OpenId string
StoreCode string // 门店编码,登录时根据门店编码查询,填写最近一次登录门店 id
OpenId string
SceneId string
}
type WeChatLogin struct {
UUID string // 使用的是微信的唯一 id而不是openid保证微信服务号小程序绑定的系统用户为同一个

View File

@ -33,9 +33,10 @@ type TaskReward struct {
}
type UserTask2 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
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
BindType int `json:"bindType" orm:"bind_type"`
Status int `json:"status" orm:"status" description:"任务状态1=进行中2=已完成中3=未完成"` // 任务状态1=进行中(显示领取按钮)2=已完成
SerialNumber string `json:"serialNumber" orm:"serial_number" description:"流水号,确保用户任务唯一性"` // 流水号,确保用户任务唯一性
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
@ -125,6 +126,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 +142,7 @@ type UserTaskRecordsListIn struct {
RewardTypeId int
TimeType int
GameId int
BindType int
}
type UserTaskRecordsListOut struct {

View File

@ -1,16 +1,17 @@
package ecode
var (
OK = New(0, "操作成功")
Sub = New(1, "") // 自定义错误信息
Fail = New(2, "服务器内部错误")
InvalidOperation = New(3, "非法的操作请求")
Params = New(4, "请求参数错误")
Logout = New(5, "用户未登录")
Disabled = New(6, "账户已被禁用")
Denied = New(7, "没有权限执行该操作")
Expire = New(8, "token已过期")
Auth = New(1000, "账户名或密码不正确")
Password = New(1001, "密码不正确")
EmailExist = New(1002, "该邮箱已被注册")
OK = New(0, "操作成功")
Sub = New(1, "") // 自定义错误信息
Fail = New(2, "服务器内部错误")
InvalidOperation = New(3, "非法的操作请求")
Params = New(4, "请求参数错误")
Logout = New(5, "用户未登录")
Disabled = New(6, "账户已被禁用")
Denied = New(7, "没有权限执行该操作")
Expire = New(8, "token已过期")
Auth = New(1000, "账户名或密码不正确")
Password = New(1001, "密码不正确")
EmailExist = New(1002, "该邮箱已被注册")
RewardExceedLimited = New(-1, "奖励领取数量超出限制")
)

View File

@ -3,6 +3,7 @@ package gamelife
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/url"
"server/internal/dao"
@ -170,7 +171,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("设置用户信息失败")
}
@ -423,6 +424,22 @@ func (s *gamelifeClient) RequestActivity(ctx context.Context, in *model.QQNetbar
if err != nil || resp.IsError() {
return nil, ecode.Fail.Sub("请求出现异常")
}
// 判断是否为 -1 的异常
type RespData struct {
Ret int `json:"ret"`
ErrMsg string `json:"err_msg"`
ErrDesc string `json:"err_desc"`
}
var respData RespData
if err = json.Unmarshal(resp.Body(), &respData); err != nil {
return nil, ecode.Fail.Sub("解析请求结果失败")
}
if respData.Ret == -1 {
glog.Info(ctx, "奖励领取超出限制,-1")
return nil, errors.New("奖励领取超出限制,-1")
}
if result == nil {
return nil, ecode.Fail.Sub("请求结果为空")
}

View File

@ -103,6 +103,7 @@ func init() {
enforcer.AddPolicy("store", "/x/store/netfeeSetting", "POST", "修改门店网费设置")
// 门店:修改
enforcer.AddPolicy("store", "/x/task/sync", "POST", "同步任务")
enforcer.AddPolicy("store", "/x/store/detail", "GET", "获取门店详情")
// 奖励类型
enforcer.AddPolicy("store", "/x/rewardType", "GET", "获取奖励类型列表")
enforcer.AddPolicy("store", "/x/rewardType", "POST", "添加奖励类型")