|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+package tables
|
|
|
2
|
+
|
|
|
3
|
+import (
|
|
|
4
|
+ "time"
|
|
|
5
|
+
|
|
|
6
|
+ "git.x2erp.com/qdy/go-db/sqldef"
|
|
|
7
|
+)
|
|
|
8
|
+
|
|
|
9
|
+func init() {
|
|
|
10
|
+ sqldef.AddRegistration(func(r *sqldef.Registry) {
|
|
|
11
|
+ tb := sqldef.NewTable("dws_discount_analysis", "折扣深度分析表").
|
|
|
12
|
+ ID("analysis_id", 32).Comment("分析ID,主键").End().
|
|
|
13
|
+ Int("product_year").NotNull().Comment("年份").End().
|
|
|
14
|
+ String("product_season", 10).NotNull().Comment("产品季节(春/夏/秋/冬)").End().
|
|
|
15
|
+ Int("week_of_year").NotNull().Comment("年第几周(1-52)").End().
|
|
|
16
|
+ String("store_id", 32).NotNull().Comment("店铺ID").End().
|
|
|
17
|
+ String("category_id", 32).NotNull().Comment("品类ID").End().
|
|
|
18
|
+ String("inventory_age_range", 20).NotNull().Comment("库龄段(<30天,30-60天,60-90天,>90天)").End().
|
|
|
19
|
+ String("discount_range", 10).NotNull().Comment("折扣档位(全价,9折,8折,7折,6折,5折)").End().
|
|
|
20
|
+ // 生命周期相关字段
|
|
|
21
|
+ String("lifecycle_stage", 10).NotNull().Comment("生命周期阶段(导入期,成长期,成熟期,衰退期)").End().
|
|
|
22
|
+ String("season_status", 10).NotNull().Comment("季节状态(当季,临季,过季)").End().
|
|
|
23
|
+ Int("days_on_market").NotNull().Comment("上市天数").End().
|
|
|
24
|
+ String("is_cross_season", 1).Default("'0'").Comment("是否跨季款(0:否,1:是)").End().
|
|
|
25
|
+ // 核心指标
|
|
|
26
|
+ Int("sale_quantity").NotNull().Default("0").Comment("总销量").End().
|
|
|
27
|
+ Int("begin_inventory").NotNull().Default("0").Comment("期初库存").End().
|
|
|
28
|
+ Int("end_inventory").NotNull().Default("0").Comment("期末库存").End().
|
|
|
29
|
+ Int("production_quantity").NotNull().Default("0").Comment("在产量").End().
|
|
|
30
|
+ Int("consumption_rate").NotNull().Default("0").Comment("消耗率(单位:%)").End().
|
|
|
31
|
+ Int("production_sales_ratio").NotNull().Default("0").Comment("产销率(单位:%)").End().
|
|
|
32
|
+ // 时间字段
|
|
|
33
|
+ Date("stat_date").NotNull().Comment("统计日期").End().
|
|
|
34
|
+ DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
|
|
|
35
|
+
|
|
|
36
|
+ // 索引 - 支持多种分析维度
|
|
|
37
|
+ //tb.Index("idx_season_week", "product_season", "week_of_year", "category_id").End().
|
|
|
38
|
+ // Index("idx_age_discount", "inventory_age_range", "discount_range").End().
|
|
|
39
|
+ // Index("idx_lifecycle", "lifecycle_stage", "season_status").End().
|
|
|
40
|
+ // Index("idx_date_store_cat", "stat_date", "store_id", "category_id").End()
|
|
|
41
|
+
|
|
|
42
|
+ r.RegisterTable(tb.Build())
|
|
|
43
|
+ })
|
|
|
44
|
+}
|
|
|
45
|
+
|
|
|
46
|
+type DwsDiscountAnalysis struct {
|
|
|
47
|
+ AnalysisID string `gorm:"column:analysis_id;type:varchar(32);primaryKey;not null;comment:分析ID,主键"`
|
|
|
48
|
+ ProductYear int `gorm:"column:product_year;type:int(4);not null;comment:年份"`
|
|
|
49
|
+ ProductSeason string `gorm:"column:product_season;type:varchar(10);not null;comment:产品季节"`
|
|
|
50
|
+ WeekOfYear int `gorm:"column:week_of_year;type:int(2);not null;comment:年第几周"`
|
|
|
51
|
+ StoreID string `gorm:"column:store_id;type:varchar(32);not null;comment:店铺ID"`
|
|
|
52
|
+ CategoryID string `gorm:"column:category_id;type:varchar(32);not null;comment:品类ID"`
|
|
|
53
|
+ InventoryAgeRange string `gorm:"column:inventory_age_range;type:varchar(20);not null;comment:库龄段"`
|
|
|
54
|
+ DiscountRange string `gorm:"column:discount_range;type:varchar(10);not null;comment:折扣档位"`
|
|
|
55
|
+
|
|
|
56
|
+ // 生命周期相关字段
|
|
|
57
|
+ LifecycleStage string `gorm:"column:lifecycle_stage;type:varchar(10);not null;comment:生命周期阶段"`
|
|
|
58
|
+ SeasonStatus string `gorm:"column:season_status;type:varchar(10);not null;comment:季节状态"`
|
|
|
59
|
+ DaysOnMarket int `gorm:"column:days_on_market;type:int(4);not null;comment:上市天数"`
|
|
|
60
|
+ IsCrossSeason string `gorm:"column:is_cross_season;type:varchar(1);default:0;comment:是否跨季款"`
|
|
|
61
|
+
|
|
|
62
|
+ // 核心指标
|
|
|
63
|
+ SaleQuantity int `gorm:"column:sale_quantity;type:int(11);not null;default:0;comment:总销量"`
|
|
|
64
|
+ BeginInventory int `gorm:"column:begin_inventory;type:int(11);not null;default:0;comment:期初库存"`
|
|
|
65
|
+ EndInventory int `gorm:"column:end_inventory;type:int(11);not null;default:0;comment:期末库存"`
|
|
|
66
|
+ ProductionQuantity int `gorm:"column:production_quantity;type:int(11);not null;default:0;comment:在产量"`
|
|
|
67
|
+ ConsumptionRate int `gorm:"column:consumption_rate;type:int(3);not null;default:0;comment:消耗率"`
|
|
|
68
|
+ ProductionSalesRatio int `gorm:"column:production_sales_ratio;type:int(3);not null;default:0;comment:产销率"`
|
|
|
69
|
+
|
|
|
70
|
+ // 时间字段
|
|
|
71
|
+ StatDate time.Time `gorm:"column:stat_date;type:date;not null;comment:统计日期"`
|
|
|
72
|
+ CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
|
|
|
73
|
+ TenantId string `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"`
|
|
|
74
|
+}
|
|
|
75
|
+
|
|
|
76
|
+func (DwsDiscountAnalysis) TableName() string { return "dws_discount_analysis" }
|