Merge remote-tracking branch 'origin/master'

This commit is contained in:
chy
2025-07-04 15:53:53 +08:00
34 changed files with 497 additions and 314 deletions

View File

@ -16,4 +16,5 @@ type IAuthV1 interface {
MerchantCode(ctx context.Context, req *v1.MerchantCodeReq) (res *v1.MerchantCodeRes, err error) MerchantCode(ctx context.Context, req *v1.MerchantCodeReq) (res *v1.MerchantCodeRes, err error)
MerchantRegister(ctx context.Context, req *v1.MerchantRegisterReq) (res *v1.MerchantRegisterRes, err error) MerchantRegister(ctx context.Context, req *v1.MerchantRegisterReq) (res *v1.MerchantRegisterRes, err error)
StoreLogin(ctx context.Context, req *v1.StoreLoginReq) (res *v1.StoreLoginRes, err error) StoreLogin(ctx context.Context, req *v1.StoreLoginReq) (res *v1.StoreLoginRes, err error)
Quan8Autologin(ctx context.Context, req *v1.Quan8AutologinReq) (res *v1.Quan8AutologinRes, err error)
} }

View File

@ -58,3 +58,12 @@ type StoreLoginRes struct {
g.Meta `mime:"application/json"` g.Meta `mime:"application/json"`
Token string `json:"token"` Token string `json:"token"`
} }
type Quan8AutologinReq struct {
g.Meta `path:"/quan8/autologin" method:"post" tags:"PC/Auth" summary:"8圈用户自动登录该系统"`
UUID string `json:"uuid" v:"required#UUID不能为空" dc:"UUID"`
StoreId int64
}
type Quan8AutologinRes struct {
Token string `json:"token"`
}

View File

@ -45,7 +45,8 @@ type WeChatPollingRes struct {
type GetWechatSceneIdReq struct { type GetWechatSceneIdReq struct {
g.Meta `path:"/wechat/sceneId" method:"get" tags:"PC/WeChat" summary:"(PC)获取微信场景ID"` g.Meta `path:"/wechat/sceneId" method:"get" tags:"PC/WeChat" summary:"(PC)获取微信场景ID"`
NetbarAccount string `json:"netbarAccount" v:"required" dc:"网关账号"` StoreId int `json:"storeId" v:"required#门店 id 账号不能为空" dc:"门店ID"`
UUID string `json:"uuid" dc:"8圈唯一 id"`
} }
type GetWechatSceneIdRes struct { type GetWechatSceneIdRes struct {

View File

@ -0,0 +1,21 @@
package auth
import (
"context"
"server/internal/model"
"server/internal/service"
"server/api/auth/v1"
)
func (c *ControllerV1) Quan8Autologin(ctx context.Context, req *v1.Quan8AutologinReq) (res *v1.Quan8AutologinRes, err error) {
out, err := service.User().Quan8Autologin(ctx, &model.Quan8AutologinIn{
UUID: req.UUID,
StoreId: req.StoreId,
})
if err != nil {
return
}
return &v1.Quan8AutologinRes{Token: out.Token}, nil
}

View File

@ -2,11 +2,18 @@ package wx
import ( import (
"context" "context"
"fmt"
"server/api/wx/v1" "server/api/wx/v1"
"time" "server/internal/model"
"server/internal/service"
) )
func (c *ControllerV1) GetWechatSceneId(ctx context.Context, req *v1.GetWechatSceneIdReq) (res *v1.GetWechatSceneIdRes, err error) { func (c *ControllerV1) GetWechatSceneId(ctx context.Context, req *v1.GetWechatSceneIdReq) (res *v1.GetWechatSceneIdRes, err error) {
return &v1.GetWechatSceneIdRes{SceneId: fmt.Sprintf("%s_%d", req.NetbarAccount, time.Now().Unix())}, nil out, err := service.User().GenerateSceneId(ctx, &model.GenerateSceneIdIn{
StoreId: req.StoreId,
UUId: req.UUID,
})
if err != nil {
return nil, err
}
return &v1.GetWechatSceneIdRes{SceneId: out.SceneId}, nil
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,6 @@ type RewardCallbackDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. 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. // RewardCallbackColumns defines and stores column names for the table reward_callback.
@ -50,12 +49,11 @@ var rewardCallbackColumns = RewardCallbackColumns{
} }
// NewRewardCallbackDao creates and returns a new DAO object for table data access. // NewRewardCallbackDao creates and returns a new DAO object for table data access.
func NewRewardCallbackDao(handlers ...gdb.ModelHandler) *RewardCallbackDao { func NewRewardCallbackDao() *RewardCallbackDao {
return &RewardCallbackDao{ return &RewardCallbackDao{
group: "default", group: "default",
table: "reward_callback", table: "reward_callback",
columns: rewardCallbackColumns, columns: rewardCallbackColumns,
handlers: handlers,
} }
} }
@ -81,11 +79,7 @@ func (dao *RewardCallbackDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // 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 { func (dao *RewardCallbackDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,6 @@ type StoreNetfeeAreaLevelDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. 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. // StoreNetfeeAreaLevelColumns defines and stores column names for the table store_netfee_area_level.
@ -50,12 +49,11 @@ var storeNetfeeAreaLevelColumns = StoreNetfeeAreaLevelColumns{
} }
// NewStoreNetfeeAreaLevelDao creates and returns a new DAO object for table data access. // NewStoreNetfeeAreaLevelDao creates and returns a new DAO object for table data access.
func NewStoreNetfeeAreaLevelDao(handlers ...gdb.ModelHandler) *StoreNetfeeAreaLevelDao { func NewStoreNetfeeAreaLevelDao() *StoreNetfeeAreaLevelDao {
return &StoreNetfeeAreaLevelDao{ return &StoreNetfeeAreaLevelDao{
group: "default", group: "default",
table: "store_netfee_area_level", table: "store_netfee_area_level",
columns: storeNetfeeAreaLevelColumns, columns: storeNetfeeAreaLevelColumns,
handlers: handlers,
} }
} }
@ -81,11 +79,7 @@ func (dao *StoreNetfeeAreaLevelDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // 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 { func (dao *StoreNetfeeAreaLevelDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,6 @@ type UserTasksDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. 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. // UserTasksColumns defines and stores column names for the table user_tasks.
@ -54,12 +53,11 @@ var userTasksColumns = UserTasksColumns{
} }
// NewUserTasksDao creates and returns a new DAO object for table data access. // NewUserTasksDao creates and returns a new DAO object for table data access.
func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao { func NewUserTasksDao() *UserTasksDao {
return &UserTasksDao{ return &UserTasksDao{
group: "default", group: "default",
table: "user_tasks", table: "user_tasks",
columns: userTasksColumns, columns: userTasksColumns,
handlers: handlers,
} }
} }
@ -85,11 +83,7 @@ func (dao *UserTasksDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // 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 { func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type UsersDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. 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. // UsersColumns defines and stores column names for the table users.
@ -37,6 +36,7 @@ type UsersColumns struct {
DeletedAt string // 软删除时间 DeletedAt string // 软删除时间
RoleId string // 角色ID RoleId string // 角色ID
LastLoginStoreId string // 上次登录门店ID LastLoginStoreId string // 上次登录门店ID
Quan8Uuid string // 8圈使用的 uuid
} }
// usersColumns holds the columns for the table users. // usersColumns holds the columns for the table users.
@ -57,15 +57,15 @@ var usersColumns = UsersColumns{
DeletedAt: "deleted_at", DeletedAt: "deleted_at",
RoleId: "role_id", RoleId: "role_id",
LastLoginStoreId: "last_login_store_id", LastLoginStoreId: "last_login_store_id",
Quan8Uuid: "quan8_uuid",
} }
// NewUsersDao creates and returns a new DAO object for table data access. // NewUsersDao creates and returns a new DAO object for table data access.
func NewUsersDao(handlers ...gdb.ModelHandler) *UsersDao { func NewUsersDao() *UsersDao {
return &UsersDao{ return &UsersDao{
group: "default", group: "default",
table: "users", table: "users",
columns: usersColumns, columns: usersColumns,
handlers: handlers,
} }
} }
@ -91,11 +91,7 @@ func (dao *UsersDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // 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 { func (dao *UsersDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -353,3 +353,111 @@ func (s *sUser) GamelifePackUrl(ctx context.Context, in *model.GamelifePackUrlIn
Url: url, Url: url,
}, nil }, nil
} }
func (s *sUser) Quan8Autologin(ctx context.Context, in *model.Quan8AutologinIn) (out *model.Quan8AutologinOut, err error) {
b, err := dao.Stores.Ctx(ctx).WherePri(in.StoreId).Exist()
if err != nil {
return nil, ecode.Fail.Sub("查找门店失败")
}
if !b {
return nil, ecode.Params.Sub("门店 id 错误")
}
// Fetch default role
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("查找角色失败")
}
// Check if user exists by Quan8 UUID
exist, err := dao.Users.Ctx(ctx).Where(do.Users{Quan8Uuid: in.UUID}).Exist()
if err != nil {
return nil, ecode.Fail.Sub("查找用户失败")
}
var userId int64
if !exist {
// User doesn't 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("加密密码失败")
}
user := &entity.Users{
Quan8Uuid: in.UUID,
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: in.StoreId,
}
userId, err = dao.Users.Ctx(ctx).InsertAndGetId(user)
if err != nil {
return nil, ecode.Fail.Sub("创建用户失败")
}
} else {
value, err := dao.Users.Ctx(ctx).Where(do.Users{Quan8Uuid: in.UUID}).Fields(dao.Users.Columns().Id).Value()
if err != nil {
return nil, ecode.Fail.Sub("查找用户失败")
}
userId = value.Int64()
if _, err := dao.Users.Ctx(ctx).Where(do.Users{Id: userId}).Update(do.Users{LastLoginAt: gtime.Now(), LastLoginStoreId: in.StoreId}); err != nil {
return nil, ecode.Fail.Sub("更新登录时间失败")
}
}
// Generate token
token, err := jwt.GenerateToken(&jwt.TokenIn{
UserId: userId,
Role: value[dao.Roles.Columns().Code].String(),
})
if err != nil {
return nil, ecode.Fail.Sub("生成token失败")
}
return &model.Quan8AutologinOut{
Token: token,
}, nil
}
func (s *sUser) GenerateSceneId(ctx context.Context, in *model.GenerateSceneIdIn) (out *model.GenerateSceneIdOut, err error) {
var sceneId string
// Check if user exists by UUID if provided
if in.UUId != "" {
exist, err := dao.Users.Ctx(ctx).Where(do.Users{Quan8Uuid: in.UUId}).Exist()
if err != nil {
return nil, ecode.Fail.Sub("查找用户失败")
}
if !exist {
return nil, ecode.Params.Sub("用户不存在")
}
// UUID is provided and user exists, use "is" flag
sceneId = fmt.Sprintf("%d_1_%s", in.StoreId, in.UUId)
} else {
// UUID is empty, use "not" flag with random string
randomStr := grand.Str("abcdefghijklmnopqrstuvwxyz0123456789", 8)
sceneId = fmt.Sprintf("%d_0_%s", in.StoreId, randomStr)
}
return &model.GenerateSceneIdOut{
SceneId: sceneId,
}, nil
}

View File

@ -28,4 +28,5 @@ type Users struct {
DeletedAt *gtime.Time // 软删除时间 DeletedAt *gtime.Time // 软删除时间
RoleId interface{} // 角色ID RoleId interface{} // 角色ID
LastLoginStoreId interface{} // 上次登录门店ID LastLoginStoreId interface{} // 上次登录门店ID
Quan8Uuid interface{} // 8圈使用的 uuid
} }

View File

@ -26,4 +26,5 @@ type Users struct {
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间 DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
RoleId int64 `json:"roleId" orm:"role_id" description:"角色ID"` // 角色ID RoleId int64 `json:"roleId" orm:"role_id" description:"角色ID"` // 角色ID
LastLoginStoreId int64 `json:"lastLoginStoreId" orm:"last_login_store_id" description:"上次登录门店ID"` // 上次登录门店ID LastLoginStoreId int64 `json:"lastLoginStoreId" orm:"last_login_store_id" description:"上次登录门店ID"` // 上次登录门店ID
Quan8Uuid string `json:"quan8Uuid" orm:"quan8_uuid" description:"8圈使用的 uuid"` // 8圈使用的 uuid
} }

View File

@ -204,3 +204,21 @@ type GamelifePackUrlIn struct {
type GamelifePackUrlOut struct { type GamelifePackUrlOut struct {
Url string Url string
} }
type Quan8AutologinIn struct {
UUID string
NetbarAccount string
StoreId int64
}
type Quan8AutologinOut struct {
Token string
}
type GenerateSceneIdIn struct {
StoreId int
UUId string
}
type GenerateSceneIdOut struct {
SceneId string
}

View File

@ -21,6 +21,151 @@ type (
// List 奖励列表 // List 奖励列表
List(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error) List(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error)
// GetLift 领取奖励 // GetLift 领取奖励
// func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *model.GetRewardOut, err error) {
//
// giftParam := model.GiftParam{}
// var needUrl bool
// // 判断奖励类型
// if in.Source == 1 {
// // 系统奖励处理
// if in.RewradTypeId == 16 {
// // 需要大区角色
// giftParam.AreaId = in.AreaId
// giftParam.Gid = in.GameId
// giftParam.RoleIdx = in.RoleIdx
// giftParam.TaskId = in.TaskId
// } else {
// // 不需要
// giftParam.TaskId = in.TaskId
// giftParam.Gid = in.GameId
//
// }
// if in.RewardId != 16 && in.RewardId != 37 {
// needUrl = true
// }
// } else {
// // 门店奖励处理
//
// }
//
// glog.Info(ctx, "调用 tencent开始")
// activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{PopenId: in.PopenId, ServiceName: consts.GetGift, GiftParam: giftParam})
//
// if err != nil {
// return nil, err
// }
// glog.Info(ctx, "调用 tencent结束")
// fmt.Print(activity)
//
// result, ok := activity.(*model.GiftResponse)
// if !ok {
// return nil, ecode.Fail.Sub("数据类型转换失败")
// }
//
// if len(result.GiftItem) == 0 {
// return nil, ecode.Fail.Sub("奖励领取异常")
// }
//
// // 存储数据库记录
// var data model.GetRewardOut
// if err = dao.RewardWaters.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
// for _, item := range result.GiftItem {
// marshal, err := json.Marshal(item.Water)
// if err != nil {
// return ecode.Fail.Sub("序列化 json 数据出现异常")
// }
// _, err = dao.RewardWaters.Ctx(ctx).Insert(model.RewardWaters{
// OrderId: item.Water.OrderId,
// Status: int64(item.Result),
// Uid: item.Water.Uid,
// Water: string(marshal),
// TaskId: in.TaskId,
// GameId: int64(in.GameId),
// })
//
// if err != nil {
// return ecode.Fail.Sub("添加奖励领取记录异常")
// }
//
// // 根据 result判断
// data.Result = int64(item.Result)
// if item.Result == 1 {
// //// 奖励发放成功,修改状态,扣除数量
// glog.Infof(ctx, "奖励发放成功1修改状态扣除数量")
// // 查询当前奖励是否为最后一个, 如果是则更新任务状态为2 完成
// count, err := dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: in.UserTaskId}).WhereIn(dao.UserTaskRewards.Columns().Status, []int{2, 3, 5}).Count()
// if err != nil {
// return ecode.Fail.Sub("查询用户任务奖励失败")
// }
//
// if count == 1 {
// // 修改任务记录状态2
// _, err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{Id: in.UserTaskId}).Data(do.UserTasks{
// Status: 2,
// }).Update()
//
// if err != nil {
// return ecode.Fail.Sub("修改用户任务状态失败")
// }
// }
//
// // 增加奖励已领取数量
// _, err = dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.RewardId}).Increment(dao.Rewards.Columns().ReceivedNum, 1)
// if err != nil {
// return ecode.Fail.Sub("获取奖励领取记录异常")
// }
//
// // 修改用户任务奖励记录状态
// _, err = dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: in.UserTaskId, RewardId: in.RewardId}).Data(do.UserTaskRewards{
// Status: consts.RewardSuccessStatus,
// }).Update()
//
// if err != nil {
// return ecode.Fail.Sub("修改用户任务奖励记录状态异常")
// }
// } else if item.Result == 2 || item.Result == 3 {
// // 发放背包成功,修改状态
// glog.Infof(ctx, "奖励发放成功2修改状态")
// _, err = dao.UserTaskRewards.Ctx(ctx).Data(do.UserTaskRewards{
// Status: consts.RewardExchangeStatus,
// }).Where(do.UserTaskRewards{
// Id: in.UserTaskId,
// RewardId: in.RewardId,
// }).Update()
//
// if err != nil {
// return ecode.Fail.Sub("修改用户任务奖励记录状态异常")
// }
// } else if item.Result == 4 {
// // 奖励领取失败,不做操作,直接返回
// glog.Infof(ctx, "领取奖励失败")
// return ecode.Fail.Sub("领取奖励失败")
// }
//
// //data.List = append(data.List, model.GetRewardNewOut{
// // Result: int64(item.Result),
// // Water: item.Water,
// //})
// }
//
// return
//
// }); err != nil {
// return
// }
//
// if needUrl {
// data.Url, err = gamelife.GetGamelifeClient(ctx).GetGamelifePackageUrl(ctx, in.PopenId, in.GameCode, in.GameId, in.BindType)
// if err != nil {
// return nil, ecode.Fail.Sub("获取绑定链接失败")
// }
// }
//
// //return &model.GetRewardOut{
// // List: data.List,
// //}, err
// return &data, err
// }
GetLift(ctx context.Context, in *model.GetRewardIn) (out *model.GetRewardOut, err error) GetLift(ctx context.Context, in *model.GetRewardIn) (out *model.GetRewardOut, err error)
// GetGoodsList 调用外部获取物品列表 // GetGoodsList 调用外部获取物品列表
GetGoodsList(ctx context.Context, in *model.GetGoodsListIn) (out *model.GetGoodsListOut, err error) GetGoodsList(ctx context.Context, in *model.GetGoodsListIn) (out *model.GetGoodsListOut, err error)

View File

@ -22,7 +22,6 @@ type (
// GetTask 完成任务 // GetTask 完成任务
GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.GetTaskOut, err error) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.GetTaskOut, err error)
GetUserTaskRecordsList(ctx context.Context, in *model.UserTaskRecordsListIn) (out *model.UserTaskRecordsListOut, err error) GetUserTaskRecordsList(ctx context.Context, in *model.UserTaskRecordsListIn) (out *model.UserTaskRecordsListOut, err error)
// GetTaskList PC-WEB获取任务列表
GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out *model.GetTaskListV2Out, err error) GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out *model.GetTaskListV2Out, err error)
SyncTaskFromGamelife(ctx context.Context) (out *model.SyncTaskOut, err error) SyncTaskFromGamelife(ctx context.Context) (out *model.SyncTaskOut, err error)
} }

View File

@ -25,6 +25,8 @@ type (
DelUser(ctx context.Context, in *model.DelUserIn) (out *model.DeleteOut, err error) DelUser(ctx context.Context, in *model.DelUserIn) (out *model.DeleteOut, err error)
GetUserGameRole(ctx context.Context, in *model.GetUserGameRoleIn) (out *model.GetUserGameRoleOut, err error) GetUserGameRole(ctx context.Context, in *model.GetUserGameRoleIn) (out *model.GetUserGameRoleOut, err error)
GamelifePackUrl(ctx context.Context, in *model.GamelifePackUrlIn) (out *model.GamelifePackUrlOut, err error) GamelifePackUrl(ctx context.Context, in *model.GamelifePackUrlIn) (out *model.GamelifePackUrlOut, err error)
Quan8Autologin(ctx context.Context, in *model.Quan8AutologinIn) (out *model.Quan8AutologinOut, err error)
GenerateSceneId(ctx context.Context, in *model.GenerateSceneIdIn) (out *model.GenerateSceneIdOut, err error)
} }
) )