dong 1 rok temu
rodzic
commit
ad4fe90081

+ 41 - 2
mapi/api/ctcard/CTCard.php

@@ -1,11 +1,50 @@
 <?php
 
 namespace mapi;
-
+use mapi\config\config;
 class CTCard implements IOpenCard
 {
-    public function fraud_check() : bool
+    private function create_guid() : string
+    {
+        $str = md5(uniqid(mt_rand(), true));
+        $uuid  = substr($str,0,8);
+        $uuid .= substr($str,8,4);
+        $uuid .= substr($str,12,4);
+        $uuid .= substr($str,16,4);
+        $uuid .= substr($str,20,12);
+        return $uuid;
+    }
+
+    private function generate_packet_sequence_number() : string
+    {
+        return config::SYS_CODE.config::APP_CODE.date("ymdhm", time()).$this->create_guid();
+    }
+
+    private function sign() : string
+    {
+        return md5($this->generate_packet_sequence_number().config::KEY);
+    }
+
+    public function createHeader($method) : array
+    {
+        return [
+            "sysCode" => config::SYS_CODE,
+            "appCode" => config::APP_CODE,
+            "transactionId" => $this->generate_packet_sequence_number(),
+            "reqTime" => date("Y-m-d H:i:s", time()),
+            "method" => $method,
+            "version" => 1,
+            "attach" => "fraud_check",
+            "sign" => $this->sign()
+        ];
+    }
+
+
+    public function fraud_check($params, $net_errno) : bool
     {
+        $head = $this->createHeader("fraudCheck");
+        $biz = json_encode($params);
+        $resp = http_post_data(config::test_env['DCN'], $biz , $head, $net_errno);
         return false;
     }
 }

+ 3 - 2
mapi/api/ctcard/IOpenCard.php

@@ -4,5 +4,6 @@ namespace mapi;
 
 interface IOpenCard
 {
-    public function fraud_check() : bool;
-}
+    public function fraud_check($data, $net_errno) : bool;
+}
+

+ 32 - 0
mapi/api/ctcard/config/config.php

@@ -0,0 +1,32 @@
+<?php
+namespace mapi\config;
+
+class config
+{
+    const SYS_CODE = "HNDQUOP";
+    const APP_CODE = "HNWAIST";
+
+    const KEY = "b5a1fc2085986034e448d2ccc5bb9703";
+
+    // 走 Dcoos 地址时需在 http 的请求头加上 X-APP-ID 和 X-APP-KEY
+    const test_env = [
+        'DCN' => "http://135.125.60.146:30096/uop-web/httpapi/service/execute",
+        'Dcoos' => "http://135.125.60.146:9002/eop/uop-web/execute"
+    ];
+
+    const production_env = [
+        'DCN' => 'http://135.125.69.8:10096/uop-web/httpapi/service/execute',
+        'DcoosInternalNetwork' => "http://135.125.60.111:9002/eop/uop-web/execute",
+        'DcoosExternalNetwork' => "https://eop.hicloudnet.cn:9002/eop/uop-web/execute",
+    ];
+}
+
+
+
+
+
+
+
+
+
+

+ 20 - 3
test/mapi/TestCTCard.php

@@ -7,13 +7,15 @@ define('BASE_ROOT_PATH', str_replace('/test/mapi', '', dirname(__FILE__)));
 
 require_once(BASE_ROOT_PATH . '/global.php');
 require_once(BASE_CORE_PATH . '/lrlz.php');
+require_once(BASE_CORE_PATH . '/framework/function/http.php');
 require_once(BASE_ROOT_PATH . '/fooder.php');
 
 require_once(BASE_MAPI_PATH . '/api/ctcard/IOpenCard.php');
 require_once(BASE_MAPI_PATH . '/api/ctcard/CTCard.php');
+require_once(BASE_MAPI_PATH . '/api/ctcard/config/config.php');
 
 
-use mapi;
+use mapi\CTCard;
 
 class TestCTCard extends TestCase
 {
@@ -24,7 +26,22 @@ class TestCTCard extends TestCase
 
     public function testFraudCheck()
     {
-        $ctcard = new mapi\CTCard();
-        $ctcard->fraud_check();
+        $ctcard = new CTCard();
+        // biz
+        $params['biz'] = [
+            "custName" => "董朋",
+            "custCertNo" => "130634199002230034",
+            "province" => "海南省",
+            "city" => "海口市",
+            "county" => "琼山区",
+            "street" => "凤翔街道",
+            "detailedAddr" => "海南省海口市琼山区凤翔街道测试",
+            "consignee" => "董朋",
+            "receiContact" => "13581540213",
+            "scenarioCode" => "20230830180956577"
+        ];
+
+       $ctcard->fraud_check($params, 0);
+
     }
 }