shish 2 tahun lalu
induk
melakukan
548c166377
1 mengubah file dengan 22 tambahan dan 9 penghapusan
  1. 22 9
      app-ghs/controllers/TestController.php

+ 22 - 9
app-ghs/controllers/TestController.php

@@ -13,6 +13,7 @@ use bizGhs\express\services\MiniExpressService;
 use common\components\dict;
 use common\components\lakala\Lakala;
 use common\components\miniUtil;
+use common\components\noticeUtil;
 use common\components\orderSn;
 use common\components\wxUtil;
 use common\components\payUtil;
@@ -235,22 +236,34 @@ class TestController extends BaseController
             'orderSn' => 'CG26677404',
         ];
         $response = $laResource->query($queryParams, 0);
-        print_r($response);
-        die;
         if (isset($response['code']) && $response['code'] == 'BBS00000') {
-            $capitalType = dict::getDict('capitalType', 'hdPurchaseClear', 'id');
+            $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
             $connection = Yii::$app->db;
             $transaction = $connection->beginTransaction();
             try {
-                util::stop();
-                $wxPay = dict::getDict('payWay', 'wxPay');
-                //支付成功后续流程
+
+                $account_type = $response['resp_data']['account_type'] ?? 0;
+                if (empty($account_type)) {
+                    noticeUtil::push('支付回调失败了,没有找到钱包类型,请注意', '15280215347');
+                    util::end();
+                }
+                $currentPayWay = null;
+                if ($account_type == 'WECHAT') {
+                    $currentPayWay = dict::getDict('payWay', 'wxPay');
+                } elseif ($account_type == 'ALIPAY') {
+                    $currentPayWay = dict::getDict('payWay', 'alipay');
+                } else {
+                    noticeUtil::push('支付回调失败了,没有找到支付类型', '15280215347');
+                    util::end();
+                }
+
                 $attach = '';
                 $payer_amount = $response['resp_data']['payer_amount'] ?? 0;
-                $orderSn = 'CL28681399';
+                $orderSn = $response['resp_data']['out_trade_no'] ?? 0;
                 $totalFee = $payer_amount / 100;
-                $transactionId = '20231021110113130266215211135188';
-                payUtil::thirdPay($wxPay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
+                $transactionId = $response['resp_data']['trade_no'] ?? 0;
+                echo $currentPayWay.' '.$capitalType.' '.$orderSn.' '.$totalFee.' '.$attach.' '.$transaction;die;
+                payUtil::thirdPay($currentPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
                 $transaction->commit();
                 echo 'OK';
             } catch (\Exception $e) {