feat: add shipping template management and update favicon
This commit is contained in:
@@ -7,29 +7,31 @@ import (
|
||||
)
|
||||
|
||||
type Product struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"size:255;not null" json:"name"`
|
||||
Description string `json:"description"`
|
||||
Price float64 `gorm:"type:decimal(10,2);not null" json:"price"`
|
||||
Weight float64 `gorm:"type:decimal(10,2);default:0" json:"weight"` // 商品克重(克)
|
||||
MinPurchase int `gorm:"default:1" json:"min_purchase"`
|
||||
MaxPurchase *int `json:"max_purchase"`
|
||||
MinWeight *float64 `json:"min_weight"`
|
||||
MaxWeight *float64 `json:"max_weight"`
|
||||
MinAmount *float64 `json:"min_amount"`
|
||||
MaxAmount *float64 `json:"max_amount"`
|
||||
RequireCredit bool `gorm:"default:false" json:"require_credit"`
|
||||
CreditCost int `gorm:"default:0" json:"credit_cost"`
|
||||
CreditReward int `gorm:"default:0" json:"credit_reward"`
|
||||
Images string `gorm:"type:text" json:"images"`
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
BrandID *uint `json:"brand_id"`
|
||||
Brand *Brand `json:"brand,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
Categories []Category `gorm:"many2many:product_categories;" json:"categories,omitempty"`
|
||||
CustomFields []ProductCustomField `json:"custom_fields,omitempty"`
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"size:255;not null" json:"name"`
|
||||
Description string `json:"description"`
|
||||
Price float64 `gorm:"type:decimal(10,2);not null" json:"price"`
|
||||
Weight float64 `gorm:"type:decimal(10,2);default:0" json:"weight"` // 商品克重(克)
|
||||
MinPurchase int `gorm:"default:1" json:"min_purchase"`
|
||||
MaxPurchase *int `json:"max_purchase"`
|
||||
MinWeight *float64 `json:"min_weight"`
|
||||
MaxWeight *float64 `json:"max_weight"`
|
||||
MinAmount *float64 `json:"min_amount"`
|
||||
MaxAmount *float64 `json:"max_amount"`
|
||||
RequireCredit bool `gorm:"default:false" json:"require_credit"`
|
||||
CreditCost int `gorm:"default:0" json:"credit_cost"`
|
||||
CreditReward int `gorm:"default:0" json:"credit_reward"`
|
||||
Images string `gorm:"type:text" json:"images"`
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
BrandID *uint `json:"brand_id"`
|
||||
Brand *Brand `json:"brand,omitempty"`
|
||||
ShippingTemplateID *uint `json:"shipping_template_id"`
|
||||
ShippingTemplate *ShippingTemplate `json:"shipping_template,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
Categories []Category `gorm:"many2many:product_categories;" json:"categories,omitempty"`
|
||||
CustomFields []ProductCustomField `json:"custom_fields,omitempty"`
|
||||
}
|
||||
|
||||
func (Product) TableName() string {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// ShippingTemplate 运费模板
|
||||
type ShippingTemplate struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"size:255;not null" json:"name"` // 模板名称(如"江浙沪包邮"、"偏远地区")
|
||||
CalcType string `gorm:"size:20;not null;default:'weight'" json:"calc_type"` // 计费方式:weight=按重量, piece=按件数
|
||||
FirstUnit float64 `gorm:"type:decimal(10,2);not null" json:"first_unit"` // 首重/首件数量
|
||||
FirstFee float64 `gorm:"type:decimal(10,2);not null" json:"first_fee"` // 首重/首件价格
|
||||
AdditionalUnit float64 `gorm:"type:decimal(10,2);not null" json:"additional_unit"` // 续重/续件数量
|
||||
AdditionalFee float64 `gorm:"type:decimal(10,2);not null" json:"additional_fee"` // 续重/续件价格
|
||||
FreeAmount float64 `gorm:"type:decimal(10,2);default:0" json:"free_amount"` // 包邮金额(0表示不包邮)
|
||||
Provinces string `gorm:"type:text" json:"provinces"` // 适用省份列表(JSON数组,为空表示全国)
|
||||
IsDefault bool `gorm:"default:false" json:"is_default"` // 是否默认模板
|
||||
SortOrder int `gorm:"default:0" json:"sort_order"` // 排序
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
func (ShippingTemplate) TableName() string {
|
||||
return "shipping_templates"
|
||||
}
|
||||
|
||||
// 计费方式常量
|
||||
const (
|
||||
CalcTypeWeight = "weight" // 按重量计费
|
||||
CalcTypePiece = "piece" // 按件数计费
|
||||
)
|
||||
Reference in New Issue
Block a user