diff --git a/api/rewardType/v1/rewardType.go b/api/rewardType/v1/rewardType.go index 43565c8..0bcf0c6 100644 --- a/api/rewardType/v1/rewardType.go +++ b/api/rewardType/v1/rewardType.go @@ -7,41 +7,44 @@ type ListReq struct { Name string `json:"name" dc:"名称"` Page int `json:"page" dc:"页数"` Size int `json:"size" dc:"每页数量"` - Status int `json:"status" dc:"状态"` StoreId int64 `json:"storeId" dc:"门店ID"` + Source int `json:"source" v:"in:1,2#来源只能为1或2" dc:"来源"` } + type ListRes struct { List interface{} `json:"list" dc:"奖励类型列表"` Total int `json:"total" dc:"总数"` } type CreateReq struct { - g.Meta `path:"/rewardType" method:"post" tags:"RewardType" summary:"(系统、商户、门店后台)创建奖励类型"` - Name string `json:"name" v:"required#名称不能为空" dc:"名称"` - Description string `json:"description" v:"required#描述不能为空" dc:"描述"` - Status int `json:"status" v:"" dc:"状态" d:"1"` - StoreId int64 `json:"storeId" dc:"门店ID"` - Source int `json:"source" v:"in:1,2#来源只能为1或2" dc:"来源"` + g.Meta `path:"/rewardType" method:"post" tags:"RewardType" summary:"(系统、商户、门店后台)创建奖励类型"` + Name string `json:"name" v:"required#名称不能为空" dc:"名称"` + StoreId int64 `json:"storeId" dc:"门店ID"` + Source int `json:"source" v:"in:1,2#来源只能为1或2" dc:"来源"` + TencentTypeId int `json:"tencentTypeId,omitempty" dc:"腾讯奖励类型ID(仅系统奖励有效)"` } + type CreateRes struct { Id int64 `json:"id" dc:"奖励类型ID"` } type UpdateReq struct { - g.Meta `path:"/rewardType" method:"put" tags:"RewardType" summary:"(系统、商户、门店后台)更新奖励类型"` - Id int64 `json:"id" v:"required#ID不能为空" dc:"Id"` - Name string `json:"name" v:"required#名称不能为空" dc:"名称"` - Description string `json:"description" v:"required#描述不能为空" dc:"描述"` - Status int `json:"status" v:"" dc:"状态" d:"1"` - StoreId int64 `json:"storeId" dc:"门店ID"` + g.Meta `path:"/rewardType" method:"put" tags:"RewardType" summary:"(系统、商户、门店后台)更新奖励类型"` + Id int64 `json:"id" v:"required#ID不能为空" dc:"Id"` + Name string `json:"name" v:"required#名称不能为空" dc:"名称"` + StoreId int64 `json:"storeId" dc:"门店ID"` + TencentTypeId int `json:"tencentTypeId,omitempty" dc:"腾讯奖励类型ID(仅系统奖励有效)"` } + type UpdateRes struct { Success bool `json:"success" dc:"是否成功"` } + type DeleteReq struct { g.Meta `path:"/rewardType/{id}" method:"delete" tags:"RewardType" summary:"(系统、商户、门店后台)删除奖励类型"` Id int64 `in:"path" json:"id" v:"required#ID不能为空" dc:"Id"` } + type DeleteRes struct { Success bool `json:"success" dc:"是否成功"` } diff --git a/api/storeTaskReward/storeTaskReward.go b/api/storeTaskReward/storeTaskReward.go deleted file mode 100644 index c600baf..0000000 --- a/api/storeTaskReward/storeTaskReward.go +++ /dev/null @@ -1,16 +0,0 @@ -// ================================================================================= -// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. -// ================================================================================= - -package storeTaskReward - -import ( - "context" - - "server/api/storeTaskReward/v1" -) - -type IStoreTaskRewardV1 interface { - Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) - Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) -} diff --git a/api/storeTaskReward/v1/storeTaskReward.go b/api/storeTaskReward/v1/storeTaskReward.go deleted file mode 100644 index b6a30f3..0000000 --- a/api/storeTaskReward/v1/storeTaskReward.go +++ /dev/null @@ -1,22 +0,0 @@ -package v1 - -import "github.com/gogf/gf/v2/frame/g" - -type CreateReq struct { - g.Meta `path:"/storeTaskReward" method:"post" tags:"StoreTaskReward" summary:"(商户、门店后台)创建门店任务奖励"` - TaskId string `json:"taskId" v:"required#任务 Id 不能为空" dc:"任务 Id"` - RewardId int64 `json:"rewardId" v:"required#奖励ID不能为空" dc:"奖励ID"` - StoreId int64 `json:"storeId" v:"required#门店ID不能为空" dc:"门店ID"` -} - -type CreateRes struct { - Id int64 `json:"id"` -} - -type DeleteReq struct { - g.Meta `path:"/storeTaskReward/{id}" method:"delete" tags:"StoreTaskReward" summary:"(商户、门店后台)删除门店任务奖励"` - Id int64 `in:"path" json:"id" v:"required#门店任务奖励ID不能为空" dc:"门店任务奖励ID"` -} -type DeleteRes struct { - Success bool `json:"success" dc:"是否成功"` -} diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 0abf07e..ef0cf99 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -18,7 +18,6 @@ import ( "server/internal/controller/store" "server/internal/controller/storeAdmin" "server/internal/controller/storeRole" - "server/internal/controller/storeTaskReward" "server/internal/controller/task" "server/internal/controller/upload" "server/internal/controller/user" @@ -58,7 +57,6 @@ var ( game.NewV1(), rewardType.NewV1(), reward.NewV1(), - storeTaskReward.NewV1(), desktop.NewV1(), ) }) diff --git a/internal/controller/rewardType/rewardType_v1_create.go b/internal/controller/rewardType/rewardType_v1_create.go index e761a7f..ad2a3b6 100644 --- a/internal/controller/rewardType/rewardType_v1_create.go +++ b/internal/controller/rewardType/rewardType_v1_create.go @@ -3,6 +3,7 @@ package rewardType import ( "context" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/glog" "server/internal/model" "server/internal/service" @@ -13,17 +14,25 @@ func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.C fromCtx := g.RequestFromCtx(ctx) operatorId := fromCtx.GetCtxVar("id").Int64() operatorRole := fromCtx.GetCtxVar("role").String() + + glog.Infof(ctx, "请求创建奖励类型,操作用户ID:%d,角色:%s,名称:%s,来源:%d,门店ID:%d,腾讯类型ID:%d", + operatorId, operatorRole, req.Name, req.Source, req.StoreId, req.TencentTypeId, + ) + out, err := service.RewardType().Create(ctx, &model.RewardTypeCreateIn{ - OperatorId: operatorId, - OperatorRole: operatorRole, - Name: req.Name, - Description: req.Description, - Source: req.Source, - Status: req.Status, - StoreId: req.StoreId}) + OperatorId: operatorId, + OperatorRole: operatorRole, + Name: req.Name, + Source: req.Source, + StoreId: req.StoreId, + TencentTypeId: req.TencentTypeId, + }) + if err != nil { + glog.Warningf(ctx, "创建奖励类型失败,操作用户ID:%d,角色:%s,错误信息:%v", operatorId, operatorRole, err) return nil, err } - return &v1.CreateRes{Id: out.Id}, nil + glog.Infof(ctx, "创建奖励类型成功,ID:%d,操作用户ID:%d,角色:%s", out.Id, operatorId, operatorRole) + return &v1.CreateRes{Id: out.Id}, nil } diff --git a/internal/controller/rewardType/rewardType_v1_delete.go b/internal/controller/rewardType/rewardType_v1_delete.go index 8bb7fa5..68e9ae9 100644 --- a/internal/controller/rewardType/rewardType_v1_delete.go +++ b/internal/controller/rewardType/rewardType_v1_delete.go @@ -3,6 +3,7 @@ package rewardType import ( "context" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/glog" "server/internal/model" "server/internal/service" @@ -13,9 +14,20 @@ func (c *ControllerV1) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.D fromCtx := g.RequestFromCtx(ctx) operatorId := fromCtx.GetCtxVar("id").Int64() operatorRole := fromCtx.GetCtxVar("role").String() - out, err := service.RewardType().Delete(ctx, &model.RewardTypeDeleteIn{Id: req.Id, OperatorId: operatorId, OperatorRole: operatorRole}) + + glog.Infof(ctx, "请求删除奖励类型,操作用户ID:%d,角色:%s,奖励类型ID:%d", operatorId, operatorRole, req.Id) + + out, err := service.RewardType().Delete(ctx, &model.RewardTypeDeleteIn{ + Id: req.Id, + OperatorId: operatorId, + OperatorRole: operatorRole, + }) + if err != nil { + glog.Warningf(ctx, "删除奖励类型失败,操作用户ID:%d,角色:%s,奖励类型ID:%d,错误信息:%v", operatorId, operatorRole, req.Id, err) return nil, err } + + glog.Infof(ctx, "删除奖励类型成功,操作用户ID:%d,角色:%s,奖励类型ID:%d", operatorId, operatorRole, req.Id) return &v1.DeleteRes{Success: out.Success}, nil } diff --git a/internal/controller/rewardType/rewardType_v1_list.go b/internal/controller/rewardType/rewardType_v1_list.go index 89e1961..c586be6 100644 --- a/internal/controller/rewardType/rewardType_v1_list.go +++ b/internal/controller/rewardType/rewardType_v1_list.go @@ -3,6 +3,7 @@ package rewardType import ( "context" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/glog" "server/internal/model" "server/internal/service" @@ -13,10 +14,28 @@ func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListR fromCtx := g.RequestFromCtx(ctx) operatorId := fromCtx.GetCtxVar("id").Int64() operatorRole := fromCtx.GetCtxVar("role").String() - out, err := service.RewardType().List(ctx, &model.RewardTypeListIn{Page: req.Page, Size: req.Size, OperatorId: operatorId, OperatorRole: operatorRole, StoreId: req.StoreId, Name: req.Name, Status: req.Status}) + + glog.Infof(ctx, "获取奖励类型列表,操作用户ID:%d,角色:%s,页码:%d,每页大小:%d,门店ID:%d,名称过滤:%s,来源过滤:%d", + operatorId, operatorRole, req.Page, req.Size, req.StoreId, req.Name, req.Source, + ) + + out, err := service.RewardType().List(ctx, &model.RewardTypeListIn{ + Page: req.Page, + Size: req.Size, + OperatorId: operatorId, + OperatorRole: operatorRole, + StoreId: req.StoreId, + Name: req.Name, + Source: req.Source, + }) + if err != nil { + glog.Warningf(ctx, "获取奖励类型列表失败,操作用户ID:%d,角色:%s,错误信息:%v", operatorId, operatorRole, err) return nil, err } + + glog.Infof(ctx, "获取奖励类型列表成功,操作用户ID:%d,角色:%s,结果总数:%d", operatorId, operatorRole, out.Total) + return &v1.ListRes{ List: out.List, Total: out.Total, diff --git a/internal/controller/rewardType/rewardType_v1_update.go b/internal/controller/rewardType/rewardType_v1_update.go index 86bdb67..cc6fa6b 100644 --- a/internal/controller/rewardType/rewardType_v1_update.go +++ b/internal/controller/rewardType/rewardType_v1_update.go @@ -3,6 +3,7 @@ package rewardType import ( "context" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/glog" "server/internal/model" "server/internal/service" @@ -13,17 +14,24 @@ func (c *ControllerV1) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.U fromCtx := g.RequestFromCtx(ctx) operatorId := fromCtx.GetCtxVar("id").Int64() operatorRole := fromCtx.GetCtxVar("role").String() + + glog.Infof(ctx, "更新奖励类型开始,操作用户ID:%d,角色:%s,奖励类型ID:%d,名称:%s,腾讯类型ID:%d,门店ID:%d", + operatorId, operatorRole, req.Id, req.Name, req.TencentTypeId, req.StoreId, + ) + out, err := service.RewardType().Update(ctx, &model.RewardTypeUpdateIn{ - Id: req.Id, - Name: req.Name, - Description: req.Description, - Status: req.Status, - OperatorId: operatorId, - OperatorRole: operatorRole, - StoreId: req.StoreId, + Id: req.Id, + Name: req.Name, + TencentTypeId: req.TencentTypeId, + StoreId: req.StoreId, + OperatorId: operatorId, + OperatorRole: operatorRole, }) if err != nil { + glog.Warningf(ctx, "更新奖励类型失败,操作用户ID:%d,角色:%s,错误信息:%v", operatorId, operatorRole, err) return nil, err } + + glog.Infof(ctx, "更新奖励类型成功,操作用户ID:%d,角色:%s,奖励类型ID:%d", operatorId, operatorRole, req.Id) return &v1.UpdateRes{Success: out.Success}, nil } diff --git a/internal/controller/storeTaskReward/storeTaskReward.go b/internal/controller/storeTaskReward/storeTaskReward.go deleted file mode 100644 index 940ca37..0000000 --- a/internal/controller/storeTaskReward/storeTaskReward.go +++ /dev/null @@ -1,5 +0,0 @@ -// ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. -// ================================================================================= - -package storeTaskReward diff --git a/internal/controller/storeTaskReward/storeTaskReward_new.go b/internal/controller/storeTaskReward/storeTaskReward_new.go deleted file mode 100644 index b9899b8..0000000 --- a/internal/controller/storeTaskReward/storeTaskReward_new.go +++ /dev/null @@ -1,15 +0,0 @@ -// ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. -// ================================================================================= - -package storeTaskReward - -import ( - "server/api/storeTaskReward" -) - -type ControllerV1 struct{} - -func NewV1() storeTaskReward.IStoreTaskRewardV1 { - return &ControllerV1{} -} diff --git a/internal/controller/storeTaskReward/storeTaskReward_v1_create.go b/internal/controller/storeTaskReward/storeTaskReward_v1_create.go deleted file mode 100644 index 61ec376..0000000 --- a/internal/controller/storeTaskReward/storeTaskReward_v1_create.go +++ /dev/null @@ -1,21 +0,0 @@ -package storeTaskReward - -import ( - "context" - "github.com/gogf/gf/v2/frame/g" - "server/internal/model" - "server/internal/service" - - "server/api/storeTaskReward/v1" -) - -func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) { - fromCtx := g.RequestFromCtx(ctx) - operatorId := fromCtx.GetCtxVar("id").Int64() - operatorRole := fromCtx.GetCtxVar("role").String() - out, err := service.StoreTaskReward().Create(ctx, &model.StoreTaskRewardCreateIn{OperatorId: operatorId, OperatorRole: operatorRole, RewardId: req.RewardId, StoreId: req.StoreId, TaskId: req.TaskId}) - if err != nil { - return nil, err - } - return &v1.CreateRes{Id: out.Id}, nil -} diff --git a/internal/controller/storeTaskReward/storeTaskReward_v1_delete.go b/internal/controller/storeTaskReward/storeTaskReward_v1_delete.go deleted file mode 100644 index 18e8ce8..0000000 --- a/internal/controller/storeTaskReward/storeTaskReward_v1_delete.go +++ /dev/null @@ -1,21 +0,0 @@ -package storeTaskReward - -import ( - "context" - "github.com/gogf/gf/v2/frame/g" - "server/internal/model" - "server/internal/service" - - "server/api/storeTaskReward/v1" -) - -func (c *ControllerV1) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) { - fromCtx := g.RequestFromCtx(ctx) - operatorId := fromCtx.GetCtxVar("id").Int64() - operatorRole := fromCtx.GetCtxVar("role").String() - out, err := service.StoreTaskReward().Delete(ctx, &model.StoreTaskRewardDeleteIn{Id: req.Id, OperatorId: operatorId, OperatorRole: operatorRole}) - if err != nil { - return nil, err - } - return &v1.DeleteRes{Success: out.Success}, nil -} diff --git a/internal/dao/internal/admins.go b/internal/dao/internal/admins.go index dc72d15..7c3f2be 100644 --- a/internal/dao/internal/admins.go +++ b/internal/dao/internal/admins.go @@ -13,10 +13,9 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // 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. -func NewAdminsDao(handlers ...gdb.ModelHandler) *AdminsDao { +func NewAdminsDao() *AdminsDao { return &AdminsDao{ - group: "default", - table: "admins", - columns: adminsColumns, - handlers: handlers, + group: "default", + table: "admins", + columns: adminsColumns, } } @@ -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. func (dao *AdminsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/feedbacks.go b/internal/dao/internal/feedbacks.go index 7a8d085..d67a1e5 100644 --- a/internal/dao/internal/feedbacks.go +++ b/internal/dao/internal/feedbacks.go @@ -13,10 +13,9 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // 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. -func NewFeedbacksDao(handlers ...gdb.ModelHandler) *FeedbacksDao { +func NewFeedbacksDao() *FeedbacksDao { return &FeedbacksDao{ - group: "default", - table: "feedbacks", - columns: feedbacksColumns, - handlers: handlers, + group: "default", + table: "feedbacks", + columns: feedbacksColumns, } } @@ -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. func (dao *FeedbacksDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/games.go b/internal/dao/internal/games.go index dac75c7..b53dd54 100644 --- a/internal/dao/internal/games.go +++ b/internal/dao/internal/games.go @@ -13,10 +13,9 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // 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. -func NewGamesDao(handlers ...gdb.ModelHandler) *GamesDao { +func NewGamesDao() *GamesDao { return &GamesDao{ - group: "default", - table: "games", - columns: gamesColumns, - handlers: handlers, + group: "default", + table: "games", + columns: gamesColumns, } } @@ -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. func (dao *GamesDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/merchant_admins.go b/internal/dao/internal/merchant_admins.go index 64533e1..51ac691 100644 --- a/internal/dao/internal/merchant_admins.go +++ b/internal/dao/internal/merchant_admins.go @@ -13,10 +13,9 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // 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. -func NewMerchantAdminsDao(handlers ...gdb.ModelHandler) *MerchantAdminsDao { +func NewMerchantAdminsDao() *MerchantAdminsDao { return &MerchantAdminsDao{ - group: "default", - table: "merchant_admins", - columns: merchantAdminsColumns, - handlers: handlers, + group: "default", + table: "merchant_admins", + columns: merchantAdminsColumns, } } @@ -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. func (dao *MerchantAdminsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/merchants.go b/internal/dao/internal/merchants.go index 717f855..6dd5d05 100644 --- a/internal/dao/internal/merchants.go +++ b/internal/dao/internal/merchants.go @@ -13,10 +13,9 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // 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. -func NewMerchantsDao(handlers ...gdb.ModelHandler) *MerchantsDao { +func NewMerchantsDao() *MerchantsDao { return &MerchantsDao{ - group: "default", - table: "merchants", - columns: merchantsColumns, - handlers: handlers, + group: "default", + table: "merchants", + columns: merchantsColumns, } } @@ -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. func (dao *MerchantsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/reward_types.go b/internal/dao/internal/reward_types.go index 30b7375..591cab5 100644 --- a/internal/dao/internal/reward_types.go +++ b/internal/dao/internal/reward_types.go @@ -13,45 +13,41 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // RewardTypesColumns defines and stores column names for the table reward_types. type RewardTypesColumns struct { - Id string // 奖励类型ID - Name string // 奖励类型名称(如积分、优惠券) - Description string // 奖励类型描述 - Source string // 来源:1=系统默认,2=门店自定义 - StoreId string // 门店ID,系统默认类型为NULL - Status string // 状态:1=正常,2=禁用 - CreatedAt string // 创建时间 - UpdatedAt string // 更新时间 - DeletedAt string // 软删除时间戳 + Id string // 奖励类型ID + Name string // 类型名称 + TencentTypeId string // 腾讯奖励类型ID(仅系统奖励有效) + Source string // 奖励来源:1=腾讯系统,2=本系统,3=其他 + CreatedAt string // 创建时间 + UpdatedAt string // 更新时间 + DeletedAt string // 软删除时间 + StoreId string // 门店 id } // rewardTypesColumns holds the columns for the table reward_types. var rewardTypesColumns = RewardTypesColumns{ - Id: "id", - Name: "name", - Description: "description", - Source: "source", - StoreId: "store_id", - Status: "status", - CreatedAt: "created_at", - UpdatedAt: "updated_at", - DeletedAt: "deleted_at", + Id: "id", + Name: "name", + TencentTypeId: "tencent_type_id", + Source: "source", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", + StoreId: "store_id", } // NewRewardTypesDao creates and returns a new DAO object for table data access. -func NewRewardTypesDao(handlers ...gdb.ModelHandler) *RewardTypesDao { +func NewRewardTypesDao() *RewardTypesDao { return &RewardTypesDao{ - group: "default", - table: "reward_types", - columns: rewardTypesColumns, - handlers: handlers, + group: "default", + table: "reward_types", + columns: rewardTypesColumns, } } @@ -77,11 +73,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. func (dao *RewardTypesDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/rewards.go b/internal/dao/internal/rewards.go index 5cd8766..86d8d4c 100644 --- a/internal/dao/internal/rewards.go +++ b/internal/dao/internal/rewards.go @@ -13,61 +13,69 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // RewardsColumns defines and stores column names for the table rewards. type RewardsColumns struct { - Id string // 奖励ID - RewardTypeId string // 奖励类型ID - Name string // 奖励名称(如100积分、5元优惠券) - Description string // 奖励描述 - Source string // 来源:1=系统内置,2=门店自定义 - StoreId string // 门店ID,系统内置奖励为NULL - Value string // 奖励值(如积分数额、优惠金额) - Status string // 状态:1=正常,2=禁用 - CreatedAt string // 创建时间 - UpdatedAt string // 更新时间 - DeletedAt string // 软删除时间戳 - TotalNum string // 奖励总数量,NULL表示不限量 - UsedNum string // 已使用数量 - ExpireType string // 过期类型:1=时间段过期,2=领取后多少天过期 - ValidFrom string // 有效开始时间(expire_type=1 时使用) - ValidTo string // 有效结束时间(expire_type=1 时使用) - ExpireDays string // 领取后多少天过期(expire_type=2 时使用) + Id string // 奖励ID + StoreId string // 门店ID,系统奖励为NULL + Name string // 奖励名称 + RewardTypeId string // 奖励类型ID,关联 reward_types 表 + GameId string // 游戏ID + ImageUrl string // 奖励图片链接 + QqGoodsId string // QQ网吧物品ID + QqGoodsIdStr string // QQ网吧物品ID字符串 + Status string // 状态:1=启用,2=禁用 + ExpireType string // 过期方式:1=时间段过期,2=领取后过期 + ValidFrom string // 有效期开始时间(expire_type=1时) + ValidTo string // 有效期结束时间(expire_type=1时) + ExpireDays string // 领取后多少天过期(expire_type=2时) + DailyTotalLimit string // 每日发放总限(NULL表示不限制) + TotalLimit string // 奖励总限(NULL表示不限制) + UserDailyLimit string // 用户每日领取限制(NULL表示不限制) + UserTotalLimit string // 用户领取总次数限制(NULL表示不限制) + ReceivedNum string // 已领取数量 + GrantQuantity string // 每次发放个数 + CreatedAt string // 创建时间 + UpdatedAt string // 更新时间 + DeletedAt string // 删除时间(软删除) } // rewardsColumns holds the columns for the table rewards. var rewardsColumns = RewardsColumns{ - Id: "id", - RewardTypeId: "reward_type_id", - Name: "name", - Description: "description", - Source: "source", - StoreId: "store_id", - Value: "value", - Status: "status", - CreatedAt: "created_at", - UpdatedAt: "updated_at", - DeletedAt: "deleted_at", - TotalNum: "total_num", - UsedNum: "used_num", - ExpireType: "expire_type", - ValidFrom: "valid_from", - ValidTo: "valid_to", - ExpireDays: "expire_days", + Id: "id", + StoreId: "store_id", + Name: "name", + RewardTypeId: "reward_type_id", + GameId: "game_id", + ImageUrl: "image_url", + QqGoodsId: "qq_goods_id", + QqGoodsIdStr: "qq_goods_id_str", + Status: "status", + ExpireType: "expire_type", + ValidFrom: "valid_from", + ValidTo: "valid_to", + ExpireDays: "expire_days", + DailyTotalLimit: "daily_total_limit", + TotalLimit: "total_limit", + UserDailyLimit: "user_daily_limit", + UserTotalLimit: "user_total_limit", + ReceivedNum: "received_num", + GrantQuantity: "grant_quantity", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", } // NewRewardsDao creates and returns a new DAO object for table data access. -func NewRewardsDao(handlers ...gdb.ModelHandler) *RewardsDao { +func NewRewardsDao() *RewardsDao { return &RewardsDao{ - group: "default", - table: "rewards", - columns: rewardsColumns, - handlers: handlers, + group: "default", + table: "rewards", + columns: rewardsColumns, } } @@ -93,11 +101,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. func (dao *RewardsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/roles.go b/internal/dao/internal/roles.go index b540549..9eab304 100644 --- a/internal/dao/internal/roles.go +++ b/internal/dao/internal/roles.go @@ -13,10 +13,9 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // 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. -func NewRolesDao(handlers ...gdb.ModelHandler) *RolesDao { +func NewRolesDao() *RolesDao { return &RolesDao{ - group: "default", - table: "roles", - columns: rolesColumns, - handlers: handlers, + group: "default", + table: "roles", + columns: rolesColumns, } } @@ -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. func (dao *RolesDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_admins.go b/internal/dao/internal/store_admins.go index 538322c..7bcffcc 100644 --- a/internal/dao/internal/store_admins.go +++ b/internal/dao/internal/store_admins.go @@ -13,10 +13,9 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // 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. -func NewStoreAdminsDao(handlers ...gdb.ModelHandler) *StoreAdminsDao { +func NewStoreAdminsDao() *StoreAdminsDao { return &StoreAdminsDao{ - group: "default", - table: "store_admins", - columns: storeAdminsColumns, - handlers: handlers, + group: "default", + table: "store_admins", + columns: storeAdminsColumns, } } @@ -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. func (dao *StoreAdminsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_desktop_settings.go b/internal/dao/internal/store_desktop_settings.go index 88c9cb5..dec1ba9 100644 --- a/internal/dao/internal/store_desktop_settings.go +++ b/internal/dao/internal/store_desktop_settings.go @@ -13,10 +13,9 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // 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. -func NewStoreDesktopSettingsDao(handlers ...gdb.ModelHandler) *StoreDesktopSettingsDao { +func NewStoreDesktopSettingsDao() *StoreDesktopSettingsDao { return &StoreDesktopSettingsDao{ - group: "default", - table: "store_desktop_settings", - columns: storeDesktopSettingsColumns, - handlers: handlers, + group: "default", + table: "store_desktop_settings", + columns: storeDesktopSettingsColumns, } } @@ -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. func (dao *StoreDesktopSettingsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_ips.go b/internal/dao/internal/store_ips.go index dfdfd58..20197cb 100644 --- a/internal/dao/internal/store_ips.go +++ b/internal/dao/internal/store_ips.go @@ -13,10 +13,9 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // 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. -func NewStoreIpsDao(handlers ...gdb.ModelHandler) *StoreIpsDao { +func NewStoreIpsDao() *StoreIpsDao { return &StoreIpsDao{ - group: "default", - table: "store_ips", - columns: storeIpsColumns, - handlers: handlers, + group: "default", + table: "store_ips", + columns: storeIpsColumns, } } @@ -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. func (dao *StoreIpsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_netfee_area_level.go b/internal/dao/internal/store_netfee_area_level.go new file mode 100644 index 0000000..e2a43a6 --- /dev/null +++ b/internal/dao/internal/store_netfee_area_level.go @@ -0,0 +1,93 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// 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. +} + +// StoreNetfeeAreaLevelColumns defines and stores column names for the table store_netfee_area_level. +type StoreNetfeeAreaLevelColumns struct { + Id string // 主键ID + StoreId string // 门店ID + RewardId string // 奖励ID(rewards表主键) + AreaId string // 区域ID(外部系统) + AreaName string // 区域名称 + MemberLevelId string // 会员等级ID(外部系统) + MemberLevelName string // 会员等级名称 + PriceData string // 7x24价格矩阵 + CreatedAt string // 创建时间 + UpdatedAt string // 更新时间 + DeletedAt string // 删除时间 +} + +// storeNetfeeAreaLevelColumns holds the columns for the table store_netfee_area_level. +var storeNetfeeAreaLevelColumns = StoreNetfeeAreaLevelColumns{ + Id: "id", + StoreId: "store_id", + RewardId: "reward_id", + AreaId: "area_id", + AreaName: "area_name", + MemberLevelId: "member_level_id", + MemberLevelName: "member_level_name", + PriceData: "price_data", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", +} + +// NewStoreNetfeeAreaLevelDao creates and returns a new DAO object for table data access. +func NewStoreNetfeeAreaLevelDao() *StoreNetfeeAreaLevelDao { + return &StoreNetfeeAreaLevelDao{ + group: "default", + table: "store_netfee_area_level", + columns: storeNetfeeAreaLevelColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of the current DAO. +func (dao *StoreNetfeeAreaLevelDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of the current DAO. +func (dao *StoreNetfeeAreaLevelDao) Table() string { + return dao.table +} + +// Columns returns all column names of the current DAO. +func (dao *StoreNetfeeAreaLevelDao) Columns() StoreNetfeeAreaLevelColumns { + return dao.columns +} + +// Group returns the database configuration group name of the current DAO. +func (dao *StoreNetfeeAreaLevelDao) Group() string { + return dao.group +} + +// 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) +} + +// Transaction wraps the transaction logic using function f. +// It rolls back the transaction and returns the error if function f returns a non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note: Do not commit or roll back the transaction in function f, +// as it is automatically handled by this function. +func (dao *StoreNetfeeAreaLevelDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/internal/dao/internal/store_roles.go b/internal/dao/internal/store_roles.go index 137e1fa..8528459 100644 --- a/internal/dao/internal/store_roles.go +++ b/internal/dao/internal/store_roles.go @@ -13,10 +13,9 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // 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. -func NewStoreRolesDao(handlers ...gdb.ModelHandler) *StoreRolesDao { +func NewStoreRolesDao() *StoreRolesDao { return &StoreRolesDao{ - group: "default", - table: "store_roles", - columns: storeRolesColumns, - handlers: handlers, + group: "default", + table: "store_roles", + columns: storeRolesColumns, } } @@ -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. func (dao *StoreRolesDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/stores.go b/internal/dao/internal/stores.go index 69ed619..8bbdc42 100644 --- a/internal/dao/internal/stores.go +++ b/internal/dao/internal/stores.go @@ -13,10 +13,9 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // 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. -func NewStoresDao(handlers ...gdb.ModelHandler) *StoresDao { +func NewStoresDao() *StoresDao { return &StoresDao{ - group: "default", - table: "stores", - columns: storesColumns, - handlers: handlers, + group: "default", + table: "stores", + columns: storesColumns, } } @@ -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. func (dao *StoresDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/tasks.go b/internal/dao/internal/tasks.go index dfd5153..526632b 100644 --- a/internal/dao/internal/tasks.go +++ b/internal/dao/internal/tasks.go @@ -13,10 +13,9 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // TasksColumns defines and stores column names for the table tasks. @@ -58,12 +57,11 @@ var tasksColumns = TasksColumns{ } // NewTasksDao creates and returns a new DAO object for table data access. -func NewTasksDao(handlers ...gdb.ModelHandler) *TasksDao { +func NewTasksDao() *TasksDao { return &TasksDao{ - group: "default", - table: "tasks", - columns: tasksColumns, - handlers: handlers, + group: "default", + table: "tasks", + columns: tasksColumns, } } @@ -89,11 +87,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. func (dao *TasksDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/user_tasks.go b/internal/dao/internal/user_tasks.go index 257329e..69ac1d3 100644 --- a/internal/dao/internal/user_tasks.go +++ b/internal/dao/internal/user_tasks.go @@ -13,10 +13,9 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // UserTasksColumns defines and stores column names for the table user_tasks. @@ -52,12 +51,11 @@ var userTasksColumns = UserTasksColumns{ } // NewUserTasksDao creates and returns a new DAO object for table data access. -func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao { +func NewUserTasksDao() *UserTasksDao { return &UserTasksDao{ - group: "default", - table: "user_tasks", - columns: userTasksColumns, - handlers: handlers, + group: "default", + table: "user_tasks", + columns: userTasksColumns, } } @@ -83,11 +81,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. func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/users.go b/internal/dao/internal/users.go index 340eaf7..c5aa79d 100644 --- a/internal/dao/internal/users.go +++ b/internal/dao/internal/users.go @@ -13,10 +13,9 @@ 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. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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. } // UsersColumns defines and stores column names for the table users. @@ -60,12 +59,11 @@ var usersColumns = UsersColumns{ } // NewUsersDao creates and returns a new DAO object for table data access. -func NewUsersDao(handlers ...gdb.ModelHandler) *UsersDao { +func NewUsersDao() *UsersDao { return &UsersDao{ - group: "default", - table: "users", - columns: usersColumns, - handlers: handlers, + group: "default", + table: "users", + columns: usersColumns, } } @@ -91,11 +89,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. func (dao *UsersDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/store_netfee_area_level.go b/internal/dao/store_netfee_area_level.go new file mode 100644 index 0000000..266f99f --- /dev/null +++ b/internal/dao/store_netfee_area_level.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. +// ================================================================================= + +package dao + +import ( + "server/internal/dao/internal" +) + +// internalStoreNetfeeAreaLevelDao is an internal type for wrapping the internal DAO implementation. +type internalStoreNetfeeAreaLevelDao = *internal.StoreNetfeeAreaLevelDao + +// storeNetfeeAreaLevelDao is the data access object for the table store_netfee_area_level. +// You can define custom methods on it to extend its functionality as needed. +type storeNetfeeAreaLevelDao struct { + internalStoreNetfeeAreaLevelDao +} + +var ( + // StoreNetfeeAreaLevel is a globally accessible object for table store_netfee_area_level operations. + StoreNetfeeAreaLevel = storeNetfeeAreaLevelDao{ + internal.NewStoreNetfeeAreaLevelDao(), + } +) + +// Add your custom methods and functionality below. diff --git a/internal/logic/logic.go b/internal/logic/logic.go index 9d12884..f92c84a 100644 --- a/internal/logic/logic.go +++ b/internal/logic/logic.go @@ -17,7 +17,6 @@ import ( _ "server/internal/logic/storeAdmin" _ "server/internal/logic/storeDesktopSetting" _ "server/internal/logic/storeRole" - _ "server/internal/logic/storeTaskReward" _ "server/internal/logic/task" _ "server/internal/logic/upload" _ "server/internal/logic/user" diff --git a/internal/logic/reward/reward.go b/internal/logic/reward/reward.go index a9dffc0..7ca4267 100644 --- a/internal/logic/reward/reward.go +++ b/internal/logic/reward/reward.go @@ -17,6 +17,7 @@ type sReward struct{} func init() { service.RegisterReward(New()) + service.RegisterReward(New()) } func New() service.IReward { @@ -77,10 +78,7 @@ func (s *sReward) Create(ctx context.Context, in *model.RewardCreateIn) (out *mo id, err := dao.Rewards.Ctx(ctx).Data(do.Rewards{ RewardTypeId: in.RewardTypeId, Name: in.Name, - Description: in.Description, - Source: in.Source, StoreId: in.StoreId, - Value: in.Value, Status: in.Status, ValidFrom: in.ValidFrom, ValidTo: in.ValidTo, @@ -98,7 +96,7 @@ func (s *sReward) Create(ctx context.Context, in *model.RewardCreateIn) (out *mo func (s *sReward) Update(ctx context.Context, in *model.RewardUpdateIn) (out *model.RewardUpdateOut, err error) { // 查询原始记录,确保存在,并获取 source 与 store_id 用于权限校验 data, err := dao.Rewards.Ctx(ctx). - Fields(dao.Rewards.Columns().Id, dao.Rewards.Columns().Source, dao.Rewards.Columns().StoreId). + Fields(dao.Rewards.Columns().Id, dao.Rewards.Columns().StoreId). Where(do.Rewards{Id: in.Id}).One() if err != nil { return nil, ecode.Fail.Sub("查询奖励失败") @@ -107,11 +105,6 @@ func (s *sReward) Update(ctx context.Context, in *model.RewardUpdateIn) (out *mo return nil, ecode.Params.Sub("奖励不存在") } - // 系统奖励(source=1)只能由管理员修改 - if data[dao.Rewards.Columns().Source].Int() == 1 && in.OperatorRole != consts.AdminRoleCode { - return nil, ecode.Params.Sub("只有管理员可以修改系统奖励") - } - storeId := data[dao.Rewards.Columns().StoreId].Int64() // 权限校验(管理员跳过) @@ -161,14 +154,12 @@ func (s *sReward) Update(ctx context.Context, in *model.RewardUpdateIn) (out *mo _, err = dao.Rewards.Ctx(ctx). Where(do.Rewards{Id: in.Id}). Data(do.Rewards{ - Name: in.Name, - Description: in.Description, - Value: in.Value, - Status: in.Status, - ValidFrom: in.ValidFrom, - ValidTo: in.ValidTo, - ExpireType: in.ExpireType, - ExpireDays: in.ExpireDays, + Name: in.Name, + Status: in.Status, + ValidFrom: in.ValidFrom, + ValidTo: in.ValidTo, + ExpireType: in.ExpireType, + ExpireDays: in.ExpireDays, }).OmitEmptyData().Update() if err != nil { @@ -245,123 +236,13 @@ func (s *sReward) Delete(ctx context.Context, in *model.RewardDeleteIn) (out *mo // List 奖励列表 func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error) { - var list []model.Reward - orm := dao.Rewards.Ctx(ctx) - rewardCols := dao.Rewards.Columns() - rewardTypeCols := dao.RewardTypes.Columns() - - // ==== 权限校验 ==== - switch in.OperatorRole { - case consts.AdminRoleCode: - // 系统管理员只能查询 source = 1 的奖励 - orm = orm.Where(fmt.Sprintf("%s.%s = ?", dao.Rewards.Table(), rewardCols.Source), 1) - case consts.MerchantRoleCode, consts.StoreRoleCode: - // 合并商户和门店角色权限校验 - var exist bool - if in.OperatorRole == consts.MerchantRoleCode { - exist, err = dao.MerchantAdmins.Ctx(ctx). - Where(do.MerchantAdmins{Id: in.OperatorId}). - LeftJoin( - dao.Stores.Table(), - fmt.Sprintf("%s.%s = %s.%s", - dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId, - dao.Stores.Table(), dao.Stores.Columns().MerchantId, - ), - ). - Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId). - Exist() - } else { - exist, err = dao.StoreAdmins.Ctx(ctx). - Where(do.StoreAdmins{Id: in.OperatorId}). - LeftJoin( - dao.Stores.Table(), - fmt.Sprintf("%s.%s = %s.%s", - dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId, - dao.Stores.Table(), dao.Stores.Columns().Id, - ), - ). - Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId). - Exist() - } - if err != nil { - return nil, ecode.Fail.Sub("检查操作者权限异常") - } - if !exist { - return nil, ecode.Params.Sub("无门店权限") - } - // 商户和门店角色查询 source = 1 或 (source = 2 且 store_id = in.StoreId) - orm = orm.Where( - fmt.Sprintf( - "(%s.%s = ? OR (%s.%s = ? AND %s.%s = ?))", - dao.Rewards.Table(), rewardCols.Source, - dao.Rewards.Table(), rewardCols.Source, - dao.Rewards.Table(), rewardCols.StoreId, - ), - 1, 2, in.StoreId, - ) - default: - return nil, ecode.Params.Sub("无效的角色") - } - - // ==== 其他查询条件 ==== - if in.Status != 0 { - orm = orm.Where(fmt.Sprintf("%s.%s = ?", dao.Rewards.Table(), rewardCols.Status), in.Status) - } - if in.RewardTypeId != 0 { - // 确保 reward_type_id 过滤独立应用 - orm = orm.Where(fmt.Sprintf("%s.%s = ?", dao.Rewards.Table(), rewardCols.RewardTypeId), in.RewardTypeId) - } - if in.Name != "" { - orm = orm.WhereLike(rewardCols.Name, "%"+in.Name+"%") - } - - // ==== 总数统计 ==== - total, err := orm.Count() - if err != nil { - return nil, err - } - - // ==== 分页查询 + 联表字段 ==== - err = orm.Page(in.Page, in.Size). - LeftJoin( - dao.RewardTypes.Table(), - fmt.Sprintf("%s.%s = %s.%s", - dao.Rewards.Table(), rewardCols.RewardTypeId, - dao.RewardTypes.Table(), rewardTypeCols.Id, - ), - ). - Fields(fmt.Sprintf( - "%s.*, %s.%s AS reward_type_name", - dao.Rewards.Table(), - dao.RewardTypes.Table(), rewardTypeCols.Name, - )). - OrderDesc(rewardCols.CreatedAt). - Scan(&list) - if err != nil { - return nil, err - } - - return &model.RewardListOut{ - List: list, - Total: total, - }, nil + return nil, nil } // GetLift 领取奖励 func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *model.GetRewardOut, err error) { - // 遍历奖励类型列表 - //for _, v := range in.RewradTypeId { - // if v > 0 { - // // 发背包+兑换 - // - // } - // if v > 0 { - // // 直接发背包 - // } - //} - activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{PopenId: in.PopenId, ServiceName: consts.GetGift, GiftParam: model.GiftParam{ TaskId: in.TaskId, AreaId: in.AreaId, diff --git a/internal/logic/rewardType/rewardType.go b/internal/logic/rewardType/rewardType.go index bab9168..4b95892 100644 --- a/internal/logic/rewardType/rewardType.go +++ b/internal/logic/rewardType/rewardType.go @@ -10,6 +10,8 @@ import ( "server/internal/model/do" "server/internal/service" "server/utility/ecode" + + "github.com/gogf/gf/v2/os/gtime" ) type sRewardType struct { @@ -25,328 +27,192 @@ func New() service.IRewardType { // Create 创建奖励类型 func (s *sRewardType) Create(ctx context.Context, in *model.RewardTypeCreateIn) (out *model.RewardTypeCreateOut, err error) { - // 创建时,source为1的奖励类型只能由管理员创建 - // 商户和门店管理员创建奖励时需要判断是有拥有 storeId 的权限 - - // 检查 source=1 的奖励类型只能由管理员创建 - if in.Source == 1 && in.OperatorRole != consts.AdminRoleCode { - return nil, ecode.Params.Sub("只有管理员可以创建 source=1 的奖励类型") + if err = checkRewardTypePermission(ctx, in.OperatorRole, in.OperatorId, in.Source, in.StoreId); err != nil { + return nil, err } - // 根据角色和权限检查 - switch in.OperatorRole { - case consts.MerchantRoleCode: - // 检查商户是否有该门店权限 - exist, err := dao.MerchantAdmins.Ctx(ctx).LeftJoin( - dao.Stores.Table(), - fmt.Sprintf("%s.%s = %s.%s", - dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId, - dao.Stores.Table(), dao.Stores.Columns().MerchantId, - ), - ).Where( - fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId, - ).Where( - do.MerchantAdmins{Id: in.OperatorId}, - ).Exist() - if err != nil { - return nil, ecode.Fail.Sub("检查操作者权限出现异常") - } - if !exist { - return nil, ecode.Params.Sub("无门店权限") - } - - case consts.StoreRoleCode: - // 检查门店是否有权限 - exist, err := dao.StoreAdmins.Ctx(ctx).LeftJoin( - dao.Stores.Table(), - fmt.Sprintf("%s.%s = %s.%s", - dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId, - dao.Stores.Table(), dao.Stores.Columns().Id, - ), - ).Where( - fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId, - ).Where( - do.StoreAdmins{Id: in.OperatorId}, - ).Exist() - if err != nil { - return nil, ecode.Fail.Sub("检查操作者权限出现异常") - } - if !exist { - return nil, ecode.Params.Sub("无门店权限") - } + data := do.RewardTypes{ + Name: in.Name, + Source: in.Source, + StoreId: in.StoreId, + TencentTypeId: in.TencentTypeId, } - id, err := dao.RewardTypes.Ctx(ctx).Data(do.RewardTypes{ - Name: in.Name, - Description: in.Description, - Source: in.Source, - StoreId: in.StoreId, - }).OmitEmptyData().InsertAndGetId() + id, err := dao.RewardTypes.Ctx(ctx).OmitEmptyData().Data(data).InsertAndGetId() if err != nil { return nil, err } - return &model.RewardTypeCreateOut{ - Id: id, - }, nil + return &model.RewardTypeCreateOut{Id: id}, nil } // Update 更新奖励类型 func (s *sRewardType) Update(ctx context.Context, in *model.RewardTypeUpdateIn) (out *model.RewardTypeUpdateOut, err error) { - // 查询原始记录,确保存在,并获取 store_id 和 source 字段用于权限判断 - value, err := dao.RewardTypes.Ctx(ctx). - Fields(dao.RewardTypes.Columns().Id, dao.RewardTypes.Columns().Source, dao.RewardTypes.Columns().StoreId). - Where(do.RewardTypes{Id: in.Id}).One() + info, err := dao.RewardTypes.Ctx(ctx).WherePri(in.Id).One() if err != nil { - return nil, ecode.Fail.Sub("查询奖励类型失败") + return nil, err } - if value.IsEmpty() { + if info == nil { return nil, ecode.Params.Sub("奖励类型不存在") } - // source=1 的奖励类型只能由管理员修改 + source := info["source"].Int() + storeId := info["store_id"].Int64() - if value[dao.RewardTypes.Columns().Source].Int() == 1 && in.OperatorRole != consts.AdminRoleCode { - return nil, ecode.Params.Sub("只有管理员可以修改的系统奖励类型") + if err = checkRewardTypePermission(ctx, in.OperatorRole, in.OperatorId, source, storeId); err != nil { + return nil, err } - // 权限校验(管理员跳过) - switch in.OperatorRole { - case consts.MerchantRoleCode: - exist, err := dao.MerchantAdmins.Ctx(ctx).LeftJoin( - dao.Stores.Table(), - fmt.Sprintf("%s.%s = %s.%s", - dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId, - dao.Stores.Table(), dao.Stores.Columns().MerchantId, - ), - ).Where( - fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), value[dao.RewardTypes.Columns().StoreId].Int(), - ).Where( - do.MerchantAdmins{Id: in.OperatorId}, - ).Exist() - if err != nil { - return nil, ecode.Fail.Sub("检查操作者权限出现异常") - } - if !exist { - return nil, ecode.Params.Sub("无门店权限") - } - - case consts.StoreRoleCode: - exist, err := dao.StoreAdmins.Ctx(ctx).LeftJoin( - dao.Stores.Table(), - fmt.Sprintf("%s.%s = %s.%s", - dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId, - dao.Stores.Table(), dao.Stores.Columns().Id, - ), - ).Where( - fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), value[dao.RewardTypes.Columns().StoreId].Int(), - ).Where( - do.StoreAdmins{Id: in.OperatorId}, - ).Exist() - if err != nil { - return nil, ecode.Fail.Sub("检查操作者权限出现异常") - } - if !exist { - return nil, ecode.Params.Sub("无门店权限") - } + updateData := g.Map{} + if in.Name != "" { + updateData["name"] = in.Name } - // 执行更新(不允许更新 store_id 和 source) - _, err = dao.RewardTypes.Ctx(ctx). - Where(do.RewardTypes{Id: in.Id}). - Data(do.RewardTypes{ - Name: in.Name, - Description: in.Description, - Status: in.Status, - }).OmitEmptyData(). - Update() + if len(updateData) == 0 { + return nil, ecode.Params.Sub("无可更新字段") + } + + _, err = dao.RewardTypes.Ctx(ctx).WherePri(in.Id).Data(updateData).Update() if err != nil { - return nil, ecode.Fail.Sub("更新奖励类型失败") + return nil, err } - return &model.RewardTypeUpdateOut{ - Success: true, - }, nil + return &model.RewardTypeUpdateOut{Success: true}, nil } -// Delete 删除奖励类型 +// Delete 删除奖励类型(逻辑删除) func (s *sRewardType) Delete(ctx context.Context, in *model.RewardTypeDeleteIn) (out *model.RewardTypeDeleteOut, err error) { - // 查询原始记录,确保存在,并获取 store_id 和 source 字段用于权限判断 - value, err := dao.RewardTypes.Ctx(ctx). - Fields(dao.RewardTypes.Columns().Id, dao.RewardTypes.Columns().Source, dao.RewardTypes.Columns().StoreId). - Where(do.RewardTypes{Id: in.Id}). - One() + info, err := dao.RewardTypes.Ctx(ctx).WherePri(in.Id).One() if err != nil { - return nil, ecode.Fail.Sub("查询奖励类型失败") + return nil, err } - if value.IsEmpty() { + if info.IsEmpty() { return nil, ecode.Params.Sub("奖励类型不存在") } - // source=1 的奖励类型只能由管理员删除 - if value[dao.RewardTypes.Columns().Source].Int() == 1 && in.OperatorRole != consts.AdminRoleCode { - return nil, ecode.Params.Sub("只有管理员可以删除的系统奖励类型") + source := info["source"].Int() + storeId := info["store_id"].Int64() + + if err = checkRewardTypePermission(ctx, in.OperatorRole, in.OperatorId, source, storeId); err != nil { + return nil, err } - // 权限校验(管理员跳过) - switch in.OperatorRole { - case consts.MerchantRoleCode: - exist, err := dao.MerchantAdmins.Ctx(ctx).LeftJoin( - dao.Stores.Table(), - fmt.Sprintf("%s.%s = %s.%s", - dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId, - dao.Stores.Table(), dao.Stores.Columns().MerchantId, - ), - ).Where( - fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), - value[dao.RewardTypes.Columns().StoreId].Int(), - ).Where( - do.MerchantAdmins{Id: in.OperatorId}, - ).Exist() - if err != nil { - return nil, ecode.Fail.Sub("检查操作者权限出现异常") - } - if !exist { - return nil, ecode.Params.Sub("无门店权限") - } - - case consts.StoreRoleCode: - exist, err := dao.StoreAdmins.Ctx(ctx).LeftJoin( - dao.Stores.Table(), - fmt.Sprintf("%s.%s = %s.%s", - dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId, - dao.Stores.Table(), dao.Stores.Columns().Id, - ), - ).Where( - fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), - value[dao.RewardTypes.Columns().StoreId].Int(), - ).Where( - do.StoreAdmins{Id: in.OperatorId}, - ).Exist() - if err != nil { - return nil, ecode.Fail.Sub("检查操作者权限出现异常") - } - if !exist { - return nil, ecode.Params.Sub("无门店权限") - } - } - - // 执行删除(软删除) - _, err = dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Id: in.Id}).Delete() + _, err = dao.RewardTypes.Ctx(ctx).WherePri(in.Id).Data(g.Map{ + "deleted_at": gtime.Now(), + }).Update() if err != nil { - return nil, ecode.Fail.Sub("删除奖励类型失败") + return nil, err } - return &model.RewardTypeDeleteOut{ - Success: true, - }, nil + return &model.RewardTypeDeleteOut{Success: true}, nil } -// List 获取奖励类型列表 +// List 获取奖励类型列表(支持分页、过滤) func (s *sRewardType) List(ctx context.Context, in *model.RewardTypeListIn) (out *model.RewardTypeListOut, err error) { - list := make([]model.RewardType, 0) - orm := dao.RewardTypes.Ctx(ctx) + mod := dao.RewardTypes.Ctx(ctx).Where("deleted_at IS NULL") - // 根据角色和权限构建查询条件 switch in.OperatorRole { - case consts.MerchantRoleCode: - // 检查商户是否有该门店权限 - exist, err := dao.MerchantAdmins.Ctx(ctx).Where(do.MerchantAdmins{Id: in.OperatorId}).LeftJoin( - dao.Stores.Table(), - fmt.Sprintf( - "%s.%s = %s.%s", - dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId, - dao.Stores.Table(), dao.Stores.Columns().MerchantId, - ), - ).Where( - fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), - in.StoreId, - ).Exist() - if err != nil { - return nil, ecode.Fail.Sub("检查操作者权限出现异常") - } - if !exist { - return nil, ecode.Params.Sub("无门店权限") - } + case consts.AdminRoleCode: + // 系统管理员只能看系统奖励类型 + mod = mod.Where("source", 1) - // 追加限制:source = 1 或 store_id = 当前门店 - orm = orm.Where( - fmt.Sprintf("%s.%s = ?", dao.RewardTypes.Table(), dao.RewardTypes.Columns().Source), - 1, - ).WhereOr( - fmt.Sprintf("%s.%s IN (?)", dao.RewardTypes.Table(), dao.RewardTypes.Columns().StoreId), - g.Slice{in.StoreId}, - ) + case consts.MerchantRoleCode: + // 校验商户是否对该门店有权限 + if err = checkRewardTypePermission(ctx, in.OperatorRole, in.OperatorId, 2, in.StoreId); err != nil { + return nil, err + } + // 只查询该门店的奖励类型(source=2且store_id=指定门店) + mod = mod.Where("source", 2).WhereIn("store_id", in.StoreId) case consts.StoreRoleCode: - // 检查门店是否有权限 - exist, err := dao.StoreAdmins.Ctx(ctx). - Where(do.StoreAdmins{Id: in.OperatorId}). + // 校验门店权限 + if err = checkRewardTypePermission(ctx, in.OperatorRole, in.OperatorId, 2, in.StoreId); err != nil { + return nil, err + } + mod = mod.Where("source", 2).Where("store_id", in.StoreId) + + default: + return nil, ecode.Params.Sub("无效的操作角色") + } + + // 其余过滤条件 + if in.Name != "" { + mod = mod.WhereLike("name", "%"+in.Name+"%") + } + if in.Source > 0 { + mod = mod.Where("source", in.Source) + } + + count, err := mod.Count() + if err != nil { + return nil, err + } + + records, err := mod.Page(in.Page, in.Size).Order("id DESC").All() + if err != nil { + return nil, err + } + + var list []model.RewardType + if err = records.Structs(&list); err != nil { + return nil, err + } + + out = &model.RewardTypeListOut{ + Total: count, + List: list, + } + + return +} + +func checkRewardTypePermission(ctx context.Context, role string, operatorId int64, source int, storeId int64) error { + switch role { + case consts.AdminRoleCode: + if source != 1 { + return ecode.Params.Sub("系统管理员只能操作系统奖励类型") + } + case consts.MerchantRoleCode: + exist, err := dao.MerchantAdmins.Ctx(ctx). LeftJoin( dao.Stores.Table(), - fmt.Sprintf( - "%s.%s = %s.%s", - dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId, - dao.Stores.Table(), dao.Stores.Columns().Id, - ), + fmt.Sprintf("%s.%s = %s.%s", + dao.Stores.Table(), dao.Stores.Columns().MerchantId, + dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId), ). - Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId). + Where(fmt.Sprintf("%s.%s = ?", dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().Id), operatorId). + Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), storeId). Exist() if err != nil { - return nil, ecode.Fail.Sub("检查操作者权限出现异常") + return ecode.Fail.Sub("检查商户权限异常") } if !exist { - return nil, ecode.Params.Sub("无门店权限") + return ecode.Params.Sub("无门店权限") } - - // 追加限制:source = 1 或 store_id = 当前门店 - orm = orm.Where( - fmt.Sprintf("%s.%s = ?", dao.RewardTypes.Table(), dao.RewardTypes.Columns().Source), - 1, - ).WhereOr( - fmt.Sprintf("%s.%s IN (?)", dao.RewardTypes.Table(), dao.RewardTypes.Columns().StoreId), - g.Slice{in.StoreId}, - ) + if source != 2 { + return ecode.Params.Sub("商户只能操作本系统奖励类型") + } + case consts.StoreRoleCode: + exist, err := dao.StoreAdmins.Ctx(ctx). + LeftJoin( + dao.Stores.Table(), + fmt.Sprintf("%s.%s = %s.%s", + dao.Stores.Table(), dao.Stores.Columns().Id, + dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId), + ). + Where(fmt.Sprintf("%s.%s = ?", dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().Id), operatorId). + Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), storeId). + Exist() + if err != nil { + return ecode.Fail.Sub("检查门店权限异常") + } + if !exist { + return ecode.Params.Sub("无门店权限") + } + if source != 2 { + return ecode.Params.Sub("门店只能操作本系统奖励类型") + } + default: + return ecode.Params.Sub("无效的操作角色") } - - // 其他筛选 - if in.Status != 0 { - orm = orm.Where( - fmt.Sprintf("%s.%s = ?", dao.RewardTypes.Table(), dao.RewardTypes.Columns().Status), - in.Status, - ) - } - if in.Name != "" { - orm = orm.WhereLike( - fmt.Sprintf("%s.%s", dao.RewardTypes.Table(), dao.RewardTypes.Columns().Name), - "%"+in.Name+"%", - ) - } - - // 查询总数 - count, err := orm.Count() - if err != nil { - return nil, err - } - - if in.OperatorRole == consts.AdminRoleCode { - orm = orm.LeftJoin(dao.Stores.Table(), fmt.Sprintf( - "%s.%s = %s.%s", - dao.RewardTypes.Table(), dao.RewardTypes.Columns().StoreId, - dao.Stores.Table(), dao.Stores.Columns().Id), - ).Fields(fmt.Sprintf("%s.*, %s.%s %s", - dao.RewardTypes.Table(), dao.Stores.Table(), dao.Stores.Columns().Name, "storeName")) - } - - // 查询分页数据 - err = orm.Page(in.Page, in.Size). - OrderAsc(fmt.Sprintf("%s.%s", dao.RewardTypes.Table(), dao.RewardTypes.Columns().Source)). - Scan(&list) - if err != nil { - return nil, err - } - - return &model.RewardTypeListOut{ - List: list, - Total: count, - }, nil + return nil } diff --git a/internal/logic/storeTaskReward/storeTaskReward.go b/internal/logic/storeTaskReward/storeTaskReward.go deleted file mode 100644 index b1e0dc1..0000000 --- a/internal/logic/storeTaskReward/storeTaskReward.go +++ /dev/null @@ -1,142 +0,0 @@ -package storeTaskReward - -import ( - "context" - "fmt" - "server/internal/consts" - "server/internal/dao" - "server/internal/model" - "server/internal/model/do" - "server/internal/service" - "server/utility/ecode" -) - -type sStoreTaskReward struct { -} - -func New() service.IStoreTaskReward { - return &sStoreTaskReward{} -} -func init() { - service.RegisterStoreTaskReward(New()) -} -func (s *sStoreTaskReward) Create(ctx context.Context, in *model.StoreTaskRewardCreateIn) (out *model.StoreTaskRewardCreateOut, err error) { - if in.OperatorRole != consts.MerchantRoleCode && in.OperatorRole != consts.StoreRoleCode { - return nil, ecode.Params.Sub("仅允许商户或门店角色操作") - } - - // 检查操作者是否有该门店的操作权限 - switch in.OperatorRole { - case consts.MerchantRoleCode: - exist, err := dao.MerchantAdmins.Ctx(ctx). - Where(do.MerchantAdmins{Id: in.OperatorId}). - LeftJoin( - dao.Stores.Table(), - fmt.Sprintf( - "%s.%s = %s.%s", - dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId, - dao.Stores.Table(), dao.Stores.Columns().MerchantId, - ), - ). - Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId). - Exist() - if err != nil { - return nil, ecode.Fail.Sub("校验商户权限失败") - } - if !exist { - return nil, ecode.Params.Sub("商户无操作该门店权限") - } - - case consts.StoreRoleCode: - exist, err := dao.StoreAdmins.Ctx(ctx). - Where(do.StoreAdmins{Id: in.OperatorId}). - LeftJoin( - dao.Stores.Table(), - fmt.Sprintf( - "%s.%s = %s.%s", - dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId, - dao.Stores.Table(), dao.Stores.Columns().Id, - ), - ). - Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId). - Exist() - if err != nil { - return nil, ecode.Fail.Sub("校验门店权限失败") - } - if !exist { - return nil, ecode.Params.Sub("门店管理员无权限") - } - } - - id, err := dao.StoreTaskRewards.Ctx(ctx).Data(do.StoreTaskRewards{ - StoreId: in.StoreId, - TaskId: in.TaskId, - RewardId: in.RewardId, - }).InsertAndGetId() - if err != nil { - return nil, ecode.Fail.Sub("创建门店任务奖励失败, err:" + err.Error()) - } - return &model.StoreTaskRewardCreateOut{Id: id}, nil -} - -func (s *sStoreTaskReward) Delete(ctx context.Context, in *model.StoreTaskRewardDeleteIn) (out *model.StoreTaskRewardDeleteOut, err error) { - if in.OperatorRole != consts.MerchantRoleCode && in.OperatorRole != consts.StoreRoleCode { - return nil, ecode.Params.Sub("仅允许商户或门店角色操作") - } - - // 检查操作者是否有该门店的操作权限 - value, err := dao.StoreTaskRewards.Ctx(ctx).WherePri(in.Id).Fields(dao.StoreTaskRewards.Columns().StoreId).Value() - if err != nil { - return nil, ecode.Fail.Sub("查询门店任务奖励失败, err:" + err.Error()) - } - if value.IsEmpty() { - return nil, ecode.Params.Sub("门店任务奖励不存在") - } - switch in.OperatorRole { - case consts.MerchantRoleCode: - exist, err := dao.MerchantAdmins.Ctx(ctx). - Where(do.MerchantAdmins{Id: in.OperatorId}). - LeftJoin( - dao.Stores.Table(), - fmt.Sprintf( - "%s.%s = %s.%s", - dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId, - dao.Stores.Table(), dao.Stores.Columns().MerchantId, - ), - ). - Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), value.Int64()). - Exist() - if err != nil { - return nil, ecode.Fail.Sub("校验商户权限失败") - } - if !exist { - return nil, ecode.Params.Sub("商户无操作该门店权限") - } - - case consts.StoreRoleCode: - exist, err := dao.StoreAdmins.Ctx(ctx). - Where(do.StoreAdmins{Id: in.OperatorId}). - LeftJoin( - dao.Stores.Table(), - fmt.Sprintf( - "%s.%s = %s.%s", - dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId, - dao.Stores.Table(), dao.Stores.Columns().Id, - ), - ). - Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), value.Int64()). - Exist() - if err != nil { - return nil, ecode.Fail.Sub("校验门店权限失败") - } - if !exist { - return nil, ecode.Params.Sub("门店管理员无权限") - } - } - _, err = dao.StoreTaskRewards.Ctx(ctx).WherePri(in.Id).Delete() - if err != nil { - return nil, ecode.Fail.Sub("删除门店任务奖励失败") - } - - return &model.StoreTaskRewardDeleteOut{Success: true}, nil -} diff --git a/internal/model/do/reward_types.go b/internal/model/do/reward_types.go index e65bfc0..3c6634f 100644 --- a/internal/model/do/reward_types.go +++ b/internal/model/do/reward_types.go @@ -11,14 +11,13 @@ import ( // RewardTypes is the golang structure of table reward_types for DAO operations like Where/Data. type RewardTypes struct { - g.Meta `orm:"table:reward_types, do:true"` - Id interface{} // 奖励类型ID - Name interface{} // 奖励类型名称(如积分、优惠券) - Description interface{} // 奖励类型描述 - Source interface{} // 来源:1=系统默认,2=门店自定义 - StoreId interface{} // 门店ID,系统默认类型为NULL - Status interface{} // 状态:1=正常,2=禁用 - CreatedAt *gtime.Time // 创建时间 - UpdatedAt *gtime.Time // 更新时间 - DeletedAt *gtime.Time // 软删除时间戳 + g.Meta `orm:"table:reward_types, do:true"` + Id interface{} // 奖励类型ID + Name interface{} // 类型名称 + TencentTypeId interface{} // 腾讯奖励类型ID(仅系统奖励有效) + Source interface{} // 奖励来源:1=腾讯系统,2=本系统,3=其他 + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 更新时间 + DeletedAt *gtime.Time // 软删除时间 + StoreId interface{} // 门店 id } diff --git a/internal/model/do/rewards.go b/internal/model/do/rewards.go index 6e3fd75..e565a19 100644 --- a/internal/model/do/rewards.go +++ b/internal/model/do/rewards.go @@ -11,22 +11,27 @@ import ( // Rewards is the golang structure of table rewards for DAO operations like Where/Data. type Rewards struct { - g.Meta `orm:"table:rewards, do:true"` - Id interface{} // 奖励ID - RewardTypeId interface{} // 奖励类型ID - Name interface{} // 奖励名称(如100积分、5元优惠券) - Description interface{} // 奖励描述 - Source interface{} // 来源:1=系统内置,2=门店自定义 - StoreId interface{} // 门店ID,系统内置奖励为NULL - Value interface{} // 奖励值(如积分数额、优惠金额) - Status interface{} // 状态:1=正常,2=禁用 - CreatedAt *gtime.Time // 创建时间 - UpdatedAt *gtime.Time // 更新时间 - DeletedAt *gtime.Time // 软删除时间戳 - TotalNum interface{} // 奖励总数量,NULL表示不限量 - UsedNum interface{} // 已使用数量 - ExpireType interface{} // 过期类型:1=时间段过期,2=领取后多少天过期 - ValidFrom *gtime.Time // 有效开始时间(expire_type=1 时使用) - ValidTo *gtime.Time // 有效结束时间(expire_type=1 时使用) - ExpireDays interface{} // 领取后多少天过期(expire_type=2 时使用) + g.Meta `orm:"table:rewards, do:true"` + Id interface{} // 奖励ID + StoreId interface{} // 门店ID,系统奖励为NULL + Name interface{} // 奖励名称 + RewardTypeId interface{} // 奖励类型ID,关联 reward_types 表 + GameId interface{} // 游戏ID + ImageUrl interface{} // 奖励图片链接 + QqGoodsId interface{} // QQ网吧物品ID + QqGoodsIdStr interface{} // QQ网吧物品ID字符串 + Status interface{} // 状态:1=启用,2=禁用 + ExpireType interface{} // 过期方式:1=时间段过期,2=领取后过期 + ValidFrom *gtime.Time // 有效期开始时间(expire_type=1时) + ValidTo *gtime.Time // 有效期结束时间(expire_type=1时) + ExpireDays interface{} // 领取后多少天过期(expire_type=2时) + DailyTotalLimit interface{} // 每日发放总限(NULL表示不限制) + TotalLimit interface{} // 奖励总限(NULL表示不限制) + UserDailyLimit interface{} // 用户每日领取限制(NULL表示不限制) + UserTotalLimit interface{} // 用户领取总次数限制(NULL表示不限制) + ReceivedNum interface{} // 已领取数量 + GrantQuantity interface{} // 每次发放个数 + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 更新时间 + DeletedAt *gtime.Time // 删除时间(软删除) } diff --git a/internal/model/do/store_netfee_area_level.go b/internal/model/do/store_netfee_area_level.go new file mode 100644 index 0000000..4301bfb --- /dev/null +++ b/internal/model/do/store_netfee_area_level.go @@ -0,0 +1,26 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// StoreNetfeeAreaLevel is the golang structure of table store_netfee_area_level for DAO operations like Where/Data. +type StoreNetfeeAreaLevel struct { + g.Meta `orm:"table:store_netfee_area_level, do:true"` + Id interface{} // 主键ID + StoreId interface{} // 门店ID + RewardId interface{} // 奖励ID(rewards表主键) + AreaId interface{} // 区域ID(外部系统) + AreaName interface{} // 区域名称 + MemberLevelId interface{} // 会员等级ID(外部系统) + MemberLevelName interface{} // 会员等级名称 + PriceData interface{} // 7x24价格矩阵 + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 更新时间 + DeletedAt *gtime.Time // 删除时间 +} diff --git a/internal/model/entity/reward_types.go b/internal/model/entity/reward_types.go index 54960f8..3a8c360 100644 --- a/internal/model/entity/reward_types.go +++ b/internal/model/entity/reward_types.go @@ -10,13 +10,12 @@ import ( // RewardTypes is the golang structure for table reward_types. type RewardTypes struct { - Id int64 `json:"id" orm:"id" description:"奖励类型ID"` // 奖励类型ID - Name string `json:"name" orm:"name" description:"奖励类型名称(如积分、优惠券)"` // 奖励类型名称(如积分、优惠券) - Description string `json:"description" orm:"description" description:"奖励类型描述"` // 奖励类型描述 - Source int `json:"source" orm:"source" description:"来源:1=系统默认,2=门店自定义"` // 来源:1=系统默认,2=门店自定义 - StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID,系统默认类型为NULL"` // 门店ID,系统默认类型为NULL - Status int `json:"status" orm:"status" description:"状态:1=正常,2=禁用"` // 状态:1=正常,2=禁用 - 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:"软删除时间戳"` // 软删除时间戳 + Id int64 `json:"id" orm:"id" description:"奖励类型ID"` // 奖励类型ID + Name string `json:"name" orm:"name" description:"类型名称"` // 类型名称 + TencentTypeId int `json:"tencentTypeId" orm:"tencent_type_id" description:"腾讯奖励类型ID(仅系统奖励有效)"` // 腾讯奖励类型ID(仅系统奖励有效) + Source int `json:"source" orm:"source" description:"奖励来源:1=腾讯系统,2=本系统,3=其他"` // 奖励来源:1=腾讯系统,2=本系统,3=其他 + 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:"软删除时间"` // 软删除时间 + StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id } diff --git a/internal/model/entity/rewards.go b/internal/model/entity/rewards.go index cb98a45..9ce56fe 100644 --- a/internal/model/entity/rewards.go +++ b/internal/model/entity/rewards.go @@ -10,21 +10,26 @@ import ( // Rewards is the golang structure for table rewards. type Rewards struct { - Id int64 `json:"id" orm:"id" description:"奖励ID"` // 奖励ID - RewardTypeId int64 `json:"rewardTypeId" orm:"reward_type_id" description:"奖励类型ID"` // 奖励类型ID - Name string `json:"name" orm:"name" description:"奖励名称(如100积分、5元优惠券)"` // 奖励名称(如100积分、5元优惠券) - Description string `json:"description" orm:"description" description:"奖励描述"` // 奖励描述 - Source int `json:"source" orm:"source" description:"来源:1=系统内置,2=门店自定义"` // 来源:1=系统内置,2=门店自定义 - StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID,系统内置奖励为NULL"` // 门店ID,系统内置奖励为NULL - Value uint64 `json:"value" orm:"value" description:"奖励值(如积分数额、优惠金额)"` // 奖励值(如积分数额、优惠金额) - Status int `json:"status" orm:"status" description:"状态:1=正常,2=禁用"` // 状态:1=正常,2=禁用 - 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:"软删除时间戳"` // 软删除时间戳 - TotalNum uint64 `json:"totalNum" orm:"total_num" description:"奖励总数量,NULL表示不限量"` // 奖励总数量,NULL表示不限量 - UsedNum uint64 `json:"usedNum" orm:"used_num" description:"已使用数量"` // 已使用数量 - ExpireType int `json:"expireType" orm:"expire_type" description:"过期类型:1=时间段过期,2=领取后多少天过期"` // 过期类型:1=时间段过期,2=领取后多少天过期 - ValidFrom *gtime.Time `json:"validFrom" orm:"valid_from" description:"有效开始时间(expire_type=1 时使用)"` // 有效开始时间(expire_type=1 时使用) - ValidTo *gtime.Time `json:"validTo" orm:"valid_to" description:"有效结束时间(expire_type=1 时使用)"` // 有效结束时间(expire_type=1 时使用) - ExpireDays int `json:"expireDays" orm:"expire_days" description:"领取后多少天过期(expire_type=2 时使用)"` // 领取后多少天过期(expire_type=2 时使用) + Id int64 `json:"id" orm:"id" description:"奖励ID"` // 奖励ID + StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID,系统奖励为NULL"` // 门店ID,系统奖励为NULL + Name string `json:"name" orm:"name" description:"奖励名称"` // 奖励名称 + RewardTypeId int64 `json:"rewardTypeId" orm:"reward_type_id" description:"奖励类型ID,关联 reward_types 表"` // 奖励类型ID,关联 reward_types 表 + GameId int64 `json:"gameId" orm:"game_id" description:"游戏ID"` // 游戏ID + ImageUrl string `json:"imageUrl" orm:"image_url" description:"奖励图片链接"` // 奖励图片链接 + QqGoodsId string `json:"qqGoodsId" orm:"qq_goods_id" description:"QQ网吧物品ID"` // QQ网吧物品ID + QqGoodsIdStr string `json:"qqGoodsIdStr" orm:"qq_goods_id_str" description:"QQ网吧物品ID字符串"` // QQ网吧物品ID字符串 + Status int `json:"status" orm:"status" description:"状态:1=启用,2=禁用"` // 状态:1=启用,2=禁用 + ExpireType int `json:"expireType" orm:"expire_type" description:"过期方式:1=时间段过期,2=领取后过期"` // 过期方式:1=时间段过期,2=领取后过期 + ValidFrom *gtime.Time `json:"validFrom" orm:"valid_from" description:"有效期开始时间(expire_type=1时)"` // 有效期开始时间(expire_type=1时) + ValidTo *gtime.Time `json:"validTo" orm:"valid_to" description:"有效期结束时间(expire_type=1时)"` // 有效期结束时间(expire_type=1时) + ExpireDays int `json:"expireDays" orm:"expire_days" description:"领取后多少天过期(expire_type=2时)"` // 领取后多少天过期(expire_type=2时) + DailyTotalLimit uint64 `json:"dailyTotalLimit" orm:"daily_total_limit" description:"每日发放总限(NULL表示不限制)"` // 每日发放总限(NULL表示不限制) + TotalLimit uint64 `json:"totalLimit" orm:"total_limit" description:"奖励总限(NULL表示不限制)"` // 奖励总限(NULL表示不限制) + UserDailyLimit uint64 `json:"userDailyLimit" orm:"user_daily_limit" description:"用户每日领取限制(NULL表示不限制)"` // 用户每日领取限制(NULL表示不限制) + UserTotalLimit uint64 `json:"userTotalLimit" orm:"user_total_limit" description:"用户领取总次数限制(NULL表示不限制)"` // 用户领取总次数限制(NULL表示不限制) + ReceivedNum uint64 `json:"receivedNum" orm:"received_num" description:"已领取数量"` // 已领取数量 + GrantQuantity uint64 `json:"grantQuantity" orm:"grant_quantity" description:"每次发放个数"` // 每次发放个数 + 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:"删除时间(软删除)"` // 删除时间(软删除) } diff --git a/internal/model/entity/store_netfee_area_level.go b/internal/model/entity/store_netfee_area_level.go new file mode 100644 index 0000000..fbb4db0 --- /dev/null +++ b/internal/model/entity/store_netfee_area_level.go @@ -0,0 +1,24 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// StoreNetfeeAreaLevel is the golang structure for table store_netfee_area_level. +type StoreNetfeeAreaLevel struct { + Id int64 `json:"id" orm:"id" description:"主键ID"` // 主键ID + StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID"` // 门店ID + RewardId int64 `json:"rewardId" orm:"reward_id" description:"奖励ID(rewards表主键)"` // 奖励ID(rewards表主键) + AreaId int64 `json:"areaId" orm:"area_id" description:"区域ID(外部系统)"` // 区域ID(外部系统) + AreaName string `json:"areaName" orm:"area_name" description:"区域名称"` // 区域名称 + MemberLevelId int64 `json:"memberLevelId" orm:"member_level_id" description:"会员等级ID(外部系统)"` // 会员等级ID(外部系统) + MemberLevelName string `json:"memberLevelName" orm:"member_level_name" description:"会员等级名称"` // 会员等级名称 + PriceData string `json:"priceData" orm:"price_data" description:"7x24价格矩阵"` // 7x24价格矩阵 + 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:"删除时间"` // 删除时间 +} diff --git a/internal/model/rewardType.go b/internal/model/rewardType.go index 2197799..dec3cf1 100644 --- a/internal/model/rewardType.go +++ b/internal/model/rewardType.go @@ -6,27 +6,23 @@ import ( // RewardType 奖励类型表 type RewardType struct { - Id int64 `json:"id" dc:"奖励类型ID" orm:"id,primary"` - Name string `json:"name" dc:"奖励类型名称(如积分、优惠券)" orm:"name"` - Description string `json:"description" dc:"奖励类型描述" orm:"description"` - Source int `json:"source" dc:"来源:1=系统默认,2=门店自定义" orm:"source"` - StoreId int64 `json:"storeId" dc:"门店ID,系统默认类型为NULL" orm:"store_id"` - Status int `json:"status" dc:"状态:1=正常,2=禁用" orm:"status"` - CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间" orm:"created_at"` - UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间" orm:"updated_at"` - DeletedAt *gtime.Time `json:"deletedAt" dc:"软删除时间戳" orm:"deleted_at"` - StoreName string `json:"storeName" dc:"门店名称" orm:"storeName"` + Id int64 `json:"id" dc:"奖励类型ID"` + Name string `json:"name" dc:"奖励类型名称(如积分、优惠券)"` + TencentTypeId int `json:"tencentTypeId" dc:"腾讯奖励类型ID(仅系统奖励有效)"` + Source int `json:"source" dc:"来源:1=腾讯系统,2=本系统,3=其他"` + CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"` + UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"` + DeletedAt *gtime.Time `json:"deletedAt" dc:"软删除时间戳"` } // RewardTypeCreateIn 创建奖励类型入参 type RewardTypeCreateIn struct { - OperatorId int64 - OperatorRole string - Name string - Description string - Source int - StoreId int64 - Status int + OperatorId int64 + OperatorRole string + Name string + TencentTypeId int + Source int + StoreId int64 } // RewardTypeCreateOut 创建奖励类型出参 @@ -36,13 +32,12 @@ type RewardTypeCreateOut struct { // RewardTypeUpdateIn 更新奖励类型入参 type RewardTypeUpdateIn struct { - OperatorId int64 - OperatorRole string - Id int64 - Name string - Description string - StoreId int64 - Status int + OperatorId int64 + OperatorRole string + Id int64 + Name string + TencentTypeId int + StoreId int64 } // RewardTypeUpdateOut 更新奖励类型出参 @@ -71,6 +66,7 @@ type RewardTypeListIn struct { Name string StoreId int64 Status int + Source int } // RewardTypeListOut 获取奖励类型列表出参 diff --git a/internal/service/store_task_reward.go b/internal/service/store_task_reward.go deleted file mode 100644 index 4224dee..0000000 --- a/internal/service/store_task_reward.go +++ /dev/null @@ -1,33 +0,0 @@ -// ================================================================================ -// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. -// You can delete these comments if you wish manually maintain this interface file. -// ================================================================================ - -package service - -import ( - "context" - "server/internal/model" -) - -type ( - IStoreTaskReward interface { - Create(ctx context.Context, in *model.StoreTaskRewardCreateIn) (out *model.StoreTaskRewardCreateOut, err error) - Delete(ctx context.Context, in *model.StoreTaskRewardDeleteIn) (out *model.StoreTaskRewardDeleteOut, err error) - } -) - -var ( - localStoreTaskReward IStoreTaskReward -) - -func StoreTaskReward() IStoreTaskReward { - if localStoreTaskReward == nil { - panic("implement not found for interface IStoreTaskReward, forgot register?") - } - return localStoreTaskReward -} - -func RegisterStoreTaskReward(i IStoreTaskReward) { - localStoreTaskReward = i -}