实现分销网后台基础功能与独立前端
This commit is contained in:
@@ -0,0 +1,164 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// DistributionSite 表示一个独立分销网站主体。
|
||||
type DistributionSite struct {
|
||||
ID uint64 `gorm:"primaryKey" json:"id"`
|
||||
SiteCode string `gorm:"size:64;not null;uniqueIndex" json:"site_code"`
|
||||
SiteName string `gorm:"size:128;not null" json:"site_name"`
|
||||
Domain string `gorm:"size:255;not null;uniqueIndex" json:"domain"`
|
||||
Status string `gorm:"size:16;not null;default:'active';index" json:"status"`
|
||||
DisplayAccountEnabled bool `gorm:"not null;default:true" json:"display_account_enabled"`
|
||||
DefaultSupportGroupID *uint64 `gorm:"index" json:"default_support_group_id,omitempty"`
|
||||
TaxEnabled bool `gorm:"not null;default:false" json:"tax_enabled"`
|
||||
TaxRateBPS int64 `gorm:"not null;default:100" json:"tax_rate_bps"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (DistributionSite) TableName() string { return "distribution_sites" }
|
||||
|
||||
// DistributionSiteMember 将现有后台管理员映射到分销网站。
|
||||
type DistributionSiteMember struct {
|
||||
ID uint64 `gorm:"primaryKey" json:"id"`
|
||||
SiteID uint64 `gorm:"not null;uniqueIndex:uk_distribution_site_member;index" json:"site_id"`
|
||||
AdminUserID uint64 `gorm:"not null;uniqueIndex:uk_distribution_site_member;index" json:"admin_user_id"`
|
||||
MemberType string `gorm:"size:32;not null" json:"member_type"`
|
||||
Status string `gorm:"size:16;not null;default:'active';index" json:"status"`
|
||||
DataScope string `gorm:"size:32;not null;default:'site'" json:"data_scope"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (DistributionSiteMember) TableName() string { return "distribution_site_members" }
|
||||
|
||||
// DistributionSiteAccount 控制账号在分销网站的展示状态。
|
||||
type DistributionSiteAccount struct {
|
||||
ID uint64 `gorm:"primaryKey" json:"id"`
|
||||
SiteID uint64 `gorm:"not null;uniqueIndex:uk_distribution_site_account;index" json:"site_id"`
|
||||
AccountID uint64 `gorm:"not null;uniqueIndex:uk_distribution_site_account;index" json:"account_id"`
|
||||
ListingID uint64 `gorm:"not null;index" json:"listing_id"`
|
||||
DisplayStatus string `gorm:"size:16;not null;default:'enabled';index" json:"display_status"`
|
||||
DisplayStartedAt *time.Time `json:"display_started_at,omitempty"`
|
||||
DisplayEndedAt *time.Time `json:"display_ended_at,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (DistributionSiteAccount) TableName() string { return "distribution_site_accounts" }
|
||||
|
||||
// DistributionRuleVersion 是新订单使用的分账规则快照来源。
|
||||
type DistributionRuleVersion struct {
|
||||
ID uint64 `gorm:"primaryKey" json:"id"`
|
||||
SiteID *uint64 `gorm:"index" json:"site_id,omitempty"`
|
||||
Mode string `gorm:"size:32;not null;index" json:"mode"`
|
||||
Version int `gorm:"not null" json:"version"`
|
||||
Status string `gorm:"size:16;not null;default:'draft';index" json:"status"`
|
||||
PlatformReceiveRatio float64 `gorm:"type:decimal(10,2);not null;default:0" json:"platform_receive_ratio"`
|
||||
PlatformSellRatio float64 `gorm:"type:decimal(10,2);not null;default:0" json:"platform_sell_ratio"`
|
||||
DistributorReceiveRatio float64 `gorm:"type:decimal(10,2);not null;default:0" json:"distributor_receive_ratio"`
|
||||
DistributorSellRatio float64 `gorm:"type:decimal(10,2);not null;default:0" json:"distributor_sell_ratio"`
|
||||
DistributorARatio float64 `gorm:"type:decimal(10,2);not null;default:0" json:"distributor_a_ratio"`
|
||||
DistributorBRatio float64 `gorm:"type:decimal(10,2);not null;default:0" json:"distributor_b_ratio"`
|
||||
ServiceFeeValue float64 `gorm:"type:decimal(12,4);not null;default:0" json:"service_fee_value"`
|
||||
ServiceFeeUnit string `gorm:"size:24;not null;default:'percent'" json:"service_fee_unit"`
|
||||
PaymentFeeBPS int64 `gorm:"not null;default:50" json:"payment_fee_bps"`
|
||||
TaxEnabled bool `gorm:"not null;default:false" json:"tax_enabled"`
|
||||
TaxRateBPS int64 `gorm:"not null;default:100" json:"tax_rate_bps"`
|
||||
EffectiveFrom time.Time `gorm:"index" json:"effective_from"`
|
||||
EffectiveTo *time.Time `gorm:"index" json:"effective_to,omitempty"`
|
||||
CreatedBy *uint64 `json:"created_by,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
func (DistributionRuleVersion) TableName() string { return "distribution_rule_versions" }
|
||||
|
||||
// DistributionOrderFinancial 保存正常订单的分销财务快照。
|
||||
type DistributionOrderFinancial struct {
|
||||
ID uint64 `gorm:"primaryKey" json:"id"`
|
||||
OrderID uint64 `gorm:"not null;uniqueIndex" json:"order_id"`
|
||||
SiteID uint64 `gorm:"not null;index" json:"site_id"`
|
||||
RuleVersionID uint64 `gorm:"not null" json:"rule_version_id"`
|
||||
GrossPaidAmountCent int64 `gorm:"not null;default:0" json:"gross_paid_amount_cent"`
|
||||
RefundAmountCent int64 `gorm:"not null;default:0" json:"refund_amount_cent"`
|
||||
NetPaidAmountCent int64 `gorm:"not null;default:0" json:"net_paid_amount_cent"`
|
||||
PaymentFeeBPS int64 `gorm:"not null;default:50" json:"payment_fee_bps"`
|
||||
PaymentFeeCent int64 `gorm:"not null;default:0" json:"payment_fee_cent"`
|
||||
ServiceFeeValue float64 `gorm:"type:decimal(12,4);not null;default:0" json:"service_fee_value"`
|
||||
ServiceFeeUnit string `gorm:"size:24;not null;default:'percent'" json:"service_fee_unit"`
|
||||
ServiceFeeCent int64 `gorm:"not null;default:0" json:"service_fee_cent"`
|
||||
MarkupAmountCent int64 `gorm:"not null;default:0" json:"markup_amount_cent"`
|
||||
TaxEnabled bool `gorm:"not null;default:false" json:"tax_enabled"`
|
||||
TaxRateBPS int64 `gorm:"not null;default:100" json:"tax_rate_bps"`
|
||||
TaxAmountCent int64 `gorm:"not null;default:0" json:"tax_amount_cent"`
|
||||
SplitBaseAmountCent int64 `gorm:"not null;default:0" json:"split_base_amount_cent"`
|
||||
RoundingAdjustmentCent int64 `gorm:"not null;default:0" json:"rounding_adjustment_cent"`
|
||||
SettlementStatus string `gorm:"size:24;not null;default:'pending';index" json:"settlement_status"`
|
||||
SettledAt *time.Time `json:"settled_at,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (DistributionOrderFinancial) TableName() string { return "distribution_order_financials" }
|
||||
|
||||
// DistributionOrderParty 保存订单创建时的参与方和金额快照,避免规则或站点变更影响历史订单。
|
||||
type DistributionOrderParty struct {
|
||||
ID uint64 `gorm:"primaryKey" json:"id"`
|
||||
OrderID uint64 `gorm:"not null;index" json:"order_id"`
|
||||
SiteID uint64 `gorm:"not null;index" json:"site_id"`
|
||||
PartyRole string `gorm:"size:32;not null;index" json:"party_role"`
|
||||
PartyType string `gorm:"size:16;not null" json:"party_type"`
|
||||
PartyID uint64 `gorm:"not null" json:"party_id"`
|
||||
Ratio float64 `gorm:"type:decimal(10,2);not null;default:0" json:"ratio"`
|
||||
IncomeAmountCent int64 `gorm:"not null;default:0" json:"income_amount_cent"`
|
||||
CostAmountCent int64 `gorm:"not null;default:0" json:"cost_amount_cent"`
|
||||
ProfitAmountCent int64 `gorm:"not null;default:0" json:"profit_amount_cent"`
|
||||
TaxAmountCent int64 `gorm:"not null;default:0" json:"tax_amount_cent"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (DistributionOrderParty) TableName() string { return "distribution_order_parties" }
|
||||
|
||||
// DistributionSettlementBatch 是按站点生成的结算批次。
|
||||
type DistributionSettlementBatch struct {
|
||||
ID uint64 `gorm:"primaryKey" json:"id"`
|
||||
SiteID uint64 `gorm:"not null;index" json:"site_id"`
|
||||
BatchNo string `gorm:"size:64;not null;uniqueIndex" json:"batch_no"`
|
||||
PeriodStart time.Time `gorm:"not null" json:"period_start"`
|
||||
PeriodEnd time.Time `gorm:"not null" json:"period_end"`
|
||||
TotalAmountCent int64 `gorm:"not null;default:0" json:"total_amount_cent"`
|
||||
Status string `gorm:"size:16;not null;default:'draft';index" json:"status"`
|
||||
CreatedBy *uint64 `json:"created_by,omitempty"`
|
||||
SettledAt *time.Time `json:"settled_at,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (DistributionSettlementBatch) TableName() string { return "distribution_settlement_batches" }
|
||||
|
||||
type DistributionSettlementItem struct {
|
||||
ID uint64 `gorm:"primaryKey" json:"id"`
|
||||
BatchID uint64 `gorm:"not null;index" json:"batch_id"`
|
||||
OrderID uint64 `gorm:"not null;index" json:"order_id"`
|
||||
PartyID uint64 `gorm:"not null;index" json:"party_id"`
|
||||
AmountCent int64 `gorm:"not null;default:0" json:"amount_cent"`
|
||||
Status string `gorm:"size:16;not null;default:'pending'" json:"status"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
func (DistributionSettlementItem) TableName() string { return "distribution_settlement_items" }
|
||||
|
||||
// DistributionSitePaymentChannel 将一个或多个现有支付商户配置绑定到分销站点。
|
||||
type DistributionSitePaymentChannel struct {
|
||||
ID uint64 `gorm:"primaryKey" json:"id"`
|
||||
SiteID uint64 `gorm:"not null;uniqueIndex:uk_distribution_site_payment;index" json:"site_id"`
|
||||
ConfigID uint64 `gorm:"not null;uniqueIndex:uk_distribution_site_payment;index" json:"config_id"`
|
||||
Priority int `gorm:"not null;default:0" json:"priority"`
|
||||
Status string `gorm:"size:16;not null;default:'active';index" json:"status"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (DistributionSitePaymentChannel) TableName() string { return "distribution_site_payment_channels" }
|
||||
@@ -41,30 +41,36 @@ type RentalOrder struct {
|
||||
GrowthPointsAwarded int64 `gorm:"not null;default:0" json:"growth_points_awarded"`
|
||||
GrowthPointsAwardedAt *time.Time `json:"growth_points_awarded_at"`
|
||||
AccountSnapshot datatypes.JSON `json:"account_snapshot"`
|
||||
Status string `gorm:"size:32;not null;default:'pending_payment'" json:"status"`
|
||||
HandoffStatus string `gorm:"size:32;not null;default:'none'" json:"handoff_status"`
|
||||
HandoffMode string `gorm:"size:16;not null;default:'owner';index" json:"handoff_mode"`
|
||||
SettlementMode string `gorm:"size:32;not null;default:'owner_wallet'" json:"settlement_mode"`
|
||||
ManagedAdminID *uint64 `gorm:"index" json:"managed_admin_id"`
|
||||
SettlementStatus string `gorm:"size:32;not null;default:'unsettled'" json:"settlement_status"`
|
||||
OfflineSettlementStatus string `gorm:"size:16;not null;default:'none';index" json:"offline_settlement_status"`
|
||||
OfflineSettlementAmountCent int64 `gorm:"not null;default:0" json:"offline_settlement_amount_cent"`
|
||||
OfflineSettlementRemark string `gorm:"size:255;not null;default:''" json:"offline_settlement_remark"`
|
||||
OfflineSettledBy *uint64 `json:"offline_settled_by"`
|
||||
OfflineSettledAt *time.Time `json:"offline_settled_at"`
|
||||
RefundStatus string `gorm:"size:32;not null;default:'none';index" json:"refund_status"`
|
||||
RefundAmountCent int64 `gorm:"not null;default:0" json:"refund_amount_cent"`
|
||||
RefundedAt *time.Time `json:"refunded_at"`
|
||||
DepositHoldStatus string `gorm:"size:16;not null;default:'none';index" json:"deposit_hold_status"`
|
||||
DepositHoldAmountCent int64 `gorm:"not null;default:0" json:"deposit_hold_amount_cent"`
|
||||
DepositHoldReason string `gorm:"size:255;not null;default:''" json:"deposit_hold_reason"`
|
||||
DepositHeldBy *uint64 `json:"deposit_held_by"`
|
||||
DepositHeldAt *time.Time `json:"deposit_held_at"`
|
||||
DepositHoldReleasedAt *time.Time `json:"deposit_hold_released_at"`
|
||||
OwnerSettledAt *time.Time `json:"owner_settled_at"`
|
||||
SettledAt *time.Time `json:"settled_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
AccountSource string `gorm:"size:32;not null;default:'internal';index" json:"account_source"`
|
||||
SourceChannel string `gorm:"size:32;not null;default:''" json:"source_channel"`
|
||||
// 分销正常订单字段:仅在卖家和租客都通过分销网站完成交易时填写。
|
||||
DistributionSiteID *uint64 `gorm:"index" json:"distribution_site_id,omitempty"`
|
||||
DistributionMode string `gorm:"size:32;not null;default:'';index" json:"distribution_mode"`
|
||||
DistributionRuleVersionID *uint64 `gorm:"index" json:"distribution_rule_version_id,omitempty"`
|
||||
Status string `gorm:"size:32;not null;default:'pending_payment'" json:"status"`
|
||||
HandoffStatus string `gorm:"size:32;not null;default:'none'" json:"handoff_status"`
|
||||
HandoffMode string `gorm:"size:16;not null;default:'owner';index" json:"handoff_mode"`
|
||||
SettlementMode string `gorm:"size:32;not null;default:'owner_wallet'" json:"settlement_mode"`
|
||||
ManagedAdminID *uint64 `gorm:"index" json:"managed_admin_id"`
|
||||
SettlementStatus string `gorm:"size:32;not null;default:'unsettled'" json:"settlement_status"`
|
||||
OfflineSettlementStatus string `gorm:"size:16;not null;default:'none';index" json:"offline_settlement_status"`
|
||||
OfflineSettlementAmountCent int64 `gorm:"not null;default:0" json:"offline_settlement_amount_cent"`
|
||||
OfflineSettlementRemark string `gorm:"size:255;not null;default:''" json:"offline_settlement_remark"`
|
||||
OfflineSettledBy *uint64 `json:"offline_settled_by"`
|
||||
OfflineSettledAt *time.Time `json:"offline_settled_at"`
|
||||
RefundStatus string `gorm:"size:32;not null;default:'none';index" json:"refund_status"`
|
||||
RefundAmountCent int64 `gorm:"not null;default:0" json:"refund_amount_cent"`
|
||||
RefundedAt *time.Time `json:"refunded_at"`
|
||||
DepositHoldStatus string `gorm:"size:16;not null;default:'none';index" json:"deposit_hold_status"`
|
||||
DepositHoldAmountCent int64 `gorm:"not null;default:0" json:"deposit_hold_amount_cent"`
|
||||
DepositHoldReason string `gorm:"size:255;not null;default:''" json:"deposit_hold_reason"`
|
||||
DepositHeldBy *uint64 `json:"deposit_held_by"`
|
||||
DepositHeldAt *time.Time `json:"deposit_held_at"`
|
||||
DepositHoldReleasedAt *time.Time `json:"deposit_hold_released_at"`
|
||||
OwnerSettledAt *time.Time `json:"owner_settled_at"`
|
||||
SettledAt *time.Time `json:"settled_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (RentalOrder) TableName() string {
|
||||
|
||||
Reference in New Issue
Block a user