🎨 新增支付动态配置&优化支付回调&新增三方支付
This commit is contained in:
357
utils/pay/resp/response.go
Normal file
357
utils/pay/resp/response.go
Normal file
@@ -0,0 +1,357 @@
|
||||
// Package resp 神奇支付SDK响应结构体
|
||||
package resp
|
||||
|
||||
// Base 基础响应字段
|
||||
type Base struct {
|
||||
Code int `json:"code"` // 返回状态码,0为成功
|
||||
Msg string `json:"msg"` // 返回信息/错误信息
|
||||
Timestamp string `json:"timestamp"` // 时间戳
|
||||
Sign string `json:"sign"` // 签名
|
||||
SignType string `json:"sign_type"` // 签名类型
|
||||
}
|
||||
|
||||
// IsSuccess 判断是否成功
|
||||
func (b *Base) IsSuccess() bool {
|
||||
return b.Code == 0
|
||||
}
|
||||
|
||||
// CreateOrder 统一下单响应
|
||||
type CreateOrder struct {
|
||||
Base
|
||||
|
||||
// TradeNo 平台订单号
|
||||
TradeNo string `json:"trade_no"`
|
||||
|
||||
// PayType 发起支付类型
|
||||
// jump: 跳转url / html: html代码 / qrcode: 二维码 / urlscheme: 小程序url scheme
|
||||
// jsapi: JSAPI参数 / app: APP支付参数 / scan: 付款码成功 / wxplugin: 小程序插件 / wxapp: 拉起小程序
|
||||
PayType string `json:"pay_type"`
|
||||
|
||||
// PayInfo 发起支付参数,根据PayType不同返回不同内容
|
||||
PayInfo string `json:"pay_info"`
|
||||
}
|
||||
|
||||
// QueryOrder 订单查询响应
|
||||
type QueryOrder struct {
|
||||
Base
|
||||
|
||||
// TradeNo 平台订单号
|
||||
TradeNo string `json:"trade_no"`
|
||||
|
||||
// OutTradeNo 商户订单号
|
||||
OutTradeNo string `json:"out_trade_no"`
|
||||
|
||||
// ApiTradeNo 接口订单号(微信/支付宝返回的单号)
|
||||
ApiTradeNo string `json:"api_trade_no"`
|
||||
|
||||
// Type 支付方式
|
||||
Type string `json:"type"`
|
||||
|
||||
// Status 支付状态
|
||||
// 0: 未支付 / 1: 已支付 / 2: 已退款 / 3: 已冻结 / 4: 预授权
|
||||
Status int `json:"status"`
|
||||
|
||||
// PID 商户ID
|
||||
PID int `json:"pid"`
|
||||
|
||||
// Addtime 订单创建时间
|
||||
Addtime string `json:"addtime"`
|
||||
|
||||
// Endtime 订单完成时间(仅支付完成才返回)
|
||||
Endtime string `json:"endtime"`
|
||||
|
||||
// Name 商品名称
|
||||
Name string `json:"name"`
|
||||
|
||||
// Money 商品金额
|
||||
Money string `json:"money"`
|
||||
|
||||
// RefundMoney 已退款金额(仅部分退款情况返回)
|
||||
RefundMoney string `json:"refundmoney"`
|
||||
|
||||
// Param 业务扩展参数
|
||||
Param string `json:"param"`
|
||||
|
||||
// Buyer 支付用户标识(一般为openid)
|
||||
Buyer string `json:"buyer"`
|
||||
|
||||
// ClientIP 支付用户IP
|
||||
ClientIP string `json:"clientip"`
|
||||
}
|
||||
|
||||
// IsPaid 判断是否已支付
|
||||
func (q *QueryOrder) IsPaid() bool {
|
||||
return q.Status == 1
|
||||
}
|
||||
|
||||
// IsRefunded 判断是否已退款
|
||||
func (q *QueryOrder) IsRefunded() bool {
|
||||
return q.Status == 2
|
||||
}
|
||||
|
||||
// Refund 订单退款响应
|
||||
type Refund struct {
|
||||
Base
|
||||
|
||||
// RefundNo 平台退款单号
|
||||
RefundNo string `json:"refund_no"`
|
||||
|
||||
// OutRefundNo 商户退款单号
|
||||
OutRefundNo string `json:"out_refund_no"`
|
||||
|
||||
// TradeNo 平台订单号
|
||||
TradeNo string `json:"trade_no"`
|
||||
|
||||
// Money 退款金额
|
||||
Money string `json:"money"`
|
||||
|
||||
// ReduceMoney 扣减商户余额
|
||||
ReduceMoney string `json:"reducemoney"`
|
||||
}
|
||||
|
||||
// RefundQuery 退款查询响应
|
||||
type RefundQuery struct {
|
||||
Base
|
||||
|
||||
// RefundNo 平台退款单号
|
||||
RefundNo string `json:"refund_no"`
|
||||
|
||||
// OutRefundNo 商户退款单号
|
||||
OutRefundNo string `json:"out_refund_no"`
|
||||
|
||||
// TradeNo 平台订单号
|
||||
TradeNo string `json:"trade_no"`
|
||||
|
||||
// OutTradeNo 商户订单号
|
||||
OutTradeNo string `json:"out_trade_no"`
|
||||
|
||||
// Money 退款金额
|
||||
Money string `json:"money"`
|
||||
|
||||
// ReduceMoney 扣减商户余额
|
||||
ReduceMoney string `json:"reducemoney"`
|
||||
|
||||
// Status 退款状态: 0失败 / 1成功
|
||||
Status int `json:"status"`
|
||||
|
||||
// Addtime 退款时间
|
||||
Addtime string `json:"addtime"`
|
||||
}
|
||||
|
||||
// IsRefundSuccess 判断退款是否成功
|
||||
func (r *RefundQuery) IsRefundSuccess() bool {
|
||||
return r.Status == 1
|
||||
}
|
||||
|
||||
// Notify 支付结果通知
|
||||
type Notify struct {
|
||||
// PID 商户ID
|
||||
PID int `json:"pid"`
|
||||
|
||||
// TradeNo 平台订单号
|
||||
TradeNo string `json:"trade_no"`
|
||||
|
||||
// OutTradeNo 商户订单号
|
||||
OutTradeNo string `json:"out_trade_no"`
|
||||
|
||||
// ApiTradeNo 接口订单号
|
||||
ApiTradeNo string `json:"api_trade_no"`
|
||||
|
||||
// Type 支付方式
|
||||
Type string `json:"type"`
|
||||
|
||||
// TradeStatus 交易状态,固定为 TRADE_SUCCESS
|
||||
TradeStatus string `json:"trade_status"`
|
||||
|
||||
// Addtime 订单创建时间
|
||||
Addtime string `json:"addtime"`
|
||||
|
||||
// Endtime 订单完成时间
|
||||
Endtime string `json:"endtime"`
|
||||
|
||||
// Name 商品名称
|
||||
Name string `json:"name"`
|
||||
|
||||
// Money 商品金额
|
||||
Money string `json:"money"`
|
||||
|
||||
// Param 业务扩展参数
|
||||
Param string `json:"param"`
|
||||
|
||||
// Buyer 支付用户标识
|
||||
Buyer string `json:"buyer"`
|
||||
|
||||
// Timestamp 时间戳
|
||||
Timestamp string `json:"timestamp"`
|
||||
|
||||
// Sign 签名
|
||||
Sign string `json:"sign"`
|
||||
|
||||
// SignType 签名类型
|
||||
SignType string `json:"sign_type"`
|
||||
}
|
||||
|
||||
// MerchantInfo 商户信息响应
|
||||
type MerchantInfo struct {
|
||||
Base
|
||||
|
||||
// PID 商户ID
|
||||
PID int `json:"pid"`
|
||||
|
||||
// Status 商户状态: 0封禁 / 1正常 / 2待审核
|
||||
Status int `json:"status"`
|
||||
|
||||
// PayStatus 支付状态: 0关闭 / 1开启
|
||||
PayStatus int `json:"pay_status"`
|
||||
|
||||
// SettleStatus 结算状态: 0关闭 / 1开启
|
||||
SettleStatus int `json:"settle_status"`
|
||||
|
||||
// Money 商户余额
|
||||
Money string `json:"money"`
|
||||
|
||||
// SettleType 结算方式: 1支付宝 / 2微信 / 3QQ钱包 / 4银行卡
|
||||
SettleType int `json:"settle_type"`
|
||||
|
||||
// SettleAccount 结算账户
|
||||
SettleAccount string `json:"settle_account"`
|
||||
|
||||
// SettleName 结算账户姓名
|
||||
SettleName string `json:"settle_name"`
|
||||
|
||||
// OrderNum 订单总数量
|
||||
OrderNum int `json:"order_num"`
|
||||
|
||||
// OrderNumToday 今日订单数量
|
||||
OrderNumToday int `json:"order_num_today"`
|
||||
|
||||
// OrderNumLastday 昨日订单数量
|
||||
OrderNumLastday int `json:"order_num_lastday"`
|
||||
|
||||
// OrderMoneyToday 今日订单收入
|
||||
OrderMoneyToday string `json:"order_money_today"`
|
||||
|
||||
// OrderMoneyLastday 昨日订单收入
|
||||
OrderMoneyLastday string `json:"order_money_lastday"`
|
||||
}
|
||||
|
||||
// IsNormal 判断商户状态是否正常
|
||||
func (m *MerchantInfo) IsNormal() bool {
|
||||
return m.Status == 1
|
||||
}
|
||||
|
||||
// IsPayEnabled 判断支付是否开启
|
||||
func (m *MerchantInfo) IsPayEnabled() bool {
|
||||
return m.PayStatus == 1
|
||||
}
|
||||
|
||||
// OrderList 订单列表响应
|
||||
type OrderList struct {
|
||||
Base
|
||||
|
||||
// Data 订单列表
|
||||
Data []OrderItem `json:"data"`
|
||||
}
|
||||
|
||||
// OrderItem 订单列表项
|
||||
type OrderItem struct {
|
||||
TradeNo string `json:"trade_no"`
|
||||
OutTradeNo string `json:"out_trade_no"`
|
||||
ApiTradeNo string `json:"api_trade_no"`
|
||||
Type string `json:"type"`
|
||||
Status int `json:"status"`
|
||||
PID int `json:"pid"`
|
||||
Addtime string `json:"addtime"`
|
||||
Endtime string `json:"endtime"`
|
||||
Name string `json:"name"`
|
||||
Money string `json:"money"`
|
||||
Param string `json:"param"`
|
||||
Buyer string `json:"buyer"`
|
||||
ClientIP string `json:"clientip"`
|
||||
}
|
||||
|
||||
// Transfer 转账响应
|
||||
type Transfer struct {
|
||||
Base
|
||||
|
||||
// Status 转账状态: 0正在处理 / 1转账成功
|
||||
Status int `json:"status"`
|
||||
|
||||
// BizNo 系统交易号
|
||||
BizNo string `json:"biz_no"`
|
||||
|
||||
// OutBizNo 商户交易号
|
||||
OutBizNo string `json:"out_biz_no"`
|
||||
|
||||
// OrderID 接口转账单号(支付宝/微信返回)
|
||||
OrderID string `json:"orderid"`
|
||||
|
||||
// PayDate 转账完成时间
|
||||
PayDate string `json:"paydate"`
|
||||
|
||||
// CostMoney 转账花费金额
|
||||
CostMoney string `json:"cost_money"`
|
||||
}
|
||||
|
||||
// IsTransferSuccess 判断转账是否成功
|
||||
func (t *Transfer) IsTransferSuccess() bool {
|
||||
return t.Status == 1
|
||||
}
|
||||
|
||||
// IsProcessing 判断是否正在处理
|
||||
func (t *Transfer) IsProcessing() bool {
|
||||
return t.Status == 0
|
||||
}
|
||||
|
||||
// TransferQuery 转账查询响应
|
||||
type TransferQuery struct {
|
||||
Base
|
||||
|
||||
// Status 转账状态: 0正在处理 / 1转账成功 / 2转账失败
|
||||
Status int `json:"status"`
|
||||
|
||||
// ErrMsg 转账失败原因(status=2时返回)
|
||||
ErrMsg string `json:"errmsg"`
|
||||
|
||||
// BizNo 系统交易号
|
||||
BizNo string `json:"biz_no"`
|
||||
|
||||
// OutBizNo 商户交易号
|
||||
OutBizNo string `json:"out_biz_no"`
|
||||
|
||||
// OrderID 接口转账单号
|
||||
OrderID string `json:"orderid"`
|
||||
|
||||
// PayDate 转账完成时间
|
||||
PayDate string `json:"paydate"`
|
||||
|
||||
// Amount 转账金额
|
||||
Amount string `json:"amount"`
|
||||
|
||||
// CostMoney 转账花费金额
|
||||
CostMoney string `json:"cost_money"`
|
||||
|
||||
// Remark 转账备注
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
// IsTransferSuccess 判断转账是否成功
|
||||
func (t *TransferQuery) IsTransferSuccess() bool {
|
||||
return t.Status == 1
|
||||
}
|
||||
|
||||
// IsTransferFailed 判断转账是否失败
|
||||
func (t *TransferQuery) IsTransferFailed() bool {
|
||||
return t.Status == 2
|
||||
}
|
||||
|
||||
// Balance 余额查询响应
|
||||
type Balance struct {
|
||||
Base
|
||||
|
||||
// AvailableMoney 商户可用余额
|
||||
AvailableMoney string `json:"available_money"`
|
||||
|
||||
// TransferRate 转账手续费率(%)
|
||||
TransferRate string `json:"transfer_rate"`
|
||||
}
|
||||
Reference in New Issue
Block a user