shish 2 лет назад
Родитель
Сommit
f2cc7b74a7
1 измененных файлов с 64 добавлено и 0 удалено
  1. 64 0
      app-ghs/controllers/TestController.php

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

@@ -380,6 +380,70 @@ class TestController extends BaseController
         }
     }
 
+    //零售订单查询 ssh 20231031
+    public function actionClear()
+    {
+        $shopId = 10649;
+        $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' => 'KD26461864',
+            'tradeNo' => '20231230110113130266215700775011',
+        ];
+        $response = $laResource->query($queryParams, 1);
+        print_r($response);
+        util::stop();
+        if (isset($response['code']) && $response['code'] == 'BBS00000') {
+
+            $connection = Yii::$app->db;
+            $transaction = $connection->beginTransaction();
+            try {
+
+                $postData = $response['resp_data'] ?? [];
+                $orderSn = $postData['out_trade_no'] ?? '';
+                $total_amount = $postData['total_amount'] ?? 0;
+                $account_type = $postData['account_type'] ?? '';
+                if (empty($account_type)) {
+                    noticeUtil::push('支付回调失败了,没有找到钱包类型,请注意,orderSn:' . $orderSn, '15280215347');
+                    util::end();
+                }
+                $totalFee = $total_amount / 100;
+                $transactionId = $postData['trade_no'] ?? 0;
+                $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
+
+                $currentPayWay = null;
+                if ($account_type == 'WECHAT') {
+                    $currentPayWay = dict::getDict('payWay', 'wxPay');
+                } elseif ($account_type == 'ALIPAY') {
+                    $currentPayWay = dict::getDict('payWay', 'alipay');
+                } else {
+                    noticeUtil::push('支付回调失败了,没有找到支付类型,orderSn:' . $orderSn, '15280215347');
+                    util::end();
+                }
+                $attach = '';
+                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()
     {