stanley-king 4 年之前
父节点
当前提交
e57413a897
共有 6 个文件被更改,包括 67 次插入3 次删除
  1. 3 2
      application/index/controller/Order.php
  2. 9 0
      conf/etc/hosts
  3. 23 1
      conf/nginx/nginx-debug-http.conf
  4. 1 0
      docker-compose-mac.yml
  5. 5 0
      public/index.php
  6. 26 0
      tests/TestOrder.php

+ 3 - 2
application/index/controller/Order.php

@@ -55,9 +55,10 @@ class Order extends Base
         $code = $this->createRandCode();
         $code = $this->createRandCode();
         $ret  = $this->CreateOrder($order_sn , $trunk , $cabinet_number,$code);
         $ret  = $this->CreateOrder($order_sn , $trunk , $cabinet_number,$code);
 
 
-        if($ret['code'] != 1){
+        if($ret['code'] != 1) {
             json_error(1006);
             json_error(1006);
-        }else{
+        }
+        else {
             $alias = $cabinet['alias'];
             $alias = $cabinet['alias'];
             $this->box_action_record($cabinet_number , $trunk , 1 , $order_sn , $alias);
             $this->box_action_record($cabinet_number , $trunk , 1 , $order_sn , $alias);
             $msg = "{$alias}柜门{$trunk}箱门,密码信息{$code}";
             $msg = "{$alias}柜门{$trunk}箱门,密码信息{$code}";

+ 9 - 0
conf/etc/hosts

@@ -0,0 +1,9 @@
+127.0.0.1       localhost
+::1     localhost ip6-localhost ip6-loopback
+fe00::0 ip6-localnet
+ff00::0 ip6-mcastprefix
+ff02::1 ip6-allnodes
+ff02::2 ip6-allrouters
+172.22.0.3      ccbdc2e88e1a
+172.22.0.3      api.zng.com
+172.22.0.3      admin.zng.com

+ 23 - 1
conf/nginx/nginx-debug-http.conf

@@ -29,7 +29,7 @@ http
     {
     {
     	listen       8080;
     	listen       8080;
         set  $folder_name /var/www/html/public;
         set  $folder_name /var/www/html/public;
-        server_name 127.0.0.1;
+        server_name api.zng.com;
         root $folder_name;
         root $folder_name;
         index index.html index.php;
         index index.html index.php;
     	client_max_body_size 100m;
     	client_max_body_size 100m;
@@ -70,4 +70,26 @@ http
             include        fastcgi_params;
             include        fastcgi_params;
         }
         }
     }
     }
+
+    server
+    {
+        listen       8080;
+        set  $folder_name /var/www/html/admin;
+        server_name admin.zng.com;
+        root $folder_name;
+        index index.html index.php;
+        client_max_body_size 100m;
+        proxy_connect_timeout 500s;
+        proxy_read_timeout 500s;
+        proxy_send_timeout 500s;
+        fastcgi_connect_timeout 75;
+        fastcgi_read_timeout 600;
+        fastcgi_send_timeout 600;
+
+        charset utf-8;
+
+        location / {
+            index  index.html index.htm index.php;
+        }
+    }
 }
 }

+ 1 - 0
docker-compose-mac.yml

@@ -7,6 +7,7 @@ services:
       - "8080:8080"
       - "8080:8080"
     volumes:
     volumes:
       - $PWD/conf/etc/localtime:/etc/localtime:ro
       - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - $PWD/conf/etc/hosts:/etc/hosts:ro
       - $PWD/conf/nginx/nginx-debug-http.conf:/etc/nginx/nginx.conf:ro
       - $PWD/conf/nginx/nginx-debug-http.conf:/etc/nginx/nginx.conf:ro
       - $PWD:/var/www/html
       - $PWD:/var/www/html
     links:
     links:

+ 5 - 0
public/index.php

@@ -12,6 +12,11 @@
 // [ 应用入口文件 ]
 // [ 应用入口文件 ]
 namespace think;
 namespace think;
 
 
+header("Access-Control-Allow-Origin: http://admin.zng.com:8081");
+header("Access-Control-Allow-Methods:GET, POST, OPTIONS, DELETE");
+header("Access-Control-Allow-Credentials: true");
+header("Access-Control-Allow-Headers:DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type, Accept-Language, Origin, Accept-Encoding");
+
 // 加载基础文件
 // 加载基础文件
 require __DIR__ . '/../thinkphp/base.php';
 require __DIR__ . '/../thinkphp/base.php';
 
 

+ 26 - 0
tests/TestOrder.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace think;
+
+use PHPUnit\Framework\TestCase;
+
+define('BASE_ROOT_PATH',str_replace('/tests','',dirname(__FILE__)));
+define('BASE_PATH',BASE_ROOT_PATH . '/tests');
+define('APP_ID','tests');
+define('BASE_DATA_PATH',BASE_ROOT_PATH . '/data');
+require_once(BASE_ROOT_PATH . '/thinkphp/base.php');
+
+
+class TestOrder extends TestCase
+{
+    protected $baseUrl = 'http://localhost';
+    public static function setUpBeforeClass() : void
+    {
+        App::getInstance()->path(BASE_ROOT_PATH . '/application/')->initialize();
+    }
+    public function testCheckOrder()
+    {
+        $resp = http_request('http://host.docker.internal:8080/CheckOrder',['order_sn' => '123456'],'GET');
+    }
+
+}