설명 없음
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.

sales_transaction.go 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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("sales_transaction", "销售流水表").
  9. ID("transaction_id", 32).Comment("交易流水ID,主键").End().
  10. String("erp_order_id", 64).NotNull().Comment("ERP原始订单号").End().
  11. String("sku_id", 32).NotNull().Comment("商品SKU").End().
  12. String("channel_id", 32).NotNull().Comment("销售渠道").End().
  13. String("tenant_id", 8).NotNull().Comment("租户ID").End().
  14. Int("quantity").NotNull().Default("0").Comment("销售数量").End().
  15. Decimal("original_amount", 12, 2).NotNull().Comment("吊牌价金额").End().
  16. Decimal("actual_amount", 12, 2).NotNull().Comment("实收金额").End().
  17. DateTime("sale_time").NotNull().Comment("销售时间").End().
  18. DateTime("extracted_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("数据抽取时间").End()
  19. r.RegisterTable(tb.Build())
  20. })
  21. }
  22. // SalesTransaction 销售流水表结构体
  23. type SalesTransaction struct {
  24. TransactionID string `gorm:"column:transaction_id;type:varchar(32);primaryKey;not null;comment:交易流水ID,主键"`
  25. ErpOrderID string `gorm:"column:erp_order_id;type:varchar(64);not null;comment:ERP原始订单号;index"`
  26. SkuID string `gorm:"column:sku_id;type:varchar(32);not null;comment:商品SKU;index:idx_sku_channel_time"`
  27. ChannelID string `gorm:"column:channel_id;type:varchar(32);not null;comment:销售渠道;index:idx_sku_channel_time"`
  28. Quantity int `gorm:"column:quantity;not null;default:0;comment:销售数量"`
  29. OriginalAmount float64 `gorm:"column:original_amount;type:decimal(12,2);not null;comment:吊牌价金额"`
  30. ActualAmount float64 `gorm:"column:actual_amount;type:decimal(12,2);not null;comment:实收金额"`
  31. SaleTime time.Time `gorm:"column:sale_time;not null;comment:销售时间;index:idx_sku_channel_time"`
  32. ExtractedAt time.Time `gorm:"column:extracted_at;not null;default:CURRENT_TIMESTAMP;comment:数据抽取时间"`
  33. TenantId string `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"`
  34. }
  35. func (SalesTransaction) TableName() string {
  36. return "sales_transaction"
  37. }