HARUHARU 4 éve
szülő
commit
bc980c12d1
2 módosított fájl, 41 hozzáadás és 13 törlés
  1. 2 2
      application/common.php
  2. 39 11
      application/index/controller/Index.php

+ 2 - 2
application/common.php

@@ -124,12 +124,12 @@ function http_request($method,$url,$data)
 
 function http_get($url,$data)
 {
-    return http_request('GET',$url,$data);
+    return json_decode(http_request('GET',$url,$data),true);
 }
 
 function http_post($url,$data)
 {
-    return http_request('POST',$url,$data);
+    return json_decode(http_request('POST',$url,$data),true);
 }
 
 /**

+ 39 - 11
application/index/controller/Index.php

@@ -4,8 +4,8 @@ namespace app\index\controller;
 
 class Index
 {
-    const admin_url = '192.168.1.200:8080';
-    const path_check_order = '/CheckRcode';
+//    const admin_url = 'host.docker.internal';
+    const admin_url = 'docker.hostip';
 
     protected function request($params)
     {
@@ -18,22 +18,50 @@ class Index
     }
     public function CheckOrder(){
         $order_sn = input('param.order_sn');
-        $ret = ['existed' => true,'order_sn' => $order_sn];
-        json_success($ret);
+        $result = http_get(self::admin_url . ':8080/CheckOrder' ,['order_sn' => $order_sn]);
+        if($result == false){
+            json_return(500,[],'网络错误');
+        }
+        if($result['code'] != 0){
+            json_return($result['code'],[],$result['msg']);
+        }
+        json_success($result['data']);
+
     }
     public function CheckFcode(){
         $code = input('param.code');
-        $trunk = 1;
-        $cabinet = 2;
-        $ret = ['existed' => true,'code' => $code , 'trunk' => $trunk , 'cabinet' => $cabinet];
-        json_success($ret);
+        $result = http_get(self::admin_url . ':8080/CheckFcode' ,['code' => $code]);
+        if($result == false){
+            json_return(500,[],'网络错误');
+        }
+        if($result['code'] != 0){
+            json_return($result['code'],[],$result['msg']);
+        }
+        json_success($result['data']);
     }
     public function RecordStore(){
         $order_sn = input('param.order_sn');
-        json_success([]);
+        $trunk = input('param.trunk');
+        $cabinet = input('param.cabinet');
+        $result = http_get(self::admin_url . ':8080/RecordStore' ,['order_sn' => $order_sn , 'trunk' => $trunk , 'cabinet' => $cabinet]);
+        if($result == false){
+            json_return(500,[],'网络错误');
+        }
+        if($result['code'] != 0){
+            json_return($result['code'],[],$result['msg']);
+        }
+        json_success($result['data']);
     }
     public function RecordFetch(){
-        $order_sn = input('param.order_sn');
-        json_success([]);
+        $trunk = input('param.trunk');
+        $cabinet = input('param.cabinet');
+        $result = http_get(self::admin_url . ':8080/RecordFetch' ,['trunk' => $trunk , 'cabinet' => $cabinet]);
+        if($result == false){
+            json_return(500,[],'网络错误');
+        }
+        if($result['code'] != 0){
+            json_return($result['code'],[],$result['msg']);
+        }
+        json_success($result['data']);
     }
 }