Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

dwa_discount_daily.go 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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("dwa_discount_daily", "折扣快速监控表").
  9. ID("stat_id", 32).Comment("统计ID,主键").End().
  10. Date("stat_date").NotNull().Comment("统计日期").End().
  11. String("store_id", 32).NotNull().Comment("店铺ID").End().
  12. String("category_id", 32).NotNull().Comment("品类ID").End().
  13. String("discount_range", 10).NotNull().Comment("折扣档位(全价,9折,8折,7折,6折,5折)").End().
  14. Int("inventory_age").NotNull().Comment("平均库龄(天)").End().
  15. Int("sale_quantity").NotNull().Default("0").Comment("销量").End().
  16. Int("sale_amount").NotNull().Default("0").Comment("销售额(单位:分)").End().
  17. Int("current_stock").NotNull().Default("0").Comment("当前库存").End().
  18. DateTime("update_time").NotNull().Default("CURRENT_TIMESTAMP").Comment("更新时间").End()
  19. // 索引
  20. //tb.Index("idx_date_store", "stat_date", "store_id").End().
  21. // Index("idx_category_date", "category_id", "stat_date").End()
  22. r.RegisterTable(tb.Build())
  23. })
  24. }
  25. type DwaDiscountDaily struct {
  26. StatID string `gorm:"column:stat_id;type:varchar(32);primaryKey;not null;comment:统计ID,主键"`
  27. StatDate time.Time `gorm:"column:stat_date;type:date;not null;comment:统计日期"`
  28. StoreID string `gorm:"column:store_id;type:varchar(32);not null;comment:店铺ID"`
  29. CategoryID string `gorm:"column:category_id;type:varchar(32);not null;comment:品类ID"`
  30. DiscountRange string `gorm:"column:discount_range;type:varchar(10);not null;comment:折扣档位"`
  31. InventoryAge int `gorm:"column:inventory_age;type:int(4);not null;comment:平均库龄"`
  32. SaleQuantity int `gorm:"column:sale_quantity;type:int(11);not null;default:0;comment:销量"`
  33. SaleAmount int `gorm:"column:sale_amount;type:int(11);not null;default:0;comment:销售额"`
  34. CurrentStock int `gorm:"column:current_stock;type:int(11);not null;default:0;comment:当前库存"`
  35. UpdateTime time.Time `gorm:"column:update_time;not null;default:CURRENT_TIMESTAMP;comment:更新时间"`
  36. TenantId string `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"`
  37. }
  38. func (DwaDiscountDaily) TableName() string { return "dwa_discount_daily" }