package models import ( "time" ) // SalesOrder 卖单表 type SalesOrder struct { ID uint `gorm:"primaryKey;autoIncrement" json:"id"` OrderNo string `gorm:"type:varchar(50);not null;uniqueIndex;comment:订单编号" json:"order_no"` SellerID uint `gorm:"type:int;not null;comment:卖家用户ID" json:"seller_id" binding:"required"` BuyerID uint `gorm:"type:int;not null;comment:买家用户ID" json:"buyer_id" binding:"required"` SecondaryProductID uint `gorm:"type:int;not null;comment:二级商品ID" json:"secondary_product_id" binding:"required"` ProductName string `gorm:"type:varchar(200);not null;comment:商品名称" json:"product_name" binding:"required"` ProductImages string `gorm:"type:text;comment:商品图片URLs,逗号分割" json:"product_images"` SellingPrice float64 `gorm:"type:decimal(10,2);not null;comment:出售价格" json:"selling_price" binding:"required"` Quantity int `gorm:"type:int;not null;default:1;comment:数量" json:"quantity"` TotalAmount float64 `gorm:"type:decimal(10,2);not null;comment:总金额" json:"total_amount" binding:"required"` AddressID *uint `gorm:"type:int;comment:收货地址ID" json:"address_id"` OrderStatus uint8 `gorm:"type:tinyint;not null;default:0;comment:订单状态:0待付款,1待发货,2确认完成,3已取消" json:"order_status"` CompleteTime *time.Time `gorm:"type:timestamp;null;comment:完成时间" json:"complete_time"` Remark string `gorm:"type:text;comment:备注" json:"remark"` CreatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"` UpdatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"` PaymentProofImage string `json:"payment_proof_image" gorm:"type:varchar(255)"` PurchaseOrderID uint `gorm:"type:int;" json:"purchase_order_id"` // 关联关系 Seller *User `gorm:"foreignKey:SellerID" json:"seller,omitempty"` Buyer User `gorm:"foreignKey:BuyerID" json:"buyer,omitempty"` SecondaryProduct SecondaryProduct `gorm:"foreignKey:SecondaryProductID" json:"secondary_product,omitempty"` Address *UserAddress `gorm:"foreignKey:AddressID" json:"address,omitempty"` PurchaseOrder *PurchaseOrder `gorm:"foreignKey:PurchaseOrderID" json:"purchase_order,omitempty"` } func (SalesOrder) TableName() string { return "sales_orders" }