Browse Source

Connect to Hainan electric channel interface

dong 1 năm trước cách đây
mục cha
commit
4ca8d58ece
3 tập tin đã thay đổi với 90 bổ sung124 xóa
  1. 21 121
      mapi/api/ctcard/CTCard.php
  2. 1 1
      mapi/api/ctcard/IOpenCard.php
  3. 68 2
      test/mapi/TestCTCard.php

+ 21 - 121
mapi/api/ctcard/CTCard.php

@@ -42,13 +42,13 @@ class CTCard implements IOpenCard
             "reqTime"=>$reqTime,
             "method"=>$method,
             "version"=>"1",
-            "attach"=>"fraud_check",
+            "attach"=>"hello",
             "sign"=>$sign
         ];
     }
 
 
-    private function request($head_method,$biz,&$net_errno)
+    private function request($head_method,$biz,&$net_errno) : array
     {
         $params['head'] = $this->head($head_method);
         $params['biz'] = $biz;
@@ -76,143 +76,43 @@ class CTCard implements IOpenCard
     }
 
 
-    public function fraud_check($biz) : array
+    public function fraud_check($biz) : void
     {
         [$succ, $head, $biz] = $this->request('fraudCheck', $biz, $net_errno);
-
-
     }
 
-    public function number_list($biz, &$net_errno = 0) : array
+    public function number_list($biz) : void
     {
-        $params['head'] = $this->head("qryNbrList");
-        $params['biz'] = $biz;
-        $requestParameters = json_encode($params, JSON_UNESCAPED_UNICODE);
-        $resp = http_post_data(config::production_env['DcoosExternalNetwork'], $requestParameters , config::HeaderProduction, $net_errno);
-        return $resp;
+        [$succ, $head, $biz] = $this->request('qryNbrList', $biz, $net_errno);
     }
 
-    public function address_delivery($biz, &$net_errno = 0) : array
+    public function address_delivery($biz) : void
     {
-        $callBack = function ($resp)
-        {
-            $resp = json_decode($resp, true);
-            $err = $resp["head"]["err"];
-            $code = $resp["head"]["code"];
-            if(empty($resp["biz"])){
-                return [$err, $code, []];
-            }
-            return [$err, $code, $resp];
-        };
-
-        $params['head'] = $this->head("qryReceiveAddr");
-        $params['biz'] = $biz;
-        $requestParameters = json_encode($params, JSON_UNESCAPED_UNICODE);
-        $resp = http_post_data(config::production_env['DcoosExternalNetwork'], $requestParameters , config::HeaderProduction, $net_errno);
-        if (empty($resp)) {
-            return [false, '网络错误'];
-        }
-        else
-        {
-            list($err, $code, $response) = $callBack($resp);
-            if ($code == 0){ // 成功
-                return [true, "成功", $response];
-            }else { // 失败
-                return [false, $err];
-            }
-        }
+        [$succ, $head, $biz] = $this->request('qryReceiveAddr', $biz, $net_errno);
     }
 
-    public function broadband_address_list($biz, &$net_errno = 0) : array
+    public function broadband_address_list($biz) : void
     {
-        $callBack = function ($resp)
-        {
-            $resp = json_decode($resp, true);
-            $err = $resp["head"]["err"];
-            $code = $resp["head"]["code"];
-            if(empty($resp["biz"])){
-                return [$err, $code, []];
-            }
-            return [$err, $code, $resp];
-        };
-
-        $params['head'] = $this->head("qryAddressInfo");
-        $params['biz'] = $biz;
-        $requestParameters = json_encode($params, JSON_UNESCAPED_UNICODE);
-        $resp = http_post_data(config::production_env['DcoosExternalNetwork'], $requestParameters , config::HeaderProduction, $net_errno);
-        if (empty($resp)) {
-            return [false, '网络错误'];
-        }
-        else
-        {
-            list($err, $code, $response) = $callBack($resp);
-            if ($code == 0){ // 成功
-                return [true, "成功", $response];
-            }else { // 失败
-                return [false, $err];
-            }
-        }
+        [$succ, $head, $biz] = $this->request('qryAddressInfo', $biz, $net_errno);
     }
 
-    public function broadband_address_resource_query($biz, &$net_errno = 0) : array
+    public function broadband_address_resource_query($biz) : void
     {
-        $callBack = function ($resp)
-        {
-            $resp = json_decode($resp, true);
-            $err = $resp["head"]["err"];
-            $code = $resp["head"]["code"];
-            if(empty($resp["biz"])){
-                return [$err, $code, []];
-            }
-            return [$err, $code, $resp];
-        };
+        [$succ, $head, $biz] = $this->request('getAddressCover', $biz, $net_errno);
+    }
 
-        $params['head'] = $this->head("getAddressCover");
-        $params['biz'] = $biz;
-        $requestParameters = json_encode($params, JSON_UNESCAPED_UNICODE);
-        $resp = http_post_data(config::production_env['DcoosExternalNetwork'], $requestParameters , config::HeaderProduction, $net_errno);
-        if (empty($resp)) {
-            return [false, '网络错误'];
-        }
-        else
-        {
-            list($err, $code, $response) = $callBack($resp);
-            if ($code == 0){ // 成功
-                return [true, "成功", $response];
-            }else { // 失败
-                return [false, $err];
-            }
-        }
+    public function logistics_path_query($biz) : void
+    {
+        [$succ, $head, $biz] = $this->request('getLogisticsTrajectory', $biz, $net_errno);
     }
 
-    public function logistics_path_query($biz, &$net_errno = 0) : array
+    public function add_order($biz) : void
     {
-        $callBack = function ($resp)
-        {
-            $resp = json_decode($resp, true);
-            $err = $resp["head"]["err"];
-            $code = $resp["head"]["code"];
-            if(empty($resp["biz"])){
-                return [$err, $code, []];
-            }
-            return [$err, $code, $resp];
-        };
+        [$succ, $head, $biz] = $this->request('synOrderInfo', $biz, $net_errno);
+    }
 
-        $params['head'] = $this->head("getAddressCover");
-        $params['biz'] = $biz;
-        $requestParameters = json_encode($params, JSON_UNESCAPED_UNICODE);
-        $resp = http_post_data(config::production_env['DcoosExternalNetwork'], $requestParameters , config::HeaderProduction, $net_errno);
-        if (empty($resp)) {
-            return [false, '网络错误'];
-        }
-        else
-        {
-            list($err, $code, $response) = $callBack($resp);
-            if ($code == 0){ // 成功
-                return [true, "成功", $response];
-            }else { // 失败
-                return [false, $err];
-            }
-        }
+    public function order_information_query($biz) : void
+    {
+        [$succ, $head, $biz] = $this->request('queryOrderInfo', $biz, $net_errno);
     }
 }

+ 1 - 1
mapi/api/ctcard/IOpenCard.php

@@ -4,6 +4,6 @@ namespace mapi;
 
 interface IOpenCard
 {
-    public function fraud_check($biz) : array;
+    public function fraud_check($biz) : void;
 }
 

+ 68 - 2
test/mapi/TestCTCard.php

@@ -104,10 +104,76 @@ class TestCTCard extends TestCase
         $ctcard = new CTCard();
         // biz
         $params = [
-            "orderCode" => "DQ201909260000112355670197",
-            "logisticNbr" => "JDV003703415445"
+            "orderCode" => "DQ202308312817072821436174",
+            "logisticNbr" => "JDVB24429069390"
         ];
 
         $ctcard->logistics_path_query($params);
     }
+
+    public function testNumberList()
+    {
+        $ctcard = new CTCard();
+        // biz
+        $params = [
+            "goodsId" => "20191023105408565",
+        ];
+
+        $ctcard->number_list([]);
+    }
+
+    public function testAddOrder()
+    {
+        $ctcard = new CTCard();
+        // biz
+        $params = [
+            "orderType" => "28",
+            "devStaffCode" => "F127020",
+            "devMobile" => "17372000970",
+            "orderAcceptType" => "10",
+            "orderOpenNo" => "",
+            "devOrgId",
+            "pOpenNo",
+            "orderBusiInfo" => [
+                "custCertType" => "10",
+                "custCertNo" => "130634199002230034",
+                "accNbr" => null,
+                "custName" => "董朋",
+                "mainAccNbr" => ""
+            ],
+            "openNo" => "DXW1EQNCKSIYDXZ7XRHRAO4IQP3GCILZ",
+            "statusCd" => "2300",
+            "busiScenarioCode" => "20230803081553180",
+            "orderProdInst" => [
+                "prodNo" => "20230803082357084",
+                "prodName" => "39元星卡(185G通用流量+30G定向)(2023版)",
+                "prodInstAct" => "ADD"
+            ],
+            "orderLogisticInfo" => [
+                "receiverType" => "14",
+                "receiverPhone" => "15017573651",
+                "receiverAddr" => "广东广州市白云区太和街道测试地址不要发货",
+                "receiverName" => "蔡鑫诺",
+                "provinceAddr" => "广东",
+                "cityAddr" => "广州市",
+                "areaAddr" => "白云区",
+                "streetAddr" => "太和街道"
+            ],
+
+            "orderAmount" => "0",
+            "orderArea" => "460",
+            "orderDate" => "2023-08-31 17:00:58"
+        ];
+
+        $ctcard->add_order($params);
+    }
+
+    public function testOrderInformationQuery()
+    {
+        $ctcard = new CTCard();
+        $params = [
+            "orderCode" => "DQ202308312817072821436174"
+        ];
+        $ctcard->order_information_query($params);
+    }
 }