shish 2 yıl önce
ebeveyn
işleme
22fdb16126

+ 31 - 5
app-mall/controllers/TestController.php

@@ -2,18 +2,44 @@
 
 namespace mall\controllers;
 
-use bizMall\merchant\services\MerchantService;
-use bizMall\message\services\InformAdminService;
-use bizMall\order\services\OrderService;
+use bizMall\shop\classes\ShopClass;
 use common\components\util;
 use Yii;
+use common\components\lakala\Lakala;
 
 class TestController extends BaseController
 {
 
-    public function actionIndex()
+    public $guestAccess = ['trade-query'];
+
+    //收银台订单查询 ssh 20231026
+    public function actionTradeQuery()
     {
-        echo 'aaa';
+        $shopId = 1;
+        $shop = ShopClass::getById($shopId, true);
+        if (empty($shop)) {
+            util::fail('没有找到订单');
+        }
+        $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);
+        $orderSn = 'KD26449727';
+        $cashParams = [
+            'out_order_no' => $orderSn,
+        ];
+        $response = $laResource->cashierQuery($cashParams);
+        if (isset($response['code']) == false || $response['code'] != '000000') {
+            util::fail('支付失败了');
+        }
+        print_r($response);
     }
 
 }

+ 19 - 0
common/components/lakala/Lakala.php

@@ -133,6 +133,25 @@ class Lakala
         return $this->post($url, $body, $authorization);
     }
 
+    //收银机订单查询 ssh 20231026
+    public function cashierQuery($params)
+    {
+        $out_order_no = $params['out_order_no'];
+        $arr = [
+            'merchant_no' => $this->merchant_no,
+            'out_order_no' => $out_order_no,
+        ];
+        $baseRequestVO = [
+            'req_data' => $arr,
+            'req_time' => date("YmdHis"),
+            'version' => $this->version,
+        ];
+        $body = json_encode($baseRequestVO, JSON_UNESCAPED_UNICODE);
+        $authorization = $this->getAuthorization($body);
+        $url = 'https://s2.lakala.com/api/v3/ccss/counter/order/query';
+        return $this->post($url, $body, $authorization);
+    }
+
     public function query($params, $lklSn = 0)
     {
         $orderSn = $params['orderSn'] ?? '';