ayHaru 4 年之前
父节点
当前提交
58b7ac1a73
共有 3 个文件被更改,包括 636 次插入627 次删除
  1. 525 519
      application/index/controller/Cabinet.php
  2. 4 1
      application/index/controller/Order.php
  3. 107 107
      application/index/model/OrderModel.php

文件差异内容过多而无法显示
+ 525 - 519
application/index/controller/Cabinet.php


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

@@ -151,13 +151,14 @@ class Order extends Base
         $param['pageNumber'] = isset($param['pageNumber']) ? $param['pageNumber'] : 1;
         $offset = ($param['pageNumber'] - 1) * $limit;
         if(!empty($param['order_sn'])){
-            $where['order_sn'] = $param['order_sn'];
+            $where['sc_order.order_sn'] = $param['order_sn'];
         }else{
             $where = [];
         }
         $OrderModel = new OrderModel();
         $selectResult = $OrderModel->getOrdersByWhere($where,$offset, $limit);
         $order_status = ['1' => '已存入' , '2' => '已取走'];
+        $CabinetModel = new CabinetModel();
         // 拼装参数
         foreach($selectResult as $key=>$vo){
             $selectResult[$key]['order_status'] = $order_status[$vo['order_status']];
@@ -167,6 +168,8 @@ class Order extends Base
             }else{
                 $selectResult[$key]['out_time'] = date("m-d H:i",strtotime($vo['out_time']));
             }
+            $cabinet = $CabinetModel->find($vo['cabinet_number']);
+            $selectResult[$key]['alias'] = $cabinet['alias'];
         }
         $return['total'] = $OrderModel->getAllCounts($where);  //总数量
         $return['rows'] = $selectResult;

+ 107 - 107
application/index/model/OrderModel.php

@@ -1,108 +1,108 @@
-<?php
-
-namespace app\index\model;
-
-use app\index\model\BoxModel;
-use think\Exception;
-use think\Model;
-
-class OrderModel extends Model{
-
-    // 确定链接表名
-    protected $name = 'order';
-
-    public function getOne($order_sn){
-        return $this->where('order_sn' , $order_sn)->find();
-    }
-
-    public function Box()
-    {
-        return $this->hasOne('BoxModel', 'order_sn', 'order_sn');
-    }
-
-    public function CreateOrder($params){
-        try {
-            $result = $this->save($params);
-            if(false === $result){
-                // 验证失败 输出错误信息
-                return msg(-1, '', $this->getError());
-            }else{
-                $BoxModel = new BoxModel();
-                $ret = $BoxModel->save(['order_sn' => $params['order_sn'] , 'fetch_code' => $params['code'] , 'box_status' => 1] ,
-                    ['cabinet_number' => $params['cabinet_number'] , 'box_number' => $params['box_number']]);
-                if($ret === false){
-                    return msg(-1, '', $this->getError());
-                }else{
-                    return msg(1, '', 'success');
-                }
-            }
-        }catch (Exception $e){
-            return msg(-2, '', $e->getMessage());
-        }
-    }
-
-    /**
-     * 根据既定条件修改信息
-     * @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());
-        }
-    }
-    /**
-     * 检查取件码
-    */
-    public function check_fcode($code)
-    {
-        $where['sc_order.code'] = $code;
-        $where['BoxModel.box_status'] = 1;
-        try{
-            $order = $this->Box()->hasWhere($where)->find();
-            if(empty($order)){
-                // 验证失败 输出错误信息
-                return msg(-1, '', $this->getError());
-            }else{
-                $data['code'] = $code;
-                $data['existed'] = true;
-                $data['trunk'] = $order['box_number'];
-                $data['cabinet'] = $order['cabinet_number'];
-                return msg(1, $data, 'success');
-            }
-        }catch(\Exception $e){
-            return msg(-2, '', $e->getMessage());
-        }
-    }
-
-    public function checkOrder($order_sn){
-        return $this->where(['order_sn' => $order_sn])->find();
-    }
-
-    /**
-     * 根据搜索条件获取箱子列表信息
-     * @param $offset
-     * @param $limit
-     */
-    public function getOrdersByWhere($where, $offset, $limit)
-    {
-        return $this->where($where)->limit($offset, $limit)->order('id desc')->select();
-    }
-
-    /**
-     * 根据搜索条件获取所有的箱子数量
-     */
-    public function getAllCounts($where)
-    {
-        return $this->where($where)->count();
-    }
+<?php
+
+namespace app\index\model;
+
+use app\index\model\BoxModel;
+use think\Exception;
+use think\Model;
+
+class OrderModel extends Model{
+
+    // 确定链接表名
+    protected $name = 'order';
+
+    public function getOne($order_sn){
+        return $this->where('order_sn' , $order_sn)->find();
+    }
+
+    public function Box()
+    {
+        return $this->hasOne('BoxModel', 'order_sn', 'order_sn');
+    }
+
+    public function CreateOrder($params){
+        try {
+            $result = $this->save($params);
+            if(false === $result){
+                // 验证失败 输出错误信息
+                return msg(-1, '', $this->getError());
+            }else{
+                $BoxModel = new BoxModel();
+                $ret = $BoxModel->save(['order_sn' => $params['order_sn'] , 'fetch_code' => $params['code'] , 'box_status' => 1] ,
+                    ['cabinet_number' => $params['cabinet_number'] , 'box_number' => $params['box_number']]);
+                if($ret === false){
+                    return msg(-1, '', $this->getError());
+                }else{
+                    return msg(1, '', 'success');
+                }
+            }
+        }catch (Exception $e){
+            return msg(-2, '', $e->getMessage());
+        }
+    }
+
+    /**
+     * 根据既定条件修改信息
+     * @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());
+        }
+    }
+    /**
+     * 检查取件码
+    */
+    public function check_fcode($code)
+    {
+        $where['sc_order.code'] = $code;
+        $where['BoxModel.box_status'] = 1;
+        try{
+            $order = $this->Box()->hasWhere($where)->find();
+            if(empty($order)){
+                // 验证失败 输出错误信息
+                return msg(-1, '', $this->getError());
+            }else{
+                $data['code'] = $code;
+                $data['existed'] = true;
+                $data['trunk'] = $order['box_number'];
+                $data['cabinet'] = $order['cabinet_number'];
+                return msg(1, $data, 'success');
+            }
+        }catch(\Exception $e){
+            return msg(-2, '', $e->getMessage());
+        }
+    }
+
+    public function checkOrder($order_sn){
+        return $this->where(['order_sn' => $order_sn])->find();
+    }
+
+    /**
+     * 根据搜索条件获取箱子列表信息
+     * @param $offset
+     * @param $limit
+     */
+    public function getOrdersByWhere($where, $offset, $limit)
+    {
+        return $this->where($where)->limit($offset, $limit)->order('id desc')->select();
+    }
+
+    /**
+     * 根据搜索条件获取所有的箱子数量
+     */
+    public function getAllCounts($where)
+    {
+        return $this->where($where)->count();
+    }
 }