Files
junhong_cmp_fiber/internal/model/shop_series_allocation.go
huang d81bd242a4
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m19s
fix(force-recharge): 补充强充配置缺失的接口和数据库字段
- 订单管理:增加 payment_method 字段支持,合并代购订单逻辑
- 套餐系列分配:增加强充配置字段(enable_force_recharge、force_recharge_amount、force_recharge_trigger_type)
- 数据库迁移:添加 force_recharge_trigger_type 字段
- 测试:更新订单服务测试用例
- OpenSpec:归档 fix-force-recharge-missing-interfaces 变更
2026-01-31 15:34:32 +08:00

63 lines
3.7 KiB
Go

package model
import (
"gorm.io/gorm"
)
// ShopSeriesAllocation 店铺套餐系列分配模型
// 记录上级店铺为下级店铺分配的套餐系列,包含基础返佣配置和梯度返佣开关
// 分配者只能分配自己已被分配的套餐系列,且只能分配给直属下级
type ShopSeriesAllocation struct {
gorm.Model
BaseModel `gorm:"embedded"`
ShopID uint `gorm:"column:shop_id;index;not null;comment:被分配的店铺ID" json:"shop_id"`
SeriesID uint `gorm:"column:series_id;index;not null;comment:套餐系列ID" json:"series_id"`
AllocatorShopID uint `gorm:"column:allocator_shop_id;index;not null;comment:分配者店铺ID(上级)" json:"allocator_shop_id"`
BaseCommissionMode string `gorm:"column:base_commission_mode;type:varchar(20);not null;default:percent;comment:基础返佣模式 fixed-固定金额 percent-百分比" json:"base_commission_mode"`
BaseCommissionValue int64 `gorm:"column:base_commission_value;type:bigint;not null;default:0;comment:基础返佣值(分或千分比,如200=20%)" json:"base_commission_value"`
// 一次性佣金配置
EnableOneTimeCommission bool `gorm:"column:enable_one_time_commission;type:boolean;not null;default:false;comment:是否启用一次性佣金" json:"enable_one_time_commission"`
OneTimeCommissionType string `gorm:"column:one_time_commission_type;type:varchar(20);comment:一次性佣金类型 fixed-固定 tiered-梯度" json:"one_time_commission_type"`
OneTimeCommissionTrigger string `gorm:"column:one_time_commission_trigger;type:varchar(30);comment:触发条件 single_recharge-单次充值 accumulated_recharge-累计充值" json:"one_time_commission_trigger"`
OneTimeCommissionThreshold int64 `gorm:"column:one_time_commission_threshold;type:bigint;default:0;comment:最低阈值(分)" json:"one_time_commission_threshold"`
OneTimeCommissionMode string `gorm:"column:one_time_commission_mode;type:varchar(20);comment:返佣模式 fixed-固定金额 percent-百分比" json:"one_time_commission_mode"`
OneTimeCommissionValue int64 `gorm:"column:one_time_commission_value;type:bigint;default:0;comment:佣金金额(分)或比例(千分比)" json:"one_time_commission_value"`
// 强充配置
EnableForceRecharge bool `gorm:"column:enable_force_recharge;type:boolean;default:false;comment:是否启用强充(累计充值时可选)" json:"enable_force_recharge"`
ForceRechargeAmount int64 `gorm:"column:force_recharge_amount;type:bigint;default:0;comment:强充金额(分,0表示使用阈值金额)" json:"force_recharge_amount"`
ForceRechargeTriggerType int `gorm:"column:force_recharge_trigger_type;type:int;default:2;comment:强充触发类型(1:单次充值, 2:累计充值)" json:"force_recharge_trigger_type"`
Status int `gorm:"column:status;type:int;default:1;not null;comment:状态 1-启用 2-禁用" json:"status"`
}
// TableName 指定表名
func (ShopSeriesAllocation) TableName() string {
return "tb_shop_series_allocation"
}
// 返佣模式常量
const (
// CommissionModeFixed 固定金额返佣
CommissionModeFixed = "fixed"
// CommissionModePercent 百分比返佣(千分比)
CommissionModePercent = "percent"
)
// 一次性佣金类型常量
const (
// OneTimeCommissionTypeFixed 固定一次性佣金
OneTimeCommissionTypeFixed = "fixed"
// OneTimeCommissionTypeTiered 梯度一次性佣金
OneTimeCommissionTypeTiered = "tiered"
)
// 一次性佣金触发类型常量
const (
// OneTimeCommissionTriggerSingleRecharge 单次充值触发
OneTimeCommissionTriggerSingleRecharge = "single_recharge"
// OneTimeCommissionTriggerAccumulatedRecharge 累计充值触发
OneTimeCommissionTriggerAccumulatedRecharge = "accumulated_recharge"
)