ayHaru 4 yıl önce
ebeveyn
işleme
1fcc0f4ad1

+ 23 - 25
application/index/controller/Order.php

@@ -7,7 +7,6 @@ use app\index\model\BoxModel;
 use app\index\model\CabinetModel;
 use app\index\model\MsgModel;
 use app\index\model\OrderModel;
-use think\Controller;
 
 class Order extends Base
 {
@@ -22,6 +21,11 @@ class Order extends Base
 
         //商网接口
         $postData['orderCode'] = $order_sn;
+        $OrderModel = new OrderModel();
+        $order = $OrderModel->checkOrder();
+        if(empty($order_sn)){
+            json_error(2006);
+        }
         $postData = json_encode($postData);
         $result = http_post_json(self::base_url . '/check' , $postData);
         if($result == false){
@@ -48,36 +52,31 @@ class Order extends Base
         $cabinet = CabinetModel::where('cabinet_code',$cabinet_code)->find();
 
         $cabinet_number = $cabinet['id'];
-        $checkNumber = $this->hasBox($cabinet_number , $trunk);
-        if($checkNumber == false){
-            json_error(2004);
-        }
+
         $code = $this->createRandCode();
         $ret  = $this->CreateOrder($order_sn , $trunk , $cabinet_number,$code);
 
         if($ret['code'] != 1) {
             json_error(1006);
         }
-        else {
-            $alias = $cabinet['alias'];
-            $this->box_action_record($cabinet_number , $trunk , 1 , $order_sn , $alias);
-
-            $msg = "{$alias}柜门{$trunk}箱门,密码信息{$code}";
-            $postData['orderCode'] = $order_sn;
-            $postData['boxMsg'] = $msg;
-            $postData = json_encode($postData);
-            $result = http_post_json(self::base_url . '/deliver' , $postData);
-            if($result == false){
-                json_error(3000);
-            }
-            $result = json_decode($result,true);
-            if($result['code'] != 0){
-                json_return($result['code'] , [] , $result['message']);
-            }
+        $alias = $cabinet['alias'];
+        $this->box_action_record($cabinet_number , $trunk , 1 , $order_sn , $alias);
 
-            $this->CreateMsg($cabinet_number,$trunk,$msg,$order_sn,1);
-            json_success([]);
+        $msg = "{$alias}柜门{$trunk}箱门,密码信息{$code}";
+        $postData['orderCode'] = $order_sn;
+        $postData['boxMsg'] = $msg;
+        $postData = json_encode($postData);
+        $result = http_post_json(self::base_url . '/deliver' , $postData);
+        if($result == false){
+            json_error(3000);
         }
+        $result = json_decode($result,true);
+        if($result['code'] != 0){
+            json_return($result['code'] , [] , $result['message']);
+        }
+
+        $this->CreateMsg($cabinet_number,$trunk,$msg,$order_sn,1);
+        json_success([]);
     }
 
     public function CheckFcode(){
@@ -195,8 +194,7 @@ class Order extends Base
     private function hasBox($cabinet_number , $box_number)
     {
         $BoxModel = new BoxModel();
-        $box = $BoxModel->getOneCabinetBox($cabinet_number , $box_number);
-        return !empty($box);
+        return $BoxModel->getOneCabinetBox($cabinet_number , $box_number);
     }
 
     private function CreateMsg($cabinet_number , $box_number , $msg , $order_sn , $type){

+ 0 - 0
application/index/controller/Recharged.php


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

@@ -84,6 +84,10 @@ class OrderModel extends Model{
         }
     }
 
+    public function checkOrder($order_sn){
+        return $this->where(['order_sn' => $order_sn , 'order_status' => 1])->find();
+    }
+
     /**
      * 根据搜索条件获取箱子列表信息
      * @param $offset

+ 1 - 0
config/errorCode.php

@@ -22,6 +22,7 @@ return [
     '2003'  =>  '取件码无效',
     '2004'  =>  '箱子不存在',
     '2005'  =>  '箱子已被使用',
+    '2006'  =>  '订单已被取走',
 
     '3000'  =>  '商网通信失败',
 ];

+ 12 - 12
docker-compose-windows.yml

@@ -6,9 +6,9 @@ services:
     ports:
       - "8080:8080"
     volumes:
-      - /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
+      - /d/zng/apisongcan/conf/etc/localtime:/etc/localtime:ro
+      - /d/zng/apisongcan/conf/nginx/nginx-debug-http.conf:/etc/nginx/nginx.conf:ro
+      - /d/zng/apisongcan:/var/www/html
     links:
       - lfpm
     container_name: "logic-nginx"
@@ -19,18 +19,18 @@ services:
     ports:
       - "6380:6379"
     volumes:
-      - /d/phpstudy_pro/WWW/apisongcan/conf/etc/localtime:/etc/localtime:ro
+      - /d/zng/apisongcan/conf/etc/localtime:/etc/localtime:ro
     container_name: "logic-redis"
     command: [ "redis-server"]
 
   lfpm:
       image: php-fpm:alpine
       volumes:
-        - /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
+        - /d/zng/apisongcan/conf/etc/localtime:/etc/localtime:ro
+        - /d/zng/apisongcan:/var/www/html
+        - /d/zng/apisongcan/conf/php-fpm/php-debug.ini:/usr/local/etc/php/php.ini
+        - /d/zng/apisongcan/conf/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.conf
+        - /d/zng/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:
@@ -39,9 +39,9 @@ services:
   lphp:
     image: php-zts-debug:7.3.18
     volumes:
-      - /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
+      - /d/zng/apisongcan/conf/etc/localtime:/etc/localtime:ro
+      - /d/zng/apisongcan/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
+      - /d/zng/apisongcan:/var/www/html
     links:
       - lredis
     container_name: "logic-php"

+ 1 - 0
route/route.php

@@ -33,4 +33,5 @@
 
         'GetCabinetsBoxs'           => 'index/cabinet/GetCabinetsBoxs',
         'BoxChangeStatus'           => 'index/cabinet/BoxChangeStatus',
+
     ));