shish 1 rok temu
rodzic
commit
b6690e6451
1 zmienionych plików z 63 dodań i 0 usunięć
  1. 63 0
      app-ghs/controllers/TestController.php

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

@@ -892,6 +892,69 @@ class TestController extends BaseController
         }
     }
 
+    public function actionRechargeQuery()
+    {
+        $shopId = 23580;
+        $shop = ShopClass::getById($shopId, true);
+        if (empty($shop)) {
+            util::stop('没有找到门店,编号677230');
+        }
+        $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' => 'CRS55742',
+            //'tradeNo' => '66221061685504',
+        ];
+        $response = $laResource->query($queryParams, 0);
+        echo "<pre>";
+        print_r($response);
+        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());
+            }
+        }
+    }
+
+
     public function actionAliRun2()
     {
         $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';