Forráskód Böngészése

支付流程处理

shish 5 éve
szülő
commit
6f686b9393
2 módosított fájl, 33 hozzáadás és 32 törlés
  1. 3 13
      app-ghs/controllers/NoticeController.php
  2. 30 19
      common/components/pay.php

+ 3 - 13
app-ghs/controllers/NoticeController.php

@@ -7,6 +7,7 @@ use bizGhs\order\classes\OrderClass;
 use bizGhs\order\classes\OrderExpressClass;
 use bizGhs\order\classes\OrderSendClass;
 use common\components\dict;
+use common\components\pay;
 use Yii;
 use common\components\util;
 use biz\recharge\classes\RechargeClass;
@@ -41,7 +42,7 @@ class NoticeController extends PublicController
 
         $wxPay = dict::getDict('payWay', 'wxPay');
         //支付成功后续流程
-        $this->_thirdPay($wxPay, $capitalType, $orderSn, $totalFee, $attach);
+        pay::thirdPay($wxPay, $capitalType, $orderSn, $totalFee, $attach);
 
         echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
     }
@@ -122,24 +123,13 @@ class NoticeController extends PublicController
 
             $aliPay = dict::getDict('payWay', 'alipay');
             //支付成功后续流程
-            $this->_thirdPay($aliPay, $capitalType, $orderSn, $totalFee, $attach);
+            pay::thirdPay($aliPay, $capitalType, $orderSn, $totalFee, $attach);
 
         }
         //请不要修改
         echo "success";
     }
 
-    public function _thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach)
-    {
-        //流水类型列表
-        switch ($capitalType) {
-            case dict::getDict('capitalType', 'xhRecharge', 'id'):
-                //充值
-                RechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
-                break;
-            default:
-        }
-    }
 
     /*
      *   {

+ 30 - 19
common/components/pay.php

@@ -13,26 +13,37 @@ class pay
 
     public static function thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach)
     {
-        //流水类型列表
-        switch ($capitalType) {
-            case dict::getDict('capitalType', 'xhRecharge', 'id'):
-                //零售和供货商充值
-                RechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
-                break;
-            case dict::getDict('capitalType', 'xhPurchase', 'id'):
-                //零售采购订单
-                PurchaseClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
-                break;
-            case dict::getDict('capitalType', 'hdPurchaseClear', 'id'):
-                //零售采购订单结算
-                PurchaseClearClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
-                break;
-            case dict::getDict('capitalType', 'xhOrder', 'id'):
-                //零售订单
-                OrderClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
-                break;
-            default:
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+
+            //流水类型列表
+            switch ($capitalType) {
+                case dict::getDict('capitalType', 'xhRecharge', 'id'):
+                    //零售和供货商充值
+                    RechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                    break;
+                case dict::getDict('capitalType', 'xhPurchase', 'id'):
+                    //零售采购订单
+                    PurchaseClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                    break;
+                case dict::getDict('capitalType', 'hdPurchaseClear', 'id'):
+                    //零售采购订单结算
+                    PurchaseClearClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                    break;
+                case dict::getDict('capitalType', 'xhOrder', 'id'):
+                    //零售订单
+                    OrderClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                    break;
+                default:
+            }
+
+            $transaction->commit();
+        } catch (Exception $exception) {
+            $transaction->rollBack();
+            util::fail("支付回调处理失败 orderSn:{$orderSn} capitalType:{$capitalType}");
         }
+
     }
 
 }