Przeglądaj źródła

Release v0.1.12181

qdy 2 miesięcy temu
commit
a23f7a7d04

+ 32
- 0
tables/dim_category.go Wyświetl plik

@@ -0,0 +1,32 @@
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("dim_category", "品类档案表").
12
+			ID("category_id", 32).Comment("品类ID,主键").End().
13
+			String("category_code", 32).NotNull().Unique().Comment("品类编码").End().
14
+			String("category_name", 64).NotNull().Comment("品类名称").End().
15
+			String("season_attribute", 32).Comment("季节属性(春/夏/秋/冬/四季)").End().
16
+			String("creator", 32).NotNull().Comment("创建人").End().
17
+			DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
18
+		r.RegisterTable(tb.Build())
19
+	})
20
+}
21
+
22
+type DimCategory struct {
23
+	CategoryID      string    `gorm:"column:category_id;type:varchar(32);primaryKey;not null;comment:品类ID,主键"`
24
+	CategoryCode    string    `gorm:"column:category_code;type:varchar(32);not null;unique;comment:品类编码"`
25
+	CategoryName    string    `gorm:"column:category_name;type:varchar(64);not null;comment:品类名称"`
26
+	SeasonAttribute string    `gorm:"column:season_attribute;type:varchar(32);comment:季节属性"`
27
+	Creator         string    `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
28
+	CreatedAt       time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
29
+	TenantId        string    `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"`
30
+}
31
+
32
+func (DimCategory) TableName() string { return "dim_category" }

+ 39
- 0
tables/dim_city.go Wyświetl plik

@@ -0,0 +1,39 @@
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
+		// 城市档案主表
12
+		tb := sqldef.NewTable("dim_city", "城市档案表").
13
+			ID("city_id", 32).Comment("城市ID,主键").End().
14
+			String("city_code", 32).NotNull().Unique().Comment("城市编码").End().
15
+			String("city_name", 64).NotNull().Comment("城市名称").End().
16
+			String("country_code", 8).NotNull().Comment("国家代码(CN,US等)").End().
17
+			String("temperature_zone", 32).NotNull().Comment("温度带(热带/亚热带/温带/寒带)").End().
18
+			Decimal("avg_winter_temp", 5, 2).Comment("冬季平均温度℃").End().
19
+			Decimal("avg_summer_temp", 5, 2).Comment("夏季平均温度℃").End().
20
+			String("creator", 32).NotNull().Comment("创建人").End().
21
+			DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
22
+		r.RegisterTable(tb.Build())
23
+	})
24
+}
25
+
26
+type DimCity struct {
27
+	CityID          string    `gorm:"column:city_id;type:varchar(32);primaryKey;not null;comment:城市ID,主键"`
28
+	CityCode        string    `gorm:"column:city_code;type:varchar(32);not null;unique;comment:城市编码"`
29
+	CityName        string    `gorm:"column:city_name;type:varchar(64);not null;comment:城市名称"`
30
+	CountryCode     string    `gorm:"column:country_code;type:varchar(8);not null;comment:国家代码"`
31
+	TemperatureZone string    `gorm:"column:temperature_zone;type:varchar(32);not null;comment:温度带"`
32
+	AvgWinterTemp   float64   `gorm:"column:avg_winter_temp;type:decimal(5,2);comment:冬季平均温度℃"`
33
+	AvgSummerTemp   float64   `gorm:"column:avg_summer_temp;type:decimal(5,2);comment:夏季平均温度℃"`
34
+	Creator         string    `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
35
+	CreatedAt       time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
36
+	TenantId        string    `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"`
37
+}
38
+
39
+func (DimCity) TableName() string { return "dim_city" }

+ 45
- 0
tables/dim_city_temperature.go Wyświetl plik

@@ -0,0 +1,45 @@
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
+		// 温度带季节上下架子表
12
+		tb := sqldef.NewTable("dim_city_temperature", "温度带季节波段表").
13
+			ID("band_id", 32).Comment("波段ID,主键").End().
14
+			String("temperature_zone", 32).NotNull().Comment("温度带").End().
15
+			String("season", 32).NotNull().Comment("季节(春/夏/秋/冬)").End().
16
+			Int("start_month").NotNull().Comment("开始月份(1-12)").End().
17
+			Int("start_day").NotNull().Comment("开始日期(1-31)").End().
18
+			Int("end_month").NotNull().Comment("结束月份(1-12)").End().
19
+			Int("end_day").NotNull().Comment("结束日期(1-31)").End().
20
+			String("season_id", 32).NotNull().Comment("服装类型(春装/夏装/秋装/冬装)").End().
21
+			String("creator", 32).NotNull().Comment("创建人").End().
22
+			DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
23
+
24
+		// 添加唯一索引,防止重复配置
25
+		//tb.Index("uk_temperature_season", "temperature_zone", "season", "clothing_type").Unique().End()
26
+
27
+		r.RegisterTable(tb.Build())
28
+	})
29
+}
30
+
31
+type DimTemperatureSeasonBand struct {
32
+	BandID          string    `gorm:"column:band_id;type:varchar(32);primaryKey;not null;comment:波段ID,主键"`
33
+	TemperatureZone string    `gorm:"column:temperature_zone;type:varchar(32);not null;comment:温度带"`
34
+	Season          string    `gorm:"column:season;type:varchar(32);not null;comment:季节"`
35
+	StartMonth      int       `gorm:"column:start_month;type:int(2);not null;comment:开始月份"`
36
+	StartDay        int       `gorm:"column:start_day;type:int(2);not null;comment:开始日期"`
37
+	EndMonth        int       `gorm:"column:end_month;type:int(2);not null;comment:结束月份"`
38
+	EndDay          int       `gorm:"column:end_day;type:int(2);not null;comment:结束日期"`
39
+	ClothingType    string    `gorm:"column:clothing_type;type:varchar(32);not null;comment:服装类型"`
40
+	Creator         string    `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
41
+	CreatedAt       time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
42
+	TenantId        string    `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"`
43
+}
44
+
45
+func (DimTemperatureSeasonBand) TableName() string { return "dim_temperature_season_band" }

+ 36
- 0
tables/dim_date.go Wyświetl plik

@@ -0,0 +1,36 @@
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("dim_date", "时间维度表").
12
+			ID("date_id", 32).Comment("日期ID,主键").End().
13
+			Date("date_value").NotNull().Unique().Comment("日期值").End().
14
+			Int("year").NotNull().Comment("年份").End().
15
+			Int("quarter").NotNull().Comment("季度(1-4)").End().
16
+			Int("month").NotNull().Comment("月份(1-12)").End().
17
+			Int("week_of_year").NotNull().Comment("年第几周(1-52)").End().
18
+			String("season", 10).Comment("季节(春/夏/秋/冬)").End().
19
+			String("is_holiday", 1).Default("'0'").Comment("是否节假日(0:否,1:是)").End()
20
+		r.RegisterTable(tb.Build())
21
+	})
22
+}
23
+
24
+type DimDate struct {
25
+	DateID     string    `gorm:"column:date_id;type:varchar(32);primaryKey;not null;comment:日期ID,主键"`
26
+	DateValue  time.Time `gorm:"column:date_value;type:date;not null;unique;comment:日期值"`
27
+	Year       int       `gorm:"column:year;type:int(4);not null;comment:年份"`
28
+	Quarter    int       `gorm:"column:quarter;type:int(1);not null;comment:季度"`
29
+	Month      int       `gorm:"column:month;type:int(2);not null;comment:月份"`
30
+	WeekOfYear int       `gorm:"column:week_of_year;type:int(2);not null;comment:年第几周"`
31
+	Season     string    `gorm:"column:season;type:varchar(10);comment:季节"`
32
+	IsHoliday  string    `gorm:"column:is_holiday;type:varchar(1);default:0;comment:是否节假日"`
33
+	TenantId   string    `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"`
34
+}
35
+
36
+func (DimDate) TableName() string { return "dim_date" }

+ 49
- 0
tables/dim_discount_rule.go Wyświetl plik

@@ -0,0 +1,49 @@
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("dim_discount_rule", "折扣决策规则表").
12
+			ID("rule_id", 32).Comment("规则ID,主键").End().
13
+			String("category_id", 32).NotNull().Comment("品类ID").End().
14
+			Int("season_month").NotNull().Comment("季节月份(3,5,7,9,11等)").End().
15
+			Int("target_inventory_age").NotNull().Comment("目标库龄(天)").End().
16
+			Int("recommended_discount").NotNull().Comment("推荐折扣(如70表示7折)").End().
17
+			Int("expected_consumption").NotNull().Comment("预期消耗率(%)").End().
18
+			Int("confidence_score").NotNull().Comment("置信度(%)").End().
19
+			Date("effective_date").NotNull().Comment("生效日期").End().
20
+			Date("expired_date").Comment("失效日期").End().
21
+			Date("last_apply_date").Comment("最近应用日期").End().
22
+			String("creator", 32).NotNull().Comment("创建人").End().
23
+			DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
24
+
25
+		// 索引
26
+		//tb.Index("idx_category_season", "category_id", "season_month").End().
27
+		//	Index("idx_effective", "effective_date", "expired_date").End()
28
+
29
+		r.RegisterTable(tb.Build())
30
+	})
31
+}
32
+
33
+type DimDiscountRule struct {
34
+	RuleID              string    `gorm:"column:rule_id;type:varchar(32);primaryKey;not null;comment:规则ID,主键"`
35
+	CategoryID          string    `gorm:"column:category_id;type:varchar(32);not null;comment:品类ID"`
36
+	SeasonMonth         int       `gorm:"column:season_month;type:int(2);not null;comment:季节月份"`
37
+	TargetInventoryAge  int       `gorm:"column:target_inventory_age;type:int(4);not null;comment:目标库龄"`
38
+	RecommendedDiscount int       `gorm:"column:recommended_discount;type:int(3);not null;comment:推荐折扣"`
39
+	ExpectedConsumption int       `gorm:"column:expected_consumption;type:int(3);not null;comment:预期消耗率"`
40
+	ConfidenceScore     int       `gorm:"column:confidence_score;type:int(3);not null;comment:置信度"`
41
+	EffectiveDate       time.Time `gorm:"column:effective_date;type:date;not null;comment:生效日期"`
42
+	ExpiredDate         time.Time `gorm:"column:expired_date;type:date;comment:失效日期"`
43
+	LastApplyDate       time.Time `gorm:"column:last_apply_date;type:date;comment:最近应用日期"`
44
+	Creator             string    `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
45
+	CreatedAt           time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
46
+	TenantId            string    `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"`
47
+}
48
+
49
+func (DimDiscountRule) TableName() string { return "dim_discount_rule" }

+ 34
- 0
tables/dim_store.go Wyświetl plik

@@ -0,0 +1,34 @@
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("dim_store", "店铺档案表").
12
+			ID("store_id", 32).Comment("店铺ID,主键").End().
13
+			String("store_code", 32).NotNull().Unique().Comment("店铺编码").End().
14
+			String("store_name", 64).NotNull().Comment("店铺名称").End().
15
+			String("store_group_id", 32).Comment("所属店铺组ID").End().
16
+			String("region_code", 32).Comment("区域编码").End().
17
+			String("creator", 32).NotNull().Comment("创建人").End().
18
+			DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
19
+		r.RegisterTable(tb.Build())
20
+	})
21
+}
22
+
23
+type DimStore struct {
24
+	StoreID      string    `gorm:"column:store_id;type:varchar(32);primaryKey;not null;comment:店铺ID,主键"`
25
+	StoreCode    string    `gorm:"column:store_code;type:varchar(32);not null;unique;comment:店铺编码"`
26
+	StoreName    string    `gorm:"column:store_name;type:varchar(64);not null;comment:店铺名称"`
27
+	StoreGroupID string    `gorm:"column:store_group_id;type:varchar(32);comment:所属店铺组ID"`
28
+	RegionCode   string    `gorm:"column:region_code;type:varchar(32);comment:区域编码"`
29
+	Creator      string    `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
30
+	CreatedAt    time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
31
+	TenantId     string    `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"`
32
+}
33
+
34
+func (DimStore) TableName() string { return "dim_store" }

+ 45
- 0
tables/dwa_discount_daily.go Wyświetl plik

@@ -0,0 +1,45 @@
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("dwa_discount_daily", "折扣快速监控表").
12
+			ID("stat_id", 32).Comment("统计ID,主键").End().
13
+			Date("stat_date").NotNull().Comment("统计日期").End().
14
+			String("store_id", 32).NotNull().Comment("店铺ID").End().
15
+			String("category_id", 32).NotNull().Comment("品类ID").End().
16
+			String("discount_range", 10).NotNull().Comment("折扣档位(全价,9折,8折,7折,6折,5折)").End().
17
+			Int("inventory_age").NotNull().Comment("平均库龄(天)").End().
18
+			Int("sale_quantity").NotNull().Default("0").Comment("销量").End().
19
+			Int("sale_amount").NotNull().Default("0").Comment("销售额(单位:分)").End().
20
+			Int("current_stock").NotNull().Default("0").Comment("当前库存").End().
21
+			DateTime("update_time").NotNull().Default("CURRENT_TIMESTAMP").Comment("更新时间").End()
22
+
23
+		// 索引
24
+		//tb.Index("idx_date_store", "stat_date", "store_id").End().
25
+		//	Index("idx_category_date", "category_id", "stat_date").End()
26
+
27
+		r.RegisterTable(tb.Build())
28
+	})
29
+}
30
+
31
+type DwaDiscountDaily struct {
32
+	StatID        string    `gorm:"column:stat_id;type:varchar(32);primaryKey;not null;comment:统计ID,主键"`
33
+	StatDate      time.Time `gorm:"column:stat_date;type:date;not null;comment:统计日期"`
34
+	StoreID       string    `gorm:"column:store_id;type:varchar(32);not null;comment:店铺ID"`
35
+	CategoryID    string    `gorm:"column:category_id;type:varchar(32);not null;comment:品类ID"`
36
+	DiscountRange string    `gorm:"column:discount_range;type:varchar(10);not null;comment:折扣档位"`
37
+	InventoryAge  int       `gorm:"column:inventory_age;type:int(4);not null;comment:平均库龄"`
38
+	SaleQuantity  int       `gorm:"column:sale_quantity;type:int(11);not null;default:0;comment:销量"`
39
+	SaleAmount    int       `gorm:"column:sale_amount;type:int(11);not null;default:0;comment:销售额"`
40
+	CurrentStock  int       `gorm:"column:current_stock;type:int(11);not null;default:0;comment:当前库存"`
41
+	UpdateTime    time.Time `gorm:"column:update_time;not null;default:CURRENT_TIMESTAMP;comment:更新时间"`
42
+	TenantId      string    `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"`
43
+}
44
+
45
+func (DwaDiscountDaily) TableName() string { return "dwa_discount_daily" }

+ 76
- 0
tables/dws_discount_analysis.go Wyświetl plik

@@ -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" }

Ładowanie…
Anuluj
Zapisz