Sfoglia il codice sorgente

1. 红包系统, 微信二次支付时, 订单金额修改后支付失败bug修正
2. 允许红包多次支付订单
3. 修正使用红包支付后, 支付宝订单金额不正确bug

songjiyuan 9 anni fa
parent
commit
11fdec7f05
3 ha cambiato i file con 14 aggiunte e 11 eliminazioni
  1. 4 4
      data/logic/payment.logic.php
  2. 4 2
      mobile/control/app_pay.php
  3. 6 5
      mobile/wxnotify.php

+ 4 - 4
data/logic/payment.logic.php

@@ -53,10 +53,10 @@ class paymentLogic
                 // 计算运费+订单总额
                 $total_amount = floatval($order_info['order_amount']) + floatval($order_info['shipping_fee']);
                 // 已经使用过红包, 不允许第二次使用
-                if (intval($order_info['pd_amount']) != 0) {
-                    DB::rollback();
-                    return -2;
-                }
+                // if (intval($order_info['pd_amount']) != 0) {
+                //     DB::rollback();
+                //     return -2;
+                // }
                 if ((floatval($pd_amount) + floatval($order_info['pd_amount'])) > floatval($total_amount))  {
                     // 预存款增量, 当二次付款并使用红包的时候, 需要进行二次计算预存款
                     $increment_amount = floatval($total_amount) - floatval($order_info['pd_amount']);

+ 4 - 2
mobile/control/app_pay.php

@@ -138,7 +138,7 @@ class app_payControl extends mbMemberControl
             $ret['out_trade_no'] = $pay_info['order_list'][0]['pay_sn'];   // 商户网站唯一订单号
             $ret['subject'] = $subject;                                     // 商品名称
             $ret['body'] = '商品详情';                                       // 商品详情
-            $ret['total_fee'] = $pay_info['order_list'][0]['order_amount']; // 商品金额
+            $ret['total_fee'] = floatval($pay_info['order_list'][0]['order_amount']) - floatval($pay_info['order_list'][0]['pd_amount']); // 商品金额
             $ret['notify_url'] = self::ali_notifyurl;                       // 服务器异步通知页面路径
             $ret['service'] = 'mobile.securitypay.pay';                     // 服务器接口名称,固定值
             $ret['payment_type'] = '1';                                     // 支付类型,固定值
@@ -259,7 +259,9 @@ class app_payControl extends mbMemberControl
         $input = new WxPayUnifiedOrder();
         $input->SetBody($body); //商品或支付单简要描述
         $input->SetAttach($paysn); //附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据
-        $input->SetOut_trade_no($paysn);//商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号
+        $model_pd = Model('predeposit');
+        $order_sn = $model_pd->makeSn();    // 给微信用的每次重新生成的商户订单SN, 避免二次支付, 数额修改导致支付失败
+        $input->SetOut_trade_no($order_sn);//商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号
 
         $input->SetTotal_fee("{$fee}");//订单总金额,单位为分,详见支付金额
         $input->SetTime_start(date("YmdHis")); //订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则

+ 6 - 5
mobile/wxnotify.php

@@ -60,12 +60,13 @@ try
     wxLog::DEBUG("result_code= {$ret_code}");
     if($ret_code == 'SUCCESS')
     {
-        $out_trade_no = $result['out_trade_no'];
+        $out_trade_no = $result['out_trade_no'];    //  给微信用的随机商户订单SN
+        $attach = $result['attach'];    // 真正的我们平台的订单SN号
         $transaction_id=$result['transaction_id'];
-        wxLog::DEBUG("out_trade_no={$out_trade_no} and transaction_id = {$transaction_id}");
-        Log::record("out_trade_no={$out_trade_no} and transaction_id = {$transaction_id}",Log::DEBUG);
+        wxLog::DEBUG("out_trade_no={$out_trade_no} and attach={$attach} and transaction_id = {$transaction_id}");
+        Log::record("out_trade_no={$out_trade_no} and attach={$attach} and transaction_id = {$transaction_id}",Log::DEBUG);
 
-        $cb_info = app_payControl::update_order($out_trade_no,$transaction_id,'wxpay');
+        $cb_info = app_payControl::update_order($attach,$transaction_id,'wxpay');
 
         if($cb_info['state'] == false) {
             wxLog::ERROR('wxpay error 1.');
@@ -74,7 +75,7 @@ try
             wxLog::DEBUG('wxpay success.');
             Log::record('wxpay success.',Log::DEBUG);
             $logic_delivery = Logic('delivery');
-            $ret = $logic_delivery->putOrder($out_trade_no, $transaction_id);
+            $ret = $logic_delivery->putOrder($attach, $transaction_id);
         }
 
         $ret_wx['return_code'] = 'SUCCESS';