fix version 1

This commit is contained in:
2026-09-22 21:15:34 +08:00
parent 9f86366638
commit d63d7e8b3a
277 changed files with 9959 additions and 1514 deletions

View File

@@ -2,6 +2,7 @@ package alipay
import (
"context"
"strconv"
"bsm/full/module/finance/wallet/internal/config"
"github.com/go-pay/gopay"
@@ -23,8 +24,8 @@ func NewAlipay() (*AliPay, error) {
if err != nil {
return nil, err
}
// 打开Debug开关输出日志默认关闭
client.DebugSwitch = gopay.DebugOn
// 调试开关默认关闭,避免渠道请求/响应(含金额、订单号)写入进程日志
client.DebugSwitch = gopay.DebugOff
// 设置支付宝请求 公共参数
client.SetLocation(alipay.LocationShanghai) // 设置时区,不设置或出错均为默认服务器时间
@@ -44,17 +45,22 @@ func NewAlipay() (*AliPay, error) {
}
return &AliPay{
ctx: context.Background(),
Client: client,
// ctx: context.Background(),
Body: &gopay.BodyMap{},
}, nil
}
func (srv *AliPay) SetBody(body, orderNo string, amount int64) {
// SetBody 组装支付宝下单公共参数
// productCodeWAP 场景为 QUICK_WAP_WAYAPP 场景为 QUICK_MSECURITY_PAY
func (srv *AliPay) SetBody(body, orderNo string, amount int64, productCode string) {
// 支付宝要求 total_amount 为两位小数的元字符串,不能用整数除法截断
totalAmount := strconv.FormatFloat(float64(amount)/100, 'f', 2, 64)
srv.Body.Set("subject", config.Spec.Wallet.Name).
Set("body", body). //finance_payment表的identity
Set("product_code", "QUICK_WAP_WAY").
Set("product_code", productCode).
Set("out_trade_no", orderNo).
Set("total_amount", amount/100).
Set("total_amount", totalAmount).
Set("timeout_express", "60m").
Set("quit_url", config.Spec.Alipay.QuitURL)
}