shish 2 tahun lalu
induk
melakukan
d393451028

+ 30 - 2
app-ghs/controllers/TestController.php

@@ -2,6 +2,7 @@
 
 namespace ghs\controllers;
 
+use biz\shop\classes\ShopClass;
 use biz\sj\services\MerchantService;
 use bizGhs\express\services\DadaExpressServices;
 use bizGhs\order\classes\OrderClass;
@@ -20,11 +21,11 @@ use common\components\util;
 class TestController extends BaseController
 {
 
-    public $guestAccess = ['inform', 'notice', 'order-query', 'add-order', 'index', 'get'];
+    public $guestAccess = ['inform', 'notice', 'order-query', 'add-order', 'index', 'get', 'trade-query'];
 
     public function actionApply()
     {
-        $sjNo ='';
+        $sjNo = '';
 
         $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
         $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
@@ -159,6 +160,33 @@ class TestController extends BaseController
         die;
     }
 
+    //交易查询 ssh 20231021
+    public function actionTradeQuery()
+    {
+        $shopId = 795;
+        $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 = [
+            'tradeNo' => '20231021110113130266215211135188',
+        ];
+        $response = $laResource->query($queryParams);
+        echo "<pre>";
+        print_r($response);
+    }
+
     public function actionAliRun2()
     {
         $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';

+ 8 - 3
common/components/lakala/Lakala.php

@@ -114,17 +114,22 @@ class Lakala
         return $this->post($url, $body, $authorization);
     }
 
-    public function query($params)
+    public function query($params, $lklSn = 0)
     {
-        $orderSn = $params['orderSn'];
+        $orderSn = $params['orderSn'] ?? '';
+        $tradeNo = $params['tradeNo'] ?? '';
         $ip = $this->getClientIp();
         $location_info = ['request_ip' => $ip];
         $arr = [
             'merchant_no' => $this->merchant_no,
             'term_no' => $this->term_no,
-            'out_trade_no' => $orderSn,
             'location_info' => $location_info,
         ];
+        if ($lklSn == 0) {
+            $arr['out_trade_no'] = $orderSn;
+        } else {
+            $arr['trade_no'] = $tradeNo;
+        }
         $baseRequestVO = [
             'req_data' => $arr,
             'req_time' => date("YmdHis"),