package tables import ( "time" "git.x2erp.com/qdy/go-db/sqldef" ) func init() { sqldef.AddRegistration(func(r *sqldef.Registry) { tb := sqldef.NewTable("bill_sales_retail", "零售销售单据表"). ID("id", 50).NotNull().Comment("主键ID").End(). String("tenant_id", 50).NotNull().Comment("租户ID").End(). String("bill_id", 50).NotNull().Comment("单据编号").End(). String("bill_type", 20).NotNull().Comment("单据类型 (SALE销售/RETURN退货/ADJUST调整)").End(). String("bill_status", 20).NotNull().Comment("单据状态 (DRAFT草稿/SUBMITTED已提交/APPROVED已审核/COMPLETED已完成/CANCELLED已取消)").End(). String("from_store_id", 50).NotNull().Comment("店铺ID").End(). String("company_id", 50).Comment("所属公司ID").End(). String("business_type_id", 50).Comment("业务类型ID").End(). String("business_type_name", 100).Comment("业务类型名称").End(). String("price_type_id", 50).Comment("价格类型ID").End(). String("price_type_name", 100).Comment("价格类型名称").End(). String("finance_type_id", 50).Comment("财务类型ID").End(). String("finance_type_name", 100).Comment("财务类型名称").End(). Int("sure_status").NotNull().Default("0").Comment("登账标识 (0:草稿, 1:已登账)").End(). Date("sure_date").Comment("登账日期").End(). String("product_id", 50).NotNull().Comment("商品ID").End(). String("product_code", 50).NotNull().Comment("商品编码").End(). String("product_name", 200).NotNull().Comment("商品名称").End(). String("size_code", 10).Comment("尺码代码").End(). String("color_code", 10).Comment("颜色代码").End(). Decimal("settlement_qty", 12, 4).NotNull().Default("0").Comment("结算数量").End(). Decimal("discount_rate", 5, 4).NotNull().Default("0").Comment("折扣率").End(). Decimal("settlement_price", 12, 2).NotNull().Default("0").Comment("结算单价").End(). Decimal("settlement_amount", 12, 2).NotNull().Default("0").Comment("结算金额").End(). String("currency_code", 3).NotNull().Default("'CNY'").Comment("货币代码").End(). String("payment_method", 20).Comment("支付方式 (CASH现金/CARD银行卡/ALIPAY支付宝/WECHAT微信)").End(). String("customer_id", 50).Comment("客户ID").End(). String("customer_name", 200).Comment("客户姓名").End(). String("customer_phone", 20).Comment("客户电话").End(). String("salesperson_id", 50).Comment("销售人员ID").End(). String("salesperson_name", 100).Comment("销售人员姓名").End(). String("approver_id", 50).Comment("审核人ID").End(). String("approver_name", 100).Comment("审核人姓名").End(). DateTime("approved_time").Comment("审核时间").End(). String("remark", 500).Comment("备注").End(). String("creator", 32).NotNull().Comment("创建人").End(). DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End(). DateTime("updated_at").NotNull().Default("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").Comment("更新时间").End(). Date("data_date").NotNull().Comment("数据日期 (数据仓库快照)").End() tb.AddUniqueIndex("idx_bill_id_product", "bill_id", "product_id", "size_code", "color_code") tb.AddIndex("idx_tenant_id", "tenant_id") tb.AddIndex("idx_bill_type", "bill_type") tb.AddIndex("idx_bill_status", "bill_status") tb.AddIndex("idx_from_store_id", "from_store_id") tb.AddIndex("idx_document_date", "data_date") tb.AddIndex("idx_customer_id", "customer_id") tb.AddIndex("idx_product_id", "product_id") tb.AddIndex("idx_data_date", "data_date") tb.AddIndex("idx_from_store_date_type", "from_store_id", "data_date", "bill_type") tb.AddIndex("idx_status_date", "bill_status", "data_date") tb.AddIndex("idx_company_id", "company_id") tb.AddIndex("idx_sure_status", "sure_status") r.RegisterTable(tb.Build()) }) } type BillSalesRetail struct { ID string `gorm:"column:id;type:varchar(50);not null;primaryKey;comment:主键ID"` TenantID string `gorm:"column:tenant_id;type:varchar(50);not null;comment:租户ID"` BillID string `gorm:"column:bill_id;type:varchar(50);not null;comment:单据编号"` BillType string `gorm:"column:bill_type;type:varchar(20);not null;comment:单据类型 (SALE销售/RETURN退货/ADJUST调整)"` BillStatus string `gorm:"column:bill_status;type:varchar(20);not null;comment:单据状态 (DRAFT草稿/SUBMITTED已提交/APPROVED已审核/COMPLETED已完成/CANCELLED已取消)"` FromStoreID string `gorm:"column:from_store_id;type:varchar(50);not null;comment:店铺ID"` CompanyID string `gorm:"column:company_id;type:varchar(50);comment:所属公司ID"` BusinessTypeID string `gorm:"column:business_type_id;type:varchar(50);comment:业务类型ID"` BusinessTypeName string `gorm:"column:business_type_name;type:varchar(100);comment:业务类型名称"` PriceTypeID string `gorm:"column:price_type_id;type:varchar(50);comment:价格类型ID"` PriceTypeName string `gorm:"column:price_type_name;type:varchar(100);comment:价格类型名称"` FinanceTypeID string `gorm:"column:finance_type_id;type:varchar(50);comment:财务类型ID"` FinanceTypeName string `gorm:"column:finance_type_name;type:varchar(100);comment:财务类型名称"` SureStatus int32 `gorm:"column:sure_status;type:int;not null;default:0;comment:登账标识 (0:草稿, 1:已登账)"` SureDate *time.Time `gorm:"column:sure_date;comment:登账日期"` ProductID string `gorm:"column:product_id;type:varchar(50);not null;comment:商品ID"` ProductCode string `gorm:"column:product_code;type:varchar(50);not null;comment:商品编码"` ProductName string `gorm:"column:product_name;type:varchar(200);not null;comment:商品名称"` SizeCode string `gorm:"column:size_code;type:varchar(10);comment:尺码代码"` ColorCode string `gorm:"column:color_code;type:varchar(10);comment:颜色代码"` SettlementQty float64 `gorm:"column:settlement_qty;type:decimal(12,4);not null;default:0;comment:结算数量"` DiscountRate float64 `gorm:"column:discount_rate;type:decimal(5,4);not null;default:0;comment:折扣率"` SettlementPrice float64 `gorm:"column:settlement_price;type:decimal(12,2);not null;default:0;comment:结算单价"` SettlementAmount float64 `gorm:"column:settlement_amount;type:decimal(12,2);not null;default:0;comment:结算金额"` CurrencyCode string `gorm:"column:currency_code;type:varchar(3);not null;default:CNY;comment:货币代码"` PaymentMethod string `gorm:"column:payment_method;type:varchar(20);comment:支付方式 (CASH现金/CARD银行卡/ALIPAY支付宝/WECHAT微信)"` CustomerID string `gorm:"column:customer_id;type:varchar(50);comment:客户ID"` CustomerName string `gorm:"column:customer_name;type:varchar(200);comment:客户姓名"` CustomerPhone string `gorm:"column:customer_phone;type:varchar(20);comment:客户电话"` SalespersonID string `gorm:"column:salesperson_id;type:varchar(50);comment:销售人员ID"` SalespersonName string `gorm:"column:salesperson_name;type:varchar(100);comment:销售人员姓名"` ApproverID string `gorm:"column:approver_id;type:varchar(50);comment:审核人ID"` ApproverName string `gorm:"column:approver_name;type:varchar(100);comment:审核人姓名"` ApprovedTime *time.Time `gorm:"column:approved_time;comment:审核时间"` Remark string `gorm:"column:remark;type:varchar(500);comment:备注"` Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"` CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"` UpdatedAt time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"` DataDate time.Time `gorm:"column:data_date;type:date;not null;comment:数据日期 (数据仓库快照)"` } type BillSalesRetailDB struct { ID string `db:"id" json:"id"` TenantID string `db:"tenant_id" json:"tenantID"` BillID string `db:"bill_id" json:"billID"` BillType string `db:"bill_type" json:"billType"` BillStatus string `db:"bill_status" json:"billStatus"` FromStoreID string `db:"from_store_id" json:"fromStoreID"` CompanyID string `db:"company_id" json:"companyID"` BusinessTypeID string `db:"business_type_id" json:"businessTypeID"` BusinessTypeName string `db:"business_type_name" json:"businessTypeName"` PriceTypeID string `db:"price_type_id" json:"priceTypeID"` PriceTypeName string `db:"price_type_name" json:"priceTypeName"` FinanceTypeID string `db:"finance_type_id" json:"financeTypeID"` FinanceTypeName string `db:"finance_type_name" json:"financeTypeName"` SureStatus int32 `db:"sure_status" json:"sureStatus"` SureDate *time.Time `db:"sure_date" json:"sureDate"` ProductID string `db:"product_id" json:"productID"` ProductCode string `db:"product_code" json:"productCode"` ProductName string `db:"product_name" json:"productName"` SizeCode string `db:"size_code" json:"sizeCode"` ColorCode string `db:"color_code" json:"colorCode"` SettlementQty float64 `db:"settlement_qty" json:"settlementQty"` DiscountRate float64 `db:"discount_rate" json:"discountRate"` SettlementPrice float64 `db:"settlement_price" json:"settlementPrice"` SettlementAmount float64 `db:"settlement_amount" json:"settlementAmount"` CurrencyCode string `db:"currency_code" json:"currencyCode"` PaymentMethod string `db:"payment_method" json:"paymentMethod"` CustomerID string `db:"customer_id" json:"customerID"` CustomerName string `db:"customer_name" json:"customerName"` CustomerPhone string `db:"customer_phone" json:"customerPhone"` SalespersonID string `db:"salesperson_id" json:"salespersonID"` SalespersonName string `db:"salesperson_name" json:"salespersonName"` ApproverID string `db:"approver_id" json:"approverID"` ApproverName string `db:"approver_name" json:"approverName"` ApprovedTime *time.Time `db:"approved_time" json:"approvedTime"` Remark string `db:"remark" json:"remark"` Creator string `db:"creator" json:"creator"` CreatedAt time.Time `db:"created_at" json:"createdAt"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` DataDate time.Time `db:"data_date" json:"dataDate"` } func (BillSalesRetail) TableName() string { return "bill_sales_retail" }