package model import ( "time" ) // Order 订单实体 type Order struct { BaseModel // 业务唯一键 OrderID string `gorm:"uniqueIndex:uk_order_order_id;not null;size:50" json:"order_id"` // 关联关系 (仅存储 ID,不使用 GORM 关联) UserID uint `gorm:"not null;index:idx_order_user_id" json:"user_id"` // 订单信息 Amount int64 `gorm:"not null" json:"amount"` // 金额(分) Status string `gorm:"not null;size:20;default:'pending';index:idx_order_status" json:"status"` Remark string `gorm:"size:500" json:"remark,omitempty"` // 时间字段 PaidAt *time.Time `gorm:"column:paid_at" json:"paid_at,omitempty"` CompletedAt *time.Time `gorm:"column:completed_at" json:"completed_at,omitempty"` } // TableName 指定表名 func (Order) TableName() string { return "tb_order" }