animeic před 1 rokem
rodič
revize
1618cc20e5
4 změnil soubory, kde provedl 13 přidání a 3 odebrání
  1. binární
      pay/__debug_bin
  2. 1 0
      pay/assettest.log
  3. 6 2
      pay/bus/multiAliPay.go
  4. 6 1
      pay/bus/multiWechatPay.go

binární
pay/__debug_bin


+ 1 - 0
pay/assettest.log

@@ -36,3 +36,4 @@
 {"level":"info","timestamp":"2023-07-06 17:07:18","message":"[初始化支付客户端]","service_name":"assettest"}
 {"level":"info","timestamp":"2023-07-06 17:18:02","message":"[初始化支付客户端]","service_name":"assettest"}
 {"level":"error","timestamp":"2023-07-06 17:21:19","message":"{\"code\":\"ACQ.MERCHANT_STATUS_NOT_NORMAL\",\"msg\":\"Business Failed\",\"sub_code\":\"ACQ.MERCHANT_STATUS_NOT_NORMAL\",\"sub_msg\":\"商户协议状态非正常状态\"}","service_name":"assettest"}
+{"level":"info","timestamp":"2023-07-06 17:30:09","message":"[初始化支付客户端]","service_name":"assettest"}

+ 6 - 2
pay/bus/multiAliPay.go

@@ -10,6 +10,7 @@ import (
 	"pay/log"
 	"pay/pay"
 	"pay/utils"
+	"strconv"
 
 	"github.com/go-pay/gopay"
 	"github.com/go-pay/gopay/alipay"
@@ -29,7 +30,10 @@ func (a *MutliAliPay) Pay(ctx context.Context, orderMsg *cpay.OrderMsg) (interfa
 	// 初始化 BodyMap
 	orderId := orderMsg.Project + "_" + orderMsg.Id.Hex()
 	bm := make(gopay.BodyMap)
-	parseAmount, err := utils.IntToDecimal(int32(*orderMsg.Amount))
+	amount, err := strconv.ParseFloat(fmt.Sprintf("%.2f", *orderMsg.Amount), 64)
+	if err != nil {
+		return nil, errors.New("价格parse错误!")
+	}
 
 	if err != nil {
 		return nil, err
@@ -63,7 +67,7 @@ func (a *MutliAliPay) Pay(ctx context.Context, orderMsg *cpay.OrderMsg) (interfa
 		Set("scene", "bar_code").
 		//Set("auth_code", util.RandomNumber(10))
 		Set("out_trade_no", orderId).
-		Set("total_amount", parseAmount).
+		Set("total_amount", amount).
 		// 口碑门店,如果是第三方授权这里填写app_auth_token对应账号
 		// Set("seller_id", "2088441503441284"). // sku3d
 		Set("seller_id", seller.AlipaySellerId). // um

+ 6 - 1
pay/bus/multiWechatPay.go

@@ -11,6 +11,7 @@ import (
 	"pay/log"
 	"pay/pay"
 	"pay/utils"
+	"strconv"
 	"time"
 
 	"github.com/go-pay/gopay"
@@ -58,6 +59,10 @@ func (w *MutliWechatPay) Pay(ctx context.Context, orderMsg *cpay.OrderMsg) (inte
 	if !ok {
 		return nil, fmt.Errorf("当前商户 %s 支付模块没接入", orderMsg.SellerKey)
 	}
+	amount, err := strconv.ParseFloat(fmt.Sprintf("%.2f", *orderMsg.Amount), 64)
+	if err != nil {
+		return nil, errors.New("价格parse错误!")
+	}
 
 	// 初始化 BodyMap
 	orderId := orderMsg.Project + "_" + orderMsg.Id.Hex()
@@ -70,7 +75,7 @@ func (w *MutliWechatPay) Pay(ctx context.Context, orderMsg *cpay.OrderMsg) (inte
 		Set("time_expire", time.Now().Add(10*time.Minute).Format(time.RFC3339)).
 		Set("notify_url", multiPayCnf.WechatPay.NotifyUrl).
 		SetBodyMap("amount", func(bm gopay.BodyMap) {
-			bm.Set("total", orderMsg.Amount).
+			bm.Set("total", amount*100).
 				Set("currency", "CNY")
 		})