Files
nuyue 13768f5f5b
Build and Push Docker Image / build-and-push (push) Successful in 1m6s
Build and Push Docker Image / deploy (push) Successful in 8s
feat: update order model with packaging_fee and international_fee, remove tax
2026-07-16 18:17:29 +08:00

74 lines
3.0 KiB
Go

package models
import (
"time"
"gorm.io/gorm"
)
type Order struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index;not null" json:"user_id"`
SupplierID *uint `gorm:"index" json:"supplier_id"`
Subtotal float64 `gorm:"type:decimal(10,2);not null" json:"subtotal"`
ShippingFee float64 `gorm:"type:decimal(10,2);default:0" json:"shipping_fee"`
ServiceFee float64 `gorm:"type:decimal(10,2);default:0" json:"service_fee"`
ChannelFee float64 `gorm:"type:decimal(10,2);default:0" json:"channel_fee"`
PackagingFee float64 `gorm:"type:decimal(10,2);default:0" json:"packaging_fee"`
InternationalFee float64 `gorm:"type:decimal(10,2);default:0" json:"international_fee"`
TotalAmount float64 `gorm:"type:decimal(10,2);not null" json:"total_amount"`
RefundAmount *float64 `gorm:"type:decimal(10,2)" json:"refund_amount"`
RefundStatus string `gorm:"size:20" json:"refund_status"`
RefundReason string `json:"refund_reason"`
Status string `gorm:"size:20;not null;default:'pending_payment'" json:"status"`
ShippingAddressID *uint `json:"shipping_address_id"`
TrackingNumber string `gorm:"size:100" json:"tracking_number"`
ShippingPhoto string `gorm:"type:text" json:"shipping_photo"`
ExpressPhoto string `gorm:"type:text" json:"express_photo"`
CustomsPhoto string `gorm:"type:text" json:"customs_photo"`
PaymentMethod string `gorm:"size:50" json:"payment_method"`
PaymentExpiresAt *time.Time `json:"payment_expires_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
OrderItems []OrderItem `json:"order_items,omitempty"`
ShippingAddress *Address `json:"shipping_address,omitempty"`
User User `json:"user,omitempty"`
}
func (Order) TableName() string {
return "orders"
}
type OrderItem struct {
ID uint `gorm:"primaryKey" json:"id"`
OrderID uint `gorm:"index;not null" json:"order_id"`
ProductID uint `gorm:"index;not null" json:"product_id"`
Quantity int `gorm:"not null" json:"quantity"`
Price float64 `gorm:"type:decimal(10,2);not null" json:"price"`
Product Product `json:"product,omitempty"`
}
func (OrderItem) TableName() string {
return "order_items"
}
const (
OrderStatusPendingPayment = "pending_payment"
OrderStatusPendingConfirm = "pending_confirm"
OrderStatusPendingShip = "pending_ship"
OrderStatusShipped = "shipped"
OrderStatusCompleted = "completed"
OrderStatusRefunding = "refunding"
OrderStatusRefunded = "refunded"
OrderStatusCancelled = "cancelled"
)
const (
RefundStatusNone = ""
RefundStatusPending = "pending"
RefundStatusApproved = "approved"
RefundStatusRejected = "rejected"
RefundStatusCompleted = "completed"
)