Ver Fonte

余额查询

shish há 2 anos atrás
pai
commit
4de69fa8c1

+ 24 - 1
app-ghs/controllers/TestController.php

@@ -22,7 +22,7 @@ use common\components\util;
 class TestController extends BaseController
 {
 
-    public $guestAccess = ['inform', 'notice', 'order-query', 'add-order', 'index', 'get', 'trade-query', 'query'];
+    public $guestAccess = ['inform', 'notice', 'order-query', 'add-order', 'index', 'get', 'trade-query', 'query', 'balance-query'];
 
     public function actionApply()
     {
@@ -162,6 +162,29 @@ class TestController extends BaseController
         die;
     }
 
+    public function actionBalanceQuery()
+    {
+        $shopId = 1212;
+        $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);
+        $response = $laResource->accountBalanceQuery();
+        echo "<pre>";
+        print_r($response);
+    }
+
     public function actionQuery()
     {
         $shopId = 1212;

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

@@ -18,6 +18,26 @@ class Lakala
     private $version = '3.0';
     private $preUrl = '';
 
+    public function accountBalanceQuery()
+    {
+        $arr = [
+            'merchantNo' => $this->merchant_no,
+            //机构代号
+            'orgCode' => '970936',
+        ];
+        $rand = time() . '_' . stringUtil::charsShuffle(22);
+        $baseRequestVO = [
+            'reqData' => $arr,
+            'timestamp' => time(),
+            'reqId' => $rand,
+            'ver' => '1.0.0',
+        ];
+        $body = json_encode($baseRequestVO, JSON_UNESCAPED_UNICODE);
+        $authorization = $this->getAuthorization($body);
+        $url = 'https://s2.lakala.com/api/v2/mms/sme/mrchAuthStateQuery';
+        return $this->post($url, $body, $authorization);
+    }
+
     //申请主动结算 ssh
     public function applyInviteClear($params)
     {