12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package request
- import (
- "gorm.io/gorm"
- pb "sghgogs.com/micro/shopping-service/proto"
- "time"
- )
- // Created 创建 订单被创建,但尚未进行任何处理
- // Pending Payment 待付款 客户已创建订单,但尚未完成支付
- // Paid 已付款 订单支付已成功,等待商家确认
- // Processing 处理中 商家已确认订单,并开始处理订单中的商品。
- // Shipped 发货中 商品已从商家发货,运送中
- // Completed 已完 订单已经成功交付,交易完成。
- // Canceled 已取消 订单被取消,交易终止。
- // Refund in Progress 退款中 客户请求退款,正在处理中。
- // Refunded 已退款 退款已完成,交易终止
- // Return in Progress 退货中 客户请求退货,正在处理中
- // Returned 已退货 退货已完成,交易终止。
- // Under Review 审核中 订单或支付信息正在被审核。
- // Order 订单表模型
- type Order struct {
- ID int64 `gorm:"primary_key;not_null;auto_increment;" json:"id"`
- UserID int64 `gorm:"not null" json:"user_id"`
- User User `gorm:"foreignKey:UserID" json:"user"`
- AddressID int64 `gorm:"not null" json:"address_id"`
- Address Address `gorm:"foreignKey:AddressID" json:"address"`
- TotalAmount int32 `json:"total_amount"` // 订单总金额
- Status pb.OrderStatusEnum `json:"status"` // 订单状态
- PaymentMethod pb.PaymentMethodEnum `json:"payment_method"` // 支付方式
- OrderItems []OrderItem `gorm:"foreignKey:OrderID" comment:"订单项列表" json:"order_items"`
- Payment Payment `gorm:"foreignKey:OrderID" json:"payment"`
- CreatedAt time.Time `json:"created_at"`
- UpdatedAt *time.Time `json:"updated_at"`
- OrderDate gorm.DeletedAt
- }
- type OrderItem struct {
- ID int64 `gorm:"primary_key;not_null;auto_increment;" json:"id"`
- OrderID int64 `gorm:"not null" json:"order_id" comment:"订单ID"`
- Order Order `gorm:"foreignKey:OrderID" comment:"关联的订单" json:"order"`
- ProductID int64 `gorm:"not null" json:"product_id" comment:"商品ID"`
- Product Product `gorm:"foreignKey:ProductID" json:"product" comment:"关联的商品"`
- Quantity int64 `json:"quantity" comment:"商品数量"`
- Subtotal int64 `json:"subtotal" comment:"订单项小计"`
- CreatedAt time.Time `json:"created_at"`
- UpdatedAt *time.Time `json:"updated_at"`
- }
|