fix: 通过 code 或 type 查找支付通道
Build and Push Docker Image / build-and-push (push) Successful in 1m3s
Build and Push Docker Image / deploy (push) Successful in 8s

This commit is contained in:
2026-07-14 09:17:02 +00:00
parent dfd7d6a256
commit c419eb3d4a
+19 -11
View File
@@ -73,26 +73,34 @@ func (h *PaymentHandler) CreatePayment(c *gin.Context) {
}
// 根据订单支付方式获取对应的支付通道
paymentType := order.PaymentMethod
if paymentType == "" {
paymentType = "bepusdt" // 默认使用 bepusdt
paymentMethod := order.PaymentMethod
if paymentMethod == "" {
paymentMethod = "usdt" // 默认
}
// 如果是 hashpay,调用 HashPay 支付
if paymentType == "hashpay" {
h.CreateHashPayPayment(c)
return
}
// BepUsdt 支付流程
// 先通过 code 查找支付通道
var channels []models.PaymentChannel
utils.DB.Where("is_enabled = ? AND type = ?", true, paymentType).Order("sort_order ASC").Find(&channels)
utils.DB.Where("is_enabled = ? AND code = ?", true, paymentMethod).Order("sort_order ASC").Find(&channels)
// 如果没找到,尝试通过 type 查找
if len(channels) == 0 {
utils.DB.Where("is_enabled = ? AND type = ?", true, paymentMethod).Order("sort_order ASC").Find(&channels)
}
if len(channels) == 0 {
c.JSON(http.StatusBadRequest, gin.H{"error": "No available payment channel"})
return
}
channel := channels[0]
// 如果是 hashpay,调用 HashPay 支付
if channel.Type == "hashpay" {
h.CreateHashPayPayment(c)
return
}
// BepUsdt 支付流程
config := parseChannelConfig(channel.Config)
apiURL := strings.TrimSuffix(config["bepusdt_api_url"], "/")