shish 2 years ago
parent
commit
13d6172fba
1 changed files with 63 additions and 5 deletions
  1. 63 5
      app-ghs/controllers/TestController.php

+ 63 - 5
app-ghs/controllers/TestController.php

@@ -284,6 +284,68 @@ class TestController extends BaseController
         print_r($response);
     }
 
+    //零售订单查询 ssh 20231031
+    public function actionLsTradeQuery()
+    {
+        $shopId = 12004;
+        $shop = ShopClass::getById($shopId, true);
+        if (empty($shop)) {
+            util::stop('没有找到门店');
+        }
+        $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
+        $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
+        $params = [
+            'appid' => 'OP00002119',
+            'serial_no' => '018b08cfddbd',
+            'merchant_no' => $shop->lklSjNo,
+            'term_no' => $shop->lklScanTermNo,
+            'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
+            'lklCertificatePath' => $lklCertificatePath,
+        ];
+        $laResource = new Lakala($params);
+        $queryParams = [
+            'orderSn' => 'KD26452235',
+            //'tradeNo' => '20231029110113130266215259252887',
+        ];
+        $response = $laResource->query($queryParams, 0);
+        print_r($response);
+        die;
+        util::stop();
+        if (isset($response['code']) && $response['code'] == 'BBS00000') {
+            $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
+            $connection = Yii::$app->db;
+            $transaction = $connection->beginTransaction();
+            try {
+
+                $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 = '';
+                $total_amount = $response['resp_data']['total_amount'] ?? 0;
+                $orderSn = $response['resp_data']['out_trade_no'] ?? 0;
+                $totalFee = $total_amount / 100;
+                $transactionId = $response['resp_data']['trade_no'] ?? 0;
+                payUtil::thirdPay($currentPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
+                $transaction->commit();
+                echo 'OK';
+            } catch (\Exception $e) {
+                $transaction->rollBack();
+                Yii::error("失败原因:" . $e->getMessage());
+            }
+        }
+    }
 
     //交易查询 ssh 20231021
     public function actionTradeQuery()
@@ -309,10 +371,7 @@ class TestController extends BaseController
             'tradeNo' => '20231029110113130266215259252887',
         ];
         $response = $laResource->query($queryParams, 1);
-
-        print_r($response);
-        die;
-
+        util::stop();
         if (isset($response['code']) && $response['code'] == 'BBS00000') {
             $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
             $connection = Yii::$app->db;
@@ -339,7 +398,6 @@ class TestController extends BaseController
                 $orderSn = $response['resp_data']['out_trade_no'] ?? 0;
                 $totalFee = $total_amount / 100;
                 $transactionId = $response['resp_data']['trade_no'] ?? 0;
-                //echo $currentPayWay . ' ' . $capitalType . ' ' . $orderSn . ' ' . $totalFee . ' ' . $attach . ' ' . $transactionId;
                 payUtil::thirdPay($currentPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
                 $transaction->commit();
                 echo 'OK';