f
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"tyc-server/app/main/api/internal/config"
|
||||
"tyc-server/app/main/model"
|
||||
@@ -273,10 +274,14 @@ func (w *WechatPayService) CreateWechatH5Order(ctx context.Context, amount float
|
||||
func (w *WechatPayService) CreateWechatOrder(ctx context.Context, amount float64, description string, outTradeNo string) (interface{}, error) {
|
||||
platformVal := ctx.Value("platform")
|
||||
platform, ok := platformVal.(string)
|
||||
platform = strings.TrimSpace(platform)
|
||||
if !ok || platform == "" {
|
||||
logx.WithContext(ctx).Errorf("[WechatPay] CreateWechatOrder 缺少 X-Platform")
|
||||
return "", fmt.Errorf("缺少 X-Platform 请求头(微信内请传 wxh5)")
|
||||
}
|
||||
|
||||
logx.WithContext(ctx).Infof("[WechatPay] CreateWechatOrder platform=%q out_trade_no=%s", platform, outTradeNo)
|
||||
|
||||
var prepayData interface{}
|
||||
var err error
|
||||
|
||||
@@ -319,6 +324,10 @@ func (w *WechatPayService) CreateWechatOrder(ctx context.Context, amount float64
|
||||
return "", fmt.Errorf("支付订单创建失败: %v", err)
|
||||
}
|
||||
|
||||
if prepayData == nil {
|
||||
logx.WithContext(ctx).Errorf("[WechatPay] CreateWechatOrder 返回 prepayData 为 nil platform=%q", platform)
|
||||
}
|
||||
|
||||
// 返回预支付ID
|
||||
return prepayData, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user