99 lines
4.5 KiB
Go
99 lines
4.5 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/datatypes"
|
|
)
|
|
|
|
// MohongCategory 摸大红商品分类。
|
|
type MohongCategory struct {
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
Name string `gorm:"size:64;not null;uniqueIndex" json:"name"`
|
|
Code string `gorm:"size:64;not null;default:''" json:"code"`
|
|
SortOrder int `gorm:"column:sort_order;not null;default:0" json:"sort_order"`
|
|
Status string `gorm:"size:16;not null;default:'enabled'" json:"status"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (MohongCategory) TableName() string {
|
|
return "mohong_categories"
|
|
}
|
|
|
|
// MohongProductCategory 商品与分类多对多(同一商品可出现在大红/九格等)。
|
|
type MohongProductCategory struct {
|
|
ProductID uint64 `gorm:"column:product_id;primaryKey" json:"product_id"`
|
|
CategoryID uint64 `gorm:"column:category_id;primaryKey;index" json:"category_id"`
|
|
}
|
|
|
|
func (MohongProductCategory) TableName() string {
|
|
return "mohong_product_categories"
|
|
}
|
|
|
|
// MohongProduct 摸大红商品。
|
|
type MohongProduct struct {
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
CategoryID *uint64 `gorm:"column:category_id;index" json:"category_id"` // 主分类(展示用)
|
|
Title string `gorm:"size:128;not null" json:"title"`
|
|
CoverURL string `gorm:"column:cover_url;size:512;not null;default:''" json:"cover_url"`
|
|
ImageURLs datatypes.JSON `gorm:"column:image_urls" json:"image_urls"`
|
|
Description string `gorm:"type:text;not null" json:"description"`
|
|
PriceCent int64 `gorm:"column:price_cent;not null;default:0" json:"-"`
|
|
OriginalPriceCent int64 `gorm:"column:original_price_cent;not null;default:0" json:"-"`
|
|
Unit string `gorm:"size:32;not null;default:'份'" json:"unit"`
|
|
Stock int `gorm:"not null;default:-1" json:"stock"`
|
|
SortOrder int `gorm:"column:sort_order;not null;default:0" json:"sort_order"`
|
|
Status string `gorm:"size:16;not null;default:'draft'" json:"status"`
|
|
QrcodeImageURL string `gorm:"column:qrcode_image_url;size:512;not null;default:''" json:"qrcode_image_url"`
|
|
CreatedBy *uint64 `gorm:"column:created_by" json:"created_by"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (MohongProduct) TableName() string {
|
|
return "mohong_products"
|
|
}
|
|
|
|
// MohongOrder 摸大红订单。
|
|
type MohongOrder struct {
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
OrderNo string `gorm:"size:64;not null;uniqueIndex" json:"order_no"`
|
|
UserID uint64 `gorm:"not null;index" json:"user_id"`
|
|
ProductID uint64 `gorm:"not null;index" json:"product_id"`
|
|
Quantity int `gorm:"not null;default:1" json:"quantity"`
|
|
UnitPriceCent int64 `gorm:"column:unit_price_cent;not null;default:0" json:"-"`
|
|
AmountCent int64 `gorm:"column:amount_cent;not null;default:0" json:"-"`
|
|
Status string `gorm:"size:32;not null;default:'pending_payment';index" json:"status"`
|
|
ProductSnapshot datatypes.JSON `gorm:"column:product_snapshot" json:"product_snapshot"`
|
|
QrcodeURLSnapshot string `gorm:"column:qrcode_url_snapshot;size:512;not null;default:''" json:"qrcode_url_snapshot"`
|
|
CopyText string `gorm:"type:text;not null" json:"copy_text"`
|
|
ConversationID *uint64 `gorm:"column:conversation_id" json:"conversation_id"`
|
|
PaidAt *time.Time `json:"paid_at"`
|
|
CompletedAt *time.Time `json:"completed_at"`
|
|
CancelledAt *time.Time `json:"cancelled_at"`
|
|
CancelReason string `gorm:"size:255;not null;default:''" json:"cancel_reason"`
|
|
AdminRemark string `gorm:"size:255;not null;default:''" json:"admin_remark"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (MohongOrder) TableName() string {
|
|
return "mohong_orders"
|
|
}
|
|
|
|
const (
|
|
MohongCategoryStatusEnabled = "enabled"
|
|
MohongCategoryStatusDisabled = "disabled"
|
|
|
|
MohongProductStatusDraft = "draft"
|
|
MohongProductStatusOnSale = "on_sale"
|
|
MohongProductStatusOffSale = "off_sale"
|
|
|
|
MohongOrderStatusPendingPayment = "pending_payment"
|
|
MohongOrderStatusPaid = "paid"
|
|
MohongOrderStatusCompleted = "completed"
|
|
MohongOrderStatusCancelled = "cancelled"
|
|
MohongOrderStatusRefunded = "refunded"
|
|
)
|