shish před 2 roky
rodič
revize
f002db3dd9
1 změnil soubory, kde provedl 24 přidání a 22 odebrání
  1. 24 22
      app-ghs/controllers/OrderController.php

+ 24 - 22
app-ghs/controllers/OrderController.php

@@ -405,17 +405,21 @@ class OrderController extends BaseController
                     $order->sendType = OrderClass::SEND_TYPE_NO;
                     $order->save();
 
-                    $payWay = $cg->payWay;
+                    $payWayType = dict::getDict('payWay', 'wxPay');
                     $account_type = $response['resp_data']['account_type'] ?? '';
                     if ($account_type == 'WECHAT') {
-                        $payWay = dict::getDict('payWay', 'wxPay');
+                        $payWayType = dict::getDict('payWay', 'wxPay');
                     }
                     if ($account_type == 'ALIPAY') {
-                        $payWay = dict::getDict('payWay', 'alipay');
+                        $payWayType = dict::getDict('payWay', 'alipay');
                     }
+                    $order->payWay = $payWayType;
+                    $order->save();
+                    $cg->payWay = $payWayType;
+                    $cg->save();
 
                     $attach = '';
-                    payUtil::thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
+                    payUtil::thirdPay($payWayType, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
                     $transaction->commit();
 
                     $saleId = $order->id ?? 0;
@@ -479,18 +483,9 @@ class OrderController extends BaseController
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
-
             $subject = '购买花材';
             $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
-
-            $wxPayWay = dict::getDict('payWay', 'wxPay');
-            $order->payWay = $wxPayWay;
-            $order->save();
-            $cg->payWay = $wxPayWay;
-            $cg->save();
-
             $shop = $this->shop;
-
             $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
             $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
             $params = [
@@ -514,8 +509,21 @@ class OrderController extends BaseController
             $response = $laResource->scanPay($scanParams);
             if (isset($response['code']) && $response['code'] == 'BBS00000') {
 
-                $transactionId = $res['transaction_id'] ?? '';
-                $openId = $res['openid'] ?? '';
+                $account_type = $response['resp_data']['account_type'] ?? '';
+                $payWayType = dict::getDict('payWay', 'wxPay');
+                if ($account_type == 'WECHAT') {
+                    $payWayType = dict::getDict('payWay', 'wxPay');
+                }
+                if ($account_type == 'ALIPAY') {
+                    $payWayType = dict::getDict('payWay', 'alipay');
+                }
+                $order->payWay = $payWayType;
+                $order->save();
+                $cg->payWay = $payWayType;
+                $cg->save();
+
+                $transactionId = $response['resp_data']['trade_no'] ?? '';
+                $openId = '';
                 $aliUserId = '';
 
                 $cg->onlinePay = dict::getDict('onlinePay', 'yes');
@@ -533,17 +541,12 @@ class OrderController extends BaseController
                 $order->save();
 
                 $attach = '';
-                payUtil::thirdPay($wxPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
+                payUtil::thirdPay($payWayType, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
                 $transaction->commit();
 
                 $saleId = $order->id ?? 0;
                 $order = OrderClass::getById($saleId, true);
                 if (!empty($order)) {
-                    $shopId = $order->shopId ?? 0;
-                    $shop = ShopClass::getById($shopId, true);
-                    if (!empty($shop)) {
-                        //WxMessageClass::ghsHasNewOrderInform($shop, $order);
-                    }
                     //订单生成时唤起在线打印
                     if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {
                         if ($order->status != 1 && $order->status != 5) {
@@ -554,7 +557,6 @@ class OrderController extends BaseController
                     }
                     ShopExtClass::ghsGatheringReport($order);
                 }
-
                 util::success(['returnStatus' => 'SUCCESS']);
             } else {
                 $msg = $response['msg'] ?? '';