重构: 手续费改为百分比/固定二选一,清理旧 Skin/Order/ShipLog 演示链路
手续费: - 新增 fee_type 字段(rate/fixed),百分比与固定金额二选一,不再叠加 - calculateServiceFee 按 fee_type 分支计算 - 商户创建/更新校验 fee_type,订单落库快照 fee_type - 前端表单改为下拉选择手续费类型,动态显示对应输入框 - 测试拆为 TestFeeRate + TestFeeFixed 清理旧链路: - 删除旧 Skin/Order/ShipLog 模型及 OrderService/SkinService - Dashboard 迁移到 FulfillmentService - 上游 /api/open/v1 改为基于 FulfillmentOrder 实现,接口契约不变 - 推送留痕改用 AuditLog,不再建 ShipLog 表 - 删除前端 Skins/Orders/ShipLogs/Distributors 页面及路由、菜单、API、类型 - 新增迁移 003: 添加 fee_type 列并 DROP 旧表
This commit is contained in:
@@ -10,11 +10,21 @@ const (
|
||||
MerchantStatusActive = "active"
|
||||
MerchantStatusDisabled = "disabled"
|
||||
|
||||
MerchantFeatureProducts = "products"
|
||||
MerchantFeatureOrders = "orders"
|
||||
MerchantFeatureWallet = "wallet"
|
||||
MerchantFeatureAPI = "api"
|
||||
MerchantFeatureCallbacks = "callbacks"
|
||||
DefaultMerchantFeatures = "products,orders,wallet,api,callbacks"
|
||||
|
||||
MemberRoleOwner = "owner"
|
||||
MemberRoleOperator = "operator"
|
||||
MemberRoleFinance = "finance"
|
||||
MemberRoleViewer = "viewer"
|
||||
|
||||
FeeTypeRate = "rate" // 手续费按百分比
|
||||
FeeTypeFixed = "fixed" // 手续费按固定金额
|
||||
|
||||
APIClientStatusActive = "active"
|
||||
APIClientStatusDisabled = "disabled"
|
||||
|
||||
@@ -63,6 +73,22 @@ type Merchant struct {
|
||||
Status string `gorm:"size:16;not null;default:active;index" json:"status"`
|
||||
ContactName string `gorm:"size:64" json:"contact_name"`
|
||||
ContactInfo string `gorm:"size:128" json:"contact_info"`
|
||||
Features string `gorm:"type:text;not null;default:'products,orders,wallet,api,callbacks'" json:"features"`
|
||||
|
||||
// 手续费按"百分比或固定"二选一:fee_type=rate 用 fee_rate_bp,fee_type=fixed 用 fee_fixed_amount。
|
||||
FeeType string `gorm:"size:16;not null;default:rate" json:"fee_type"`
|
||||
FeeRateBP int64 `gorm:"not null;default:0" json:"fee_rate_bp"`
|
||||
FeeFixedAmount int64 `gorm:"not null;default:0" json:"fee_fixed_amount"`
|
||||
}
|
||||
|
||||
func (m *Merchant) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.Features == "" {
|
||||
m.Features = DefaultMerchantFeatures
|
||||
}
|
||||
if m.FeeType == "" {
|
||||
m.FeeType = FeeTypeRate
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MerchantMember 将系统账号和商户权限分离,账号可以属于多个商户。
|
||||
@@ -179,6 +205,11 @@ type FulfillmentOrder struct {
|
||||
ProductSKU string `gorm:"size:96;not null" json:"product_sku"`
|
||||
ProductName string `gorm:"size:160;not null" json:"product_name"`
|
||||
Quantity int64 `gorm:"not null;default:1" json:"quantity"`
|
||||
BaseAmount int64 `gorm:"not null;default:0" json:"base_amount"`
|
||||
FeeType string `gorm:"size:16;not null;default:rate" json:"fee_type"`
|
||||
FeeRateBP int64 `gorm:"not null;default:0" json:"fee_rate_bp"`
|
||||
FeeFixedAmount int64 `gorm:"not null;default:0" json:"fee_fixed_amount"`
|
||||
ServiceFeeAmount int64 `gorm:"not null;default:0" json:"service_fee_amount"`
|
||||
Amount int64 `gorm:"not null" json:"amount"`
|
||||
Currency string `gorm:"size:12;not null;default:CNY" json:"currency"`
|
||||
PaymentStatus string `gorm:"size:16;not null;default:pending;index" json:"payment_status"`
|
||||
|
||||
Reference in New Issue
Block a user