feat(tenant): 按租户隔离支付退款与商户配置

This commit is contained in:
yml
2026-11-15 16:06:30 +08:00
parent 6d2affa15f
commit c7dacfa025
33 changed files with 767 additions and 233 deletions
+1
View File
@@ -8,6 +8,7 @@ import (
type PaymentOrder struct {
ID uint64 `gorm:"primaryKey" json:"id"`
TenantID uint64 `gorm:"not null;default:0;index:idx_payment_orders_tenant_created" json:"tenant_id"`
PaymentNo string `gorm:"size:64;not null;uniqueIndex" json:"payment_no"`
OrderID uint64 `gorm:"not null;index" json:"order_id"`
OrderNo string `gorm:"size:64;not null;index" json:"order_no"`
@@ -8,23 +8,24 @@ import (
// PaymentMerchantConfig 支付商户配置
type PaymentMerchantConfig struct {
ID uint64 `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:128;not null" json:"name"`
Provider string `gorm:"size:32;not null;index:idx_payment_merchant_configs_provider" json:"provider"`
MerchantID string `gorm:"size:128;not null;index:idx_payment_merchant_configs_merchant_id" json:"merchant_id"`
GatewayURL string `gorm:"size:512;not null;default:''" json:"gateway_url"`
SignKey string `gorm:"type:text" json:"sign_key"` // 加密存储,拉卡拉使用商户私钥 PEM
NotifyKey string `gorm:"type:text" json:"notify_key"` // 加密存储,拉卡拉使用通知验签证书 PEM
NotifyURL string `gorm:"size:512;not null;default:''" json:"notify_url"`
JumpURL string `gorm:"size:512;not null;default:''" json:"jump_url"`
PayWay string `gorm:"size:32;not null;default:'ZFBZF';index:idx_payment_merchant_configs_pay_way" json:"pay_way"`
JSPayFlag string `gorm:"column:jspay_flag;size:8;not null;default:'2'" json:"jspay_flag"`
SignType string `gorm:"size:32;not null;default:'MD5'" json:"sign_type"`
ExtraConfig JSONMap `gorm:"type:json" json:"extra_config"`
IsDefault bool `gorm:"not null;default:0;index:idx_payment_merchant_configs_default" json:"is_default"`
Status string `gorm:"size:32;not null;default:'active';index:idx_payment_merchant_configs_status" json:"status"`
Environment string `gorm:"size:16;not null;default:'production'" json:"environment"`
BusinessTags JSONArray `gorm:"type:json" json:"business_tags"`
ID uint64 `gorm:"primaryKey" json:"id"`
OwnerTenantID uint64 `gorm:"not null;default:0;index:idx_payment_merchant_configs_owner" json:"owner_tenant_id"`
Name string `gorm:"size:128;not null" json:"name"`
Provider string `gorm:"size:32;not null;index:idx_payment_merchant_configs_provider" json:"provider"`
MerchantID string `gorm:"size:128;not null;index:idx_payment_merchant_configs_merchant_id" json:"merchant_id"`
GatewayURL string `gorm:"size:512;not null;default:''" json:"gateway_url"`
SignKey string `gorm:"type:text" json:"sign_key"` // 加密存储,拉卡拉使用商户私钥 PEM
NotifyKey string `gorm:"type:text" json:"notify_key"` // 加密存储,拉卡拉使用通知验签证书 PEM
NotifyURL string `gorm:"size:512;not null;default:''" json:"notify_url"`
JumpURL string `gorm:"size:512;not null;default:''" json:"jump_url"`
PayWay string `gorm:"size:32;not null;default:'ZFBZF';index:idx_payment_merchant_configs_pay_way" json:"pay_way"`
JSPayFlag string `gorm:"column:jspay_flag;size:8;not null;default:'2'" json:"jspay_flag"`
SignType string `gorm:"size:32;not null;default:'MD5'" json:"sign_type"`
ExtraConfig JSONMap `gorm:"type:json" json:"extra_config"`
IsDefault bool `gorm:"not null;default:0;index:idx_payment_merchant_configs_default" json:"is_default"`
Status string `gorm:"size:32;not null;default:'active';index:idx_payment_merchant_configs_status" json:"status"`
Environment string `gorm:"size:16;not null;default:'production'" json:"environment"`
BusinessTags JSONArray `gorm:"type:json" json:"business_tags"`
// 统计信息
TotalTransactions int64 `gorm:"not null;default:0" json:"total_transactions"`
@@ -89,6 +90,7 @@ func (j *JSONArray) Scan(value any) error {
// PaymentConfigUsageLog 支付配置使用日志
type PaymentConfigUsageLog struct {
ID uint64 `gorm:"primaryKey" json:"id"`
TenantID uint64 `gorm:"not null;default:0;index:idx_payment_config_usage_logs_tenant" json:"tenant_id"`
ConfigID uint64 `gorm:"not null;index:idx_payment_config_usage_logs_config" json:"config_id"`
PaymentOrderID uint64 `gorm:"not null;index:idx_payment_config_usage_logs_payment" json:"payment_order_id"`
Provider string `gorm:"size:32;not null" json:"provider"`