From 8107b9a7192b6b5092b5716790f7f4bbf36482b9 Mon Sep 17 00:00:00 2001 From: denghui <1016848185@qq.com> Date: Thu, 26 Jun 2025 14:52:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=A5=96=E5=8A=B1=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=92=8C=E5=A5=96=E5=8A=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/task/task.go | 1 + api/task/v1/task.go | 15 ++++++ .../task_v1_get_user_task_records_list.go | 23 ++++++++ internal/dao/internal/admins.go | 22 +++----- internal/dao/internal/feedbacks.go | 22 +++----- internal/dao/internal/games.go | 22 +++----- internal/dao/internal/merchant_admins.go | 22 +++----- internal/dao/internal/merchants.go | 22 +++----- internal/dao/internal/notices.go | 22 +++----- internal/dao/internal/reward_callback.go | 22 +++----- internal/dao/internal/reward_types.go | 52 ++++++++----------- internal/dao/internal/reward_waters.go | 22 +++----- internal/dao/internal/rewards.go | 26 +++++----- internal/dao/internal/roles.go | 22 +++----- internal/dao/internal/store_admins.go | 22 +++----- .../dao/internal/store_desktop_settings.go | 22 +++----- internal/dao/internal/store_ips.go | 22 +++----- .../dao/internal/store_netfee_area_level.go | 22 +++----- internal/dao/internal/store_roles.go | 22 +++----- internal/dao/internal/stores.go | 22 +++----- internal/dao/internal/task_rewards.go | 22 +++----- internal/dao/internal/tasks.go | 22 +++----- internal/dao/internal/user_task_rewards.go | 24 ++++----- internal/dao/internal/user_tasks.go | 22 +++----- internal/dao/internal/users.go | 22 +++----- internal/logic/reward/reward.go | 39 ++++---------- internal/logic/rewardType/rewardType.go | 5 +- internal/logic/task/task.go | 12 +++-- internal/model/do/reward_types.go | 17 +++--- internal/model/do/rewards.go | 2 + internal/model/do/user_task_rewards.go | 1 + internal/model/entity/reward_types.go | 15 +++--- internal/model/entity/rewards.go | 2 + internal/model/entity/user_task_rewards.go | 1 + internal/model/reward.go | 48 ++++++++--------- internal/model/userTask.go | 13 +++++ internal/service/reward.go | 1 + internal/service/task.go | 1 + 38 files changed, 313 insertions(+), 403 deletions(-) create mode 100644 internal/controller/task/task_v1_get_user_task_records_list.go diff --git a/api/task/task.go b/api/task/task.go index ffda4bf..1082c50 100644 --- a/api/task/task.go +++ b/api/task/task.go @@ -17,4 +17,5 @@ type ITaskV1 interface { List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) Selector(ctx context.Context, req *v1.SelectorReq) (res *v1.SelectorRes, err error) GetTask(ctx context.Context, req *v1.GetTaskReq) (res *v1.GetTaskRes, err error) + GetUserTaskRecordsList(ctx context.Context, req *v1.GetUserTaskRecordsListReq) (res *v1.GetUserTaskRecordsListRes, err error) } diff --git a/api/task/v1/task.go b/api/task/v1/task.go index 6e72bb7..32c8c54 100644 --- a/api/task/v1/task.go +++ b/api/task/v1/task.go @@ -85,3 +85,18 @@ type GetTaskReq struct { type GetTaskRes struct { Success bool `json:"success"` } + +type GetUserTaskRecordsListReq struct { + g.Meta `path:"/task/records" method:"get" tags:"Task" summary:"(PC)用户任务记录列表"` + TaskId string `json:"taskId" dc:"任务 id"` + StoreId int `json:"storeId" dc:"门店 id"` + NetbarAccount string `json:"netbarAccount" dc:"网关账号"` + Page int `json:"page" dc:"页数"` + Size int `json:"size" dc:"条数"` + StartTime int32 `json:"startTime" dc:"开始时间"` + EndTime int32 `json:"endTime" dc:"结束时间"` +} +type GetUserTaskRecordsListRes struct { + List interface{} `json:"list"` + Total int `json:"total"` +} diff --git a/internal/controller/task/task_v1_get_user_task_records_list.go b/internal/controller/task/task_v1_get_user_task_records_list.go new file mode 100644 index 0000000..b9ffb06 --- /dev/null +++ b/internal/controller/task/task_v1_get_user_task_records_list.go @@ -0,0 +1,23 @@ +package task + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "server/internal/model" + "server/internal/service" + + "server/api/task/v1" +) + +func (c *ControllerV1) GetUserTaskRecordsList(ctx context.Context, req *v1.GetUserTaskRecordsListReq) (res *v1.GetUserTaskRecordsListRes, err error) { + fromCtx := g.RequestFromCtx(ctx) + userId := fromCtx.GetCtxVar("id").Int() + out, err := service.Task().GetUserTaskRecordsList(ctx, &model.UserTaskRecordsListIn{UserId: userId}) + if err != nil { + return nil, err + } + return &v1.GetUserTaskRecordsListRes{ + List: out.List, + Total: out.Total, + }, 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/notices.go b/internal/dao/internal/notices.go index 9c2cfce..5cc451a 100644 --- a/internal/dao/internal/notices.go +++ b/internal/dao/internal/notices.go @@ -13,10 +13,9 @@ import ( // NoticesDao is the data access object for the table notices. type NoticesDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns NoticesColumns // columns contains all the column names of Table for convenient usage. - 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 NoticesColumns // columns contains all the column names of Table for convenient usage. } // 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. -func NewNoticesDao(handlers ...gdb.ModelHandler) *NoticesDao { +func NewNoticesDao() *NoticesDao { return &NoticesDao{ - group: "default", - table: "notices", - columns: noticesColumns, - handlers: handlers, + group: "default", + table: "notices", + columns: noticesColumns, } } @@ -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. func (dao *NoticesDao) 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_callback.go b/internal/dao/internal/reward_callback.go index 249829d..e5291f6 100644 --- a/internal/dao/internal/reward_callback.go +++ b/internal/dao/internal/reward_callback.go @@ -13,10 +13,9 @@ import ( // RewardCallbackDao is the data access object for the table reward_callback. type RewardCallbackDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns RewardCallbackColumns // columns contains all the column names of Table for convenient usage. - 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 RewardCallbackColumns // columns contains all the column names of Table for convenient usage. } // RewardCallbackColumns defines and stores column names for the table reward_callback. @@ -48,12 +47,11 @@ var rewardCallbackColumns = RewardCallbackColumns{ } // NewRewardCallbackDao creates and returns a new DAO object for table data access. -func NewRewardCallbackDao(handlers ...gdb.ModelHandler) *RewardCallbackDao { +func NewRewardCallbackDao() *RewardCallbackDao { return &RewardCallbackDao{ - group: "default", - table: "reward_callback", - columns: rewardCallbackColumns, - handlers: handlers, + group: "default", + table: "reward_callback", + columns: rewardCallbackColumns, } } @@ -79,11 +77,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. func (dao *RewardCallbackDao) 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 b8d246d..ae9bf09 100644 --- a/internal/dao/internal/reward_types.go +++ b/internal/dao/internal/reward_types.go @@ -13,43 +13,39 @@ 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 // 类型名称 - TencentTypeId string // 腾讯奖励类型ID(仅系统奖励有效) - Source string // 奖励来源:1=腾讯系统,2=本系统,3=其他 - CreatedAt string // 创建时间 - UpdatedAt string // 更新时间 - DeletedAt string // 软删除时间 - StoreId string // 门店 id + Id string // 奖励类型ID + Name string // 类型名称 + Code string // 唯一编码 + IconUrl string // 图标链接地址 + CreatedAt string // 创建时间 + UpdatedAt string // 更新时间 + DeletedAt string // 软删除时间 } // rewardTypesColumns holds the columns for the table reward_types. var rewardTypesColumns = RewardTypesColumns{ - Id: "id", - Name: "name", - TencentTypeId: "tencent_type_id", - Source: "source", - CreatedAt: "created_at", - UpdatedAt: "updated_at", - DeletedAt: "deleted_at", - StoreId: "store_id", + Id: "id", + Name: "name", + Code: "code", + IconUrl: "icon_url", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", } // 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, } } @@ -75,11 +71,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/reward_waters.go b/internal/dao/internal/reward_waters.go index 6534919..d40f2c7 100644 --- a/internal/dao/internal/reward_waters.go +++ b/internal/dao/internal/reward_waters.go @@ -13,10 +13,9 @@ import ( // RewardWatersDao is the data access object for the table reward_waters. type RewardWatersDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns RewardWatersColumns // columns contains all the column names of Table for convenient usage. - 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 RewardWatersColumns // columns contains all the column names of Table for convenient usage. } // RewardWatersColumns defines and stores column names for the table reward_waters. @@ -46,12 +45,11 @@ var rewardWatersColumns = RewardWatersColumns{ } // NewRewardWatersDao creates and returns a new DAO object for table data access. -func NewRewardWatersDao(handlers ...gdb.ModelHandler) *RewardWatersDao { +func NewRewardWatersDao() *RewardWatersDao { return &RewardWatersDao{ - group: "default", - table: "reward_waters", - columns: rewardWatersColumns, - handlers: handlers, + group: "default", + table: "reward_waters", + columns: rewardWatersColumns, } } @@ -77,11 +75,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. func (dao *RewardWatersDao) 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 1f3bc3b..6b91001 100644 --- a/internal/dao/internal/rewards.go +++ b/internal/dao/internal/rewards.go @@ -13,10 +13,9 @@ 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. @@ -43,6 +42,8 @@ type RewardsColumns struct { CreatedAt string // 创建时间 UpdatedAt string // 更新时间 DeletedAt string // 删除时间(软删除) + PrizeId string // 券 id + Source string // 奖励来源,1 为系统奖励对接腾讯,2 是门店 } // rewardsColumns holds the columns for the table rewards. @@ -69,15 +70,16 @@ var rewardsColumns = RewardsColumns{ CreatedAt: "created_at", UpdatedAt: "updated_at", DeletedAt: "deleted_at", + PrizeId: "prize_id", + Source: "source", } // 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, } } @@ -103,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. 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 index ffa209a..e2a43a6 100644 --- a/internal/dao/internal/store_netfee_area_level.go +++ b/internal/dao/internal/store_netfee_area_level.go @@ -13,10 +13,9 @@ import ( // StoreNetfeeAreaLevelDao is the data access object for the table store_netfee_area_level. type StoreNetfeeAreaLevelDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns StoreNetfeeAreaLevelColumns // columns contains all the column names of Table for convenient usage. - 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 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. @@ -50,12 +49,11 @@ var storeNetfeeAreaLevelColumns = StoreNetfeeAreaLevelColumns{ } // NewStoreNetfeeAreaLevelDao creates and returns a new DAO object for table data access. -func NewStoreNetfeeAreaLevelDao(handlers ...gdb.ModelHandler) *StoreNetfeeAreaLevelDao { +func NewStoreNetfeeAreaLevelDao() *StoreNetfeeAreaLevelDao { return &StoreNetfeeAreaLevelDao{ - group: "default", - table: "store_netfee_area_level", - columns: storeNetfeeAreaLevelColumns, - handlers: handlers, + group: "default", + table: "store_netfee_area_level", + columns: storeNetfeeAreaLevelColumns, } } @@ -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. func (dao *StoreNetfeeAreaLevelDao) 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_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/task_rewards.go b/internal/dao/internal/task_rewards.go index 95ce8f4..ea0ec0a 100644 --- a/internal/dao/internal/task_rewards.go +++ b/internal/dao/internal/task_rewards.go @@ -13,10 +13,9 @@ import ( // TaskRewardsDao is the data access object for the table task_rewards. type TaskRewardsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns TaskRewardsColumns // columns contains all the column names of Table for convenient usage. - 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 TaskRewardsColumns // columns contains all the column names of Table for convenient usage. } // TaskRewardsColumns defines and stores column names for the table task_rewards. @@ -32,12 +31,11 @@ var taskRewardsColumns = TaskRewardsColumns{ } // NewTaskRewardsDao creates and returns a new DAO object for table data access. -func NewTaskRewardsDao(handlers ...gdb.ModelHandler) *TaskRewardsDao { +func NewTaskRewardsDao() *TaskRewardsDao { return &TaskRewardsDao{ - group: "default", - table: "task_rewards", - columns: taskRewardsColumns, - handlers: handlers, + group: "default", + table: "task_rewards", + columns: taskRewardsColumns, } } @@ -63,11 +61,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. func (dao *TaskRewardsDao) 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_task_rewards.go b/internal/dao/internal/user_task_rewards.go index 0ec45fc..12edf5d 100644 --- a/internal/dao/internal/user_task_rewards.go +++ b/internal/dao/internal/user_task_rewards.go @@ -13,10 +13,9 @@ import ( // UserTaskRewardsDao is the data access object for the table user_task_rewards. type UserTaskRewardsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns UserTaskRewardsColumns // columns contains all the column names of Table for convenient usage. - 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 UserTaskRewardsColumns // columns contains all the column names of Table for convenient usage. } // UserTaskRewardsColumns defines and stores column names for the table user_task_rewards. @@ -32,6 +31,7 @@ type UserTaskRewardsColumns struct { CreatedAt string // 创建时间 UpdatedAt string // 更新时间 DeletedAt string // 软删除时间 + ExpiredAt string // 奖励过期时间 } // userTaskRewardsColumns holds the columns for the table user_task_rewards. @@ -47,15 +47,15 @@ var userTaskRewardsColumns = UserTaskRewardsColumns{ CreatedAt: "created_at", UpdatedAt: "updated_at", DeletedAt: "deleted_at", + ExpiredAt: "expired_at", } // NewUserTaskRewardsDao creates and returns a new DAO object for table data access. -func NewUserTaskRewardsDao(handlers ...gdb.ModelHandler) *UserTaskRewardsDao { +func NewUserTaskRewardsDao() *UserTaskRewardsDao { return &UserTaskRewardsDao{ - group: "default", - table: "user_task_rewards", - columns: userTaskRewardsColumns, - handlers: handlers, + group: "default", + table: "user_task_rewards", + columns: userTaskRewardsColumns, } } @@ -81,11 +81,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. func (dao *UserTaskRewardsDao) 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/logic/reward/reward.go b/internal/logic/reward/reward.go index 3012b27..eae482f 100644 --- a/internal/logic/reward/reward.go +++ b/internal/logic/reward/reward.go @@ -260,20 +260,18 @@ func (s *sReward) Delete(ctx context.Context, in *model.RewardDeleteIn) (out *mo func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error) { rewardCols := dao.Rewards.Columns() - rewardTypeCols := dao.RewardTypes.Columns() - rewardTypeIds := make([]int64, 0) - // ==== 权限校验 ==== + orm := dao.Rewards.Ctx(ctx).LeftJoin( + dao.RewardTypes.Table(), + fmt.Sprintf( + "%s.%s = %s.%s", + dao.Rewards.Table(), dao.Rewards.Columns().RewardTypeId, + dao.RewardTypes.Table(), dao.RewardTypes.Columns().Id, + ), + ).Fields(fmt.Sprintf("%s.*,%s.name as reward_type_name", dao.Rewards.Table(), dao.RewardTypes.Table())) switch in.OperatorRole { case consts.AdminRoleCode: // 系统管理员只能查询 source = 1 的奖励 - array, err := dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Source: 1}).Fields(rewardTypeCols.Id).Array() - if err != nil { - return nil, ecode.Fail.Sub("获取奖励类型列表失败") - } - for _, value := range array { - rewardTypeIds = append(rewardTypeIds, value.Int64()) - } - + orm = orm.Where(rewardCols.Source, 1) case consts.MerchantRoleCode, consts.StoreRoleCode: // 合并商户和门店角色权限校验 var exist bool @@ -308,28 +306,11 @@ func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model. if !exist { return nil, ecode.Params.Sub("无门店权限") } - - // - array, err := dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Source: 2, StoreId: in.StoreId}).Fields(rewardTypeCols.Id).Array() - if err != nil { - return nil, ecode.Fail.Sub("获取奖励类型列表失败") - } - for _, value := range array { - rewardTypeIds = append(rewardTypeIds, value.Int64()) - } + orm = orm.Where(rewardCols.Source, 2) default: return nil, ecode.Params.Sub("无效的角色") } - orm := dao.Rewards.Ctx(ctx).LeftJoin( - dao.RewardTypes.Table(), - fmt.Sprintf( - "%s.%s = %s.%s", - dao.Rewards.Table(), dao.Rewards.Columns().RewardTypeId, - dao.RewardTypes.Table(), dao.RewardTypes.Columns().Id, - ), - ).Fields(fmt.Sprintf("%s.*,%s.name as reward_type_name", dao.Rewards.Table(), dao.RewardTypes.Table())). - WhereIn(dao.Rewards.Columns().RewardTypeId, rewardTypeIds) // ==== 其他查询条件 ==== if in.Status != 0 { orm = orm.Where(fmt.Sprintf("%s.%s = ?", dao.Rewards.Table(), rewardCols.Status), in.Status) diff --git a/internal/logic/rewardType/rewardType.go b/internal/logic/rewardType/rewardType.go index 4b95892..f8b1a1a 100644 --- a/internal/logic/rewardType/rewardType.go +++ b/internal/logic/rewardType/rewardType.go @@ -32,10 +32,7 @@ func (s *sRewardType) Create(ctx context.Context, in *model.RewardTypeCreateIn) } data := do.RewardTypes{ - Name: in.Name, - Source: in.Source, - StoreId: in.StoreId, - TencentTypeId: in.TencentTypeId, + Name: in.Name, } id, err := dao.RewardTypes.Ctx(ctx).OmitEmptyData().Data(data).InsertAndGetId() diff --git a/internal/logic/task/task.go b/internal/logic/task/task.go index b0c33ec..08f4ff5 100644 --- a/internal/logic/task/task.go +++ b/internal/logic/task/task.go @@ -190,12 +190,10 @@ func (s *sTask) GetNonLoginTaskList(ctx context.Context, in *model.GetTaskListIn dao.RewardTypes.Table(), dao.RewardTypes.Columns().Id, dao.Rewards.Table(), dao.Rewards.Columns().RewardTypeId)). Fields( - fmt.Sprintf("%s.*, `%s`.`%s` AS %s, `%s`.`%s` AS %s", + fmt.Sprintf( + "%s.*, `%s`.`%s` AS %s", dao.Rewards.Table(), - dao.RewardTypes.Table(), dao.RewardTypes.Columns().Name, - "reward_type_name", - dao.RewardTypes.Table(), dao.RewardTypes.Columns().Source, - "reward_type_source", + dao.RewardTypes.Table(), dao.RewardTypes.Columns().Name, "reward_type_name", ), ).Where(dao.TaskRewards.Columns().TaskId, task.TaskID).Scan(&data.Rewards) if err != nil { @@ -385,3 +383,7 @@ func (s *sTask) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.Ge Success: true, }, nil } + +func (s *sTask) GetUserTaskRecordsList(ctx context.Context, in *model.UserTaskRecordsListIn) (out *model.UserTaskRecordsListOut, err error) { + return +} diff --git a/internal/model/do/reward_types.go b/internal/model/do/reward_types.go index 3c6634f..a70b718 100644 --- a/internal/model/do/reward_types.go +++ b/internal/model/do/reward_types.go @@ -11,13 +11,12 @@ 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{} // 类型名称 - TencentTypeId interface{} // 腾讯奖励类型ID(仅系统奖励有效) - Source interface{} // 奖励来源:1=腾讯系统,2=本系统,3=其他 - CreatedAt *gtime.Time // 创建时间 - UpdatedAt *gtime.Time // 更新时间 - DeletedAt *gtime.Time // 软删除时间 - StoreId interface{} // 门店 id + g.Meta `orm:"table:reward_types, do:true"` + Id interface{} // 奖励类型ID + Name interface{} // 类型名称 + Code interface{} // 唯一编码 + IconUrl interface{} // 图标链接地址 + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 更新时间 + DeletedAt *gtime.Time // 软删除时间 } diff --git a/internal/model/do/rewards.go b/internal/model/do/rewards.go index e565a19..21a6d2f 100644 --- a/internal/model/do/rewards.go +++ b/internal/model/do/rewards.go @@ -34,4 +34,6 @@ type Rewards struct { CreatedAt *gtime.Time // 创建时间 UpdatedAt *gtime.Time // 更新时间 DeletedAt *gtime.Time // 删除时间(软删除) + PrizeId interface{} // 券 id + Source interface{} // 奖励来源,1 为系统奖励对接腾讯,2 是门店 } diff --git a/internal/model/do/user_task_rewards.go b/internal/model/do/user_task_rewards.go index 20bf094..d188677 100644 --- a/internal/model/do/user_task_rewards.go +++ b/internal/model/do/user_task_rewards.go @@ -23,4 +23,5 @@ type UserTaskRewards struct { CreatedAt *gtime.Time // 创建时间 UpdatedAt *gtime.Time // 更新时间 DeletedAt *gtime.Time // 软删除时间 + ExpiredAt *gtime.Time // 奖励过期时间 } diff --git a/internal/model/entity/reward_types.go b/internal/model/entity/reward_types.go index 3a8c360..eb2f34f 100644 --- a/internal/model/entity/reward_types.go +++ b/internal/model/entity/reward_types.go @@ -10,12 +10,11 @@ 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:"类型名称"` // 类型名称 - 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 + Id int64 `json:"id" orm:"id" description:"奖励类型ID"` // 奖励类型ID + Name string `json:"name" orm:"name" description:"类型名称"` // 类型名称 + Code string `json:"code" orm:"code" description:"唯一编码"` // 唯一编码 + IconUrl string `json:"iconUrl" orm:"icon_url" 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/rewards.go b/internal/model/entity/rewards.go index 9ce56fe..88113c6 100644 --- a/internal/model/entity/rewards.go +++ b/internal/model/entity/rewards.go @@ -32,4 +32,6 @@ type Rewards struct { 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:"删除时间(软删除)"` // 删除时间(软删除) + PrizeId string `json:"prizeId" orm:"prize_id" description:"券 id"` // 券 id + Source int `json:"source" orm:"source" description:"奖励来源,1 为系统奖励对接腾讯,2 是门店"` // 奖励来源,1 为系统奖励对接腾讯,2 是门店 } diff --git a/internal/model/entity/user_task_rewards.go b/internal/model/entity/user_task_rewards.go index df801ff..50027d2 100644 --- a/internal/model/entity/user_task_rewards.go +++ b/internal/model/entity/user_task_rewards.go @@ -21,4 +21,5 @@ type UserTaskRewards struct { 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:"软删除时间"` // 软删除时间 + ExpiredAt *gtime.Time `json:"expiredAt" orm:"expired_at" description:"奖励过期时间"` // 奖励过期时间 } diff --git a/internal/model/reward.go b/internal/model/reward.go index 561b407..533a0d4 100644 --- a/internal/model/reward.go +++ b/internal/model/reward.go @@ -6,30 +6,30 @@ import ( // Reward 奖励表 type Reward struct { - 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 表 - RewardTypeName string `json:"rewardTypeName" orm:"reward_type_name" description:"奖励类型名称"` // 奖励类型名称 - RewardTypeSource int `json:"rewardTypeSource" orm:"reward_type_source" description:"奖励类型来源"` // 奖励类型来源 - 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:"删除时间(软删除)"` // 删除时间(软删除) + 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 表 + RewardTypeName string `json:"rewardTypeName" orm:"reward_type_name" description:"奖励类型名称"` // 奖励类型名称 + Source int `json:"source" orm:"source" description:"奖励来源,1=系统奖励(对接腾讯),2=门店追加"` // 奖励来源,1=系统奖励(对接腾讯),2=门店追加 + 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:"删除时间(软删除)"` // 删除时间(软删除) } // RewardCreateIn 创建奖励入参 diff --git a/internal/model/userTask.go b/internal/model/userTask.go index 55e0914..313b6f3 100644 --- a/internal/model/userTask.go +++ b/internal/model/userTask.go @@ -70,3 +70,16 @@ type GetTaskIn struct { type GetTaskOut struct { Success bool `json:"success"` } + +type UserTaskRecordsListIn struct { + UserId int + Page int + Size int + StoreId int + NetBarAccount string +} + +type UserTaskRecordsListOut struct { + List []UserTask + Total int +} diff --git a/internal/service/reward.go b/internal/service/reward.go index b0943ed..9d88ec2 100644 --- a/internal/service/reward.go +++ b/internal/service/reward.go @@ -29,6 +29,7 @@ type ( // GetGoodsDetails 物品详情 GetGoodsDetails(ctx context.Context, in *model.GetGoodsDetailsIn) (out *model.QueryUserGoodsDetailResponse, err error) OperateTaskReward(ctx context.Context, in *model.OperateTaskRewardIn) (out *model.OperateTaskRewardOut, err error) + // CallBack 奖励回调 CallBack(ctx context.Context, in *model.RewardCallbackIn) (out *model.RewardCallbackOut, err error) } ) diff --git a/internal/service/task.go b/internal/service/task.go index abec86d..53ce6f8 100644 --- a/internal/service/task.go +++ b/internal/service/task.go @@ -21,6 +21,7 @@ type ( GetSelectorList(ctx context.Context, in *model.SelectorIn) (out *[]model.SelectorOut, err error) // GetTask 完成任务 GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.GetTaskOut, err error) + GetUserTaskRecordsList(ctx context.Context, in *model.UserTaskRecordsListIn) (out *model.UserTaskRecordsListOut, err error) } )