| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package tables
-
- import (
- "time"
-
- "git.x2erp.com/qdy/go-db/sqldef"
- )
-
- func init() {
- sqldef.AddRegistration(func(r *sqldef.Registry) {
- tb := sqldef.NewTable("dim_discount_rule", "折扣决策规则表").
- ID("rule_id", 32).Comment("规则ID,主键").End().
- String("category_id", 32).NotNull().Comment("品类ID").End().
- Int("season_month").NotNull().Comment("季节月份(3,5,7,9,11等)").End().
- Int("target_inventory_age").NotNull().Comment("目标库龄(天)").End().
- Int("recommended_discount").NotNull().Comment("推荐折扣(如70表示7折)").End().
- Int("expected_consumption").NotNull().Comment("预期消耗率(%)").End().
- Int("confidence_score").NotNull().Comment("置信度(%)").End().
- Date("effective_date").NotNull().Comment("生效日期").End().
- Date("expired_date").Comment("失效日期").End().
- Date("last_apply_date").Comment("最近应用日期").End().
- String("creator", 32).NotNull().Comment("创建人").End().
- DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
-
- // 索引
- //tb.Index("idx_category_season", "category_id", "season_month").End().
- // Index("idx_effective", "effective_date", "expired_date").End()
-
- r.RegisterTable(tb.Build())
- })
- }
-
- type DimDiscountRule struct {
- RuleID string `gorm:"column:rule_id;type:varchar(32);primaryKey;not null;comment:规则ID,主键"`
- CategoryID string `gorm:"column:category_id;type:varchar(32);not null;comment:品类ID"`
- SeasonMonth int `gorm:"column:season_month;type:int(2);not null;comment:季节月份"`
- TargetInventoryAge int `gorm:"column:target_inventory_age;type:int(4);not null;comment:目标库龄"`
- RecommendedDiscount int `gorm:"column:recommended_discount;type:int(3);not null;comment:推荐折扣"`
- ExpectedConsumption int `gorm:"column:expected_consumption;type:int(3);not null;comment:预期消耗率"`
- ConfidenceScore int `gorm:"column:confidence_score;type:int(3);not null;comment:置信度"`
- EffectiveDate time.Time `gorm:"column:effective_date;type:date;not null;comment:生效日期"`
- ExpiredDate time.Time `gorm:"column:expired_date;type:date;comment:失效日期"`
- LastApplyDate time.Time `gorm:"column:last_apply_date;type:date;comment:最近应用日期"`
- Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
- CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
- TenantId string `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"`
- }
-
- func (DimDiscountRule) TableName() string { return "dim_discount_rule" }
|