ayHaru 4 éve
szülő
commit
6a8b64813d

+ 15 - 13
application/index/controller/Base.php

@@ -6,22 +6,24 @@ use app\index\model\RoleModel;
 
 class Base extends Controller{
 
-    public function initialize(){
-
-        if(empty(session('username')) || empty(session('id'))){
-            //登录超时
-            json(json_error_exception('1005'))->send();
-        }
+    private $noCheck = ['cabinet/check_fcode' , 'cabinet/record_store' , 'cabinet/record_fetch' , 'cabinet/add_cabinet' , 'order/order_bind_code'];
 
-        $this->cacheCheck();
+    public function initialize(){
 
-        // 检测权限
         $control = lcfirst(request()->controller());
         $action = lcfirst(request()->action());
-
-        if(empty(authCheck($control . '/' . $action))){
-            json(json_error_exception('1000'))->send();
-        }
+        $checkUrl = $control . '/' . $action;
+//        if(!in_array($checkUrl , $this->noCheck)){
+//            if(empty(session('username')) || empty(session('id'))){
+//                //登录超时
+//                json(json_error_exception('1005'))->send();
+//            }
+//            $this->cacheCheck();
+//            // 检测权限
+//            if(empty(authCheck($checkUrl))){
+//                json(json_error_exception('1000'))->send();
+//            }
+//        }
     }
 
     private function cacheCheck()
@@ -37,7 +39,7 @@ class Base extends Controller{
         }
     }
 
-    protected function removRoleCache()
+    protected function removeRoleCache()
     {
         $roleModel = new RoleModel();
         $roleList = $roleModel->getRole();

+ 43 - 0
application/index/controller/Box.php

@@ -0,0 +1,43 @@
+<?php
+
+namespace app\index\controller;
+
+use app\index\model\BoxModel;
+
+class Box extends Base{
+
+    /**
+     * 自提柜箱子修改状态
+     */
+    public function change_box_status(){
+        $cabinet_number     = input('param.cabinet_number');
+        $box_number         = input('param.box_number');
+        $status             = input('param.status');
+        $BoxModel = new BoxModel();
+        $box = $BoxModel->getOneCabinetBox($cabinet_number,$box_number);
+        if(empty($cabinet)){
+            return json(json_error_exception(1008));
+        }
+        if($box['status'] == $status){
+            json_success('','success');
+        }
+    }
+
+    /**
+     * 自提柜箱子绑定订单号
+    */
+    public function box_bind_order(){
+        $where['cabinet_number']    = input('param.cabinet_number');
+        $where['box_number']        = input('param.box_number');
+
+        $update['enter_time']       = date('Y-m-d H:i:s');
+        $update['order_sn']         = input('param.order_sn');
+
+        $BoxModel = new BoxModel();
+        $result = $BoxModel->editData($where,$update);
+        if($result['code'] != 1){
+            return json(json_error_exception('1006',$result['msg']));
+        }
+        json_return(200,[],'success');
+    }
+}

+ 20 - 3
application/index/controller/Cabinet.php

@@ -2,9 +2,10 @@
 
 namespace app\index\controller;
 
-use think\Controller;
+use app\index\model\CabinetModel;
+use app\index\model\BoxModel;
 
-class Cabinet extends Controller{
+class Cabinet extends Base{
 
     /**
      * 检查取件码
@@ -29,8 +30,24 @@ class Cabinet extends Controller{
         $trunk      = input('param.trunk');
         $cabinet    = input('param.cabinet');
         $state      = input('param.state');
+    }
 
 
-
+    /**
+     * 自提柜批量生产
+    */
+    public function add_cabinet(){
+        $param = input('param.');
+        $validate = new \app\index\validate\CabinetValidate;
+        if (!$validate->check($param)) {
+            return json(json_error_exception('1007',$validate->getError()));
+        }
+        $CabinetModel = new CabinetModel();
+        $flag = $CabinetModel->insertCabinet($param);
+        if($flag['code'] != 1){
+            return json(json_error_exception('1006',$flag['msg']));
+        }
+        json_return(200,[],'success');
     }
+
 }

+ 0 - 1
application/index/controller/Index.php

@@ -2,7 +2,6 @@
 namespace app\index\controller;
 
 use app\index\model\NodeModel;
-use app\index\controller\Base;
 
 class Index extends Base
 {

+ 2 - 2
application/index/controller/Node.php

@@ -27,7 +27,7 @@ class Node extends Base{
         if($flag['code'] != 1){
             return json(json_error_exception('1006',$flag['msg']));
         }
-        $this->removRoleCache();
+        $this->removeRoleCache();
         json_return(200,[],'success');
     }
 
@@ -41,7 +41,7 @@ class Node extends Base{
         if($flag['code'] != 1){
             return json(json_error_exception('1006',$flag['msg']));
         }
-        $this->removRoleCache();
+        $this->removeRoleCache();
         json_return(200,[],'success');
     }
 

+ 32 - 1
application/index/controller/Order.php

@@ -2,6 +2,7 @@
 
 namespace app\index\controller;
 
+use app\index\model\OrderModel;
 use think\Controller;
 
 class Order extends Controller
@@ -11,4 +12,34 @@ class Order extends Controller
         $ret = ['check' => true,'order_sn' => $order_sn];
         json_success($ret);
     }
-}
+
+    public function order_bind_code(){
+        $order_sn = input('param.order_sn');
+        $OrderModel = new OrderModel();
+
+        $order = $OrderModel->getOne($order_sn);
+        if(empty($order)){
+            return json(json_error_exception(1008));
+        }
+        $code = $this->createRandCode($order_sn);
+    }
+
+    public function createRandCode($order_sn){
+
+    }
+}
+
+application/index/controller/Base.php application/index/controller/Box.php application/index/controller/Cabinet.php application/index/controller/Index.php application/index/controller/Node.php application/index/controller/Order.php
+        application/index/controller/Role.php
+        application/index/model/BoxModel.php
+        application/index/model/CabinetModel.php
+        application/index/model/NodeModel.php
+        application/index/model/OrderModel.php
+        application/index/model/RoleModel.php
+        application/index/validate/CabinetValidate.php
+        application/index/validate/RoleValidate.php
+        application/index/validate/UserValidate.php
+        conf/php-fpm/docker-php-fpm-start
+        config/errorCode.php
+        docker-compose-windows.yml
+        route/route.php

+ 1 - 1
application/index/controller/Role.php

@@ -54,7 +54,7 @@ class Role extends Base{
         if($flag['code'] != 1){
             return json(json_error_exception('1006',$flag['msg']));
         }
-        $this->removRoleCache();
+        $this->removeRoleCache();
         json_return(200,[],'success');
     }
 }

+ 42 - 0
application/index/model/BoxModel.php

@@ -0,0 +1,42 @@
+<?php
+
+namespace app\index\model;
+
+use think\Model;
+
+class BoxModel extends Model {
+
+    // 确定链接表名
+    protected $name = 'box';
+
+    /**
+     * 根据柜号箱号获取箱子信息
+     * @cabinet_number $param
+     * @box_number $param
+     */
+    public function getOneCabinetBox($cabinet_number,$box_number)
+    {
+        return $this->where(['cabinet_number' => $cabinet_number, 'box_number'=>$box_number])->find();
+    }
+
+    /**
+     * 根据既定条件修改信息
+     * @where $param
+     * @update $param
+     */
+    public function editData($where,$update)
+    {
+        try{
+            $result = $this->save($update, $where);
+            if(false === $result){
+                // 验证失败 输出错误信息
+                return msg(-1, '', $this->getError());
+            }else{
+
+                return msg(1, '', 'success');
+            }
+        }catch(\Exception $e){
+            return msg(-2, '', $e->getMessage());
+        }
+    }
+}

+ 48 - 0
application/index/model/CabinetModel.php

@@ -0,0 +1,48 @@
+<?php
+
+namespace app\index\model;
+
+use think\Model;
+use app\index\model\BoxModel;
+
+class CabinetModel extends Model{
+    // 确定链接表名
+    protected $name = 'cabinet';
+
+    /**
+     * 插入柜子信息
+     * @param $param
+     */
+    public function insertCabinet($param)
+    {
+        try{
+            $this->startTrans();
+            $result = $this->save($param);
+            if(false === $result){
+                $this->rollback();
+                // 验证失败 输出错误信息
+                return msg(-1, '', $this->getError());
+            }else{
+                $cabinet_number = $this->id;
+                $boxData = [];
+                for ($i=1; $i<=$param['box_number']; $i++){
+                    $boxData['cabinet_number']  = $cabinet_number;
+                    $boxData['box_number']      = $i;
+                    $saveAllData[] = $boxData;
+                }
+                $BoxModel = new BoxModel();
+                $result = $BoxModel->saveAll($saveAllData);
+                if(false === $result){
+                    $this->rollback();
+                    return msg(-1, '', $this->getError());
+                }else{
+                    $this->commit();
+                    return msg(1, '', '添加成功');
+                }
+            }
+        }catch(PDOException $e){
+            $this->rollback();
+            return msg(-2, '', $e->getMessage());
+        }
+    }
+}

+ 1 - 3
application/index/model/NodeModel.php

@@ -31,9 +31,7 @@ class NodeModel extends Model{
 
         $result = $this->field('id,node_name,type_id,control_name,action_name,style')
             ->where($where)->select();
-        $menu = prepareMenu($result);
-
-        return $menu;
+        return prepareMenu($result);
     }
 
     /**

+ 15 - 0
application/index/model/OrderModel.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace app\index\model;
+
+use think\Model;
+
+class OrderModel extends Model{
+
+    // 确定链接表名
+    protected $name = 'order';
+
+    public function getOne($order_sn){
+        return $this->where('order_sn' , $order_sn)->find();
+    }
+}

+ 1 - 1
application/index/model/RoleModel.php

@@ -75,7 +75,7 @@ class RoleModel extends Model{
                 return msg(-1, '', $this->getError());
             }else{
 
-                return msg(1, url('role/index'), '添加角色成功');
+                return msg(1, '', '添加角色成功');
             }
         }catch(PDOException $e){
 

+ 21 - 0
application/index/validate/CabinetValidate.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace app\index\validate;
+
+use think\Validate;
+
+class CabinetValidate extends Validate
+{
+    protected $rule = array(
+        'cabinet_name'      => 'require|unique:cabinet',
+        'cabinet_sort'      => 'require|unique:cabinet',
+        'cabinet_ip'        => 'require|unique:cabinet',
+        'box_number'        => 'number',
+    );
+    protected $message = array(
+        'cabinet_name.require'      => '柜子名称已经存在',
+        'cabinet_sort.require'      => '柜子端口已经存在',
+        'cabinet_ip.require'        => '柜子ip已经存在',
+        'box_number.number'         => '箱子数量必须是数字',
+    );
+}

+ 1 - 9
application/index/validate/RoleValidate.php

@@ -1,13 +1,5 @@
 <?php
-// +----------------------------------------------------------------------
-// | snake
-// +----------------------------------------------------------------------
-// | Copyright (c) 2016~2022 http://baiyf.cn All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
-// +----------------------------------------------------------------------
-// | Author: NickBai <1902822973@qq.com>
-// +----------------------------------------------------------------------
+
 namespace app\index\validate;
 
 use think\Validate;

+ 1 - 9
application/index/validate/UserValidate.php

@@ -1,13 +1,5 @@
 <?php
-// +----------------------------------------------------------------------
-// | snake
-// +----------------------------------------------------------------------
-// | Copyright (c) 2016~2022 http://baiyf.cn All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
-// +----------------------------------------------------------------------
-// | Author: NickBai <1902822973@qq.com>
-// +----------------------------------------------------------------------
+
 namespace app\index\validate;
 
 use think\Validate;

+ 1 - 0
config/errorCode.php

@@ -13,4 +13,5 @@ return [
     '1005'  =>  '登录超时',
     '1006'  =>  '操作失败',
     '1007'  =>  '信息有误',
+    '1008'  =>  '数据不存在',
 ];

+ 24 - 40
docker-compose-windows.yml

@@ -1,65 +1,49 @@
 version: "3.7"
 
 services:
-  devnginx:
+  lnginx:
     image: nginx:alpine
     ports:
       - "8080:8080"
     volumes:
-      - /d/phpstudy_pro/WWW/tp51/conf/etc/localtime:/etc/localtime:ro
-      - /d/phpstudy_pro/WWW/tp51/conf/nginx/nginx-debug-http.conf:/etc/nginx/nginx.conf:ro
-      - /d/phpstudy_pro/WWW/tp51:/var/www/html
+      - /d/phpstudy_pro/WWW/apisongcan/conf/etc/localtime:/etc/localtime:ro
+      - /d/phpstudy_pro/WWW/apisongcan/conf/nginx/nginx-debug-http.conf:/etc/nginx/nginx.conf:ro
+      - /d/phpstudy_pro/WWW/apisongcan:/var/www/html
     links:
-      - devfpm
-    container_name: "dev-nginx"
+      - lfpm
+    container_name: "logic-nginx"
     command: [nginx,'-g','daemon off;']
 
-  devredis:
+  lredis:
     image: redis:alpine
     ports:
       - "6380:6380"
     volumes:
-      - /d/phpstudy_pro/WWW/tp51/conf/etc/localtime:/etc/localtime:ro
-    container_name: "dev-redis"
+      - /d/phpstudy_pro/WWW/apisongcan/conf/etc/localtime:/etc/localtime:ro
+    container_name: "logic-redis"
     command: [ "redis-server"]
 
-  devfpm:
+  lfpm:
       image: php-fpm:alpine
       volumes:
-        - /d/phpstudy_pro/WWW/tp51/conf/etc/localtime:/etc/localtime:ro
-        - /d/phpstudy_pro/WWW/tp51:/var/www/html
-        - /d/phpstudy_pro/WWW/tp51/conf/php-fpm/php-debug.ini:/usr/local/etc/php/php.ini
-        - /d/phpstudy_pro/WWW/tp51/conf/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.conf
-        - /d/phpstudy_pro/WWW/tp51/conf/php-fpm/docker-php-fpm-start:/usr/local/bin/docker-php-fpm-start
-      container_name: "dev-web"
+        - /d/phpstudy_pro/WWW/apisongcan/conf/etc/localtime:/etc/localtime:ro
+        - /d/phpstudy_pro/WWW/apisongcan:/var/www/html
+        - /d/phpstudy_pro/WWW/apisongcan/conf/php-fpm/php-debug.ini:/usr/local/etc/php/php.ini
+        - /d/phpstudy_pro/WWW/apisongcan/conf/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.conf
+        - /d/phpstudy_pro/WWW/apisongcan/conf/php-fpm/docker-php-fpm-start:/usr/local/bin/docker-php-fpm-start
+      container_name: "logic-web"
       command: [docker-php-fpm-start]
       depends_on:
-        - devredis
+        - lredis
 
-  devphp:
+  lphp:
     image: php-zts-debug:7.3.18
     volumes:
-      - /d/phpstudy_pro/WWW/tp51/conf/etc/localtime:/etc/localtime:ro
-      - /d/phpstudy_pro/WWW/tp51/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
-      - /d/phpstudy_pro/WWW/tp51:/var/www/html
+      - /d/phpstudy_pro/WWW/apisongcan/conf/etc/localtime:/etc/localtime:ro
+      - /d/phpstudy_pro/WWW/apisongcan/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
+      - /d/phpstudy_pro/WWW/apisongcan:/var/www/html
     links:
-      - devredis
-    container_name: "dev-php"
+      - lredis
+    container_name: "logic-php"
     depends_on:
-      - "devredis"
-
-  crontabsrv:
-      image: php-zts-debug:7.3.18
-      volumes:
-        - /d/phpstudy_pro/WWW/tp51/conf/etc/localtime:/etc/localtime:ro
-        - /d/phpstudy_pro/WWW/tp51:/var/www/html
-        - /Volumes/Transcend/upload:/var/www/html/data/upload
-        - /d/phpstudy_pro/WWW/tp51/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
-        - /d/phpstudy_pro/WWW/tp51/conf/crontab/debug-root:/var/spool/cron/crontabs/root
-        - /d/phpstudy_pro/WWW/tp51/conf/crontab/docker-start:/usr/local/bin/docker-start
-      links:
-        - devredis
-      container_name: "dev-crontab"
-      command: [docker-start]
-      depends_on:
-        - "devredis"
+      - "lredis"

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 66970 - 0
phpunit-9.2.5.phar


+ 4 - 0
route/route.php

@@ -5,4 +5,8 @@
         'roleList'                  => 'index/user/roleList',
         'roleAdd'                   => 'index/user/roleAdd',
         'roleDel'                   => 'index/user/roleDel',
+
+        'checkFcode'                => 'index/cabinet/check_fcode',
+        'changeCabinetStatus'       => 'index/cabinet/change_cabinet_status',
+        'addCabinet'                => 'index/cabinet/add_cabinet',
     ));