Files
jiu/backend/internal/model/license_purchase.go
T
wangjia 858f24f74b fix(backend): license_purchases.pay_url 512→TEXT——支付宝网关 URL 超列宽导致下单 1406 失败
真单联调发现:pay v2 redirect payload.url 是支付宝网关完整签名 URL(2KB+),
回填 pay_url 报 Data too long,且残留 out_trade_no='' 行使重试撞唯一索引。
model + schema.sql + db-schema.html 三处同步,AutoMigrate 自动 ALTER。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 23:58:57 +08:00

24 lines
1.7 KiB
Go

package model
import "time"
// LicensePurchase 在线购买/续费记录(走 pay 收款中枢,契约见 ~/code/pay-contract)。
// out_trade_no = pay 订单号,兼作对账键与幂等键(同一单只续期一次)。
// Amount 存 pay 下单响应回传的权威金额(如 "2999.00"),webhook 回调时逐分核对。
type LicensePurchase struct {
Base
ShopID uint64 `gorm:"not null;index" json:"shop_id"`
UserID uint64 `gorm:"not null" json:"user_id"`
ProductBizCode string `gorm:"size:64;not null" json:"product_biz_code"`
AmountMinor int64 `gorm:"not null;default:0" json:"amount_minor"` // v2 口径:最小单位(CNY=分)
Currency string `gorm:"size:8;not null;default:''" json:"currency"`
PayURL string `gorm:"type:text" json:"pay_url,omitempty"` // v2 session payload.url(支付宝网关 URL 带签名参数可超 2KB),订单管理「继续支付」复用
RenewedTo *time.Time `json:"renewed_to,omitempty"` // settle 续期后的授权到期日(订单流水「授权续期至」展示)
Amount string `gorm:"size:16" json:"amount"` // Deprecated: v1 元字符串,只读兜底输出,观察一版后 DROP
OutTradeNo string `gorm:"size:64;uniqueIndex:uk_out_trade_no" json:"out_trade_no"`
Status string `gorm:"type:enum('pending','paid','failed');default:'pending';index" json:"status"`
TradeNo string `gorm:"size:64" json:"trade_no,omitempty"` // 渠道交易号(支付宝/微信)
Channel string `gorm:"size:16" json:"channel,omitempty"`
PaidAt *time.Time `json:"paid_at,omitempty"`
}