18925d7d15
- POST /license/purchase(仅管理员)建单并调 pay 下单,返回收银台 pay_url - POST /pay/callback 公开接收器:HMAC 验签+时间戳窗口+按 out_trade_no 幂等+金额逐分核对,同事务续期 - 续期与兑换券同口径:未过期从到期日叠加、已过期从现在起算,写入 tier/max_devices/features - 后台每 60s 查单兜底防 webhook 丢失;closed 标 failed - 新表 license_purchases(schema.sql/AutoMigrate/testutil 同步);配置 PAY_SECRET/PAY_BASE_URL/PAY_RETURN_URL - 契约真相源 ~/code/pay-contract openapi.yaml v1.0.0 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJ1g8XV1YhhmHRzhwWEW7o
20 lines
1.0 KiB
Go
20 lines
1.0 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"`
|
|
Amount string `gorm:"size:16" json:"amount"`
|
|
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"`
|
|
}
|