package model import ( "time" "gorm.io/gorm" ) const ( PaymentMerchantStatusDisabled = 0 PaymentMerchantStatusEnabled = 1 PaymentMerchantStrategyAmount = "amount" PaymentMerchantStrategyCount = "count" PaymentMerchantStrategyTime = "time" ) // PaymentMerchant 是实际收款商户,凭证只保存在受控字段。 type PaymentMerchant struct { gorm.Model BaseModel `gorm:"embedded"` Name string `gorm:"column:name" json:"name"` PaymentMethod string `gorm:"column:payment_method" json:"payment_method"` ProviderType string `gorm:"column:provider_type" json:"provider_type"` MerchantIdentity string `gorm:"column:merchant_identity" json:"merchant_identity"` Credentials JSONB `gorm:"column:credentials;type:jsonb" json:"-"` CredentialVersion int64 `gorm:"column:credential_version" json:"credential_version"` Status int `gorm:"column:status" json:"status"` Remark string `gorm:"column:remark" json:"remark"` } func (PaymentMerchant) TableName() string { return "tb_payment_merchant" } // PaymentMerchantPool 是一种支付方式的商户轮询池。 type PaymentMerchantPool struct { gorm.Model BaseModel `gorm:"embedded"` Name string `gorm:"column:name" json:"name"` PaymentMethod string `gorm:"column:payment_method" json:"payment_method"` Status int `gorm:"column:status" json:"status"` Strategy string `gorm:"column:strategy" json:"strategy"` ThresholdAmount *int64 `gorm:"column:threshold_amount" json:"threshold_amount,omitempty"` ThresholdCount *int64 `gorm:"column:threshold_count" json:"threshold_count,omitempty"` StatisticCycle *string `gorm:"column:statistic_cycle" json:"statistic_cycle,omitempty"` TimePeriodValue *int64 `gorm:"column:time_period_value" json:"time_period_value,omitempty"` TimePeriodUnit *string `gorm:"column:time_period_unit" json:"time_period_unit,omitempty"` TimePeriodStartedAt *time.Time `gorm:"column:time_period_started_at" json:"time_period_started_at,omitempty"` RoutingEpoch int64 `gorm:"column:routing_epoch" json:"routing_epoch"` Remark string `gorm:"column:remark" json:"remark"` } func (PaymentMerchantPool) TableName() string { return "tb_payment_merchant_pool" } // PaymentMerchantPoolMember 是商户池内按顺序参与轮询的商户。 type PaymentMerchantPoolMember struct { gorm.Model BaseModel `gorm:"embedded"` PoolID uint `gorm:"column:pool_id" json:"pool_id"` MerchantID uint `gorm:"column:merchant_id" json:"merchant_id"` SortOrder int64 `gorm:"column:sort_order" json:"sort_order"` } func (PaymentMerchantPoolMember) TableName() string { return "tb_payment_merchant_pool_member" } // WechatAuthorization 是 C 端微信 OAuth、小程序与支付 AppID 的全局授权配置。 type WechatAuthorization struct { gorm.Model BaseModel `gorm:"embedded"` OaAppID string `gorm:"column:oa_app_id" json:"oa_app_id"` OaAppSecret string `gorm:"column:oa_app_secret" json:"-"` OaToken string `gorm:"column:oa_token" json:"-"` OaAesKey string `gorm:"column:oa_aes_key" json:"-"` OaOAuthRedirectURL string `gorm:"column:oa_oauth_redirect_url" json:"oa_oauth_redirect_url"` MiniappAppID string `gorm:"column:miniapp_app_id" json:"miniapp_app_id"` MiniappAppSecret string `gorm:"column:miniapp_app_secret" json:"-"` CredentialVersion int64 `gorm:"column:credential_version" json:"credential_version"` Status int `gorm:"column:status" json:"status"` } func (WechatAuthorization) TableName() string { return "tb_wechat_authorization" } // PaymentMerchantRoutingSuccess 是支付首次成功的唯一统计事实。 type PaymentMerchantRoutingSuccess struct { ID uint `gorm:"column:id;primaryKey" json:"id"` PaymentID uint `gorm:"column:payment_id" json:"payment_id"` MerchantID uint `gorm:"column:merchant_id" json:"merchant_id"` PoolID uint `gorm:"column:pool_id" json:"pool_id"` RoutingEpoch int64 `gorm:"column:routing_epoch" json:"routing_epoch"` Amount int64 `gorm:"column:amount" json:"amount"` PaidAt time.Time `gorm:"column:paid_at" json:"paid_at"` CreatedAt time.Time `gorm:"column:created_at" json:"created_at"` } func (PaymentMerchantRoutingSuccess) TableName() string { return "tb_payment_merchant_routing_success" }