Geen omschrijving
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.

stock_store_snapshot.go 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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("stock_store_snapshot", "日店铺库存快照表 - 用于保存每天晚上所有店铺的商品库存").
  9. ID("id", 50).NotNull().Comment("主键ID").End().
  10. String("store_id", 50).NotNull().Comment("店铺ID").End().
  11. String("product_id", 50).NotNull().Comment("商品ID").End().
  12. String("style_code", 30).NotNull().Comment("款式编码").End().
  13. String("color_code", 20).NotNull().Comment("颜色代码").End().
  14. String("color_name", 50).NotNull().Comment("颜色名称").End().
  15. String("size_code", 10).NotNull().Comment("尺码代码").End().
  16. String("size_name", 20).NotNull().Comment("尺码名称").End().
  17. Decimal("stock_actual", 12, 4).NotNull().Default("0").Comment("目前库存").End().
  18. Date("data_date").NotNull().Comment("快照日期").End().
  19. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
  20. tb.AddUniqueIndex("idx_store_product", "store_id", "product_id")
  21. tb.AddIndex("idx_style_code", "style_code")
  22. tb.AddIndex("idx_store_id", "store_id")
  23. tb.AddIndex("idx_product_id", "product_id")
  24. tb.AddIndex("idx_data_date", "data_date")
  25. tb.AddIndex("idx_store_product_date", "store_id", "product_id", "data_date")
  26. r.RegisterTable(tb.Build())
  27. })
  28. }
  29. type StockStoreSnapshot struct {
  30. ID string `gorm:"column:id;type:varchar(50);not null;primaryKey;comment:主键ID"`
  31. StoreID string `gorm:"column:store_id;type:varchar(50);not null;comment:店铺ID"`
  32. ProductID string `gorm:"column:product_id;type:varchar(50);not null;comment:商品ID"`
  33. StyleCode string `gorm:"column:style_code;type:varchar(30);not null;comment:款式编码"`
  34. ColorCode string `gorm:"column:color_code;type:varchar(20);not null;comment:颜色代码"`
  35. ColorName string `gorm:"column:color_name;type:varchar(50);not null;comment:颜色名称"`
  36. SizeCode string `gorm:"column:size_code;type:varchar(10);not null;comment:尺码代码"`
  37. SizeName string `gorm:"column:size_name;type:varchar(20);not null;comment:尺码名称"`
  38. StockActual float64 `gorm:"column:stock_actual;type:decimal(12,4);not null;default:0;comment:目前库存"`
  39. DataDate time.Time `gorm:"column:data_date;type:date;not null;comment:快照日期"`
  40. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  41. }
  42. type StockStoreSnapshotDB struct {
  43. ID string `db:"id" json:"id"`
  44. StoreID string `db:"store_id" json:"storeID"`
  45. ProductID string `db:"product_id" json:"productID"`
  46. StyleCode string `db:"style_code" json:"styleCode"`
  47. ColorCode string `db:"color_code" json:"colorCode"`
  48. ColorName string `db:"color_name" json:"colorName"`
  49. SizeCode string `db:"size_code" json:"sizeCode"`
  50. SizeName string `db:"size_name" json:"sizeName"`
  51. StockActual float64 `db:"stock_actual" json:"stockActual"`
  52. DataDate time.Time `db:"data_date" json:"dataDate"`
  53. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  54. }
  55. func (StockStoreSnapshot) TableName() string {
  56. return "stock_store_snapshot"
  57. }