修改奖励类型

This commit is contained in:
2025-06-24 19:53:39 +08:00
parent e28c44ecbb
commit 1c0b9a2d93
42 changed files with 666 additions and 1060 deletions

View File

@ -7,9 +7,10 @@ type ListReq struct {
Name string `json:"name" dc:"名称"`
Page int `json:"page" dc:"页数"`
Size int `json:"size" dc:"每页数量"`
Status int `json:"status" dc:"状态"`
StoreId int64 `json:"storeId" dc:"门店ID"`
Source int `json:"source" v:"in:1,2#来源只能为1或2" dc:"来源"`
}
type ListRes struct {
List interface{} `json:"list" dc:"奖励类型列表"`
Total int `json:"total" dc:"总数"`
@ -18,11 +19,11 @@ type ListRes struct {
type CreateReq struct {
g.Meta `path:"/rewardType" method:"post" tags:"RewardType" summary:"(系统、商户、门店后台)创建奖励类型"`
Name string `json:"name" v:"required#名称不能为空" dc:"名称"`
Description string `json:"description" v:"required#描述不能为空" dc:"描述"`
Status int `json:"status" v:"" dc:"状态" d:"1"`
StoreId int64 `json:"storeId" dc:"门店ID"`
Source int `json:"source" v:"in:1,2#来源只能为1或2" dc:"来源"`
TencentTypeId int `json:"tencentTypeId,omitempty" dc:"腾讯奖励类型ID仅系统奖励有效"`
}
type CreateRes struct {
Id int64 `json:"id" dc:"奖励类型ID"`
}
@ -31,17 +32,19 @@ type UpdateReq struct {
g.Meta `path:"/rewardType" method:"put" tags:"RewardType" summary:"(系统、商户、门店后台)更新奖励类型"`
Id int64 `json:"id" v:"required#ID不能为空" dc:"Id"`
Name string `json:"name" v:"required#名称不能为空" dc:"名称"`
Description string `json:"description" v:"required#描述不能为空" dc:"描述"`
Status int `json:"status" v:"" dc:"状态" d:"1"`
StoreId int64 `json:"storeId" dc:"门店ID"`
TencentTypeId int `json:"tencentTypeId,omitempty" dc:"腾讯奖励类型ID仅系统奖励有效"`
}
type UpdateRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type DeleteReq struct {
g.Meta `path:"/rewardType/{id}" method:"delete" tags:"RewardType" summary:"(系统、商户、门店后台)删除奖励类型"`
Id int64 `in:"path" json:"id" v:"required#ID不能为空" dc:"Id"`
}
type DeleteRes struct {
Success bool `json:"success" dc:"是否成功"`
}

View File

@ -1,16 +0,0 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package storeTaskReward
import (
"context"
"server/api/storeTaskReward/v1"
)
type IStoreTaskRewardV1 interface {
Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error)
Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error)
}

View File

@ -1,22 +0,0 @@
package v1
import "github.com/gogf/gf/v2/frame/g"
type CreateReq struct {
g.Meta `path:"/storeTaskReward" method:"post" tags:"StoreTaskReward" summary:"(商户、门店后台)创建门店任务奖励"`
TaskId string `json:"taskId" v:"required#任务 Id 不能为空" dc:"任务 Id"`
RewardId int64 `json:"rewardId" v:"required#奖励ID不能为空" dc:"奖励ID"`
StoreId int64 `json:"storeId" v:"required#门店ID不能为空" dc:"门店ID"`
}
type CreateRes struct {
Id int64 `json:"id"`
}
type DeleteReq struct {
g.Meta `path:"/storeTaskReward/{id}" method:"delete" tags:"StoreTaskReward" summary:"(商户、门店后台)删除门店任务奖励"`
Id int64 `in:"path" json:"id" v:"required#门店任务奖励ID不能为空" dc:"门店任务奖励ID"`
}
type DeleteRes struct {
Success bool `json:"success" dc:"是否成功"`
}

View File

@ -18,7 +18,6 @@ import (
"server/internal/controller/store"
"server/internal/controller/storeAdmin"
"server/internal/controller/storeRole"
"server/internal/controller/storeTaskReward"
"server/internal/controller/task"
"server/internal/controller/upload"
"server/internal/controller/user"
@ -58,7 +57,6 @@ var (
game.NewV1(),
rewardType.NewV1(),
reward.NewV1(),
storeTaskReward.NewV1(),
desktop.NewV1(),
)
})

View File

@ -3,6 +3,7 @@ package rewardType
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/glog"
"server/internal/model"
"server/internal/service"
@ -13,17 +14,25 @@ func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.C
fromCtx := g.RequestFromCtx(ctx)
operatorId := fromCtx.GetCtxVar("id").Int64()
operatorRole := fromCtx.GetCtxVar("role").String()
glog.Infof(ctx, "请求创建奖励类型操作用户ID%d角色%s名称%s来源%d门店ID%d腾讯类型ID%d",
operatorId, operatorRole, req.Name, req.Source, req.StoreId, req.TencentTypeId,
)
out, err := service.RewardType().Create(ctx, &model.RewardTypeCreateIn{
OperatorId: operatorId,
OperatorRole: operatorRole,
Name: req.Name,
Description: req.Description,
Source: req.Source,
Status: req.Status,
StoreId: req.StoreId})
StoreId: req.StoreId,
TencentTypeId: req.TencentTypeId,
})
if err != nil {
glog.Warningf(ctx, "创建奖励类型失败操作用户ID%d角色%s错误信息%v", operatorId, operatorRole, err)
return nil, err
}
return &v1.CreateRes{Id: out.Id}, nil
glog.Infof(ctx, "创建奖励类型成功ID%d操作用户ID%d角色%s", out.Id, operatorId, operatorRole)
return &v1.CreateRes{Id: out.Id}, nil
}

View File

@ -3,6 +3,7 @@ package rewardType
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/glog"
"server/internal/model"
"server/internal/service"
@ -13,9 +14,20 @@ func (c *ControllerV1) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.D
fromCtx := g.RequestFromCtx(ctx)
operatorId := fromCtx.GetCtxVar("id").Int64()
operatorRole := fromCtx.GetCtxVar("role").String()
out, err := service.RewardType().Delete(ctx, &model.RewardTypeDeleteIn{Id: req.Id, OperatorId: operatorId, OperatorRole: operatorRole})
glog.Infof(ctx, "请求删除奖励类型操作用户ID%d角色%s奖励类型ID%d", operatorId, operatorRole, req.Id)
out, err := service.RewardType().Delete(ctx, &model.RewardTypeDeleteIn{
Id: req.Id,
OperatorId: operatorId,
OperatorRole: operatorRole,
})
if err != nil {
glog.Warningf(ctx, "删除奖励类型失败操作用户ID%d角色%s奖励类型ID%d错误信息%v", operatorId, operatorRole, req.Id, err)
return nil, err
}
glog.Infof(ctx, "删除奖励类型成功操作用户ID%d角色%s奖励类型ID%d", operatorId, operatorRole, req.Id)
return &v1.DeleteRes{Success: out.Success}, nil
}

View File

@ -3,6 +3,7 @@ package rewardType
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/glog"
"server/internal/model"
"server/internal/service"
@ -13,10 +14,28 @@ func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListR
fromCtx := g.RequestFromCtx(ctx)
operatorId := fromCtx.GetCtxVar("id").Int64()
operatorRole := fromCtx.GetCtxVar("role").String()
out, err := service.RewardType().List(ctx, &model.RewardTypeListIn{Page: req.Page, Size: req.Size, OperatorId: operatorId, OperatorRole: operatorRole, StoreId: req.StoreId, Name: req.Name, Status: req.Status})
glog.Infof(ctx, "获取奖励类型列表操作用户ID%d角色%s页码%d每页大小%d门店ID%d名称过滤%s来源过滤%d",
operatorId, operatorRole, req.Page, req.Size, req.StoreId, req.Name, req.Source,
)
out, err := service.RewardType().List(ctx, &model.RewardTypeListIn{
Page: req.Page,
Size: req.Size,
OperatorId: operatorId,
OperatorRole: operatorRole,
StoreId: req.StoreId,
Name: req.Name,
Source: req.Source,
})
if err != nil {
glog.Warningf(ctx, "获取奖励类型列表失败操作用户ID%d角色%s错误信息%v", operatorId, operatorRole, err)
return nil, err
}
glog.Infof(ctx, "获取奖励类型列表成功操作用户ID%d角色%s结果总数%d", operatorId, operatorRole, out.Total)
return &v1.ListRes{
List: out.List,
Total: out.Total,

View File

@ -3,6 +3,7 @@ package rewardType
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/glog"
"server/internal/model"
"server/internal/service"
@ -13,17 +14,24 @@ func (c *ControllerV1) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.U
fromCtx := g.RequestFromCtx(ctx)
operatorId := fromCtx.GetCtxVar("id").Int64()
operatorRole := fromCtx.GetCtxVar("role").String()
glog.Infof(ctx, "更新奖励类型开始操作用户ID%d角色%s奖励类型ID%d名称%s腾讯类型ID%d门店ID%d",
operatorId, operatorRole, req.Id, req.Name, req.TencentTypeId, req.StoreId,
)
out, err := service.RewardType().Update(ctx, &model.RewardTypeUpdateIn{
Id: req.Id,
Name: req.Name,
Description: req.Description,
Status: req.Status,
TencentTypeId: req.TencentTypeId,
StoreId: req.StoreId,
OperatorId: operatorId,
OperatorRole: operatorRole,
StoreId: req.StoreId,
})
if err != nil {
glog.Warningf(ctx, "更新奖励类型失败操作用户ID%d角色%s错误信息%v", operatorId, operatorRole, err)
return nil, err
}
glog.Infof(ctx, "更新奖励类型成功操作用户ID%d角色%s奖励类型ID%d", operatorId, operatorRole, req.Id)
return &v1.UpdateRes{Success: out.Success}, nil
}

View File

@ -1,5 +0,0 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package storeTaskReward

View File

@ -1,15 +0,0 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package storeTaskReward
import (
"server/api/storeTaskReward"
)
type ControllerV1 struct{}
func NewV1() storeTaskReward.IStoreTaskRewardV1 {
return &ControllerV1{}
}

View File

@ -1,21 +0,0 @@
package storeTaskReward
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"server/internal/model"
"server/internal/service"
"server/api/storeTaskReward/v1"
)
func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) {
fromCtx := g.RequestFromCtx(ctx)
operatorId := fromCtx.GetCtxVar("id").Int64()
operatorRole := fromCtx.GetCtxVar("role").String()
out, err := service.StoreTaskReward().Create(ctx, &model.StoreTaskRewardCreateIn{OperatorId: operatorId, OperatorRole: operatorRole, RewardId: req.RewardId, StoreId: req.StoreId, TaskId: req.TaskId})
if err != nil {
return nil, err
}
return &v1.CreateRes{Id: out.Id}, nil
}

View File

@ -1,21 +0,0 @@
package storeTaskReward
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"server/internal/model"
"server/internal/service"
"server/api/storeTaskReward/v1"
)
func (c *ControllerV1) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) {
fromCtx := g.RequestFromCtx(ctx)
operatorId := fromCtx.GetCtxVar("id").Int64()
operatorRole := fromCtx.GetCtxVar("role").String()
out, err := service.StoreTaskReward().Delete(ctx, &model.StoreTaskRewardDeleteIn{Id: req.Id, OperatorId: operatorId, OperatorRole: operatorRole})
if err != nil {
return nil, err
}
return &v1.DeleteRes{Success: out.Success}, nil
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,42 +16,38 @@ type RewardTypesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RewardTypesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// RewardTypesColumns defines and stores column names for the table reward_types.
type RewardTypesColumns struct {
Id string // 奖励类型ID
Name string // 奖励类型名称(如积分、优惠券)
Description string // 奖励类型描述
Source string // 来源1=系统默认2=门店自定义
StoreId string // 门店ID系统默认类型为NULL
Status string // 状态1=正常2=禁用
Name string // 类型名称
TencentTypeId string // 腾讯奖励类型ID仅系统奖励有效
Source string // 奖励来源1=腾讯系统2=本系统3=其他
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间
DeletedAt string // 软删除时间
StoreId string // 门店 id
}
// rewardTypesColumns holds the columns for the table reward_types.
var rewardTypesColumns = RewardTypesColumns{
Id: "id",
Name: "name",
Description: "description",
TencentTypeId: "tencent_type_id",
Source: "source",
StoreId: "store_id",
Status: "status",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
StoreId: "store_id",
}
// NewRewardTypesDao creates and returns a new DAO object for table data access.
func NewRewardTypesDao(handlers ...gdb.ModelHandler) *RewardTypesDao {
func NewRewardTypesDao() *RewardTypesDao {
return &RewardTypesDao{
group: "default",
table: "reward_types",
columns: rewardTypesColumns,
handlers: handlers,
}
}
@ -77,11 +73,7 @@ func (dao *RewardTypesDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *RewardTypesDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,58 +16,66 @@ type RewardsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RewardsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// RewardsColumns defines and stores column names for the table rewards.
type RewardsColumns struct {
Id string // 奖励ID
RewardTypeId string // 奖励类型ID
Name string // 奖励名称如100积分、5元优惠券
Description string // 奖励描述
Source string // 来源1=系统内置2=门店自定义
StoreId string // 门店ID系统内置奖励为NULL
Value string // 奖励值(如积分数额、优惠金额)
Status string // 状态1=正常2=禁用
StoreId string // 门店ID系统奖励为NULL
Name string // 奖励名称
RewardTypeId string // 奖励类型ID关联 reward_types 表
GameId string // 游戏ID
ImageUrl string // 奖励图片链接
QqGoodsId string // QQ网吧物品ID
QqGoodsIdStr string // QQ网吧物品ID字符串
Status string // 状态1=启用2=禁用
ExpireType string // 过期方式1=时间段过期2=领取后过期
ValidFrom string // 有效期开始时间expire_type=1时
ValidTo string // 有效期结束时间expire_type=1时
ExpireDays string // 领取后多少天过期expire_type=2时
DailyTotalLimit string // 每日发放总限NULL表示不限制
TotalLimit string // 奖励总限NULL表示不限制
UserDailyLimit string // 用户每日领取限制NULL表示不限制
UserTotalLimit string // 用户领取总次数限制NULL表示不限制
ReceivedNum string // 已领取数量
GrantQuantity string // 每次发放个数
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 删除时间
TotalNum string // 奖励总数量NULL表示不限量
UsedNum string // 已使用数量
ExpireType string // 过期类型1=时间段过期2=领取后多少天过期
ValidFrom string // 有效开始时间expire_type=1 时使用)
ValidTo string // 有效结束时间expire_type=1 时使用)
ExpireDays string // 领取后多少天过期expire_type=2 时使用)
DeletedAt string // 删除时间(软删除)
}
// rewardsColumns holds the columns for the table rewards.
var rewardsColumns = RewardsColumns{
Id: "id",
RewardTypeId: "reward_type_id",
Name: "name",
Description: "description",
Source: "source",
StoreId: "store_id",
Value: "value",
Name: "name",
RewardTypeId: "reward_type_id",
GameId: "game_id",
ImageUrl: "image_url",
QqGoodsId: "qq_goods_id",
QqGoodsIdStr: "qq_goods_id_str",
Status: "status",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
TotalNum: "total_num",
UsedNum: "used_num",
ExpireType: "expire_type",
ValidFrom: "valid_from",
ValidTo: "valid_to",
ExpireDays: "expire_days",
DailyTotalLimit: "daily_total_limit",
TotalLimit: "total_limit",
UserDailyLimit: "user_daily_limit",
UserTotalLimit: "user_total_limit",
ReceivedNum: "received_num",
GrantQuantity: "grant_quantity",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewRewardsDao creates and returns a new DAO object for table data access.
func NewRewardsDao(handlers ...gdb.ModelHandler) *RewardsDao {
func NewRewardsDao() *RewardsDao {
return &RewardsDao{
group: "default",
table: "rewards",
columns: rewardsColumns,
handlers: handlers,
}
}
@ -93,11 +101,7 @@ func (dao *RewardsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *RewardsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,93 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// StoreNetfeeAreaLevelDao is the data access object for the table store_netfee_area_level.
type StoreNetfeeAreaLevelDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreNetfeeAreaLevelColumns // columns contains all the column names of Table for convenient usage.
}
// StoreNetfeeAreaLevelColumns defines and stores column names for the table store_netfee_area_level.
type StoreNetfeeAreaLevelColumns struct {
Id string // 主键ID
StoreId string // 门店ID
RewardId string // 奖励IDrewards表主键
AreaId string // 区域ID外部系统
AreaName string // 区域名称
MemberLevelId string // 会员等级ID外部系统
MemberLevelName string // 会员等级名称
PriceData string // 7x24价格矩阵
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 删除时间
}
// storeNetfeeAreaLevelColumns holds the columns for the table store_netfee_area_level.
var storeNetfeeAreaLevelColumns = StoreNetfeeAreaLevelColumns{
Id: "id",
StoreId: "store_id",
RewardId: "reward_id",
AreaId: "area_id",
AreaName: "area_name",
MemberLevelId: "member_level_id",
MemberLevelName: "member_level_name",
PriceData: "price_data",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
}
// NewStoreNetfeeAreaLevelDao creates and returns a new DAO object for table data access.
func NewStoreNetfeeAreaLevelDao() *StoreNetfeeAreaLevelDao {
return &StoreNetfeeAreaLevelDao{
group: "default",
table: "store_netfee_area_level",
columns: storeNetfeeAreaLevelColumns,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *StoreNetfeeAreaLevelDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *StoreNetfeeAreaLevelDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *StoreNetfeeAreaLevelDao) Columns() StoreNetfeeAreaLevelColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *StoreNetfeeAreaLevelDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreNetfeeAreaLevelDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *StoreNetfeeAreaLevelDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,27 @@
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================
package dao
import (
"server/internal/dao/internal"
)
// internalStoreNetfeeAreaLevelDao is an internal type for wrapping the internal DAO implementation.
type internalStoreNetfeeAreaLevelDao = *internal.StoreNetfeeAreaLevelDao
// storeNetfeeAreaLevelDao is the data access object for the table store_netfee_area_level.
// You can define custom methods on it to extend its functionality as needed.
type storeNetfeeAreaLevelDao struct {
internalStoreNetfeeAreaLevelDao
}
var (
// StoreNetfeeAreaLevel is a globally accessible object for table store_netfee_area_level operations.
StoreNetfeeAreaLevel = storeNetfeeAreaLevelDao{
internal.NewStoreNetfeeAreaLevelDao(),
}
)
// Add your custom methods and functionality below.

View File

@ -17,7 +17,6 @@ import (
_ "server/internal/logic/storeAdmin"
_ "server/internal/logic/storeDesktopSetting"
_ "server/internal/logic/storeRole"
_ "server/internal/logic/storeTaskReward"
_ "server/internal/logic/task"
_ "server/internal/logic/upload"
_ "server/internal/logic/user"

View File

@ -17,6 +17,7 @@ type sReward struct{}
func init() {
service.RegisterReward(New())
service.RegisterReward(New())
}
func New() service.IReward {
@ -77,10 +78,7 @@ func (s *sReward) Create(ctx context.Context, in *model.RewardCreateIn) (out *mo
id, err := dao.Rewards.Ctx(ctx).Data(do.Rewards{
RewardTypeId: in.RewardTypeId,
Name: in.Name,
Description: in.Description,
Source: in.Source,
StoreId: in.StoreId,
Value: in.Value,
Status: in.Status,
ValidFrom: in.ValidFrom,
ValidTo: in.ValidTo,
@ -98,7 +96,7 @@ func (s *sReward) Create(ctx context.Context, in *model.RewardCreateIn) (out *mo
func (s *sReward) Update(ctx context.Context, in *model.RewardUpdateIn) (out *model.RewardUpdateOut, err error) {
// 查询原始记录,确保存在,并获取 source 与 store_id 用于权限校验
data, err := dao.Rewards.Ctx(ctx).
Fields(dao.Rewards.Columns().Id, dao.Rewards.Columns().Source, dao.Rewards.Columns().StoreId).
Fields(dao.Rewards.Columns().Id, dao.Rewards.Columns().StoreId).
Where(do.Rewards{Id: in.Id}).One()
if err != nil {
return nil, ecode.Fail.Sub("查询奖励失败")
@ -107,11 +105,6 @@ func (s *sReward) Update(ctx context.Context, in *model.RewardUpdateIn) (out *mo
return nil, ecode.Params.Sub("奖励不存在")
}
// 系统奖励source=1只能由管理员修改
if data[dao.Rewards.Columns().Source].Int() == 1 && in.OperatorRole != consts.AdminRoleCode {
return nil, ecode.Params.Sub("只有管理员可以修改系统奖励")
}
storeId := data[dao.Rewards.Columns().StoreId].Int64()
// 权限校验(管理员跳过)
@ -162,8 +155,6 @@ func (s *sReward) Update(ctx context.Context, in *model.RewardUpdateIn) (out *mo
Where(do.Rewards{Id: in.Id}).
Data(do.Rewards{
Name: in.Name,
Description: in.Description,
Value: in.Value,
Status: in.Status,
ValidFrom: in.ValidFrom,
ValidTo: in.ValidTo,
@ -245,123 +236,13 @@ func (s *sReward) Delete(ctx context.Context, in *model.RewardDeleteIn) (out *mo
// List 奖励列表
func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error) {
var list []model.Reward
orm := dao.Rewards.Ctx(ctx)
rewardCols := dao.Rewards.Columns()
rewardTypeCols := dao.RewardTypes.Columns()
// ==== 权限校验 ====
switch in.OperatorRole {
case consts.AdminRoleCode:
// 系统管理员只能查询 source = 1 的奖励
orm = orm.Where(fmt.Sprintf("%s.%s = ?", dao.Rewards.Table(), rewardCols.Source), 1)
case consts.MerchantRoleCode, consts.StoreRoleCode:
// 合并商户和门店角色权限校验
var exist bool
if in.OperatorRole == consts.MerchantRoleCode {
exist, err = dao.MerchantAdmins.Ctx(ctx).
Where(do.MerchantAdmins{Id: in.OperatorId}).
LeftJoin(
dao.Stores.Table(),
fmt.Sprintf("%s.%s = %s.%s",
dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId,
dao.Stores.Table(), dao.Stores.Columns().MerchantId,
),
).
Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId).
Exist()
} else {
exist, err = dao.StoreAdmins.Ctx(ctx).
Where(do.StoreAdmins{Id: in.OperatorId}).
LeftJoin(
dao.Stores.Table(),
fmt.Sprintf("%s.%s = %s.%s",
dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId,
dao.Stores.Table(), dao.Stores.Columns().Id,
),
).
Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId).
Exist()
}
if err != nil {
return nil, ecode.Fail.Sub("检查操作者权限异常")
}
if !exist {
return nil, ecode.Params.Sub("无门店权限")
}
// 商户和门店角色查询 source = 1 或 (source = 2 且 store_id = in.StoreId)
orm = orm.Where(
fmt.Sprintf(
"(%s.%s = ? OR (%s.%s = ? AND %s.%s = ?))",
dao.Rewards.Table(), rewardCols.Source,
dao.Rewards.Table(), rewardCols.Source,
dao.Rewards.Table(), rewardCols.StoreId,
),
1, 2, in.StoreId,
)
default:
return nil, ecode.Params.Sub("无效的角色")
}
// ==== 其他查询条件 ====
if in.Status != 0 {
orm = orm.Where(fmt.Sprintf("%s.%s = ?", dao.Rewards.Table(), rewardCols.Status), in.Status)
}
if in.RewardTypeId != 0 {
// 确保 reward_type_id 过滤独立应用
orm = orm.Where(fmt.Sprintf("%s.%s = ?", dao.Rewards.Table(), rewardCols.RewardTypeId), in.RewardTypeId)
}
if in.Name != "" {
orm = orm.WhereLike(rewardCols.Name, "%"+in.Name+"%")
}
// ==== 总数统计 ====
total, err := orm.Count()
if err != nil {
return nil, err
}
// ==== 分页查询 + 联表字段 ====
err = orm.Page(in.Page, in.Size).
LeftJoin(
dao.RewardTypes.Table(),
fmt.Sprintf("%s.%s = %s.%s",
dao.Rewards.Table(), rewardCols.RewardTypeId,
dao.RewardTypes.Table(), rewardTypeCols.Id,
),
).
Fields(fmt.Sprintf(
"%s.*, %s.%s AS reward_type_name",
dao.Rewards.Table(),
dao.RewardTypes.Table(), rewardTypeCols.Name,
)).
OrderDesc(rewardCols.CreatedAt).
Scan(&list)
if err != nil {
return nil, err
}
return &model.RewardListOut{
List: list,
Total: total,
}, nil
return nil, nil
}
// GetLift 领取奖励
func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *model.GetRewardOut, err error) {
// 遍历奖励类型列表
//for _, v := range in.RewradTypeId {
// if v > 0 {
// // 发背包+兑换
//
// }
// if v > 0 {
// // 直接发背包
// }
//}
activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{PopenId: in.PopenId, ServiceName: consts.GetGift, GiftParam: model.GiftParam{
TaskId: in.TaskId,
AreaId: in.AreaId,

View File

@ -10,6 +10,8 @@ import (
"server/internal/model/do"
"server/internal/service"
"server/utility/ecode"
"github.com/gogf/gf/v2/os/gtime"
)
type sRewardType struct {
@ -25,328 +27,192 @@ func New() service.IRewardType {
// Create 创建奖励类型
func (s *sRewardType) Create(ctx context.Context, in *model.RewardTypeCreateIn) (out *model.RewardTypeCreateOut, err error) {
// 创建时source为1的奖励类型只能由管理员创建
// 商户和门店管理员创建奖励时需要判断是有拥有 storeId 的权限
// 检查 source=1 的奖励类型只能由管理员创建
if in.Source == 1 && in.OperatorRole != consts.AdminRoleCode {
return nil, ecode.Params.Sub("只有管理员可以创建 source=1 的奖励类型")
if err = checkRewardTypePermission(ctx, in.OperatorRole, in.OperatorId, in.Source, in.StoreId); err != nil {
return nil, err
}
// 根据角色和权限检查
switch in.OperatorRole {
case consts.MerchantRoleCode:
// 检查商户是否有该门店权限
exist, err := dao.MerchantAdmins.Ctx(ctx).LeftJoin(
dao.Stores.Table(),
fmt.Sprintf("%s.%s = %s.%s",
dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId,
dao.Stores.Table(), dao.Stores.Columns().MerchantId,
),
).Where(
fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId,
).Where(
do.MerchantAdmins{Id: in.OperatorId},
).Exist()
if err != nil {
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
}
if !exist {
return nil, ecode.Params.Sub("无门店权限")
}
case consts.StoreRoleCode:
// 检查门店是否有权限
exist, err := dao.StoreAdmins.Ctx(ctx).LeftJoin(
dao.Stores.Table(),
fmt.Sprintf("%s.%s = %s.%s",
dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId,
dao.Stores.Table(), dao.Stores.Columns().Id,
),
).Where(
fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId,
).Where(
do.StoreAdmins{Id: in.OperatorId},
).Exist()
if err != nil {
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
}
if !exist {
return nil, ecode.Params.Sub("无门店权限")
}
}
id, err := dao.RewardTypes.Ctx(ctx).Data(do.RewardTypes{
data := do.RewardTypes{
Name: in.Name,
Description: in.Description,
Source: in.Source,
StoreId: in.StoreId,
}).OmitEmptyData().InsertAndGetId()
TencentTypeId: in.TencentTypeId,
}
id, err := dao.RewardTypes.Ctx(ctx).OmitEmptyData().Data(data).InsertAndGetId()
if err != nil {
return nil, err
}
return &model.RewardTypeCreateOut{
Id: id,
}, nil
return &model.RewardTypeCreateOut{Id: id}, nil
}
// Update 更新奖励类型
func (s *sRewardType) Update(ctx context.Context, in *model.RewardTypeUpdateIn) (out *model.RewardTypeUpdateOut, err error) {
// 查询原始记录,确保存在,并获取 store_id 和 source 字段用于权限判断
value, err := dao.RewardTypes.Ctx(ctx).
Fields(dao.RewardTypes.Columns().Id, dao.RewardTypes.Columns().Source, dao.RewardTypes.Columns().StoreId).
Where(do.RewardTypes{Id: in.Id}).One()
info, err := dao.RewardTypes.Ctx(ctx).WherePri(in.Id).One()
if err != nil {
return nil, ecode.Fail.Sub("查询奖励类型失败")
return nil, err
}
if value.IsEmpty() {
if info == nil {
return nil, ecode.Params.Sub("奖励类型不存在")
}
// source=1 的奖励类型只能由管理员修改
source := info["source"].Int()
storeId := info["store_id"].Int64()
if value[dao.RewardTypes.Columns().Source].Int() == 1 && in.OperatorRole != consts.AdminRoleCode {
return nil, ecode.Params.Sub("只有管理员可以修改的系统奖励类型")
if err = checkRewardTypePermission(ctx, in.OperatorRole, in.OperatorId, source, storeId); err != nil {
return nil, err
}
// 权限校验(管理员跳过)
switch in.OperatorRole {
case consts.MerchantRoleCode:
exist, err := dao.MerchantAdmins.Ctx(ctx).LeftJoin(
dao.Stores.Table(),
fmt.Sprintf("%s.%s = %s.%s",
dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId,
dao.Stores.Table(), dao.Stores.Columns().MerchantId,
),
).Where(
fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), value[dao.RewardTypes.Columns().StoreId].Int(),
).Where(
do.MerchantAdmins{Id: in.OperatorId},
).Exist()
updateData := g.Map{}
if in.Name != "" {
updateData["name"] = in.Name
}
if len(updateData) == 0 {
return nil, ecode.Params.Sub("无可更新字段")
}
_, err = dao.RewardTypes.Ctx(ctx).WherePri(in.Id).Data(updateData).Update()
if err != nil {
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
}
if !exist {
return nil, ecode.Params.Sub("无门店权限")
return nil, err
}
case consts.StoreRoleCode:
exist, err := dao.StoreAdmins.Ctx(ctx).LeftJoin(
dao.Stores.Table(),
fmt.Sprintf("%s.%s = %s.%s",
dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId,
dao.Stores.Table(), dao.Stores.Columns().Id,
),
).Where(
fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), value[dao.RewardTypes.Columns().StoreId].Int(),
).Where(
do.StoreAdmins{Id: in.OperatorId},
).Exist()
if err != nil {
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
}
if !exist {
return nil, ecode.Params.Sub("无门店权限")
}
return &model.RewardTypeUpdateOut{Success: true}, nil
}
// 执行更新(不允许更新 store_id 和 source
_, err = dao.RewardTypes.Ctx(ctx).
Where(do.RewardTypes{Id: in.Id}).
Data(do.RewardTypes{
Name: in.Name,
Description: in.Description,
Status: in.Status,
}).OmitEmptyData().
Update()
if err != nil {
return nil, ecode.Fail.Sub("更新奖励类型失败")
}
return &model.RewardTypeUpdateOut{
Success: true,
}, nil
}
// Delete 删除奖励类型
// Delete 删除奖励类型(逻辑删除
func (s *sRewardType) Delete(ctx context.Context, in *model.RewardTypeDeleteIn) (out *model.RewardTypeDeleteOut, err error) {
// 查询原始记录,确保存在,并获取 store_id 和 source 字段用于权限判断
value, err := dao.RewardTypes.Ctx(ctx).
Fields(dao.RewardTypes.Columns().Id, dao.RewardTypes.Columns().Source, dao.RewardTypes.Columns().StoreId).
Where(do.RewardTypes{Id: in.Id}).
One()
info, err := dao.RewardTypes.Ctx(ctx).WherePri(in.Id).One()
if err != nil {
return nil, ecode.Fail.Sub("查询奖励类型失败")
return nil, err
}
if value.IsEmpty() {
if info.IsEmpty() {
return nil, ecode.Params.Sub("奖励类型不存在")
}
// source=1 的奖励类型只能由管理员删除
if value[dao.RewardTypes.Columns().Source].Int() == 1 && in.OperatorRole != consts.AdminRoleCode {
return nil, ecode.Params.Sub("只有管理员可以删除的系统奖励类型")
source := info["source"].Int()
storeId := info["store_id"].Int64()
if err = checkRewardTypePermission(ctx, in.OperatorRole, in.OperatorId, source, storeId); err != nil {
return nil, err
}
// 权限校验(管理员跳过)
switch in.OperatorRole {
case consts.MerchantRoleCode:
exist, err := dao.MerchantAdmins.Ctx(ctx).LeftJoin(
dao.Stores.Table(),
fmt.Sprintf("%s.%s = %s.%s",
dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId,
dao.Stores.Table(), dao.Stores.Columns().MerchantId,
),
).Where(
fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id),
value[dao.RewardTypes.Columns().StoreId].Int(),
).Where(
do.MerchantAdmins{Id: in.OperatorId},
).Exist()
_, err = dao.RewardTypes.Ctx(ctx).WherePri(in.Id).Data(g.Map{
"deleted_at": gtime.Now(),
}).Update()
if err != nil {
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
}
if !exist {
return nil, ecode.Params.Sub("无门店权限")
return nil, err
}
case consts.StoreRoleCode:
exist, err := dao.StoreAdmins.Ctx(ctx).LeftJoin(
dao.Stores.Table(),
fmt.Sprintf("%s.%s = %s.%s",
dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId,
dao.Stores.Table(), dao.Stores.Columns().Id,
),
).Where(
fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id),
value[dao.RewardTypes.Columns().StoreId].Int(),
).Where(
do.StoreAdmins{Id: in.OperatorId},
).Exist()
if err != nil {
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
}
if !exist {
return nil, ecode.Params.Sub("无门店权限")
}
return &model.RewardTypeDeleteOut{Success: true}, nil
}
// 执行删除(软删除
_, err = dao.RewardTypes.Ctx(ctx).Where(do.RewardTypes{Id: in.Id}).Delete()
if err != nil {
return nil, ecode.Fail.Sub("删除奖励类型失败")
}
return &model.RewardTypeDeleteOut{
Success: true,
}, nil
}
// List 获取奖励类型列表
// List 获取奖励类型列表(支持分页、过滤
func (s *sRewardType) List(ctx context.Context, in *model.RewardTypeListIn) (out *model.RewardTypeListOut, err error) {
list := make([]model.RewardType, 0)
orm := dao.RewardTypes.Ctx(ctx)
mod := dao.RewardTypes.Ctx(ctx).Where("deleted_at IS NULL")
// 根据角色和权限构建查询条件
switch in.OperatorRole {
case consts.MerchantRoleCode:
// 检查商户是否有该门店权限
exist, err := dao.MerchantAdmins.Ctx(ctx).Where(do.MerchantAdmins{Id: in.OperatorId}).LeftJoin(
dao.Stores.Table(),
fmt.Sprintf(
"%s.%s = %s.%s",
dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId,
dao.Stores.Table(), dao.Stores.Columns().MerchantId,
),
).Where(
fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id),
in.StoreId,
).Exist()
if err != nil {
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
}
if !exist {
return nil, ecode.Params.Sub("无门店权限")
}
case consts.AdminRoleCode:
// 系统管理员只能看系统奖励类型
mod = mod.Where("source", 1)
// 追加限制source = 1 或 store_id = 当前门店
orm = orm.Where(
fmt.Sprintf("%s.%s = ?", dao.RewardTypes.Table(), dao.RewardTypes.Columns().Source),
1,
).WhereOr(
fmt.Sprintf("%s.%s IN (?)", dao.RewardTypes.Table(), dao.RewardTypes.Columns().StoreId),
g.Slice{in.StoreId},
)
case consts.MerchantRoleCode:
// 校验商户是否对该门店有权限
if err = checkRewardTypePermission(ctx, in.OperatorRole, in.OperatorId, 2, in.StoreId); err != nil {
return nil, err
}
// 只查询该门店的奖励类型source=2且store_id=指定门店)
mod = mod.Where("source", 2).WhereIn("store_id", in.StoreId)
case consts.StoreRoleCode:
// 检查门店是否有权限
exist, err := dao.StoreAdmins.Ctx(ctx).
Where(do.StoreAdmins{Id: in.OperatorId}).
// 校验门店权限
if err = checkRewardTypePermission(ctx, in.OperatorRole, in.OperatorId, 2, in.StoreId); err != nil {
return nil, err
}
mod = mod.Where("source", 2).Where("store_id", in.StoreId)
default:
return nil, ecode.Params.Sub("无效的操作角色")
}
// 其余过滤条件
if in.Name != "" {
mod = mod.WhereLike("name", "%"+in.Name+"%")
}
if in.Source > 0 {
mod = mod.Where("source", in.Source)
}
count, err := mod.Count()
if err != nil {
return nil, err
}
records, err := mod.Page(in.Page, in.Size).Order("id DESC").All()
if err != nil {
return nil, err
}
var list []model.RewardType
if err = records.Structs(&list); err != nil {
return nil, err
}
out = &model.RewardTypeListOut{
Total: count,
List: list,
}
return
}
func checkRewardTypePermission(ctx context.Context, role string, operatorId int64, source int, storeId int64) error {
switch role {
case consts.AdminRoleCode:
if source != 1 {
return ecode.Params.Sub("系统管理员只能操作系统奖励类型")
}
case consts.MerchantRoleCode:
exist, err := dao.MerchantAdmins.Ctx(ctx).
LeftJoin(
dao.Stores.Table(),
fmt.Sprintf(
"%s.%s = %s.%s",
dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId,
dao.Stores.Table(), dao.Stores.Columns().Id,
),
fmt.Sprintf("%s.%s = %s.%s",
dao.Stores.Table(), dao.Stores.Columns().MerchantId,
dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId),
).
Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId).
Where(fmt.Sprintf("%s.%s = ?", dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().Id), operatorId).
Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), storeId).
Exist()
if err != nil {
return nil, ecode.Fail.Sub("检查操作者权限出现异常")
return ecode.Fail.Sub("检查商户权限异常")
}
if !exist {
return nil, ecode.Params.Sub("无门店权限")
return ecode.Params.Sub("无门店权限")
}
// 追加限制source = 1 或 store_id = 当前门店
orm = orm.Where(
fmt.Sprintf("%s.%s = ?", dao.RewardTypes.Table(), dao.RewardTypes.Columns().Source),
1,
).WhereOr(
fmt.Sprintf("%s.%s IN (?)", dao.RewardTypes.Table(), dao.RewardTypes.Columns().StoreId),
g.Slice{in.StoreId},
)
if source != 2 {
return ecode.Params.Sub("商户只能操作本系统奖励类型")
}
// 其他筛选
if in.Status != 0 {
orm = orm.Where(
fmt.Sprintf("%s.%s = ?", dao.RewardTypes.Table(), dao.RewardTypes.Columns().Status),
in.Status,
)
}
if in.Name != "" {
orm = orm.WhereLike(
fmt.Sprintf("%s.%s", dao.RewardTypes.Table(), dao.RewardTypes.Columns().Name),
"%"+in.Name+"%",
)
}
// 查询总数
count, err := orm.Count()
case consts.StoreRoleCode:
exist, err := dao.StoreAdmins.Ctx(ctx).
LeftJoin(
dao.Stores.Table(),
fmt.Sprintf("%s.%s = %s.%s",
dao.Stores.Table(), dao.Stores.Columns().Id,
dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId),
).
Where(fmt.Sprintf("%s.%s = ?", dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().Id), operatorId).
Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), storeId).
Exist()
if err != nil {
return nil, err
return ecode.Fail.Sub("检查门店权限异常")
}
if in.OperatorRole == consts.AdminRoleCode {
orm = orm.LeftJoin(dao.Stores.Table(), fmt.Sprintf(
"%s.%s = %s.%s",
dao.RewardTypes.Table(), dao.RewardTypes.Columns().StoreId,
dao.Stores.Table(), dao.Stores.Columns().Id),
).Fields(fmt.Sprintf("%s.*, %s.%s %s",
dao.RewardTypes.Table(), dao.Stores.Table(), dao.Stores.Columns().Name, "storeName"))
if !exist {
return ecode.Params.Sub("无门店权限")
}
// 查询分页数据
err = orm.Page(in.Page, in.Size).
OrderAsc(fmt.Sprintf("%s.%s", dao.RewardTypes.Table(), dao.RewardTypes.Columns().Source)).
Scan(&list)
if err != nil {
return nil, err
if source != 2 {
return ecode.Params.Sub("门店只能操作本系统奖励类型")
}
return &model.RewardTypeListOut{
List: list,
Total: count,
}, nil
default:
return ecode.Params.Sub("无效的操作角色")
}
return nil
}

View File

@ -1,142 +0,0 @@
package storeTaskReward
import (
"context"
"fmt"
"server/internal/consts"
"server/internal/dao"
"server/internal/model"
"server/internal/model/do"
"server/internal/service"
"server/utility/ecode"
)
type sStoreTaskReward struct {
}
func New() service.IStoreTaskReward {
return &sStoreTaskReward{}
}
func init() {
service.RegisterStoreTaskReward(New())
}
func (s *sStoreTaskReward) Create(ctx context.Context, in *model.StoreTaskRewardCreateIn) (out *model.StoreTaskRewardCreateOut, err error) {
if in.OperatorRole != consts.MerchantRoleCode && in.OperatorRole != consts.StoreRoleCode {
return nil, ecode.Params.Sub("仅允许商户或门店角色操作")
}
// 检查操作者是否有该门店的操作权限
switch in.OperatorRole {
case consts.MerchantRoleCode:
exist, err := dao.MerchantAdmins.Ctx(ctx).
Where(do.MerchantAdmins{Id: in.OperatorId}).
LeftJoin(
dao.Stores.Table(),
fmt.Sprintf(
"%s.%s = %s.%s",
dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId,
dao.Stores.Table(), dao.Stores.Columns().MerchantId,
),
).
Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId).
Exist()
if err != nil {
return nil, ecode.Fail.Sub("校验商户权限失败")
}
if !exist {
return nil, ecode.Params.Sub("商户无操作该门店权限")
}
case consts.StoreRoleCode:
exist, err := dao.StoreAdmins.Ctx(ctx).
Where(do.StoreAdmins{Id: in.OperatorId}).
LeftJoin(
dao.Stores.Table(),
fmt.Sprintf(
"%s.%s = %s.%s",
dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId,
dao.Stores.Table(), dao.Stores.Columns().Id,
),
).
Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId).
Exist()
if err != nil {
return nil, ecode.Fail.Sub("校验门店权限失败")
}
if !exist {
return nil, ecode.Params.Sub("门店管理员无权限")
}
}
id, err := dao.StoreTaskRewards.Ctx(ctx).Data(do.StoreTaskRewards{
StoreId: in.StoreId,
TaskId: in.TaskId,
RewardId: in.RewardId,
}).InsertAndGetId()
if err != nil {
return nil, ecode.Fail.Sub("创建门店任务奖励失败, err:" + err.Error())
}
return &model.StoreTaskRewardCreateOut{Id: id}, nil
}
func (s *sStoreTaskReward) Delete(ctx context.Context, in *model.StoreTaskRewardDeleteIn) (out *model.StoreTaskRewardDeleteOut, err error) {
if in.OperatorRole != consts.MerchantRoleCode && in.OperatorRole != consts.StoreRoleCode {
return nil, ecode.Params.Sub("仅允许商户或门店角色操作")
}
// 检查操作者是否有该门店的操作权限
value, err := dao.StoreTaskRewards.Ctx(ctx).WherePri(in.Id).Fields(dao.StoreTaskRewards.Columns().StoreId).Value()
if err != nil {
return nil, ecode.Fail.Sub("查询门店任务奖励失败, err:" + err.Error())
}
if value.IsEmpty() {
return nil, ecode.Params.Sub("门店任务奖励不存在")
}
switch in.OperatorRole {
case consts.MerchantRoleCode:
exist, err := dao.MerchantAdmins.Ctx(ctx).
Where(do.MerchantAdmins{Id: in.OperatorId}).
LeftJoin(
dao.Stores.Table(),
fmt.Sprintf(
"%s.%s = %s.%s",
dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId,
dao.Stores.Table(), dao.Stores.Columns().MerchantId,
),
).
Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), value.Int64()).
Exist()
if err != nil {
return nil, ecode.Fail.Sub("校验商户权限失败")
}
if !exist {
return nil, ecode.Params.Sub("商户无操作该门店权限")
}
case consts.StoreRoleCode:
exist, err := dao.StoreAdmins.Ctx(ctx).
Where(do.StoreAdmins{Id: in.OperatorId}).
LeftJoin(
dao.Stores.Table(),
fmt.Sprintf(
"%s.%s = %s.%s",
dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId,
dao.Stores.Table(), dao.Stores.Columns().Id,
),
).
Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), value.Int64()).
Exist()
if err != nil {
return nil, ecode.Fail.Sub("校验门店权限失败")
}
if !exist {
return nil, ecode.Params.Sub("门店管理员无权限")
}
}
_, err = dao.StoreTaskRewards.Ctx(ctx).WherePri(in.Id).Delete()
if err != nil {
return nil, ecode.Fail.Sub("删除门店任务奖励失败")
}
return &model.StoreTaskRewardDeleteOut{Success: true}, nil
}

View File

@ -13,12 +13,11 @@ import (
type RewardTypes struct {
g.Meta `orm:"table:reward_types, do:true"`
Id interface{} // 奖励类型ID
Name interface{} // 奖励类型名称(如积分、优惠券)
Description interface{} // 奖励类型描述
Source interface{} // 来源1=系统默认2=门店自定义
StoreId interface{} // 门店ID系统默认类型为NULL
Status interface{} // 状态1=正常2=禁用
Name interface{} // 类型名称
TencentTypeId interface{} // 腾讯奖励类型ID仅系统奖励有效
Source interface{} // 奖励来源1=腾讯系统2=本系统3=其他
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 软删除时间
DeletedAt *gtime.Time // 软删除时间
StoreId interface{} // 门店 id
}

View File

@ -13,20 +13,25 @@ import (
type Rewards struct {
g.Meta `orm:"table:rewards, do:true"`
Id interface{} // 奖励ID
RewardTypeId interface{} // 奖励类型ID
Name interface{} // 奖励名称如100积分、5元优惠券
Description interface{} // 奖励描述
Source interface{} // 来源1=系统内置2=门店自定义
StoreId interface{} // 门店ID系统内置奖励为NULL
Value interface{} // 奖励值(如积分数额、优惠金额)
Status interface{} // 状态1=正常2=禁用
StoreId interface{} // 门店ID系统奖励为NULL
Name interface{} // 奖励名称
RewardTypeId interface{} // 奖励类型ID关联 reward_types 表
GameId interface{} // 游戏ID
ImageUrl interface{} // 奖励图片链接
QqGoodsId interface{} // QQ网吧物品ID
QqGoodsIdStr interface{} // QQ网吧物品ID字符串
Status interface{} // 状态1=启用2=禁用
ExpireType interface{} // 过期方式1=时间段过期2=领取后过期
ValidFrom *gtime.Time // 有效期开始时间expire_type=1时
ValidTo *gtime.Time // 有效期结束时间expire_type=1时
ExpireDays interface{} // 领取后多少天过期expire_type=2时
DailyTotalLimit interface{} // 每日发放总限NULL表示不限制
TotalLimit interface{} // 奖励总限NULL表示不限制
UserDailyLimit interface{} // 用户每日领取限制NULL表示不限制
UserTotalLimit interface{} // 用户领取总次数限制NULL表示不限制
ReceivedNum interface{} // 已领取数量
GrantQuantity interface{} // 每次发放个数
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 删除时间
TotalNum interface{} // 奖励总数量NULL表示不限量
UsedNum interface{} // 已使用数量
ExpireType interface{} // 过期类型1=时间段过期2=领取后多少天过期
ValidFrom *gtime.Time // 有效开始时间expire_type=1 时使用)
ValidTo *gtime.Time // 有效结束时间expire_type=1 时使用)
ExpireDays interface{} // 领取后多少天过期expire_type=2 时使用)
DeletedAt *gtime.Time // 删除时间(软删除)
}

View File

@ -0,0 +1,26 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// StoreNetfeeAreaLevel is the golang structure of table store_netfee_area_level for DAO operations like Where/Data.
type StoreNetfeeAreaLevel struct {
g.Meta `orm:"table:store_netfee_area_level, do:true"`
Id interface{} // 主键ID
StoreId interface{} // 门店ID
RewardId interface{} // 奖励IDrewards表主键
AreaId interface{} // 区域ID外部系统
AreaName interface{} // 区域名称
MemberLevelId interface{} // 会员等级ID外部系统
MemberLevelName interface{} // 会员等级名称
PriceData interface{} // 7x24价格矩阵
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 删除时间
}

View File

@ -11,12 +11,11 @@ import (
// RewardTypes is the golang structure for table reward_types.
type RewardTypes struct {
Id int64 `json:"id" orm:"id" description:"奖励类型ID"` // 奖励类型ID
Name string `json:"name" orm:"name" description:"奖励类型名称(如积分、优惠券)"` // 奖励类型名称(如积分、优惠券)
Description string `json:"description" orm:"description" description:"奖励类型描述"` // 奖励类型描述
Source int `json:"source" orm:"source" description:"来源1=系统默认2=门店自定义"` // 来源1=系统默认2=门店自定义
StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID系统默认类型为NULL"` // 门店ID系统默认类型为NULL
Status int `json:"status" orm:"status" description:"状态1=正常2=禁用"` // 状态1=正常2=禁用
Name string `json:"name" orm:"name" description:"类型名称"` // 类型名称
TencentTypeId int `json:"tencentTypeId" orm:"tencent_type_id" description:"腾讯奖励类型ID仅系统奖励有效"` // 腾讯奖励类型ID仅系统奖励有效
Source int `json:"source" orm:"source" description:"奖励来源1=腾讯系统2=本系统3=其他"` // 奖励来源1=腾讯系统2=本系统3=其他
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id
}

View File

@ -11,20 +11,25 @@ import (
// Rewards is the golang structure for table rewards.
type Rewards struct {
Id int64 `json:"id" orm:"id" description:"奖励ID"` // 奖励ID
RewardTypeId int64 `json:"rewardTypeId" orm:"reward_type_id" description:"奖励类型ID"` // 奖励类型ID
Name string `json:"name" orm:"name" description:"奖励名称如100积分、5元优惠券"` // 奖励名称如100积分、5元优惠券
Description string `json:"description" orm:"description" description:"奖励描述"` // 奖励描述
Source int `json:"source" orm:"source" description:"来源1=系统内置2=门店自定义"` // 来源1=系统内置2=门店自定义
StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID系统内置奖励为NULL"` // 门店ID系统内置奖励为NULL
Value uint64 `json:"value" orm:"value" description:"奖励值(如积分数额、优惠金额)"` // 奖励值(如积分数额、优惠金额)
Status int `json:"status" orm:"status" description:"状态1=正常2=禁用"` // 状态1=正常2=禁用
StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID系统奖励为NULL"` // 门店ID系统奖励为NULL
Name string `json:"name" orm:"name" description:"奖励名称"` // 奖励名称
RewardTypeId int64 `json:"rewardTypeId" orm:"reward_type_id" description:"奖励类型ID关联 reward_types 表"` // 奖励类型ID关联 reward_types 表
GameId int64 `json:"gameId" orm:"game_id" description:"游戏ID"` // 游戏ID
ImageUrl string `json:"imageUrl" orm:"image_url" description:"奖励图片链接"` // 奖励图片链接
QqGoodsId string `json:"qqGoodsId" orm:"qq_goods_id" description:"QQ网吧物品ID"` // QQ网吧物品ID
QqGoodsIdStr string `json:"qqGoodsIdStr" orm:"qq_goods_id_str" description:"QQ网吧物品ID字符串"` // QQ网吧物品ID字符串
Status int `json:"status" orm:"status" description:"状态1=启用2=禁用"` // 状态1=启用2=禁用
ExpireType int `json:"expireType" orm:"expire_type" description:"过期方式1=时间段过期2=领取后过期"` // 过期方式1=时间段过期2=领取后过期
ValidFrom *gtime.Time `json:"validFrom" orm:"valid_from" description:"有效期开始时间expire_type=1时"` // 有效期开始时间expire_type=1时
ValidTo *gtime.Time `json:"validTo" orm:"valid_to" description:"有效期结束时间expire_type=1时"` // 有效期结束时间expire_type=1时
ExpireDays int `json:"expireDays" orm:"expire_days" description:"领取后多少天过期expire_type=2时"` // 领取后多少天过期expire_type=2时
DailyTotalLimit uint64 `json:"dailyTotalLimit" orm:"daily_total_limit" description:"每日发放总限NULL表示不限制"` // 每日发放总限NULL表示不限制
TotalLimit uint64 `json:"totalLimit" orm:"total_limit" description:"奖励总限NULL表示不限制"` // 奖励总限NULL表示不限制
UserDailyLimit uint64 `json:"userDailyLimit" orm:"user_daily_limit" description:"用户每日领取限制NULL表示不限制"` // 用户每日领取限制NULL表示不限制
UserTotalLimit uint64 `json:"userTotalLimit" orm:"user_total_limit" description:"用户领取总次数限制NULL表示不限制"` // 用户领取总次数限制NULL表示不限制
ReceivedNum uint64 `json:"receivedNum" orm:"received_num" description:"已领取数量"` // 已领取数量
GrantQuantity uint64 `json:"grantQuantity" orm:"grant_quantity" description:"每次发放个数"` // 每次发放个数
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"删除时间"` // 删除时间
TotalNum uint64 `json:"totalNum" orm:"total_num" description:"奖励总数量NULL表示不限量"` // 奖励总数量NULL表示不限量
UsedNum uint64 `json:"usedNum" orm:"used_num" description:"已使用数量"` // 已使用数量
ExpireType int `json:"expireType" orm:"expire_type" description:"过期类型1=时间段过期2=领取后多少天过期"` // 过期类型1=时间段过期2=领取后多少天过期
ValidFrom *gtime.Time `json:"validFrom" orm:"valid_from" description:"有效开始时间expire_type=1 时使用)"` // 有效开始时间expire_type=1 时使用)
ValidTo *gtime.Time `json:"validTo" orm:"valid_to" description:"有效结束时间expire_type=1 时使用)"` // 有效结束时间expire_type=1 时使用)
ExpireDays int `json:"expireDays" orm:"expire_days" description:"领取后多少天过期expire_type=2 时使用)"` // 领取后多少天过期expire_type=2 时使用)
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"删除时间(软删除)"` // 删除时间(软删除)
}

View File

@ -0,0 +1,24 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// StoreNetfeeAreaLevel is the golang structure for table store_netfee_area_level.
type StoreNetfeeAreaLevel struct {
Id int64 `json:"id" orm:"id" description:"主键ID"` // 主键ID
StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID"` // 门店ID
RewardId int64 `json:"rewardId" orm:"reward_id" description:"奖励IDrewards表主键"` // 奖励IDrewards表主键
AreaId int64 `json:"areaId" orm:"area_id" description:"区域ID外部系统"` // 区域ID外部系统
AreaName string `json:"areaName" orm:"area_name" description:"区域名称"` // 区域名称
MemberLevelId int64 `json:"memberLevelId" orm:"member_level_id" description:"会员等级ID外部系统"` // 会员等级ID外部系统
MemberLevelName string `json:"memberLevelName" orm:"member_level_name" description:"会员等级名称"` // 会员等级名称
PriceData string `json:"priceData" orm:"price_data" description:"7x24价格矩阵"` // 7x24价格矩阵
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"删除时间"` // 删除时间
}

View File

@ -6,16 +6,13 @@ import (
// RewardType 奖励类型表
type RewardType struct {
Id int64 `json:"id" dc:"奖励类型ID" orm:"id,primary"`
Name string `json:"name" dc:"奖励类型名称(如积分、优惠券)" orm:"name"`
Description string `json:"description" dc:"奖励类型描述" orm:"description"`
Source int `json:"source" dc:"来源1=系统默认2=门店自定义" orm:"source"`
StoreId int64 `json:"storeId" dc:"门店ID系统默认类型为NULL" orm:"store_id"`
Status int `json:"status" dc:"状态1=正常2=禁用" orm:"status"`
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间" orm:"created_at"`
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间" orm:"updated_at"`
DeletedAt *gtime.Time `json:"deletedAt" dc:"软删除时间戳" orm:"deleted_at"`
StoreName string `json:"storeName" dc:"门店名称" orm:"storeName"`
Id int64 `json:"id" dc:"奖励类型ID"`
Name string `json:"name" dc:"奖励类型名称(如积分、优惠券)"`
TencentTypeId int `json:"tencentTypeId" dc:"腾讯奖励类型ID仅系统奖励有效"`
Source int `json:"source" dc:"来源1=腾讯系统2=本系统3=其他"`
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
DeletedAt *gtime.Time `json:"deletedAt" dc:"软删除时间戳"`
}
// RewardTypeCreateIn 创建奖励类型入参
@ -23,10 +20,9 @@ type RewardTypeCreateIn struct {
OperatorId int64
OperatorRole string
Name string
Description string
TencentTypeId int
Source int
StoreId int64
Status int
}
// RewardTypeCreateOut 创建奖励类型出参
@ -40,9 +36,8 @@ type RewardTypeUpdateIn struct {
OperatorRole string
Id int64
Name string
Description string
TencentTypeId int
StoreId int64
Status int
}
// RewardTypeUpdateOut 更新奖励类型出参
@ -71,6 +66,7 @@ type RewardTypeListIn struct {
Name string
StoreId int64
Status int
Source int
}
// RewardTypeListOut 获取奖励类型列表出参

View File

@ -1,33 +0,0 @@
// ================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
"server/internal/model"
)
type (
IStoreTaskReward interface {
Create(ctx context.Context, in *model.StoreTaskRewardCreateIn) (out *model.StoreTaskRewardCreateOut, err error)
Delete(ctx context.Context, in *model.StoreTaskRewardDeleteIn) (out *model.StoreTaskRewardDeleteOut, err error)
}
)
var (
localStoreTaskReward IStoreTaskReward
)
func StoreTaskReward() IStoreTaskReward {
if localStoreTaskReward == nil {
panic("implement not found for interface IStoreTaskReward, forgot register?")
}
return localStoreTaskReward
}
func RegisterStoreTaskReward(i IStoreTaskReward) {
localStoreTaskReward = i
}