1.0
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// PurchaseOrder 买单表
|
||||
type PurchaseOrder struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
OrderNo string `gorm:"type:varchar(50);not null;uniqueIndex;comment:订单编号" json:"order_no"`
|
||||
BuyerID uint `gorm:"type:int;not null;comment:买家用户ID" json:"buyer_id" binding:"required"`
|
||||
SellerID *uint `gorm:"type:int;comment:卖家用户ID(二级商品交易时使用)" json:"seller_id"`
|
||||
ProductID uint `gorm:"type:int;not null;comment:商品ID" json:"product_id" binding:"required"`
|
||||
ProductType uint8 `gorm:"type:tinyint;not null;comment:商品类型:1一级商品,2二级商品" json:"product_type" 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"`
|
||||
UnitPrice float64 `gorm:"type:decimal(10,2);not null;comment:单价" json:"unit_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"`
|
||||
ConfirmTime *time.Time `gorm:"type:timestamp;null;comment:确认时间" json:"confirm_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 `gorm:"type:varchar(255)" json:"payment_proof_image"`
|
||||
// 关联关系
|
||||
Buyer User `gorm:"foreignKey:BuyerID" json:"buyer,omitempty"`
|
||||
Seller *User `gorm:"foreignKey:SellerID" json:"seller,omitempty"`
|
||||
Address *UserAddress `gorm:"foreignKey:AddressID" json:"address,omitempty"`
|
||||
}
|
||||
|
||||
func (PurchaseOrder) TableName() string {
|
||||
return "purchase_orders"
|
||||
}
|
||||
Reference in New Issue
Block a user