From 1980c846f2bedd21d6e10586d33e83878ff8463a Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 16 Mar 2026 23:29:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=A2=E5=8D=95/=E8=B5=84=E4=BA=A7?= =?UTF-8?q?=E5=85=85=E5=80=BC/=E4=BB=A3=E7=90=86=E5=85=85=E5=80=BC?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E6=96=B0=E5=A2=9E=20PaymentConfigID=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - order.go: Order 模型新增 PaymentConfigID *uint(记录下单时使用的支付配置) - asset_wallet.go: AssetRechargeRecord 新增 PaymentConfigID *uint - agent_wallet.go: AgentRechargeRecord 新增 PaymentConfigID *uint 配置切换时旧订单仍按 payment_config_id 加载对应配置验签,解决竞态问题 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- internal/model/agent_wallet.go | 1 + internal/model/asset_wallet.go | 1 + internal/model/order.go | 3 +++ 3 files changed, 5 insertions(+) diff --git a/internal/model/agent_wallet.go b/internal/model/agent_wallet.go index 654fb5f..7c75505 100644 --- a/internal/model/agent_wallet.go +++ b/internal/model/agent_wallet.go @@ -77,6 +77,7 @@ type AgentRechargeRecord struct { PaymentMethod string `gorm:"column:payment_method;type:varchar(20);not null;comment:支付方式(alipay-支付宝 | wechat-微信 | bank-银行转账 | offline-线下)" json:"payment_method"` PaymentChannel *string `gorm:"column:payment_channel;type:varchar(50);comment:支付渠道" json:"payment_channel,omitempty"` PaymentTransactionID *string `gorm:"column:payment_transaction_id;type:varchar(100);comment:第三方支付交易号" json:"payment_transaction_id,omitempty"` + PaymentConfigID *uint `gorm:"column:payment_config_id;index;comment:支付配置ID(关联tb_wechat_config.id)" json:"payment_config_id,omitempty"` Status int `gorm:"column:status;type:int;not null;default:1;comment:充值状态(1-待支付 2-已支付 3-已完成 4-已关闭 5-已退款)" json:"status"` PaidAt *time.Time `gorm:"column:paid_at;comment:支付时间" json:"paid_at,omitempty"` CompletedAt *time.Time `gorm:"column:completed_at;comment:完成时间" json:"completed_at,omitempty"` diff --git a/internal/model/asset_wallet.go b/internal/model/asset_wallet.go index 97aad5e..402db1c 100644 --- a/internal/model/asset_wallet.go +++ b/internal/model/asset_wallet.go @@ -77,6 +77,7 @@ type AssetRechargeRecord struct { PaymentMethod string `gorm:"column:payment_method;type:varchar(20);not null;comment:支付方式(alipay-支付宝 | wechat-微信)" json:"payment_method"` PaymentChannel *string `gorm:"column:payment_channel;type:varchar(50);comment:支付渠道" json:"payment_channel,omitempty"` PaymentTransactionID *string `gorm:"column:payment_transaction_id;type:varchar(100);comment:第三方支付交易号" json:"payment_transaction_id,omitempty"` + PaymentConfigID *uint `gorm:"column:payment_config_id;index;comment:支付配置ID(关联tb_wechat_config.id)" json:"payment_config_id,omitempty"` Status int `gorm:"column:status;type:int;not null;default:1;comment:充值状态(1-待支付 2-已支付 3-已完成 4-已关闭 5-已退款)" json:"status"` PaidAt *time.Time `gorm:"column:paid_at;comment:支付时间" json:"paid_at,omitempty"` CompletedAt *time.Time `gorm:"column:completed_at;comment:完成时间" json:"completed_at,omitempty"` diff --git a/internal/model/order.go b/internal/model/order.go index 8b3d2e6..e8e9dc9 100644 --- a/internal/model/order.go +++ b/internal/model/order.go @@ -55,6 +55,9 @@ type Order struct { // 订单超时信息 ExpiresAt *time.Time `gorm:"column:expires_at;comment:订单过期时间(NULL表示不过期)" json:"expires_at,omitempty"` + + // 支付配置 + PaymentConfigID *uint `gorm:"column:payment_config_id;index;comment:支付配置ID(关联tb_wechat_config.id)" json:"payment_config_id,omitempty"` } // TableName 指定表名