From ecee39efff3d4892834d1895283e963ff43118b4 Mon Sep 17 00:00:00 2001 From: chy <2463300564@qq.com> Date: Wed, 25 Jun 2025 20:57:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=A5=96=E5=8A=B1=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=8E=A5=E5=8F=A3=EF=BC=8C=E8=B0=83=E6=95=B4=E5=A5=96?= =?UTF-8?q?=E5=8A=B1=E9=A2=86=E5=8F=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/reward/v1/reward.go | 24 ++--- .../controller/reward/reward_v1_callback.go | 28 +++++- .../controller/reward/reward_v1_get_lift.go | 10 +- 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 | 99 +++++++++++++++++++ internal/dao/internal/reward_callback.go | 95 ++++++++++++++++++ internal/dao/internal/reward_types.go | 22 +++-- internal/dao/internal/rewards.go | 22 +++-- 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_tasks.go | 22 +++-- internal/dao/internal/users.go | 22 +++-- internal/dao/notices.go | 22 +++++ internal/dao/reward_callback.go | 22 +++++ internal/logic/reward/reward.go | 39 ++++++-- internal/model/do/notices.go | 26 +++++ internal/model/do/reward_callback.go | 23 +++++ internal/model/entity/notices.go | 24 +++++ internal/model/entity/reward_callback.go | 18 ++++ internal/model/reward.go | 29 ++++-- internal/packed/packed.go | 2 +- internal/service/reward.go | 1 + 33 files changed, 679 insertions(+), 179 deletions(-) create mode 100644 internal/dao/internal/notices.go create mode 100644 internal/dao/internal/reward_callback.go create mode 100644 internal/dao/notices.go create mode 100644 internal/dao/reward_callback.go create mode 100644 internal/model/do/notices.go create mode 100644 internal/model/do/reward_callback.go create mode 100644 internal/model/entity/notices.go create mode 100644 internal/model/entity/reward_callback.go diff --git a/api/reward/v1/reward.go b/api/reward/v1/reward.go index 0118ff0..cce5b2c 100644 --- a/api/reward/v1/reward.go +++ b/api/reward/v1/reward.go @@ -202,21 +202,23 @@ type CallbackData struct { Comment string `json:"comment"` } type CallbackRes struct { - Errcode int32 `json:"errcode"` - Errmsg string `json:"errmsg"` - AppId string `json:"appid"` - OrderId string `json:"order_id"` - Datas []CallbackData `json:"data"` + Errcode int32 `json:"errcode"` + Errmsg string `json:"errmsg"` + AppId string `json:"appid"` + OrderId string `json:"order_id"` + //Datas []CallbackData `json:"data"` + Datas interface{} `json:"data"` } type GetLiftReq struct { g.Meta `path:"/reward/getLift" method:"post" tags:"Reward" summary:"(tencent)奖励领取"` - TaskId string `json:"taskId" v:"required#任务id不能为空" dc:"任务Id"` - AreaId int64 `json:"areaId" dc:"大区Id"` - GameId int64 `json:"gameId" v:"required#游戏id不能为空" dc:"游戏Id"` - RoleIdx string `json:"roleIdx" dc:"角色索引"` - RewradType []int64 `json:"rewardType" dc:"奖励类型"` - PopenId string `json:"popenid" dc:""` + TaskId string `json:"taskId" v:"required#任务id不能为空" dc:"任务Id"` + AreaId int64 `json:"areaId" dc:"大区Id"` + GameId int64 `json:"gameId" v:"required#游戏id不能为空" dc:"游戏Id"` + RoleIdx string `json:"roleIdx" dc:"角色索引"` + RewradType int64 `json:"rewardType" v:"required#奖励类型不能为空" dc:"奖励类型"` + PopenId string `json:"popenid" dc:""` + Source int `json:"source" v:"required#来源不能为空" dc:"来源" d:"1:系统 2:门店"` } type GetLiftRes struct { diff --git a/internal/controller/reward/reward_v1_callback.go b/internal/controller/reward/reward_v1_callback.go index 9d838d3..ffe6760 100644 --- a/internal/controller/reward/reward_v1_callback.go +++ b/internal/controller/reward/reward_v1_callback.go @@ -8,6 +8,8 @@ import ( "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/glog" "server/api/reward/v1" + "server/internal/model" + "server/internal/service" "strings" ) @@ -30,5 +32,29 @@ func (c *ControllerV1) Callback(ctx context.Context, req *v1.CallbackReq) (res * return &v1.CallbackRes{Errcode: 252151000, OrderId: req.OrderId, Datas: []v1.CallbackData{{PrizeCode: req.OrderId}}}, err } glog.Infof(ctx, fmt.Sprintf("%s,%s,%s,%s,%d,%d,%d,%s,%s,%s,#%s", req.Uid, req.OrderId, req.PrizeChannelId, req.PrizeId, req.PrizeType, req.PrizeSubType, req.Num, appid, timestamp, nonce, auth)) - return &v1.CallbackRes{Errcode: 0, OrderId: req.OrderId, Datas: []v1.CallbackData{{PrizeCode: req.OrderId}}}, err + + out, err := service.Reward().CallBack(ctx, &model.RewardCallbackIn{ + Uid: req.Uid, + CustomInfo: req.CustomInfo, + OrderId: req.OrderId, + PrizeChannelId: req.PrizeChannelId, + PrizeId: req.PrizeId, + PrizeType: int(req.PrizeType), + PrizeSubType: int(req.PrizeSubType), + Num: int(req.Num), + }) + + if err != nil { + return nil, err + } + + return &v1.CallbackRes{ + AppId: appid, + Datas: out.Datas, + Errcode: out.Errcode, + Errmsg: out.Errmsg, + OrderId: out.OrderId, + }, nil + + //return &v1.CallbackRes{Errcode: 0, OrderId: req.OrderId, Datas: []v1.CallbackData{{PrizeCode: req.OrderId}}}, err } diff --git a/internal/controller/reward/reward_v1_get_lift.go b/internal/controller/reward/reward_v1_get_lift.go index 9c6da92..847e74c 100644 --- a/internal/controller/reward/reward_v1_get_lift.go +++ b/internal/controller/reward/reward_v1_get_lift.go @@ -9,9 +9,13 @@ import ( func (c *ControllerV1) GetLift(ctx context.Context, req *v1.GetLiftReq) (res *v1.GetLiftRes, err error) { out, err := service.Reward().GetLift(ctx, &model.GetRewardIn{ - GameId: int(req.GameId), - TaskId: req.TaskId, - PopenId: req.PopenId, + GameId: int(req.GameId), + TaskId: req.TaskId, + PopenId: req.PopenId, + RewradTypeId: int(req.RewradType), + RoleIdx: req.RoleIdx, + AreaId: int(req.AreaId), + Source: req.Source, }) if err != nil { diff --git a/internal/dao/internal/admins.go b/internal/dao/internal/admins.go index 7c3f2be..dc72d15 100644 --- a/internal/dao/internal/admins.go +++ b/internal/dao/internal/admins.go @@ -13,9 +13,10 @@ import ( // AdminsDao is the data access object for the table admins. type AdminsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns AdminsColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns AdminsColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // AdminsColumns defines and stores column names for the table admins. @@ -49,11 +50,12 @@ var adminsColumns = AdminsColumns{ } // NewAdminsDao creates and returns a new DAO object for table data access. -func NewAdminsDao() *AdminsDao { +func NewAdminsDao(handlers ...gdb.ModelHandler) *AdminsDao { return &AdminsDao{ - group: "default", - table: "admins", - columns: adminsColumns, + group: "default", + table: "admins", + columns: adminsColumns, + handlers: handlers, } } @@ -79,7 +81,11 @@ func (dao *AdminsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *AdminsDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/feedbacks.go b/internal/dao/internal/feedbacks.go index d67a1e5..7a8d085 100644 --- a/internal/dao/internal/feedbacks.go +++ b/internal/dao/internal/feedbacks.go @@ -13,9 +13,10 @@ import ( // FeedbacksDao is the data access object for the table feedbacks. type FeedbacksDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns FeedbacksColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns FeedbacksColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // FeedbacksColumns defines and stores column names for the table feedbacks. @@ -51,11 +52,12 @@ var feedbacksColumns = FeedbacksColumns{ } // NewFeedbacksDao creates and returns a new DAO object for table data access. -func NewFeedbacksDao() *FeedbacksDao { +func NewFeedbacksDao(handlers ...gdb.ModelHandler) *FeedbacksDao { return &FeedbacksDao{ - group: "default", - table: "feedbacks", - columns: feedbacksColumns, + group: "default", + table: "feedbacks", + columns: feedbacksColumns, + handlers: handlers, } } @@ -81,7 +83,11 @@ func (dao *FeedbacksDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *FeedbacksDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/games.go b/internal/dao/internal/games.go index b53dd54..dac75c7 100644 --- a/internal/dao/internal/games.go +++ b/internal/dao/internal/games.go @@ -13,9 +13,10 @@ import ( // GamesDao is the data access object for the table games. type GamesDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns GamesColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns GamesColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // GamesColumns defines and stores column names for the table games. @@ -45,11 +46,12 @@ var gamesColumns = GamesColumns{ } // NewGamesDao creates and returns a new DAO object for table data access. -func NewGamesDao() *GamesDao { +func NewGamesDao(handlers ...gdb.ModelHandler) *GamesDao { return &GamesDao{ - group: "default", - table: "games", - columns: gamesColumns, + group: "default", + table: "games", + columns: gamesColumns, + handlers: handlers, } } @@ -75,7 +77,11 @@ func (dao *GamesDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *GamesDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/merchant_admins.go b/internal/dao/internal/merchant_admins.go index 51ac691..64533e1 100644 --- a/internal/dao/internal/merchant_admins.go +++ b/internal/dao/internal/merchant_admins.go @@ -13,9 +13,10 @@ import ( // MerchantAdminsDao is the data access object for the table merchant_admins. type MerchantAdminsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns MerchantAdminsColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns MerchantAdminsColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // MerchantAdminsColumns defines and stores column names for the table merchant_admins. @@ -57,11 +58,12 @@ var merchantAdminsColumns = MerchantAdminsColumns{ } // NewMerchantAdminsDao creates and returns a new DAO object for table data access. -func NewMerchantAdminsDao() *MerchantAdminsDao { +func NewMerchantAdminsDao(handlers ...gdb.ModelHandler) *MerchantAdminsDao { return &MerchantAdminsDao{ - group: "default", - table: "merchant_admins", - columns: merchantAdminsColumns, + group: "default", + table: "merchant_admins", + columns: merchantAdminsColumns, + handlers: handlers, } } @@ -87,7 +89,11 @@ func (dao *MerchantAdminsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *MerchantAdminsDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/merchants.go b/internal/dao/internal/merchants.go index 6dd5d05..717f855 100644 --- a/internal/dao/internal/merchants.go +++ b/internal/dao/internal/merchants.go @@ -13,9 +13,10 @@ import ( // MerchantsDao is the data access object for the table merchants. type MerchantsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns MerchantsColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns MerchantsColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // MerchantsColumns defines and stores column names for the table merchants. @@ -71,11 +72,12 @@ var merchantsColumns = MerchantsColumns{ } // NewMerchantsDao creates and returns a new DAO object for table data access. -func NewMerchantsDao() *MerchantsDao { +func NewMerchantsDao(handlers ...gdb.ModelHandler) *MerchantsDao { return &MerchantsDao{ - group: "default", - table: "merchants", - columns: merchantsColumns, + group: "default", + table: "merchants", + columns: merchantsColumns, + handlers: handlers, } } @@ -101,7 +103,11 @@ func (dao *MerchantsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *MerchantsDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/notices.go b/internal/dao/internal/notices.go new file mode 100644 index 0000000..9c2cfce --- /dev/null +++ b/internal/dao/internal/notices.go @@ -0,0 +1,99 @@ +// ========================================================================== +// 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" +) + +// 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. +} + +// NoticesColumns defines and stores column names for the table notices. +type NoticesColumns struct { + Id string // 通知ID + Title string // 通知标题 + Content string // 通知内容 + Type string // 通知类型:1=系统公告,2=活动通知,3=维护通知 + Status string // 状态:0=关闭,1=发布 + VisibleTo string // 可见范围:1=所有人,2=仅门店,3=仅用户 + MerchantId string // 所属商户ID + StoreId string // 所属门店ID + CreatedAt string // 创建时间 + UpdatedAt string // 更新时间 + DeletedAt string // 软删除时间戳 +} + +// noticesColumns holds the columns for the table notices. +var noticesColumns = NoticesColumns{ + Id: "id", + Title: "title", + Content: "content", + Type: "type", + Status: "status", + VisibleTo: "visible_to", + MerchantId: "merchant_id", + StoreId: "store_id", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", +} + +// NewNoticesDao creates and returns a new DAO object for table data access. +func NewNoticesDao(handlers ...gdb.ModelHandler) *NoticesDao { + return &NoticesDao{ + group: "default", + table: "notices", + columns: noticesColumns, + handlers: handlers, + } +} + +// DB retrieves and returns the underlying raw database management object of the current DAO. +func (dao *NoticesDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of the current DAO. +func (dao *NoticesDao) Table() string { + return dao.table +} + +// Columns returns all column names of the current DAO. +func (dao *NoticesDao) Columns() NoticesColumns { + return dao.columns +} + +// Group returns the database configuration group name of the current DAO. +func (dao *NoticesDao) 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 *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) +} + +// 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 *NoticesDao) 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/reward_callback.go b/internal/dao/internal/reward_callback.go new file mode 100644 index 0000000..05da9b0 --- /dev/null +++ b/internal/dao/internal/reward_callback.go @@ -0,0 +1,95 @@ +// ========================================================================== +// 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" +) + +// 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. +} + +// RewardCallbackColumns defines and stores column names for the table reward_callback. +type RewardCallbackColumns struct { + Id string // + Uid string // 用户账号 + OrderId string // 订单号必须保证全局唯一(保证接口幂等) + PrizeChannelId string // 券渠道 ID + PrizeId string // 券 ID + PrizeType string // 奖励类型,1 网鱼积分,2 网鱼经验值,3 网鱼兑换码 + PrizeSubType string // 奖励子类型,默认为 0,有多种子类型时可用,如 1,5 元网费充值券,2、满 30-5 满减券等 + Num string // 奖励个数,默认 1,比如经验值 10 + CustomInfo string // 透传字段 (json串) +} + +// rewardCallbackColumns holds the columns for the table reward_callback. +var rewardCallbackColumns = RewardCallbackColumns{ + Id: "id", + Uid: "uid", + OrderId: "order_id", + PrizeChannelId: "prize_channel_id", + PrizeId: "prize_id", + PrizeType: "prize_type", + PrizeSubType: "prize_sub_type", + Num: "num", + CustomInfo: "custom_info", +} + +// NewRewardCallbackDao creates and returns a new DAO object for table data access. +func NewRewardCallbackDao(handlers ...gdb.ModelHandler) *RewardCallbackDao { + return &RewardCallbackDao{ + group: "default", + table: "reward_callback", + columns: rewardCallbackColumns, + handlers: handlers, + } +} + +// DB retrieves and returns the underlying raw database management object of the current DAO. +func (dao *RewardCallbackDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of the current DAO. +func (dao *RewardCallbackDao) Table() string { + return dao.table +} + +// Columns returns all column names of the current DAO. +func (dao *RewardCallbackDao) Columns() RewardCallbackColumns { + return dao.columns +} + +// Group returns the database configuration group name of the current DAO. +func (dao *RewardCallbackDao) 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 *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) +} + +// 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 *RewardCallbackDao) 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/reward_types.go b/internal/dao/internal/reward_types.go index 591cab5..b8d246d 100644 --- a/internal/dao/internal/reward_types.go +++ b/internal/dao/internal/reward_types.go @@ -13,9 +13,10 @@ import ( // RewardTypesDao is the data access object for the table reward_types. type RewardTypesDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns RewardTypesColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns RewardTypesColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // RewardTypesColumns defines and stores column names for the table reward_types. @@ -43,11 +44,12 @@ var rewardTypesColumns = RewardTypesColumns{ } // NewRewardTypesDao creates and returns a new DAO object for table data access. -func NewRewardTypesDao() *RewardTypesDao { +func NewRewardTypesDao(handlers ...gdb.ModelHandler) *RewardTypesDao { return &RewardTypesDao{ - group: "default", - table: "reward_types", - columns: rewardTypesColumns, + group: "default", + table: "reward_types", + columns: rewardTypesColumns, + handlers: handlers, } } @@ -73,7 +75,11 @@ func (dao *RewardTypesDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *RewardTypesDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/rewards.go b/internal/dao/internal/rewards.go index 86d8d4c..1f3bc3b 100644 --- a/internal/dao/internal/rewards.go +++ b/internal/dao/internal/rewards.go @@ -13,9 +13,10 @@ import ( // RewardsDao is the data access object for the table rewards. type RewardsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns RewardsColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns RewardsColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // RewardsColumns defines and stores column names for the table rewards. @@ -71,11 +72,12 @@ var rewardsColumns = RewardsColumns{ } // NewRewardsDao creates and returns a new DAO object for table data access. -func NewRewardsDao() *RewardsDao { +func NewRewardsDao(handlers ...gdb.ModelHandler) *RewardsDao { return &RewardsDao{ - group: "default", - table: "rewards", - columns: rewardsColumns, + group: "default", + table: "rewards", + columns: rewardsColumns, + handlers: handlers, } } @@ -101,7 +103,11 @@ func (dao *RewardsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *RewardsDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/roles.go b/internal/dao/internal/roles.go index 9eab304..b540549 100644 --- a/internal/dao/internal/roles.go +++ b/internal/dao/internal/roles.go @@ -13,9 +13,10 @@ import ( // RolesDao is the data access object for the table roles. type RolesDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns RolesColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns RolesColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // RolesColumns defines and stores column names for the table roles. @@ -47,11 +48,12 @@ var rolesColumns = RolesColumns{ } // NewRolesDao creates and returns a new DAO object for table data access. -func NewRolesDao() *RolesDao { +func NewRolesDao(handlers ...gdb.ModelHandler) *RolesDao { return &RolesDao{ - group: "default", - table: "roles", - columns: rolesColumns, + group: "default", + table: "roles", + columns: rolesColumns, + handlers: handlers, } } @@ -77,7 +79,11 @@ func (dao *RolesDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *RolesDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_admins.go b/internal/dao/internal/store_admins.go index 7bcffcc..538322c 100644 --- a/internal/dao/internal/store_admins.go +++ b/internal/dao/internal/store_admins.go @@ -13,9 +13,10 @@ import ( // StoreAdminsDao is the data access object for the table store_admins. type StoreAdminsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns StoreAdminsColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns StoreAdminsColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // StoreAdminsColumns defines and stores column names for the table store_admins. @@ -57,11 +58,12 @@ var storeAdminsColumns = StoreAdminsColumns{ } // NewStoreAdminsDao creates and returns a new DAO object for table data access. -func NewStoreAdminsDao() *StoreAdminsDao { +func NewStoreAdminsDao(handlers ...gdb.ModelHandler) *StoreAdminsDao { return &StoreAdminsDao{ - group: "default", - table: "store_admins", - columns: storeAdminsColumns, + group: "default", + table: "store_admins", + columns: storeAdminsColumns, + handlers: handlers, } } @@ -87,7 +89,11 @@ func (dao *StoreAdminsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreAdminsDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_desktop_settings.go b/internal/dao/internal/store_desktop_settings.go index dec1ba9..88c9cb5 100644 --- a/internal/dao/internal/store_desktop_settings.go +++ b/internal/dao/internal/store_desktop_settings.go @@ -13,9 +13,10 @@ import ( // StoreDesktopSettingsDao is the data access object for the table store_desktop_settings. type StoreDesktopSettingsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns StoreDesktopSettingsColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns StoreDesktopSettingsColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // StoreDesktopSettingsColumns defines and stores column names for the table store_desktop_settings. @@ -33,11 +34,12 @@ var storeDesktopSettingsColumns = StoreDesktopSettingsColumns{ } // NewStoreDesktopSettingsDao creates and returns a new DAO object for table data access. -func NewStoreDesktopSettingsDao() *StoreDesktopSettingsDao { +func NewStoreDesktopSettingsDao(handlers ...gdb.ModelHandler) *StoreDesktopSettingsDao { return &StoreDesktopSettingsDao{ - group: "default", - table: "store_desktop_settings", - columns: storeDesktopSettingsColumns, + group: "default", + table: "store_desktop_settings", + columns: storeDesktopSettingsColumns, + handlers: handlers, } } @@ -63,7 +65,11 @@ func (dao *StoreDesktopSettingsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreDesktopSettingsDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_ips.go b/internal/dao/internal/store_ips.go index 20197cb..dfdfd58 100644 --- a/internal/dao/internal/store_ips.go +++ b/internal/dao/internal/store_ips.go @@ -13,9 +13,10 @@ import ( // StoreIpsDao is the data access object for the table store_ips. type StoreIpsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns StoreIpsColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns StoreIpsColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // StoreIpsColumns defines and stores column names for the table store_ips. @@ -41,11 +42,12 @@ var storeIpsColumns = StoreIpsColumns{ } // NewStoreIpsDao creates and returns a new DAO object for table data access. -func NewStoreIpsDao() *StoreIpsDao { +func NewStoreIpsDao(handlers ...gdb.ModelHandler) *StoreIpsDao { return &StoreIpsDao{ - group: "default", - table: "store_ips", - columns: storeIpsColumns, + group: "default", + table: "store_ips", + columns: storeIpsColumns, + handlers: handlers, } } @@ -71,7 +73,11 @@ func (dao *StoreIpsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreIpsDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_netfee_area_level.go b/internal/dao/internal/store_netfee_area_level.go index e2a43a6..ffa209a 100644 --- a/internal/dao/internal/store_netfee_area_level.go +++ b/internal/dao/internal/store_netfee_area_level.go @@ -13,9 +13,10 @@ import ( // StoreNetfeeAreaLevelDao is the data access object for the table store_netfee_area_level. type StoreNetfeeAreaLevelDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns StoreNetfeeAreaLevelColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns StoreNetfeeAreaLevelColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // StoreNetfeeAreaLevelColumns defines and stores column names for the table store_netfee_area_level. @@ -49,11 +50,12 @@ var storeNetfeeAreaLevelColumns = StoreNetfeeAreaLevelColumns{ } // NewStoreNetfeeAreaLevelDao creates and returns a new DAO object for table data access. -func NewStoreNetfeeAreaLevelDao() *StoreNetfeeAreaLevelDao { +func NewStoreNetfeeAreaLevelDao(handlers ...gdb.ModelHandler) *StoreNetfeeAreaLevelDao { return &StoreNetfeeAreaLevelDao{ - group: "default", - table: "store_netfee_area_level", - columns: storeNetfeeAreaLevelColumns, + group: "default", + table: "store_netfee_area_level", + columns: storeNetfeeAreaLevelColumns, + handlers: handlers, } } @@ -79,7 +81,11 @@ func (dao *StoreNetfeeAreaLevelDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreNetfeeAreaLevelDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_roles.go b/internal/dao/internal/store_roles.go index 8528459..137e1fa 100644 --- a/internal/dao/internal/store_roles.go +++ b/internal/dao/internal/store_roles.go @@ -13,9 +13,10 @@ import ( // StoreRolesDao is the data access object for the table store_roles. type StoreRolesDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns StoreRolesColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns StoreRolesColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // StoreRolesColumns defines and stores column names for the table store_roles. @@ -39,11 +40,12 @@ var storeRolesColumns = StoreRolesColumns{ } // NewStoreRolesDao creates and returns a new DAO object for table data access. -func NewStoreRolesDao() *StoreRolesDao { +func NewStoreRolesDao(handlers ...gdb.ModelHandler) *StoreRolesDao { return &StoreRolesDao{ - group: "default", - table: "store_roles", - columns: storeRolesColumns, + group: "default", + table: "store_roles", + columns: storeRolesColumns, + handlers: handlers, } } @@ -69,7 +71,11 @@ func (dao *StoreRolesDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreRolesDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/stores.go b/internal/dao/internal/stores.go index 8bbdc42..69ed619 100644 --- a/internal/dao/internal/stores.go +++ b/internal/dao/internal/stores.go @@ -13,9 +13,10 @@ import ( // StoresDao is the data access object for the table stores. type StoresDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns StoresColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns StoresColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // StoresColumns defines and stores column names for the table stores. @@ -51,11 +52,12 @@ var storesColumns = StoresColumns{ } // NewStoresDao creates and returns a new DAO object for table data access. -func NewStoresDao() *StoresDao { +func NewStoresDao(handlers ...gdb.ModelHandler) *StoresDao { return &StoresDao{ - group: "default", - table: "stores", - columns: storesColumns, + group: "default", + table: "stores", + columns: storesColumns, + handlers: handlers, } } @@ -81,7 +83,11 @@ func (dao *StoresDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoresDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/task_rewards.go b/internal/dao/internal/task_rewards.go index ea0ec0a..95ce8f4 100644 --- a/internal/dao/internal/task_rewards.go +++ b/internal/dao/internal/task_rewards.go @@ -13,9 +13,10 @@ import ( // TaskRewardsDao is the data access object for the table task_rewards. type TaskRewardsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns TaskRewardsColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns TaskRewardsColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // TaskRewardsColumns defines and stores column names for the table task_rewards. @@ -31,11 +32,12 @@ var taskRewardsColumns = TaskRewardsColumns{ } // NewTaskRewardsDao creates and returns a new DAO object for table data access. -func NewTaskRewardsDao() *TaskRewardsDao { +func NewTaskRewardsDao(handlers ...gdb.ModelHandler) *TaskRewardsDao { return &TaskRewardsDao{ - group: "default", - table: "task_rewards", - columns: taskRewardsColumns, + group: "default", + table: "task_rewards", + columns: taskRewardsColumns, + handlers: handlers, } } @@ -61,7 +63,11 @@ func (dao *TaskRewardsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TaskRewardsDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/tasks.go b/internal/dao/internal/tasks.go index 526632b..dfd5153 100644 --- a/internal/dao/internal/tasks.go +++ b/internal/dao/internal/tasks.go @@ -13,9 +13,10 @@ import ( // TasksDao is the data access object for the table tasks. type TasksDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns TasksColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns TasksColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // TasksColumns defines and stores column names for the table tasks. @@ -57,11 +58,12 @@ var tasksColumns = TasksColumns{ } // NewTasksDao creates and returns a new DAO object for table data access. -func NewTasksDao() *TasksDao { +func NewTasksDao(handlers ...gdb.ModelHandler) *TasksDao { return &TasksDao{ - group: "default", - table: "tasks", - columns: tasksColumns, + group: "default", + table: "tasks", + columns: tasksColumns, + handlers: handlers, } } @@ -87,7 +89,11 @@ func (dao *TasksDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TasksDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/user_tasks.go b/internal/dao/internal/user_tasks.go index 69ac1d3..257329e 100644 --- a/internal/dao/internal/user_tasks.go +++ b/internal/dao/internal/user_tasks.go @@ -13,9 +13,10 @@ import ( // UserTasksDao is the data access object for the table user_tasks. type UserTasksDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns UserTasksColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns UserTasksColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // UserTasksColumns defines and stores column names for the table user_tasks. @@ -51,11 +52,12 @@ var userTasksColumns = UserTasksColumns{ } // NewUserTasksDao creates and returns a new DAO object for table data access. -func NewUserTasksDao() *UserTasksDao { +func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao { return &UserTasksDao{ - group: "default", - table: "user_tasks", - columns: userTasksColumns, + group: "default", + table: "user_tasks", + columns: userTasksColumns, + handlers: handlers, } } @@ -81,7 +83,11 @@ func (dao *UserTasksDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/users.go b/internal/dao/internal/users.go index c5aa79d..340eaf7 100644 --- a/internal/dao/internal/users.go +++ b/internal/dao/internal/users.go @@ -13,9 +13,10 @@ import ( // UsersDao is the data access object for the table users. type UsersDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns UsersColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns UsersColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // UsersColumns defines and stores column names for the table users. @@ -59,11 +60,12 @@ var usersColumns = UsersColumns{ } // NewUsersDao creates and returns a new DAO object for table data access. -func NewUsersDao() *UsersDao { +func NewUsersDao(handlers ...gdb.ModelHandler) *UsersDao { return &UsersDao{ - group: "default", - table: "users", - columns: usersColumns, + group: "default", + table: "users", + columns: usersColumns, + handlers: handlers, } } @@ -89,7 +91,11 @@ func (dao *UsersDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *UsersDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/notices.go b/internal/dao/notices.go new file mode 100644 index 0000000..b8093b6 --- /dev/null +++ b/internal/dao/notices.go @@ -0,0 +1,22 @@ +// ================================================================================= +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. +// ================================================================================= + +package dao + +import ( + "server/internal/dao/internal" +) + +// noticesDao is the data access object for the table notices. +// You can define custom methods on it to extend its functionality as needed. +type noticesDao struct { + *internal.NoticesDao +} + +var ( + // Notices is a globally accessible object for table notices operations. + Notices = noticesDao{internal.NewNoticesDao()} +) + +// Add your custom methods and functionality below. diff --git a/internal/dao/reward_callback.go b/internal/dao/reward_callback.go new file mode 100644 index 0000000..049f5df --- /dev/null +++ b/internal/dao/reward_callback.go @@ -0,0 +1,22 @@ +// ================================================================================= +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. +// ================================================================================= + +package dao + +import ( + "server/internal/dao/internal" +) + +// rewardCallbackDao is the data access object for the table reward_callback. +// You can define custom methods on it to extend its functionality as needed. +type rewardCallbackDao struct { + *internal.RewardCallbackDao +} + +var ( + // RewardCallback is a globally accessible object for table reward_callback operations. + RewardCallback = rewardCallbackDao{internal.NewRewardCallbackDao()} +) + +// Add your custom methods and functionality below. diff --git a/internal/logic/reward/reward.go b/internal/logic/reward/reward.go index 2b4f29d..432a27b 100644 --- a/internal/logic/reward/reward.go +++ b/internal/logic/reward/reward.go @@ -359,16 +359,20 @@ func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model. // 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 { - // // 直接发背包 - // } - //} + // 判断奖励类型 + if in.Source == 1 { + // 系统奖励处理 + if in.RewradTypeId != 16 { + // 需要大区角色 + + } else { + // 不需要 + + } + } else { + // 门店奖励处理 + + } activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{PopenId: in.PopenId, ServiceName: consts.GetGift, GiftParam: model.GiftParam{ TaskId: in.TaskId, @@ -496,3 +500,18 @@ func (s *sReward) OperateTaskReward(ctx context.Context, in *model.OperateTaskRe return &model.OperateTaskRewardOut{Success: true}, err } } + +// CallBack 奖励回调 +func (s *sReward) CallBack(ctx context.Context, in *model.RewardCallbackIn) (out *model.RewardCallbackOut, err error) { + + dao.RewardCallback.Ctx(ctx).Insert(do.RewardCallback{ + OrderId: in.OrderId, + PrizeId: in.PrizeId, + PrizeType: in.PrizeType, + PrizeSubType: in.PrizeSubType, + Uid: in.Uid, + Num: in.Num, + CustomInfo: in.CustomInfo, + }) + return nil, err +} diff --git a/internal/model/do/notices.go b/internal/model/do/notices.go new file mode 100644 index 0000000..aa212ea --- /dev/null +++ b/internal/model/do/notices.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" +) + +// Notices is the golang structure of table notices for DAO operations like Where/Data. +type Notices struct { + g.Meta `orm:"table:notices, do:true"` + Id interface{} // 通知ID + Title interface{} // 通知标题 + Content interface{} // 通知内容 + Type interface{} // 通知类型:1=系统公告,2=活动通知,3=维护通知 + Status interface{} // 状态:0=关闭,1=发布 + VisibleTo interface{} // 可见范围:1=所有人,2=仅门店,3=仅用户 + MerchantId interface{} // 所属商户ID + StoreId interface{} // 所属门店ID + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 更新时间 + DeletedAt *gtime.Time // 软删除时间戳 +} diff --git a/internal/model/do/reward_callback.go b/internal/model/do/reward_callback.go new file mode 100644 index 0000000..9479999 --- /dev/null +++ b/internal/model/do/reward_callback.go @@ -0,0 +1,23 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" +) + +// RewardCallback is the golang structure of table reward_callback for DAO operations like Where/Data. +type RewardCallback struct { + g.Meta `orm:"table:reward_callback, do:true"` + Id interface{} // + Uid interface{} // 用户账号 + OrderId interface{} // 订单号必须保证全局唯一(保证接口幂等) + PrizeChannelId interface{} // 券渠道 ID + PrizeId interface{} // 券 ID + PrizeType interface{} // 奖励类型,1 网鱼积分,2 网鱼经验值,3 网鱼兑换码 + PrizeSubType interface{} // 奖励子类型,默认为 0,有多种子类型时可用,如 1,5 元网费充值券,2、满 30-5 满减券等 + Num interface{} // 奖励个数,默认 1,比如经验值 10 + CustomInfo interface{} // 透传字段 (json串) +} diff --git a/internal/model/entity/notices.go b/internal/model/entity/notices.go new file mode 100644 index 0000000..b322ef0 --- /dev/null +++ b/internal/model/entity/notices.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" +) + +// Notices is the golang structure for table notices. +type Notices struct { + Id int64 `json:"id" orm:"id" description:"通知ID"` // 通知ID + Title string `json:"title" orm:"title" description:"通知标题"` // 通知标题 + Content string `json:"content" orm:"content" description:"通知内容"` // 通知内容 + Type int `json:"type" orm:"type" description:"通知类型:1=系统公告,2=活动通知,3=维护通知"` // 通知类型:1=系统公告,2=活动通知,3=维护通知 + Status int `json:"status" orm:"status" description:"状态:0=关闭,1=发布"` // 状态:0=关闭,1=发布 + VisibleTo int `json:"visibleTo" orm:"visible_to" description:"可见范围:1=所有人,2=仅门店,3=仅用户"` // 可见范围:1=所有人,2=仅门店,3=仅用户 + MerchantId int64 `json:"merchantId" orm:"merchant_id" description:"所属商户ID"` // 所属商户ID + StoreId int64 `json:"storeId" orm:"store_id" description:"所属门店ID"` // 所属门店ID + CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间 + UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间 + DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳 +} diff --git a/internal/model/entity/reward_callback.go b/internal/model/entity/reward_callback.go new file mode 100644 index 0000000..8a88730 --- /dev/null +++ b/internal/model/entity/reward_callback.go @@ -0,0 +1,18 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +// RewardCallback is the golang structure for table reward_callback. +type RewardCallback struct { + Id int64 `json:"id" orm:"id" description:""` // + Uid string `json:"uid" orm:"uid" description:"用户账号"` // 用户账号 + OrderId string `json:"orderId" orm:"order_id" description:"订单号必须保证全局唯一(保证接口幂等)"` // 订单号必须保证全局唯一(保证接口幂等) + PrizeChannelId string `json:"prizeChannelId" orm:"prize_channel_id" description:"券渠道 ID"` // 券渠道 ID + PrizeId string `json:"prizeId" orm:"prize_id" description:"券 ID"` // 券 ID + PrizeType int `json:"prizeType" orm:"prize_type" description:"奖励类型,1 网鱼积分,2 网鱼经验值,3 网鱼兑换码"` // 奖励类型,1 网鱼积分,2 网鱼经验值,3 网鱼兑换码 + PrizeSubType int `json:"prizeSubType" orm:"prize_sub_type" description:"奖励子类型,默认为 0,有多种子类型时可用,如 1,5 元网费充值券,2、满 30-5 满减券等"` // 奖励子类型,默认为 0,有多种子类型时可用,如 1,5 元网费充值券,2、满 30-5 满减券等 + Num int `json:"num" orm:"num" description:"奖励个数,默认 1,比如经验值 10"` // 奖励个数,默认 1,比如经验值 10 + CustomInfo string `json:"customInfo" orm:"custom_info" description:"透传字段 (json串)"` // 透传字段 (json串) +} diff --git a/internal/model/reward.go b/internal/model/reward.go index 79cf5df..cce534b 100644 --- a/internal/model/reward.go +++ b/internal/model/reward.go @@ -123,26 +123,37 @@ type RewardListOut struct { // RewardCallbackIn 任务奖励领取回调入参 type RewardCallbackIn struct { - AreaId int - GameId int - RewradTypeId []int - RoleIdx string - TaskId string + Uid string `json:"uid" ` // 用户账号 + OrderId string `json:"orderId"` // 订单号必须保证全局唯一(保证接口幂等) + PrizeChannelId string `json:"prizeChannelId"` // 券渠道 ID + PrizeId string `json:"prizeId"` // 券 ID + PrizeType int `json:"prizeType"` // 奖励类型,1 网鱼积分,2 网鱼经验值,3 网鱼兑换码 + PrizeSubType int `json:"prizeSubType"` // 奖励子类型,默认为 0,有多种子类型时可用,如 1,5 元网费充值券,2、满 30-5 满减券等 + Num int `json:"num"` // 奖励个数,默认 1,比如经验值 10 + CustomInfo string `json:"customInfo"` // 透传字段 (json串) } type RewardCallbackOut struct { - List interface{} `json:"list"` - Result int64 `json:"result"` - Water Water `json:"water"` + Errcode int32 `json:"errcode"` + Errmsg string `json:"errmsg"` + AppId string `json:"appid"` + OrderId string `json:"order_id"` + Datas []CallbackData `json:"data"` +} + +type CallbackData struct { + PrizeCode string `json:"prize_code"` + Comment string `json:"comment"` } type GetRewardIn struct { AreaId int GameId int - RewradTypeId []int + RewradTypeId int RoleIdx string TaskId string PopenId string + Source int } type GetRewardOut struct { List interface{} `json:"list"` diff --git a/internal/packed/packed.go b/internal/packed/packed.go index d483800..e61b667 100644 --- a/internal/packed/packed.go +++ b/internal/packed/packed.go @@ -4,7 +4,7 @@ import ( _ "github.com/gogf/gf/contrib/drivers/mysql/v2" _ "github.com/gogf/gf/contrib/nosql/redis/v2" _ "server/utility/gamelife" - _ "server/utility/mqtt/emqx" + //_ "server/utility/mqtt/emqx" _ "server/utility/myCasbin" _ "server/utility/oss/aliyun" _ "server/utility/rsa" diff --git a/internal/service/reward.go b/internal/service/reward.go index 85e0ccb..b0943ed 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(ctx context.Context, in *model.RewardCallbackIn) (out *model.RewardCallbackOut, err error) } )