修改tencent回调,领取奖励部分

This commit is contained in:
chy
2025-06-26 21:01:49 +08:00
parent 895eca3289
commit 5c47a9a9b0
27 changed files with 508 additions and 286 deletions

View File

@ -11,7 +11,6 @@ import (
"server/api/reward/v1" "server/api/reward/v1"
"server/internal/model" "server/internal/model"
"server/internal/service" "server/internal/service"
"server/utility/ecode"
"strings" "strings"
) )
@ -46,23 +45,14 @@ func (c *ControllerV1) Callback(ctx context.Context, req *v1.CallbackReq) (res *
Num: int(req.Num), 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
marshal, err := json.Marshal(out) marshal, err := json.Marshal(out)
if err != nil { if err != nil {
return nil, ecode.Fail.Sub("序列化 json 数据出现异常") glog.Error(ctx, "序列化 json 数据出现异常")
g.RequestFromCtx(ctx).Response.Write(marshal)
return nil, nil
} }
g.RequestFromCtx(ctx).Response.Write(marshal) g.RequestFromCtx(ctx).Response.Write(marshal)
return nil, nil return nil, nil
//return &v1.CallbackRes{Errcode: 0, OrderId: req.OrderId, Datas: []v1.CallbackData{{PrizeCode: req.OrderId}}}, err
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,16 +13,17 @@ import (
// RewardWatersDao is the data access object for the table reward_waters. // RewardWatersDao is the data access object for the table reward_waters.
type RewardWatersDao struct { type RewardWatersDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
columns RewardWatersColumns // columns contains all the column names of Table for convenient usage. columns RewardWatersColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// RewardWatersColumns defines and stores column names for the table reward_waters. // RewardWatersColumns defines and stores column names for the table reward_waters.
type RewardWatersColumns struct { type RewardWatersColumns struct {
Id string // Id string //
OrderId string // 订单号 OrderId string // 订单号
Uid string // 用户账号 Recvuid string // 用户账号
TaskId string // 任务 id TaskId string // 任务 id
Water string // 兑换流水 Water string // 兑换流水
Status string // 兑换状态 1:奖励发放成功 2:奖励兑换失败(礼包发放背包环节成功,需重新引导领奖) 3:针对只需要发背包,然后引导用户到人生应用背包领奖的奖励类型,发奖成功了 4:water错误(一般是 orderid),不做兑换操作 Status string // 兑换状态 1:奖励发放成功 2:奖励兑换失败(礼包发放背包环节成功,需重新引导领奖) 3:针对只需要发背包,然后引导用户到人生应用背包领奖的奖励类型,发奖成功了 4:water错误(一般是 orderid),不做兑换操作
@ -35,7 +36,7 @@ type RewardWatersColumns struct {
var rewardWatersColumns = RewardWatersColumns{ var rewardWatersColumns = RewardWatersColumns{
Id: "id", Id: "id",
OrderId: "order_id", OrderId: "order_id",
Uid: "uid", Recvuid: "recvuid",
TaskId: "task_id", TaskId: "task_id",
Water: "water", Water: "water",
Status: "status", Status: "status",
@ -45,11 +46,12 @@ var rewardWatersColumns = RewardWatersColumns{
} }
// NewRewardWatersDao creates and returns a new DAO object for table data access. // NewRewardWatersDao creates and returns a new DAO object for table data access.
func NewRewardWatersDao() *RewardWatersDao { func NewRewardWatersDao(handlers ...gdb.ModelHandler) *RewardWatersDao {
return &RewardWatersDao{ return &RewardWatersDao{
group: "default", group: "default",
table: "reward_waters", table: "reward_waters",
columns: rewardWatersColumns, columns: rewardWatersColumns,
handlers: handlers,
} }
} }
@ -75,7 +77,11 @@ func (dao *RewardWatersDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *RewardWatersDao) Ctx(ctx context.Context) *gdb.Model { func (dao *RewardWatersDao) Ctx(ctx context.Context) *gdb.Model {
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. // Transaction wraps the transaction logic using function f.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,9 +13,10 @@ import (
// UserTasksDao is the data access object for the table user_tasks. // UserTasksDao is the data access object for the table user_tasks.
type UserTasksDao struct { type UserTasksDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO. group string // group is the database configuration group name of the current DAO.
columns UserTasksColumns // columns contains all the column names of Table for convenient usage. columns UserTasksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// UserTasksColumns defines and stores column names for the table user_tasks. // UserTasksColumns defines and stores column names for the table user_tasks.
@ -51,11 +52,12 @@ var userTasksColumns = UserTasksColumns{
} }
// NewUserTasksDao creates and returns a new DAO object for table data access. // NewUserTasksDao creates and returns a new DAO object for table data access.
func NewUserTasksDao() *UserTasksDao { func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao {
return &UserTasksDao{ return &UserTasksDao{
group: "default", group: "default",
table: "user_tasks", table: "user_tasks",
columns: userTasksColumns, 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. // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model { func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model {
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. // Transaction wraps the transaction logic using function f.

View File

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

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
"server/internal/consts" "server/internal/consts"
"server/internal/dao" "server/internal/dao"
@ -12,6 +13,7 @@ import (
"server/internal/service" "server/internal/service"
"server/utility/ecode" "server/utility/ecode"
"server/utility/gamelife" "server/utility/gamelife"
"time"
) )
type sReward struct{} type sReward struct{}
@ -373,50 +375,55 @@ func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *mode
} }
// 存储数据库记录 // 存储数据库记录
for _, item := range result.GiftItem { if err = dao.RewardWaters.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
marshal, err := json.Marshal(item.Water) for _, item := range result.GiftItem {
if err != nil { marshal, err := json.Marshal(item.Water)
return nil, ecode.Fail.Sub("序列化 json 数据出现异常") if err != nil {
} return ecode.Fail.Sub("序列化 json 数据出现异常")
_, err = dao.RewardWaters.Ctx(ctx).Insert(model.RewardWaters{ }
OrderId: item.Water.OrderId, _, err = dao.RewardWaters.Ctx(ctx).Insert(model.RewardWaters{
Status: int64(item.Result), OrderId: item.Water.OrderId,
Uid: item.Water.Uid, Status: int64(item.Result),
Water: string(marshal), Uid: item.Water.Uid,
TaskId: in.TaskId, Water: string(marshal),
GameId: int64(in.GameId), TaskId: in.TaskId,
}) GameId: int64(in.GameId),
})
if err != nil { if err != nil {
return nil, ecode.Fail.Sub("添加奖励领取记录异常") return ecode.Fail.Sub("添加奖励领取记录异常")
}
// 根据 result判断
if item.Result == 1 {
// 奖励发放成功,修改状态,扣除数量
if _, err = dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{ExternalOrderId: item.Water.OrderId}).Update(consts.RewardSuccessStatus); err != nil {
return ecode.Fail.Sub("修改奖励领取记录状态异常")
}
value, err := dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{ExternalOrderId: item.Water.OrderId}).Value(dao.UserTaskRewards.Columns().RewardId)
if err != nil {
return ecode.Fail.Sub("获取奖励领取记录异常")
}
if value.IsEmpty() {
return ecode.Fail.Sub("获取奖励领取记录异常")
}
// 扣除数量
if _, err = dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: value.Int()}).One(); err != nil {
return ecode.Fail.Sub("获取奖励记录异常")
}
return
} else if item.Result == 2 || item.Result == 3 {
// 发放背包成功,修改状态
} else if item.Result == 4 {
// 奖励领取失败,不做操作,直接返回
}
} }
// 根据 result判断 return
if item.Result == 1 {
// 奖励发放成功,修改状态,扣除数量
_, err := dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{ExternalOrderId: item.Water.OrderId}).Update(consts.RewardSuccessStatus)
if err != nil {
return nil, ecode.Fail.Sub("修改奖励领取记录状态异常")
}
value, err := dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{ExternalOrderId: item.Water.OrderId}).Value(dao.UserTaskRewards.Columns().RewardId) }); err != nil {
if err != nil { return
return nil, ecode.Fail.Sub("获取奖励领取记录异常")
}
if value.IsEmpty() {
return nil, ecode.Fail.Sub("获取奖励领取记录异常")
}
// 扣除数量
_, err = dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: value.Int()}).One()
if err != nil {
return nil, ecode.Fail.Sub("获取奖励记录异常")
}
} else if item.Result == 2 || item.Result == 3 {
// 发放背包成功,修改状态
} else if item.Result == 4 {
// 奖励领取失败,不做操作,直接返回
}
} }
return nil, err return nil, err
@ -513,6 +520,111 @@ func (s *sReward) OperateTaskReward(ctx context.Context, in *model.OperateTaskRe
// CallBack 奖励回调 // CallBack 奖励回调
func (s *sReward) CallBack(ctx context.Context, in *model.RewardCallbackIn) (out *model.RewardCallbackOut, err error) { func (s *sReward) CallBack(ctx context.Context, in *model.RewardCallbackIn) (out *model.RewardCallbackOut, err error) {
var reward *model.Reward
var res model.RewardCallbackOut
res.OrderId = in.OrderId
res.AppId = in.AppId
// 查询奖励
err = dao.Rewards.Ctx(ctx).Where(do.Rewards{PrizeId: in.PrizeId}).Scan(&reward)
if err != nil {
res.Errcode = -1
res.Errmsg = "查询奖励异常"
res.Datas = nil
return &res, ecode.Fail.Sub("查询奖励异常")
}
if reward == nil {
res.Errcode = -1
res.Errmsg = "查询奖励为空"
res.Datas = nil
return &res, ecode.Params.Sub("查询奖励为空")
}
// 判断是否过期
if reward.ExpireType == 1 {
//时间段过期
if reward.ValidTo.Before(gtime.Now()) {
res.Errcode = consts.BatchOutDate
res.Errmsg = consts.BatchOutDateMSG
}
}
// 日
now := time.Now()
// 当天开始时间
start := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
// 当天结束时间
end := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 0, now.Location())
// 查先询用户当日已领取
dailyGetNum, err := dao.Rewards.Ctx(ctx).Where(dao.Rewards.Columns().PrizeId, in.PrizeId).InnerJoin(dao.UserTaskRewards.Table(), fmt.Sprintf("%s.id=%s.reward_id", dao.Rewards.Table(),
dao.UserTaskRewards.Table())).InnerJoin(dao.RewardWaters.Table(), fmt.Sprintf("%s.external_order_id = %s.order_id", dao.UserTaskRewards.Table(), dao.RewardWaters.Table())).
Where(dao.RewardWaters.Columns().Recvuid, in.Uid).Where(dao.UserTaskRewards.Columns().Status, 3).WhereOr(dao.UserTaskRewards.Columns().Status, 6).
WhereBetween(dao.UserTaskRewards.Columns().UpdatedAt, start, end).Fields(fmt.Sprintf("%s.*,%s.*", dao.Rewards.Table(), dao.UserTaskRewards.Table())).Count()
if err != nil {
res.Errcode = -1
res.Errmsg = "查询用户当日领取数量失败"
res.Datas = nil
return &res, ecode.Fail.Sub("查询用户当日领取数量失败")
}
// 判断是否达到用户日限制
if int(reward.UserDailyLimit) <= dailyGetNum {
res.Errcode = consts.UserDayLimit
res.Errmsg = consts.UserDayLimitMSG
}
// 查先询用户总共已领取
dailyTotalNum, err := dao.Rewards.Ctx(ctx).Where(dao.Rewards.Columns().PrizeId, in.PrizeId).InnerJoin(dao.UserTaskRewards.Table(), fmt.Sprintf("%s.id=%s.reward_id", dao.Rewards.Table(),
dao.UserTaskRewards.Table())).InnerJoin(dao.RewardWaters.Table(), fmt.Sprintf("%s.external_order_id = %s.order_id", dao.UserTaskRewards.Table(), dao.RewardWaters.Table())).
Where(dao.RewardWaters.Columns().Recvuid, in.Uid).Where(dao.UserTaskRewards.Columns().Status, 3).WhereOr(dao.UserTaskRewards.Columns().Status, 6).
Fields(fmt.Sprintf("%s.*,%s.*", dao.Rewards.Table(), dao.UserTaskRewards.Table())).Count()
if err != nil {
res.Errcode = -1
res.Errmsg = "查询用户当日总共领取数量失败"
res.Datas = nil
return &res, ecode.Fail.Sub("查询用户当日总共领取数量失败")
}
// 判断是否达到用户总限制
if int(reward.UserTotalLimit) <= dailyTotalNum {
res.Errcode = consts.UserTotalLimit
res.Errmsg = consts.UserTotalLimitMSG
}
// 查先询该批次当日已领取
batchDailyGetNum, err := dao.Rewards.Ctx(ctx).Where(dao.Rewards.Columns().PrizeId, in.PrizeId).InnerJoin(dao.UserTaskRewards.Table(), fmt.Sprintf("%s.id = %s.reward_id",
dao.Rewards.Table(), dao.UserTaskRewards.Table())).Where(dao.UserTaskRewards.Columns().Status, 3).WhereOr(dao.UserTaskRewards.Columns().Status, 6).
WhereBetween(dao.UserTaskRewards.Columns().UpdatedAt, start, end).Fields(fmt.Sprintf("%s.*,%s.*", dao.Rewards.Table(), dao.UserTaskRewards.Table())).Count()
if err != nil {
res.Errcode = -1
res.Errmsg = "查询该批次当日总共领取数量失败"
res.Datas = nil
return &res, ecode.Fail.Sub("查询该批次当日总共领取数量失败")
}
// 判断是否达到该批次日限制
if int(reward.DailyTotalLimit) <= batchDailyGetNum {
res.Errcode = consts.BatchDayLimit
res.Errmsg = consts.BatchDayLimitMSG
}
// 查先询该批次总共已领取
batchTotalGetNum, err := dao.Rewards.Ctx(ctx).Where(dao.Rewards.Columns().PrizeId, in.PrizeId).InnerJoin(dao.UserTaskRewards.Table(), fmt.Sprintf("%s.id = %s.reward_id",
dao.Rewards.Table(), dao.UserTaskRewards.Table())).Where(dao.UserTaskRewards.Columns().Status, 3).WhereOr(dao.UserTaskRewards.Columns().Status, 6).
Fields(fmt.Sprintf("%s.*,%s.*", dao.Rewards.Table(), dao.UserTaskRewards.Table())).Count()
if err != nil {
res.Errcode = -1
res.Errmsg = "查询该批次总共领取数量失败"
res.Datas = nil
return &res, ecode.Fail.Sub("查询该批次总共领取数量失败")
}
// 判断是否达到该批次总共限制
if int(reward.TotalLimit) <= batchTotalGetNum {
res.Errcode = consts.BatchTotalLimit
res.Errmsg = consts.BatchTotalLimitMSG
}
_, err = dao.RewardCallback.Ctx(ctx).OmitEmptyData().Insert(do.RewardCallback{ _, err = dao.RewardCallback.Ctx(ctx).OmitEmptyData().Insert(do.RewardCallback{
OrderId: in.OrderId, OrderId: in.OrderId,
@ -526,64 +638,34 @@ func (s *sReward) CallBack(ctx context.Context, in *model.RewardCallbackIn) (out
}) })
if err != nil { if err != nil {
return nil, ecode.Fail.Sub("存储奖励回调数据异常") res.Errcode = -1
res.Errmsg = "存储奖励回调数据异常"
res.Datas = nil
return &res, ecode.Fail.Sub("存储奖励回调数据异常")
} }
var reward *model.Reward // 回调成功,组装响应参数
// 查询奖励,修改状态,扣除数量 var userTaskReward []*model.UserTaskRewards
err = dao.Rewards.Ctx(ctx).Where(do.Rewards{PrizeId: in.PrizeId}).Scan(&reward) if err = dao.Rewards.Ctx(ctx).Where(dao.Rewards.Columns().PrizeId, in.PrizeId).InnerJoin(dao.UserTaskRewards.Table(), fmt.Sprintf("%s.%s = %s.%s",
if err != nil { dao.Rewards.Table(), dao.Rewards.Columns().Id, dao.UserTaskRewards.Table(), dao.UserTaskRewards.Columns().RewardId)).Scan(&userTaskReward); err != nil {
return nil, ecode.Fail.Sub("查询奖励异常") return nil, ecode.Fail.Sub("获取用户奖励记录异常")
} }
if reward == nil { if userTaskReward == nil {
return nil, ecode.Params.Sub("查询奖励为空") res.Errcode = -1
res.Errmsg = "用户奖励记录为空"
res.Datas = nil
return &res, ecode.Fail.Sub("用户奖励记录为空")
} }
// 判断是否过期 callbackData := make([]model.CallbackData, 0)
if reward.ExpireType == 1 { for _, v := range userTaskReward {
//时间段过期 callbackData = append(callbackData, model.CallbackData{
if reward.ValidTo.Before(gtime.Now()) { PrizeCode: v.InnerOrderId,
out.Errcode = consts.BatchOutDate })
out.Errmsg = consts.BatchOutDateMSG
}
} }
// 判断是否达到用户日限制 res.Datas = callbackData
// 查先询用户当日已领取
var dailyGetNum int
dao.Users.Ctx(ctx).Where(do.Users{})
if int(reward.UserDailyLimit) <= dailyGetNum {
out.Errcode = consts.UserDayLimit
out.Errmsg = consts.UserDayLimitMSG
}
// 判断是否达到用户总限制 return &res, err
// 查先询用户总共已领取
var dailyTotalNum int
if int(reward.UserTotalLimit) <= dailyTotalNum {
out.Errcode = consts.UserTotalLimit
out.Errmsg = consts.UserTotalLimitMSG
}
// 判断是否达到该批次日限制
// 查先询该批次当日已领取
var batchDailyGetNum int
if int(reward.DailyTotalLimit) <= batchDailyGetNum {
out.Errcode = consts.BatchDayLimit
out.Errmsg = consts.BatchDayLimitMSG
}
// 判断是否达到该批次总共限制
// 查先询该批次总共已领取
var batchTotalGetNum int
if int(reward.TotalLimit) <= batchTotalGetNum {
out.Errcode = consts.BatchTotalLimit
out.Errmsg = consts.BatchTotalLimitMSG
}
// 回调成功,
out.OrderId = in.OrderId
out.AppId = in.AppId
return out, err
} }

View File

@ -14,7 +14,7 @@ type RewardWaters struct {
g.Meta `orm:"table:reward_waters, do:true"` g.Meta `orm:"table:reward_waters, do:true"`
Id interface{} // Id interface{} //
OrderId interface{} // 订单号 OrderId interface{} // 订单号
Uid interface{} // 用户账号 Recvuid interface{} // 用户账号
TaskId interface{} // 任务 id TaskId interface{} // 任务 id
Water interface{} // 兑换流水 Water interface{} // 兑换流水
Status interface{} // 兑换状态 1:奖励发放成功 2:奖励兑换失败(礼包发放背包环节成功,需重新引导领奖) 3:针对只需要发背包,然后引导用户到人生应用背包领奖的奖励类型,发奖成功了 4:water错误(一般是 orderid),不做兑换操作 Status interface{} // 兑换状态 1:奖励发放成功 2:奖励兑换失败(礼包发放背包环节成功,需重新引导领奖) 3:针对只需要发背包,然后引导用户到人生应用背包领奖的奖励类型,发奖成功了 4:water错误(一般是 orderid),不做兑换操作

View File

@ -12,7 +12,7 @@ import (
type RewardWaters struct { type RewardWaters struct {
Id int64 `json:"id" orm:"id" description:""` // Id int64 `json:"id" orm:"id" description:""` //
OrderId string `json:"orderId" orm:"order_id" description:"订单号"` // 订单号 OrderId string `json:"orderId" orm:"order_id" description:"订单号"` // 订单号
Uid string `json:"uid" orm:"uid" description:"用户账号"` // 用户账号 Recvuid string `json:"recvuid" orm:"recvuid" description:"用户账号"` // 用户账号
TaskId string `json:"taskId" orm:"task_id" description:"任务 id"` // 任务 id TaskId string `json:"taskId" orm:"task_id" description:"任务 id"` // 任务 id
Water string `json:"water" orm:"water" description:"兑换流水"` // 兑换流水 Water string `json:"water" orm:"water" description:"兑换流水"` // 兑换流水
Status int64 `json:"status" orm:"status" description:"兑换状态 1:奖励发放成功 2:奖励兑换失败(礼包发放背包环节成功,需重新引导领奖) 3:针对只需要发背包,然后引导用户到人生应用背包领奖的奖励类型,发奖成功了 4:water错误(一般是 orderid),不做兑换操作"` // 兑换状态 1:奖励发放成功 2:奖励兑换失败(礼包发放背包环节成功,需重新引导领奖) 3:针对只需要发背包,然后引导用户到人生应用背包领奖的奖励类型,发奖成功了 4:water错误(一般是 orderid),不做兑换操作 Status int64 `json:"status" orm:"status" description:"兑换状态 1:奖励发放成功 2:奖励兑换失败(礼包发放背包环节成功,需重新引导领奖) 3:针对只需要发背包,然后引导用户到人生应用背包领奖的奖励类型,发奖成功了 4:water错误(一般是 orderid),不做兑换操作"` // 兑换状态 1:奖励发放成功 2:奖励兑换失败(礼包发放背包环节成功,需重新引导领奖) 3:针对只需要发背包,然后引导用户到人生应用背包领奖的奖励类型,发奖成功了 4:water错误(一般是 orderid),不做兑换操作

View File

@ -0,0 +1,18 @@
package model
import "github.com/gogf/gf/v2/os/gtime"
type UserTaskRewards struct {
Id int64 `json:"id" orm:"id" description:"用户任务奖励记录唯一标识符"` // 用户任务奖励记录唯一标识符
UserTaskId int64 `json:"userTaskId" orm:"user_task_id" description:"关联用户任务记录ID"` // 关联用户任务记录ID
RewardId int64 `json:"rewardId" orm:"reward_id" description:"奖励ID"` // 奖励ID
RewardName string `json:"rewardName" orm:"reward_name" description:"奖励名称冗余字段"` // 奖励名称冗余字段
Status int `json:"status" orm:"status" description:"状态1=待用户完成任务2=待领取3=已领取, 待兑换4=已过期5=发放失败, 6=结束"` // 状态1=待用户完成任务2=待领取3=已领取, 待兑换4=已过期5=发放失败, 6=结束
Remark string `json:"remark" orm:"remark" description:"备注或失败原因"` // 备注或失败原因
ExternalOrderId string `json:"externalOrderId" orm:"external_order_id" description:"第三方发放平台的订单ID"` // 第三方发放平台的订单ID
InnerOrderId string `json:"innerOrderId" orm:"inner_order_id" description:"系统内部订单ID"` // 系统内部订单ID
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
ExpiredAt *gtime.Time `json:"expiredAt" orm:"expired_at" description:"奖励过期时间"` // 奖励过期时间
}