🎨 新增支付动态配置&优化支付回调&新增三方支付
This commit is contained in:
96
model/system/request/sys_pay_config.go
Normal file
96
model/system/request/sys_pay_config.go
Normal file
@@ -0,0 +1,96 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.echol.cn/loser/lckt/model/common/request"
|
||||
)
|
||||
|
||||
// PayConfigSearch 支付配置搜索请求
|
||||
type PayConfigSearch struct {
|
||||
request.PageInfo
|
||||
Name string `json:"name" form:"name"` // 支付名称
|
||||
Code string `json:"code" form:"code"` // 支付编码
|
||||
Type string `json:"type" form:"type"` // 支付类型
|
||||
Enable *bool `json:"enable" form:"enable"` // 是否启用
|
||||
}
|
||||
|
||||
// PayConfigCreate 创建支付配置请求
|
||||
type PayConfigCreate struct {
|
||||
Name string `json:"name" binding:"required"` // 支付名称
|
||||
Code string `json:"code" binding:"required"` // 支付编码
|
||||
Type string `json:"type" binding:"required"` // 支付类型: wechat/shenqi
|
||||
Enable bool `json:"enable"` // 是否启用
|
||||
EnabledModes []string `json:"enabledModes"` // 启用的支付模式,如 ["h5","jsapi"] 或 ["alipay","wxpay"]
|
||||
Sort int `json:"sort"` // 排序
|
||||
Remark string `json:"remark"` // 备注
|
||||
|
||||
// ========== 微信支付配置 ==========
|
||||
WechatAppID string `json:"wechatAppId"` // 微信AppID
|
||||
WechatMchID string `json:"wechatMchId"` // 微信商户号
|
||||
WechatMchApiV3Key string `json:"wechatMchApiV3Key"` // 微信API V3密钥
|
||||
WechatPrivateKey string `json:"wechatPrivateKey"` // 微信商户私钥
|
||||
WechatSerialNo string `json:"wechatSerialNo"` // 微信证书序列号
|
||||
WechatNotifyURL string `json:"wechatNotifyUrl"` // 微信回调地址
|
||||
|
||||
// ========== 神奇支付配置 ==========
|
||||
ShenqiPID int `json:"shenqiPid"` // 神奇支付商户ID
|
||||
ShenqiPrivateKey string `json:"shenqiPrivateKey"` // 神奇支付商户私钥
|
||||
ShenqiPlatformPubKey string `json:"shenqiPlatformPubKey"` // 神奇支付平台公钥
|
||||
ShenqiNotifyURL string `json:"shenqiNotifyUrl"` // 神奇支付回调地址
|
||||
ShenqiReturnURL string `json:"shenqiReturnUrl"` // 神奇支付同步跳转地址
|
||||
ShenqiBaseURL string `json:"shenqiBaseUrl"` // 神奇支付API地址
|
||||
}
|
||||
|
||||
// PayConfigUpdate 更新支付配置请求
|
||||
type PayConfigUpdate struct {
|
||||
ID uint `json:"id" binding:"required"` // ID
|
||||
Name string `json:"name"` // 支付名称
|
||||
Code string `json:"code"` // 支付编码
|
||||
Type string `json:"type"` // 支付类型
|
||||
Enable *bool `json:"enable"` // 是否启用
|
||||
EnabledModes *[]string `json:"enabledModes"` // 启用的支付模式(使用指针来区分不传和传空数组)
|
||||
Sort *int `json:"sort"` // 排序
|
||||
Remark string `json:"remark"` // 备注
|
||||
|
||||
// ========== 微信支付配置 ==========
|
||||
WechatAppID *string `json:"wechatAppId"` // 微信AppID
|
||||
WechatMchID *string `json:"wechatMchId"` // 微信商户号
|
||||
WechatMchApiV3Key *string `json:"wechatMchApiV3Key"` // 微信API V3密钥
|
||||
WechatPrivateKey *string `json:"wechatPrivateKey"` // 微信商户私钥
|
||||
WechatSerialNo *string `json:"wechatSerialNo"` // 微信证书序列号
|
||||
WechatNotifyURL *string `json:"wechatNotifyUrl"` // 微信回调地址
|
||||
|
||||
// ========== 神奇支付配置 ==========
|
||||
ShenqiPID *int `json:"shenqiPid"` // 神奇支付商户ID
|
||||
ShenqiPrivateKey *string `json:"shenqiPrivateKey"` // 神奇支付商户私钥
|
||||
ShenqiPlatformPubKey *string `json:"shenqiPlatformPubKey"` // 神奇支付平台公钥
|
||||
ShenqiNotifyURL *string `json:"shenqiNotifyUrl"` // 神奇支付回调地址
|
||||
ShenqiReturnURL *string `json:"shenqiReturnUrl"` // 神奇支付同步跳转地址
|
||||
ShenqiBaseURL *string `json:"shenqiBaseUrl"` // 神奇支付API地址
|
||||
}
|
||||
|
||||
// PayConfigToggle 切换支付状态请求
|
||||
type PayConfigToggle struct {
|
||||
ID uint `json:"id" binding:"required"` // ID
|
||||
Enable bool `json:"enable"` // 是否启用
|
||||
}
|
||||
|
||||
// Validate 验证创建请求
|
||||
func (req *PayConfigCreate) Validate() error {
|
||||
switch req.Type {
|
||||
case "wechat":
|
||||
if req.WechatAppID == "" || req.WechatMchID == "" || req.WechatMchApiV3Key == "" ||
|
||||
req.WechatPrivateKey == "" || req.WechatSerialNo == "" || req.WechatNotifyURL == "" {
|
||||
return fmt.Errorf("微信支付配置不完整")
|
||||
}
|
||||
case "shenqi":
|
||||
if req.ShenqiPID == 0 || req.ShenqiPrivateKey == "" || req.ShenqiPlatformPubKey == "" ||
|
||||
req.ShenqiNotifyURL == "" || req.ShenqiReturnURL == "" {
|
||||
return fmt.Errorf("神奇支付配置不完整")
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("不支持的支付类型: %s", req.Type)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user