| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- package tables
-
- import (
- "time"
-
- "git.x2erp.com/qdy/go-db/sqldef"
- )
-
- func init() {
- sqldef.AddRegistration(func(r *sqldef.Registry) {
- tb := sqldef.NewTable("master_product", "商品资料主表 - 服装行业数据仓库核心表,存储商品基础信息与统计分析维度").
- ChineseName("商品资料主表").Aliases("主表", "商品资料主").
- ChineseName("商品资料主表").
- Aliases("商品表", "产品表").
- ID("product_id", 50).NotNull().Comment("主键ID").ChineseName("商品标识").Aliases("ID", "商品ID").End().
- String("product_code", 50).NotNull().Comment("商品编码/货号").ChineseName("商品编码").Aliases("货号", "编码").End().
- String("product_barcode", 100).Comment("国际商品条码/EAN码").ChineseName("商品条码").Aliases("条码", "EAN码").End().
- String("product_name", 200).NotNull().Comment("商品名称").ChineseName("商品名称").Aliases("名称", "品名").End().
- String("product_name_en", 100).Comment("商品英文名称").ChineseName("英文名称").Aliases("英文名").End().
- String("product_short_name", 100).Comment("商品简称/缩写").ChineseName("商品简称").End().
- String("category_code", 100).Comment("分类代码").ChineseName("分类代码").Aliases("分类编码").End().
- String("category_name", 100).Comment("分类名称").ChineseName("分类名称").Aliases("分类").End().
- String("brand_code", 100).Comment("品牌代码").ChineseName("品牌代码").Aliases("品牌编码").End().
- String("brand_name", 100).Comment("品牌名称").ChineseName("品牌名称").Aliases("品牌").End().
- String("style_code", 100).Comment("款式编码").ChineseName("款式编码").Aliases("款式代码").End().
- String("color_code", 100).Comment("颜色代码").ChineseName("颜色代码").Aliases("颜色编码").End().
- String("color_name", 100).Comment("颜色名称").ChineseName("颜色名称").Aliases("颜色").End().
- String("size_code", 100).Comment("尺码代码").ChineseName("尺码代码").Aliases("尺码编码").End().
- String("size_name", 100).Comment("尺码名称").ChineseName("尺码名称").Aliases("尺码").End().
- String("season_code", 100).Comment("季节代码 - SS(春夏)/FW(秋冬)").ChineseName("季节代码").Aliases("季节").End().
- Int("year").Comment("年份").ChineseName("年份").End().
- String("collection", 100).Comment("系列/批次").ChineseName("系列批次").Aliases("批次").End().
- Int("min_order_qty").Comment("最小起订量").ChineseName("最小起订量").Aliases("起订量").End().
- Int("lead_time_days").Comment("采购提前期(天)").ChineseName("采购提前期").Aliases("提前期").End().
- Decimal("cost_price", 12, 2).Comment("成本价").ChineseName("成本价").Aliases("成本").End().
- Decimal("suggested_retail_price", 12, 2).Comment("建议零售价").ChineseName("建议零售价").Aliases("零售价").End().
- Decimal("current_price", 12, 2).Comment("当前售价").ChineseName("当前售价").Aliases("售价").End().
- String("currency_code", 3).Default("'CNY'").Comment("货币代码").ChineseName("货币代码").Aliases("货币").End().
- Int("safety_stock").Comment("安全库存水平").ChineseName("安全库存").Aliases("安全库存量").End().
- Int("max_stock").Comment("最高库存量").ChineseName("最高库存").Aliases("最大库存").End().
- Int("reorder_point").Comment("补货点").ChineseName("补货点").Aliases("补货点库存").End().
- Int("economic_order_qty").Comment("经济订货量").ChineseName("经济订货量").Aliases("订货量").End().
- String("abc_class", 100).Comment("ABC分类 - A/B/C").ChineseName("ABC分类").Aliases("ABC等级").End().
- String("xyz_class", 100).Comment("XYZ分类 - X/Y/Z (基于需求稳定性)").ChineseName("XYZ分类").Aliases("XYZ等级").End().
- Decimal("sales_velocity", 12, 2).Comment("销售流速(日均销量)").ChineseName("销售流速").Aliases("日均销量").End().
- Decimal("sell_through_rate", 12, 2).Comment("售罄率").ChineseName("售罄率").Aliases("售罄率百分比").End().
- Decimal("gross_margin", 12, 2).Comment("毛利率").ChineseName("毛利率").Aliases("毛利率百分比").End().
- Decimal("return_rate", 12, 2).Comment("退货率").ChineseName("退货率").Aliases("退货率百分比").End().
- String("product_status", 100).Comment("商品状态 - active/inactive/discontinued").ChineseName("商品状态").End().
- Date("launch_date").Comment("上市日期").ChineseName("上市日期").Aliases("上市时间").End().
- Date("discontinuation_date").Comment("停售日期").ChineseName("停售日期").Aliases("停售时间").End().
- Date("data_date").Comment("数据日期 - 数据仓库快照日期").ChineseName("数据日期").Aliases("快照日期").End().
- DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").ChineseName("创建时间").Aliases("创建时间戳").End().
- DateTime("updated_at").Comment("更新时间").ChineseName("更新时间").Aliases("更新时间戳").End().
- DateTime("deleted_at").Comment("删除时间").ChineseName("删除时间").Aliases("删除时间戳").End()
-
- tb.AddUniqueIndex("idx_product_code", "product_code")
- tb.AddIndex("idx_product_barcode", "product_barcode")
- tb.AddIndex("idx_category_code", "category_code")
- tb.AddIndex("idx_brand_code", "brand_code")
- tb.AddIndex("idx_style_code", "style_code")
- tb.AddIndex("idx_category_brand_season", "category_code", "brand_code", "season_code")
-
- r.RegisterTable(tb.Build())
- })
- }
-
- type MasterProduct struct {
- ProductID string `gorm:"column:product_id;type:varchar(50);not null;primaryKey;comment:主键ID"`
- ProductCode string `gorm:"column:product_code;type:varchar(50);not null;comment:商品编码/货号"`
- ProductBarcode string `gorm:"column:product_barcode;type:varchar(20);comment:国际商品条码/EAN码"`
- ProductName string `gorm:"column:product_name;type:varchar(200);not null;comment:商品名称"`
- ProductNameEn string `gorm:"column:product_name_en;type:varchar(200);comment:商品英文名称"`
- ProductShortName string `gorm:"column:product_short_name;type:varchar(100);comment:商品简称/缩写"`
- CategoryCode string `gorm:"column:category_code;type:varchar(20);comment:分类代码"`
- CategoryName string `gorm:"column:category_name;type:varchar(100);comment:分类名称"`
- BrandCode string `gorm:"column:brand_code;type:varchar(20);comment:品牌代码"`
- BrandName string `gorm:"column:brand_name;type:varchar(100);comment:品牌名称"`
- StyleCode string `gorm:"column:style_code;type:varchar(30);comment:款式编码"`
- ColorCode string `gorm:"column:color_code;type:varchar(20);comment:颜色代码"`
- ColorName string `gorm:"column:color_name;type:varchar(50);comment:颜色名称"`
- SizeCode string `gorm:"column:size_code;type:varchar(10);comment:尺码代码"`
- SizeName string `gorm:"column:size_name;type:varchar(20);comment:尺码名称"`
- SeasonCode string `gorm:"column:season_code;type:varchar(10);comment:季节代码 - SS(春夏)/FW(秋冬)"`
- Year int32 `gorm:"column:year;type:int;comment:年份"`
- Collection string `gorm:"column:collection;type:varchar(50);comment:系列/批次"`
-
- MinOrderQty int32 `gorm:"column:min_order_qty;type:int;comment:最小起订量"`
- LeadTimeDays int32 `gorm:"column:lead_time_days;type:int;comment:采购提前期(天)"`
- CostPrice float64 `gorm:"column:cost_price;type:decimal(10,2);comment:成本价"`
- SuggestedRetailPrice float64 `gorm:"column:suggested_retail_price;type:decimal(10,2);comment:建议零售价"`
- CurrentPrice float64 `gorm:"column:current_price;type:decimal(10,2);comment:当前售价"`
- CurrencyCode string `gorm:"column:currency_code;type:varchar(3);default:CNY;comment:货币代码"`
- SafetyStock int32 `gorm:"column:safety_stock;type:int;comment:安全库存水平"`
- MaxStock int32 `gorm:"column:max_stock;type:int;comment:最高库存量"`
- ReorderPoint int32 `gorm:"column:reorder_point;type:int;comment:补货点"`
- EconomicOrderQty int32 `gorm:"column:economic_order_qty;type:int;comment:经济订货量"`
- AbcClass string `gorm:"column:abc_class;type:varchar(1);comment:ABC分类 - A/B/C"`
- XyzClass string `gorm:"column:xyz_class;type:varchar(1);comment:XYZ分类 - X/Y/Z (基于需求稳定性)"`
- SalesVelocity float64 `gorm:"column:sales_velocity;type:decimal(10,2);comment:销售流速(日均销量)"`
- SellThroughRate float64 `gorm:"column:sell_through_rate;type:decimal(5,4);comment:售罄率"`
- GrossMargin float64 `gorm:"column:gross_margin;type:decimal(5,4);comment:毛利率"`
- ReturnRate float64 `gorm:"column:return_rate;type:decimal(5,4);comment:退货率"`
- ProductStatus string `gorm:"column:product_status;type:varchar(20);comment:商品状态 - active/inactive/discontinued"`
- LaunchDate *time.Time `gorm:"column:launch_date;type:date;comment:上市日期"`
- DiscontinuationDate *time.Time `gorm:"column:discontinuation_date;type:date;comment:停售日期"`
- DataDate *time.Time `gorm:"column:data_date;type:date;comment:数据日期 - 数据仓库快照日期"`
- CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
- UpdatedAt *time.Time `gorm:"column:updated_at;comment:更新时间"`
- DeletedAt *time.Time `gorm:"column:deleted_at;comment:删除时间"`
- }
-
- type MasterProductDB struct {
- ProductID string `db:"product_id" json:"productID"`
- ProductCode string `db:"product_code" json:"productCode"`
- ProductBarcode string `db:"product_barcode" json:"productBarcode"`
- ProductName string `db:"product_name" json:"productName"`
- ProductNameEn string `db:"product_name_en" json:"productNameEn"`
- ProductShortName string `db:"product_short_name" json:"productShortName"`
- CategoryCode string `db:"category_code" json:"categoryCode"`
- CategoryName string `db:"category_name" json:"categoryName"`
- BrandCode string `db:"brand_code" json:"brandCode"`
- BrandName string `db:"brand_name" json:"brandName"`
- StyleCode string `db:"style_code" json:"styleCode"`
- ColorCode string `db:"color_code" json:"colorCode"`
- ColorName string `db:"color_name" json:"colorName"`
- SizeCode string `db:"size_code" json:"sizeCode"`
- SizeName string `db:"size_name" json:"sizeName"`
- SeasonCode string `db:"season_code" json:"seasonCode"`
- Year int32 `db:"year" json:"year"`
- Collection string `db:"collection" json:"collection"`
-
- MinOrderQty int32 `db:"min_order_qty" json:"minOrderQty"`
- LeadTimeDays int32 `db:"lead_time_days" json:"leadTimeDays"`
- CostPrice float64 `db:"cost_price" json:"costPrice"`
- SuggestedRetailPrice float64 `db:"suggested_retail_price" json:"suggestedRetailPrice"`
- CurrentPrice float64 `db:"current_price" json:"currentPrice"`
- CurrencyCode string `db:"currency_code" json:"currencyCode"`
- SafetyStock int32 `db:"safety_stock" json:"safetyStock"`
- MaxStock int32 `db:"max_stock" json:"maxStock"`
- ReorderPoint int32 `db:"reorder_point" json:"reorderPoint"`
- EconomicOrderQty int32 `db:"economic_order_qty" json:"economicOrderQty"`
- AbcClass string `db:"abc_class" json:"abcClass"`
- XyzClass string `db:"xyz_class" json:"xyzClass"`
- SalesVelocity float64 `db:"sales_velocity" json:"salesVelocity"`
- SellThroughRate float64 `db:"sell_through_rate" json:"sellThroughRate"`
- GrossMargin float64 `db:"gross_margin" json:"grossMargin"`
- ReturnRate float64 `db:"return_rate" json:"returnRate"`
- ProductStatus string `db:"product_status" json:"productStatus"`
- LaunchDate *time.Time `db:"launch_date" json:"launchDate"`
- DiscontinuationDate *time.Time `db:"discontinuation_date" json:"discontinuationDate"`
- DataDate *time.Time `db:"data_date" json:"dataDate"`
- CreatedAt time.Time `db:"created_at" json:"createdAt"`
- UpdatedAt *time.Time `db:"updated_at" json:"updatedAt"`
- DeletedAt *time.Time `db:"deleted_at" json:"deletedAt"`
- }
-
- func (MasterProduct) TableName() string {
- return "master_product"
- }
|