暫無描述
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 12KB

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