This commit is contained in:
2024-12-30 17:56:03 +08:00
parent 5bc8164dd1
commit 7309ef704d
4 changed files with 9 additions and 8 deletions

View File

@@ -81,7 +81,7 @@ func (l *PaymentLogic) Payment(req *types.PaymentReq) (resp *types.PaymentResp,
prepayID, createOrderErr = l.svcCtx.WechatPayService.CreateWechatOrder(l.ctx, amount, product.ProductName, outTradeNo)
} else if req.PayMethod == "alipay" {
outTradeNo = l.svcCtx.AlipayService.GenerateOutTradeNo()
prepayID, createOrderErr = l.svcCtx.AlipayService.CreateAlipayOrder(l.ctx, amount, product, outTradeNo)
prepayID, createOrderErr = l.svcCtx.AlipayService.CreateAlipayOrder(l.ctx, amount, product.ProductName, outTradeNo)
} else if req.PayMethod == "appleiap" {
outTradeNo = l.svcCtx.ApplePayService.GenerateOutTradeNo()
prepayID = l.svcCtx.ApplePayService.GetIappayAppID(product.ProductEn)

View File

@@ -7,7 +7,6 @@ import (
mathrand "math/rand"
"net/http"
"qnc-server/app/user/cmd/api/internal/config"
"qnc-server/app/user/model"
"qnc-server/pkg/lzkit/lzUtils"
"strconv"
"time"
@@ -60,7 +59,7 @@ func (a *AliPayService) CreateAlipayAppOrder(amount float64, subject string, out
}
// CreateAlipayH5Order 创建支付宝H5支付订单
func (a *AliPayService) CreateAlipayH5Order(amount float64, subject string, outTradeNo string, returnUrlPath string) (string, error) {
func (a *AliPayService) CreateAlipayH5Order(amount float64, subject string, outTradeNo string) (string, error) {
client := a.AlipayClient
totalAmount := lzUtils.ToAlipayAmount(amount)
// 构造H5支付请求
@@ -71,7 +70,7 @@ func (a *AliPayService) CreateAlipayH5Order(amount float64, subject string, outT
TotalAmount: totalAmount,
ProductCode: "QUICK_WAP_PAY", // H5支付专用产品码
NotifyURL: a.config.NotifyUrl, // 异步回调通知地址
ReturnURL: fmt.Sprintf("%s/%s", a.config.ReturnURL, returnUrlPath),
ReturnURL: a.config.ReturnURL,
},
}
// 获取H5支付请求字符串这里会签名
@@ -84,7 +83,7 @@ func (a *AliPayService) CreateAlipayH5Order(amount float64, subject string, outT
}
// CreateAlipayOrder 根据平台类型创建支付宝支付订单
func (a *AliPayService) CreateAlipayOrder(ctx context.Context, amount float64, product *model.Product, outTradeNo string) (string, error) {
func (a *AliPayService) CreateAlipayOrder(ctx context.Context, amount float64, subject string, outTradeNo string) (string, error) {
// 根据 ctx 中的 platform 判断平台
platform, platformOk := ctx.Value("platform").(string)
if !platformOk {
@@ -93,10 +92,10 @@ func (a *AliPayService) CreateAlipayOrder(ctx context.Context, amount float64, p
switch platform {
case "app":
// 调用App支付的创建方法
return a.CreateAlipayAppOrder(amount, product.ProductName, outTradeNo)
return a.CreateAlipayAppOrder(amount, subject, outTradeNo)
case "h5":
// 调用H5支付的创建方法并传入 returnUrl
return a.CreateAlipayH5Order(amount, product.ProductName, outTradeNo, product.ProductEn)
return a.CreateAlipayH5Order(amount, subject, outTradeNo)
default:
return "", fmt.Errorf("不支持的支付平台: %s", platform)
}

View File

@@ -9,6 +9,7 @@ import (
"github.com/tidwall/gjson"
"github.com/zeromicro/go-zero/core/logx"
"io"
"log"
"net/http"
"net/url"
"qnc-server/app/user/cmd/api/internal/config"
@@ -363,6 +364,7 @@ func (a *ApiRequestService) ProcessG35SC01Request(params []byte) ([]byte, error)
},
}
resp, callApiErr := a.westDexService.CallAPI("G35SC01", request)
log.Println(string(resp))
if callApiErr != nil {
return nil, callApiErr
}