浏览代码

docker-compose-windows

ayHaru 4 年之前
父节点
当前提交
ccf3479b8b

+ 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);
 }
 
 /**

+ 40 - 12
application/index/controller/Index.php

@@ -2,10 +2,10 @@
 namespace app\index\controller;
 
 
-class Index extends base
+class Index
 {
-    const admin_url = '192.168.1.200:8080';
-    const path_check_order = '/CheckRcode';
+//    const admin_url = 'host.docker.internal';
+    const admin_url = 'http://docker.hostip:8080';
 
     protected function request($params)
     {
@@ -18,22 +18,50 @@ class Index extends base
     }
     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 . '/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']);
     }
 }

+ 4 - 1
composer.json

@@ -22,7 +22,10 @@
     },
     "autoload": {
         "psr-4": {
-            "app\\": "application"
+            "app\\": "application",
+            "tests\\": "tests",
+            "think\\": "thinkphp/library/think",
+            "traits\\": "thinkphp/library/traits"
         }
     },
     "extra": {

+ 2 - 2
conf/crontab/root

@@ -1,4 +1,4 @@
 # do daily/weekly/monthly maintenance
 # min	hour	day	month	weekday	command
-*/15	*	*	*	*	php /var/www/html/crontab/index.php
-*    *   *   *   *   echo "test" >> /var/test.log
+*/10	*	*	*	*	php /var/www/html/crontab/index.php
+*    *   *   *   *   echo "test" >> /var/test.log- d/phpstudy_pro/WWW/access/conf/etc/localtime:/etc/localtime:ro

+ 9 - 27
conf/nginx/nginx-test-http.conf

@@ -29,7 +29,7 @@ http
     {
     	listen       80;
         set  $folder_name /var/www/html;
-        server_name www.xyzshops.cn;
+        server_name 39.97.239.116;
         root $folder_name;
         index index.html index.php; 
     	client_max_body_size 100m;
@@ -41,12 +41,6 @@ http
         fastcgi_send_timeout 600;   
 
         charset utf-8;
-        
-        location /logs {
-            deny all;
-            return 403;
-        }
-
         location /data/log {
             deny all;
             return 403;
@@ -54,31 +48,19 @@ http
         location / {
             index  index.html index.htm index.php;
         }
-        
-        location /mshop {
-            root $folder_name;
-            autoindex on;        
-            index  index.html index.htm index.php;
-	        try_files $uri $uri/ /mshop/index.html;
-        }
-
-        location ~ /mobile/[/\w]+\.php$ {
-            root           $folder_name;
-            fastcgi_pass   tmobilesrv:9100;
-            fastcgi_index  index.php;
-            fastcgi_param  SCRIPT_FILENAME  $folder_name$fastcgi_script_name;
-            include fastcgi_params;
-        }
 
-        location ~ /mobile/[/\w]+\.html$ {
-            try_files $uri $uri/ /mobile/index.html;
+        if (!-e $request_filename) {
+            rewrite  ^(.*)$  /index.php?s=/$1  last;
         }
 
-        location ~ \.php$ {
-	        add_header Cache-Control no-store;
+        location ~ \.php {
+            add_header Cache-Control no-store;
+            set  $folder_name /var/www/html/public;
             root           $folder_name;
-            fastcgi_pass   tfpmsrv:9000;
+            fastcgi_pass   accfpm:9000;
             fastcgi_index  index.php;
+            fastcgi_split_path_info ^(.+\.php)(.*)$;
+            fastcgi_param PATH_INFO $fastcgi_path_info;
             fastcgi_param  SCRIPT_FILENAME  $folder_name$fastcgi_script_name;
             include        fastcgi_params;
         }

+ 43 - 7
crontab/index.php

@@ -1,13 +1,49 @@
 <?php
 
-// [ 应用入口文件 ]
-namespace think;
-
-// 加载基础文件
-
-require __DIR__ . '/../thinkphp/base.php';
-
 define('BASE_ROOT_PATH',str_replace('/crontab','',dirname(__FILE__)));
 define('BASE_PATH',BASE_ROOT_PATH . '/crontab');
+define('BASE_DATA_PATH',BASE_ROOT_PATH . '/data');
+define('APP_ID','crontab');
 
 require_once(BASE_PATH . '/config.ini.php');
+
+require_once(BASE_ROOT_PATH . '/extend/queue.php');
+require_once(BASE_ROOT_PATH . '/extend/queue.logic.php');
+require_once(BASE_ROOT_PATH . '/extend/log.php');
+require_once(BASE_ROOT_PATH . '/extend/http.php');
+
+Log::record("Crontab startHandling something....",Log::DEBUG);
+
+class crontab
+{
+    public function onFifteenMinute()
+    {
+        $cabinets = $this->getAllCabinet();
+        foreach ($cabinets as $cabinet) {
+
+
+        }
+    }
+
+    private function getAllCabinet()
+    {
+
+    }
+
+    private function getBox($cabinet) {
+
+    }
+
+    private function reportState()
+    {
+
+    }
+}
+
+$worker = new crontab();
+$worker->onFifteenMinute();
+
+
+
+
+

+ 2 - 2
docker-compose-test.yml

@@ -4,10 +4,10 @@ services:
   accnginx:
     image: nginx:alpine
     ports:
-      - "8088:8088"
+      - "8088:80"
     volumes:
       - $PWD/conf/etc/localtime:/etc/localtime:ro
-      - $PWD/conf/nginx/nginx-debug-http.conf:/etc/nginx/nginx.conf:ro
+      - $PWD/conf/nginx/nginx-test-http.conf:/etc/nginx/nginx.conf:ro
       - $PWD:/var/www/html
     links:
       - accfpm

+ 41 - 0
docker-compose-windows.yml

@@ -4,11 +4,19 @@ services:
   accnginx:
     image: nginx:alpine
     ports:
+<<<<<<< HEAD
       - "8088:8088"
     volumes:
       - /d/phpstudy_pro/WWW/access/conf/etc/localtime:/etc/localtime:ro
       - /d/phpstudy_pro/WWW/access/conf/nginx/nginx-debug-http.conf:/etc/nginx/nginx.conf:ro
       - /d/phpstudy_pro/WWW/access:/var/www/html
+=======
+      - "8088:80"
+    volumes:
+      - d/phpstudy_pro/WWW/access/conf/etc/localtime:/etc/localtime:ro
+      - d/phpstudy_pro/WWW/access/conf/nginx/nginx-test-http.conf:/etc/nginx/nginx.conf:ro
+      - d/phpstudy_pro/WWW/access:/var/www/html
+>>>>>>> 0e677ca27c6e4a79b6f72643cfb3ef529f7e1f7d
     links:
       - accfpm
     container_name: "acc-nginx"
@@ -17,11 +25,19 @@ services:
   accfpm:
     image: php-fpm:alpine
     volumes:
+<<<<<<< HEAD
       - /d/phpstudy_pro/WWW/access/conf/etc/localtime:/etc/localtime:ro
       - /d/phpstudy_pro/WWW/access:/var/www/html
       - /d/phpstudy_pro/WWW/access/conf/php-fpm/php-debug.ini:/usr/local/etc/php/php.ini
       - /d/phpstudy_pro/WWW/access/conf/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.conf
       - /d/phpstudy_pro/WWW/access/conf/php-fpm/docker-php-fpm-start:/usr/local/bin/docker-php-fpm-start
+=======
+      - d/phpstudy_pro/WWW/access/conf/etc/localtime:/etc/localtime:ro
+      - d/phpstudy_pro/WWW/access:/var/www/html
+      - d/phpstudy_pro/WWW/access/conf/php-fpm/php-debug.ini:/usr/local/etc/php/php.ini
+      - d/phpstudy_pro/WWW/access/conf/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.conf
+      - d/phpstudy_pro/WWW/access/conf/php-fpm/docker-php-fpm-start:/usr/local/bin/docker-php-fpm-start
+>>>>>>> 0e677ca27c6e4a79b6f72643cfb3ef529f7e1f7d
     container_name: "acc-web"
     command: [docker-php-fpm-start]
     depends_on:
@@ -30,9 +46,15 @@ services:
   accphp:
     image: php-zts-debug:7.3.18
     volumes:
+<<<<<<< HEAD
       - /d/phpstudy_pro/WWW/access/conf/etc/localtime:/etc/localtime:ro
       - /d/phpstudy_pro/WWW/access/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
       - /d/phpstudy_pro/WWW/access:/var/www/html
+=======
+      - d/phpstudy_pro/WWW/access/conf/etc/localtime:/etc/localtime:ro
+      - d/phpstudy_pro/WWW/access/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
+      - d/phpstudy_pro/WWW/access:/var/www/html
+>>>>>>> 0e677ca27c6e4a79b6f72643cfb3ef529f7e1f7d
     links:
       - accredis
     container_name: "acc-php"
@@ -40,27 +62,46 @@ services:
   accredis:
     image: redis:alpine
     volumes:
+<<<<<<< HEAD
       - /d/phpstudy_pro/WWW/access/conf/etc/localtime:/etc/localtime:ro
+=======
+      - d/phpstudy_pro/WWW/access/conf/etc/localtime:/etc/localtime:ro
+>>>>>>> 0e677ca27c6e4a79b6f72643cfb3ef529f7e1f7d
     container_name: "acc-redis"
     command: [ "redis-server"]
 
   accqueue:
     image: php-zts-debug:7.3.18
     volumes:
+<<<<<<< HEAD
       - /d/phpstudy_pro/WWW/access/conf/etc/localtime:/etc/localtime:ro
       - /d/phpstudy_pro/WWW/access:/var/www/html
       - /d/phpstudy_pro/WWW/access/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
       - /d/phpstudy_pro/WWW/access/conf/queue/docker-queue-start:/usr/local/bin/docker-queue-start
+=======
+      - d/phpstudy_pro/WWW/access/conf/etc/localtime:/etc/localtime:ro
+      - d/phpstudy_pro/WWW/access:/var/www/html
+      - d/phpstudy_pro/WWW/access/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
+      - d/phpstudy_pro/WWW/access/conf/queue/docker-queue-start:/usr/local/bin/docker-queue-start
+>>>>>>> 0e677ca27c6e4a79b6f72643cfb3ef529f7e1f7d
     container_name: "acc-queue"
     command: [docker-queue-start]
 
   acccrontab:
     image: php-zts-debug:7.3.18
     volumes:
+<<<<<<< HEAD
       - /d/phpstudy_pro/WWW/access/conf/etc/localtime:/etc/localtime:ro
       - /d/phpstudy_pro/WWW/access:/var/www/html
       - /d/phpstudy_pro/WWW/access/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
       - /d/phpstudy_pro/WWW/access/conf/crontab/root:/var/spool/cron/crontabs/root
       - /d/phpstudy_pro/WWW/access/conf/crontab/docker-start:/usr/local/bin/docker-start
+=======
+      - d/phpstudy_pro/WWW/access/conf/etc/localtime:/etc/localtime:ro
+      - d/phpstudy_pro/WWW/access:/var/www/html
+      - d/phpstudy_pro/WWW/access/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
+      - d/phpstudy_pro/WWW/access/conf/crontab/root:/var/spool/cron/crontabs/root
+      - d/phpstudy_pro/WWW/access/conf/crontab/docker-start:/usr/local/bin/docker-start
+>>>>>>> 0e677ca27c6e4a79b6f72643cfb3ef529f7e1f7d
     container_name: "acc-crontab"
     command: [docker-start]

+ 0 - 20
tests/ExampleTest.php

@@ -1,20 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2006-2015 http://thinkphp.cn All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
-// +----------------------------------------------------------------------
-// | Author: yunwuxin <448901948@qq.com>
-// +----------------------------------------------------------------------
-namespace tests;
-
-class ExampleTest extends TestCase
-{
-
-    public function testBasicExample()
-    {
-        $this->visit('/')->see('ThinkPHP');
-    }
-}

+ 0 - 11
tests/LoginTest.php

@@ -1,11 +0,0 @@
-<?php
-
-namespace tests;
-
-use PHPUnit\Framework\TestCase;
-
-class LoginTest extends TestCase
-{
-
-
-}

+ 0 - 16
tests/TestCase.php

@@ -1,16 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2006-2015 http://thinkphp.cn All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
-// +----------------------------------------------------------------------
-// | Author: yunwuxin <448901948@qq.com>
-// +----------------------------------------------------------------------
-namespace tests;
-
-class TestCase extends \think\testing\TestCase
-{
-    protected $baseUrl = 'http://localhost';
-}

+ 30 - 0
tests/TestIndex.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace think;
+
+// 加载基础文件
+
+
+define('BASE_ROOT_PATH',str_replace('/tests','',dirname(__FILE__)));
+define('BASE_PATH',BASE_ROOT_PATH . '/tests');
+define('APP_ID','tests');
+
+require BASE_ROOT_PATH . '/thinkphp/base.php';
+
+use PHPUnit\Framework\TestCase;
+
+class TestIndex extends TestCase
+{
+    protected $baseUrl = 'http://localhost';
+    public static function setUpBeforeClass() : void
+    {
+        App::getInstance()->path(BASE_ROOT_PATH . '/application/')->initialize();
+    }
+
+    public function testInviteBonus()
+    {
+        $obj = new \app\index\controller\Index;
+        $obj->index();
+    }
+
+}