35 lines
4.4 KiB
Go
35 lines
4.4 KiB
Go
|
|
package models
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
"time"
|
|||
|
|
|
|||
|
|
"git.apinb.com/bsm-sdk/core/database"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// PaymentOrder 对应 payment_order,是全项目唯一的支付尝试事实。
|
|||
|
|
type PaymentOrder struct {
|
|||
|
|
Entity // 公共实体字段
|
|||
|
|
PaymentStatus int `gorm:"column:payment_status;not null;default:10;index" json:"payment_status"` // 10待支付、20确认中、23成功、30关闭、40失败、50异常
|
|||
|
|
PaymentNo string `gorm:"column:payment_no;type:varchar(64);not null;uniqueIndex" json:"payment_no"` // 平台支付单号
|
|||
|
|
RequestNo string `gorm:"column:request_no;type:varchar(128);not null;uniqueIndex:idx_payment_request" json:"request_no"` // 客户端幂等请求号
|
|||
|
|
BusinessType string `gorm:"column:business_type;type:varchar(32);not null;index;uniqueIndex:idx_payment_request" json:"business_type"` // 业务类型
|
|||
|
|
BusinessIdentity string `gorm:"column:business_identity;type:varchar(36);not null;index" json:"business_identity"` // 业务对象标识
|
|||
|
|
UserIdentity string `gorm:"column:user_identity;type:varchar(36);not null;index" json:"user_identity"` // 付款用户标识
|
|||
|
|
MerchantIdentity string `gorm:"column:merchant_identity;type:varchar(36);not null;default:'platform';index" json:"merchant_identity"` // 商户配置标识
|
|||
|
|
Channel string `gorm:"column:channel;type:varchar(32);not null;index" json:"channel"` // 支付渠道
|
|||
|
|
PayType string `gorm:"column:pay_type;type:varchar(32);not null" json:"pay_type"` // 渠道支付产品
|
|||
|
|
ChannelTradeNo string `gorm:"column:channel_trade_no;type:varchar(128);not null;default:'';uniqueIndex:idx_payment_channel_trade,where:channel_trade_no <> ''" json:"channel_trade_no"` // 渠道交易号
|
|||
|
|
Amount int64 `gorm:"column:amount;not null;check:amount > 0" json:"amount"` // 实付金额,单位分
|
|||
|
|
Subject string `gorm:"column:subject;type:varchar(256);not null" json:"subject"` // 渠道订单标题
|
|||
|
|
ClientArgs string `gorm:"column:client_args;type:text;not null;default:''" json:"-"` // 客户端调起参数
|
|||
|
|
CallbackDigest string `gorm:"column:callback_digest;type:varchar(64);not null;default:''" json:"-"` // 回调原文摘要
|
|||
|
|
FailureCode string `gorm:"column:failure_code;type:varchar(64);not null;default:''" json:"failure_code"` // 稳定失败码
|
|||
|
|
FailureMessage string `gorm:"column:failure_message;type:varchar(512);not null;default:''" json:"failure_message"` // 脱敏失败说明
|
|||
|
|
ExpiresAt time.Time `gorm:"column:expires_at;type:timestamptz;not null;index" json:"expires_at"` // 支付过期时间
|
|||
|
|
PaidAt *time.Time `gorm:"column:paid_at;type:timestamptz" json:"paid_at"` // 渠道确认支付时间
|
|||
|
|
ClosedAt *time.Time `gorm:"column:closed_at;type:timestamptz" json:"closed_at"` // 渠道关单时间
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func init() { database.AppendMigrate(&PaymentOrder{}) }
|
|||
|
|
func (*PaymentOrder) TableName() string { return "payment_order" }
|