Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

dws_discount_analysis.go 4.5KB

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