Ei kuvausta
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

master_product.go 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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("master_product", "商品资料主表 - 服装行业数据仓库核心表,存储商品基础信息与统计分析维度").
  9. ID("product_id", 50).NotNull().Comment("主键ID").End().
  10. String("product_code", 50).NotNull().Comment("商品编码/货号").End().
  11. String("product_barcode", 20).Comment("国际商品条码/EAN码").End().
  12. String("product_name", 200).NotNull().Comment("商品名称").End().
  13. String("product_name_en", 200).Comment("商品英文名称").End().
  14. String("product_short_name", 100).Comment("商品简称/缩写").End().
  15. String("category_code", 20).Comment("分类代码").End().
  16. String("category_name", 100).Comment("分类名称").End().
  17. String("brand_code", 20).Comment("品牌代码").End().
  18. String("brand_name", 100).Comment("品牌名称").End().
  19. String("style_code", 30).Comment("款式编码").End().
  20. String("color_code", 20).Comment("颜色代码").End().
  21. String("color_name", 50).Comment("颜色名称").End().
  22. String("size_code", 10).Comment("尺码代码").End().
  23. String("size_name", 20).Comment("尺码名称").End().
  24. String("season_code", 10).Comment("季节代码 - SS(春夏)/FW(秋冬)").End().
  25. Int("year").Comment("年份").End().
  26. String("collection", 50).Comment("系列/批次").End().
  27. Int("min_order_qty").Comment("最小起订量").End().
  28. Int("lead_time_days").Comment("采购提前期(天)").End().
  29. Decimal("cost_price", 10, 2).Comment("成本价").End().
  30. Decimal("suggested_retail_price", 10, 2).Comment("建议零售价").End().
  31. Decimal("current_price", 10, 2).Comment("当前售价").End().
  32. String("currency_code", 3).Default("'CNY'").Comment("货币代码").End().
  33. Int("safety_stock").Comment("安全库存水平").End().
  34. Int("max_stock").Comment("最高库存量").End().
  35. Int("reorder_point").Comment("补货点").End().
  36. Int("economic_order_qty").Comment("经济订货量").End().
  37. String("abc_class", 1).Comment("ABC分类 - A/B/C").End().
  38. String("xyz_class", 1).Comment("XYZ分类 - X/Y/Z (基于需求稳定性)").End().
  39. Decimal("sales_velocity", 10, 2).Comment("销售流速(日均销量)").End().
  40. Decimal("sell_through_rate", 5, 4).Comment("售罄率").End().
  41. Decimal("gross_margin", 5, 4).Comment("毛利率").End().
  42. Decimal("return_rate", 5, 4).Comment("退货率").End().
  43. String("product_status", 20).Comment("商品状态 - active/inactive/discontinued").End().
  44. Date("launch_date").Comment("上市日期").End().
  45. Date("discontinuation_date").Comment("停售日期").End().
  46. Date("data_date").Comment("数据日期 - 数据仓库快照日期").End().
  47. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End().
  48. DateTime("updated_at").Comment("更新时间").End().
  49. DateTime("deleted_at").Comment("删除时间").End()
  50. tb.AddUniqueIndex("idx_product_code", "product_code")
  51. tb.AddIndex("idx_product_barcode", "product_barcode")
  52. tb.AddIndex("idx_category_code", "category_code")
  53. tb.AddIndex("idx_brand_code", "brand_code")
  54. tb.AddIndex("idx_style_code", "style_code")
  55. tb.AddIndex("idx_category_brand_season", "category_id", "brand_id", "season_code")
  56. r.RegisterTable(tb.Build())
  57. })
  58. }
  59. type MasterProduct struct {
  60. ProductID string `gorm:"column:product_id;type:varchar(50);not null;primaryKey;comment:主键ID"`
  61. ProductCode string `gorm:"column:product_code;type:varchar(50);not null;comment:商品编码/货号"`
  62. ProductBarcode string `gorm:"column:product_barcode;type:varchar(20);comment:国际商品条码/EAN码"`
  63. ProductName string `gorm:"column:product_name;type:varchar(200);not null;comment:商品名称"`
  64. ProductNameEn string `gorm:"column:product_name_en;type:varchar(200);comment:商品英文名称"`
  65. ProductShortName string `gorm:"column:product_short_name;type:varchar(100);comment:商品简称/缩写"`
  66. CategoryCode string `gorm:"column:category_code;type:varchar(20);comment:分类代码"`
  67. CategoryName string `gorm:"column:category_name;type:varchar(100);comment:分类名称"`
  68. BrandCode string `gorm:"column:brand_code;type:varchar(20);comment:品牌代码"`
  69. BrandName string `gorm:"column:brand_name;type:varchar(100);comment:品牌名称"`
  70. StyleCode string `gorm:"column:style_code;type:varchar(30);comment:款式编码"`
  71. ColorCode string `gorm:"column:color_code;type:varchar(20);comment:颜色代码"`
  72. ColorName string `gorm:"column:color_name;type:varchar(50);comment:颜色名称"`
  73. SizeCode string `gorm:"column:size_code;type:varchar(10);comment:尺码代码"`
  74. SizeName string `gorm:"column:size_name;type:varchar(20);comment:尺码名称"`
  75. SeasonCode string `gorm:"column:season_code;type:varchar(10);comment:季节代码 - SS(春夏)/FW(秋冬)"`
  76. Year int32 `gorm:"column:year;type:int;comment:年份"`
  77. Collection string `gorm:"column:collection;type:varchar(50);comment:系列/批次"`
  78. MinOrderQty int32 `gorm:"column:min_order_qty;type:int;comment:最小起订量"`
  79. LeadTimeDays int32 `gorm:"column:lead_time_days;type:int;comment:采购提前期(天)"`
  80. CostPrice float64 `gorm:"column:cost_price;type:decimal(10,2);comment:成本价"`
  81. SuggestedRetailPrice float64 `gorm:"column:suggested_retail_price;type:decimal(10,2);comment:建议零售价"`
  82. CurrentPrice float64 `gorm:"column:current_price;type:decimal(10,2);comment:当前售价"`
  83. CurrencyCode string `gorm:"column:currency_code;type:varchar(3);default:CNY;comment:货币代码"`
  84. SafetyStock int32 `gorm:"column:safety_stock;type:int;comment:安全库存水平"`
  85. MaxStock int32 `gorm:"column:max_stock;type:int;comment:最高库存量"`
  86. ReorderPoint int32 `gorm:"column:reorder_point;type:int;comment:补货点"`
  87. EconomicOrderQty int32 `gorm:"column:economic_order_qty;type:int;comment:经济订货量"`
  88. AbcClass string `gorm:"column:abc_class;type:varchar(1);comment:ABC分类 - A/B/C"`
  89. XyzClass string `gorm:"column:xyz_class;type:varchar(1);comment:XYZ分类 - X/Y/Z (基于需求稳定性)"`
  90. SalesVelocity float64 `gorm:"column:sales_velocity;type:decimal(10,2);comment:销售流速(日均销量)"`
  91. SellThroughRate float64 `gorm:"column:sell_through_rate;type:decimal(5,4);comment:售罄率"`
  92. GrossMargin float64 `gorm:"column:gross_margin;type:decimal(5,4);comment:毛利率"`
  93. ReturnRate float64 `gorm:"column:return_rate;type:decimal(5,4);comment:退货率"`
  94. ProductStatus string `gorm:"column:product_status;type:varchar(20);comment:商品状态 - active/inactive/discontinued"`
  95. LaunchDate *time.Time `gorm:"column:launch_date;type:date;comment:上市日期"`
  96. DiscontinuationDate *time.Time `gorm:"column:discontinuation_date;type:date;comment:停售日期"`
  97. DataDate *time.Time `gorm:"column:data_date;type:date;comment:数据日期 - 数据仓库快照日期"`
  98. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  99. UpdatedAt *time.Time `gorm:"column:updated_at;comment:更新时间"`
  100. DeletedAt *time.Time `gorm:"column:deleted_at;comment:删除时间"`
  101. }
  102. type MasterProductDB struct {
  103. ProductID string `db:"product_id" json:"productID"`
  104. ProductCode string `db:"product_code" json:"productCode"`
  105. ProductBarcode string `db:"product_barcode" json:"productBarcode"`
  106. ProductName string `db:"product_name" json:"productName"`
  107. ProductNameEn string `db:"product_name_en" json:"productNameEn"`
  108. ProductShortName string `db:"product_short_name" json:"productShortName"`
  109. CategoryCode string `db:"category_code" json:"categoryCode"`
  110. CategoryName string `db:"category_name" json:"categoryName"`
  111. BrandCode string `db:"brand_code" json:"brandCode"`
  112. BrandName string `db:"brand_name" json:"brandName"`
  113. StyleCode string `db:"style_code" json:"styleCode"`
  114. ColorCode string `db:"color_code" json:"colorCode"`
  115. ColorName string `db:"color_name" json:"colorName"`
  116. SizeCode string `db:"size_code" json:"sizeCode"`
  117. SizeName string `db:"size_name" json:"sizeName"`
  118. SeasonCode string `db:"season_code" json:"seasonCode"`
  119. Year int32 `db:"year" json:"year"`
  120. Collection string `db:"collection" json:"collection"`
  121. MinOrderQty int32 `db:"min_order_qty" json:"minOrderQty"`
  122. LeadTimeDays int32 `db:"lead_time_days" json:"leadTimeDays"`
  123. CostPrice float64 `db:"cost_price" json:"costPrice"`
  124. SuggestedRetailPrice float64 `db:"suggested_retail_price" json:"suggestedRetailPrice"`
  125. CurrentPrice float64 `db:"current_price" json:"currentPrice"`
  126. CurrencyCode string `db:"currency_code" json:"currencyCode"`
  127. SafetyStock int32 `db:"safety_stock" json:"safetyStock"`
  128. MaxStock int32 `db:"max_stock" json:"maxStock"`
  129. ReorderPoint int32 `db:"reorder_point" json:"reorderPoint"`
  130. EconomicOrderQty int32 `db:"economic_order_qty" json:"economicOrderQty"`
  131. AbcClass string `db:"abc_class" json:"abcClass"`
  132. XyzClass string `db:"xyz_class" json:"xyzClass"`
  133. SalesVelocity float64 `db:"sales_velocity" json:"salesVelocity"`
  134. SellThroughRate float64 `db:"sell_through_rate" json:"sellThroughRate"`
  135. GrossMargin float64 `db:"gross_margin" json:"grossMargin"`
  136. ReturnRate float64 `db:"return_rate" json:"returnRate"`
  137. ProductStatus string `db:"product_status" json:"productStatus"`
  138. LaunchDate *time.Time `db:"launch_date" json:"launchDate"`
  139. DiscontinuationDate *time.Time `db:"discontinuation_date" json:"discontinuationDate"`
  140. DataDate *time.Time `db:"data_date" json:"dataDate"`
  141. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  142. UpdatedAt *time.Time `db:"updated_at" json:"updatedAt"`
  143. DeletedAt *time.Time `db:"deleted_at" json:"deletedAt"`
  144. }
  145. func (MasterProduct) TableName() string {
  146. return "master_product"
  147. }