cqpCow vor 1 Jahr
Ursprung
Commit
27d67edd0b

+ 8 - 4
app/Http/Middleware/CheckLogin.php

@@ -42,14 +42,18 @@ class CheckLogin
         $return = EmployeeService::getLoginDepart($result);
         //所属部门
         $data['rule_depart'] = $return[0] ?? [];
-        //顶级部门
+        //顶级公司
         $data['depart_top'] = $return[1] ?? [];
-        //部门对应的顶级部门
+        //部门对应的顶级公司
         $data['depart_map'] = $return[2] ?? [];
-        //权限范围内的部门
+        //权限范围内的部门以及公司
         $data['depart_range'] = $return[3] ?? [];
-        //是否有所有的部门 (就是 是否总公司)
+        //是否有所有的部门 (是否总公司)
         $data['is_all_depart'] = $return[4] ?? 0;
+        //总公司
+        $data['head'] = $return[5] ?? [];
+        //是否库存校验
+        $data['is_check_stock'] = true;
 
         //写入user信息
         $request->userData = $data;

+ 9 - 7
app/Service/CheckService.php

@@ -10,6 +10,7 @@ use App\Model\InvoiceOrder;
 use App\Model\InvoiceOrderInfo;
 use App\Model\Product;
 use App\Model\ProductInventory;
+use App\Model\ProductInventorySet;
 use App\Model\PurchaseOrder;
 use App\Model\PurchaseOrderInfo;
 use App\Model\ReturnExchangeOrder;
@@ -170,8 +171,8 @@ class CheckService extends Service
         //没有供应商 不创建合同
         if(empty($order['supplier'])) return [true, ''];
         //总公司的采购单 不创建合同
-        $top_depart_id = Depart::where('parent_id',0)->where('is_main',1)->value('id');
-        if($top_depart_id == $order['top_depart_id']) return [true, ''];
+        $top_depart_id = $user['head'] ?? [];
+        if($top_depart_id['id'] == $order['top_depart_id']) return [true, ''];
         //分社公司的采购单 不向总供应商采购 不创建合同
         $is_create = Supplier::where('id',$order['supplier'])->value('is_main');
         if(empty($is_create)) return [true, ''];
@@ -361,7 +362,7 @@ class CheckService extends Service
                     return [false, $msg];
                 }
                 //库存
-                $bool = $this->changeInventory($data, $order);
+                $bool = $this->changeInventory($data, $order, $user);
                 if(! $bool) {
                     DB::rollBack();
                     return [false, $msg];
@@ -386,7 +387,7 @@ class CheckService extends Service
     }
 
     //更新库存
-    public function changeInventory($data,$order){
+    public function changeInventory($data,$order,$user){
         $number_symbol = "";
         if(in_array($data['opt_case'],self::$in_opt)){
             $number_symbol = ">";
@@ -441,8 +442,9 @@ class CheckService extends Service
         }
 
         //是否锁定
-        $setting_map = Setting::where('setting_name','lock_number')
-            ->pluck('setting_value','setting_name')->toArray();
+        $lock = 0;
+        if($user['head']['id'] != $order['top_depart_id']) $lock = DB::table('depart_set')->where('top_depart_id',$order['top_depart_id'])->value('param_one');
+
         $result = array_values($result);
         foreach ($result as $key => $value){
             $keys = $value['product_id'] . $value['storehouse_id'];
@@ -455,7 +457,7 @@ class CheckService extends Service
                 ProductInventory::insert($result[$key]);
             }else{
                 $lock_number_tmp = 0;
-                if(! empty($setting_map['lock_number']) && ! empty($lock_number[$keys])) $lock_number_tmp = $lock_number[$keys];
+                if($lock && ! empty($lock_number[$keys])) $lock_number_tmp = $lock_number[$keys];
 
                 ProductInventory::where('product_id',$m->product_id)
                     ->where('storehouse_id',$m->storehouse_id)

+ 12 - 6
app/Service/ConstructionService.php

@@ -411,15 +411,17 @@ class ConstructionService extends Service
         if(! empty($data['handover_time'])) $data['handover_time'] = $this->changeDateToDateMin($data['handover_time']);
 
         if($data['model_type'] == Construction::Model_type_one){
-            if(empty($data['install_method'])) return [false,'安装方式不能为空'];
-            if(empty($data['install_position'])) return [false,'安装地点不能为空'];
+//            if(empty($data['install_method'])) return [false,'安装方式不能为空'];
+//            if(empty($data['install_position'])) return [false,'安装地点不能为空'];
         }else{
-            if(empty($data['construction_contact'])) return [false,'联系方式不能为空'];
-            if(empty($data['address1']) || empty($data['address2'])) return [false,'地址不能为空'];
+//            if(empty($data['construction_contact'])) return [false,'联系方式不能为空'];
+//            if(empty($data['address1']) || empty($data['address2'])) return [false,'地址不能为空'];
         }
         //所属部门 以及  顶级部门
-        if(empty($data['depart_id'])) $data['depart_id'] = $this->getDepart($user);
-        $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
+        if(empty($data['depart_id'])) {
+            $data['depart_id'] = $this->getDepart($user);
+            $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
+        }
 
         $product_submit = $product_id = [];
         foreach ($data['product'] as $value){
@@ -452,6 +454,10 @@ class ConstructionService extends Service
 
         $id = $data['id'] ?? 0;
         $product_save = $this->getSaveDetail($id);
+
+        //是否校验库存
+        ProductInventoryService::is_check($user,$data);
+
         list($status,$msg) = (new ProductInventoryService())->compareStock($user,$product_id, $product_submit, $product_save);
         if(! $status) return [false, $msg];
 

+ 5 - 4
app/Service/CustomerService.php

@@ -552,8 +552,10 @@ class CustomerService extends Service
         if(! in_array($data['model_type'],Customer::$model_type)) return [false,'客户模板类型错误'];
         if(empty($data['title'])) return [false,'客户名称不能为空'];
         //所属部门 以及  顶级部门
-        if(empty($data['depart_id'])) $data['depart_id'] = $this->getDepart($user);
-        $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
+        if(empty($data['depart_id'])) {
+            $data['depart_id'] = $this->getDepart($user);
+            $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
+        }
         if($data['model_type'] == Customer::Model_type_one){
             if(empty($data['customer_from'])) return [false,'客户来源不能为空'];
             if(empty($data['customer_type'])) return [false,'客户类别不能为空'];
@@ -573,10 +575,9 @@ class CustomerService extends Service
                 ->exists();
         }else{
             if(empty($data['id'])) return [false,'ID不能为空'];
-            $top_depart_id = Customer::where('id',$data['id'])->value('top_depart_id');
             $bool = Customer::where('del_time',0)
                 ->where('id','<>',$data['id'])
-                ->where('top_depart_id',$top_depart_id)
+                ->where('top_depart_id',$data['top_depart_id'])
                 ->where('title',$data['title'])
                 ->where('model_type',$data['model_type'])
                 ->exists();

+ 7 - 2
app/Service/EmployeeService.php

@@ -1222,7 +1222,7 @@ class EmployeeService extends Service
             ->orderBy('a.depart_id','asc')
             ->get()->toArray();
 
-        $top = $map = $rule = [];
+        $top = $map = $rule = $head = [];
         $is_all_depart = 0;
         if(! empty($depart)){
             //库存校验
@@ -1289,9 +1289,14 @@ class EmployeeService extends Service
                     }
                 }
             }
+            foreach ($list as $value){
+                if(empty($value['parent_id']) && ! empty($value['is_main'])) $head = $value;
+            }
         }
+        $top = array_values($top);
+        $rule = array_unique($rule);
 
-        return [$depart, array_values($top), $map, array_unique($rule), $is_all_depart];
+        return [$depart, $top, $map, $rule, $is_all_depart,$head];
     }
 
     //判断是否总公司

+ 13 - 5
app/Service/InvoiceOrderService.php

@@ -137,7 +137,7 @@ class InvoiceOrderService extends Service
 
         $order = InvoiceOrder::where('order_number',$data['order_number'])
             ->where('del_time',0)
-            ->select('id','order_number','sales_order_id','send','send_time','take','take_address','take_phone','logistics_company','logistics_number','crt_id','mark','state','crt_time','storehouse_id')
+            ->select('id','order_number','sales_order_id','send','send_time','take','take_address','take_phone','logistics_company','logistics_number','crt_id','mark','state','crt_time','storehouse_id','top_depart_id','depart_id')
             ->first();
         if(empty($order)) return [false, '发货订单不存在或已被删除'];
         $order = $order->toArray();
@@ -292,6 +292,13 @@ class InvoiceOrderService extends Service
             if(empty($sales)) return [false,'合同不存在或已被删除'];
             if($sales['sales_order_type'] != SalesOrder::Order_type_two) return [false,'非快递件合同'];
         }
+
+        //所属部门 以及  顶级部门
+        if(empty($data['depart_id'])) {
+            $data['depart_id'] = $this->getDepart($user);
+            $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
+        }
+
         $product_submit = $product_id = [];
         foreach ($data['product'] as $value){
             if(empty($value['number'])) return [false,'产品数量不能为空'];
@@ -308,18 +315,19 @@ class InvoiceOrderService extends Service
         }
         $order_number = $data['order_number'] ?? '';
         $product_save = $this->getSaveDetail($order_number);
+
+        //是否校验库存
+        ProductInventoryService::is_check($user,$data);
+
         list($status,$msg) = (new ProductInventoryService())->compareStock($user,$product_id, $product_submit, $product_save);
         if(! $status) return [false, $msg];
 
-        //所属部门 以及  顶级部门
-        if(empty($data['depart_id'])) $data['depart_id'] = $this->getDepart($user);
-        $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
-
         if($is_check){
             $order_number = (new OrderNoService())->createOrderNumber(InvoiceOrder::prefix);
             if(empty($order_number)) return [false,'发货单号生成失败!'];
             $data['order_number'] = $order_number;
         }else{
+            if($this->isEmpty($data,'id')) return [false,'发货单ID不能为空!'];
             if($this->isEmpty($data,'order_number')) return [false,'发货单号不能为空!'];
         }
 

+ 37 - 12
app/Service/ProductActivityService.php

@@ -19,7 +19,7 @@ class ProductActivityService extends Service
             DB::beginTransaction();
 
             $model = ProductActivity::where('id',$data['id'])->first();
-            $model->title = $data['title'];
+            $model->title = $data['title'] ?? "";
             $model->start_time = $data['start_time'] ?? 0;
             $model->end_time = $data['end_time'] ?? 0;
             $model->mark = $data['mark'] ?? '';
@@ -35,8 +35,8 @@ class ProductActivityService extends Service
                 $insert = [];
                 foreach ($data['product'] as $value){
                     $insert[] = [
-                        'product_activity_id' => $model->id,
-                        'product_id' => $model->id,
+                        'product_activity_id' => $data['id'],
+                        'product_id' => $value['product_id'],
                         'basic_type_id' => $value['basic_type_id'],
                         'price' => $value['price'],
                         'crt_time' => $time,
@@ -64,8 +64,7 @@ class ProductActivityService extends Service
             DB::beginTransaction();
 
             $model = new ProductActivity();
-            $model->product_category_id = $data['product_category_id'] ?? 0;
-            $model->title = $data['title'];
+            $model->title = $data['title'] ?? "";
             $model->start_time = $data['start_time'] ?? 0;
             $model->end_time = $data['end_time'] ?? 0;
             $model->mark = $data['mark'] ?? '';
@@ -81,7 +80,7 @@ class ProductActivityService extends Service
                 foreach ($data['product'] as $value){
                     $insert[] = [
                         'product_activity_id' => $model->id,
-                        'product_id' => $model->id,
+                        'product_id' =>  $value['product_id'],
                         'basic_type_id' => $value['basic_type_id'],
                         'price' => $value['price'],
                         'crt_time' => $time,
@@ -138,14 +137,26 @@ class ProductActivityService extends Service
             ->pluck('title','id')
             ->toArray();
         $customer['product'] = [];
+
+        //产品字典
+        $map = (new ProductService())->getProductDetail(array_unique(array_column($detail,'product_id')));
+
         foreach ($detail as $value){
-            $customer['product'][] = [
+            $basic_tmp = [
                 'basic_type_id' => $value['basic_type_id'],
                 'basic_type_title' => $title_map[$value['basic_type_id']] ?? '',
                 'price' => $value['price'],
             ];
+            if(! isset($customer['product'][$value['product_id']])){
+                $tmp = $map[$value['product_id']] ?? [];
+                $tmp['activity'][] = $basic_tmp;
+                $customer['product'][$value['product_id']] = $tmp;
+            }else{
+                $customer['product'][$value['product_id']]['activity'][] = $basic_tmp;
+            }
         }
 
+        $customer['product'] = array_values($customer['product']);
         $customer['crt_name'] = Employee::where('id',$customer['crt_id'])->value('emp_name');
         $customer['crt_time'] = $customer['crt_time'] ? date("Y-m-d H:i:s",$customer['crt_time']): '';
 
@@ -155,9 +166,20 @@ class ProductActivityService extends Service
     public function productList($data,$user){
         $model = new ProductActivity(['userData' => $user, 'search' => $data]);
         $model = $model->where('del_time',0)
+            ->select('id','title','crt_id','mark','start_time','end_time','crt_time')
             ->orderby('id', 'desc');
 
         if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
+        if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
+            $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
+            $model->where('crt_time','>=',$return[0]);
+            $model->where('crt_time','<=',$return[1]);
+        }
+        if(! empty($data['activity_time'][0]) && ! empty($data['activity_time'][1])) {
+            $return = $this->changeDateToTimeStampAboutRange($data['activity_time']);
+            $model->where('start_time','>=',$return[0]);
+            $model->where('end_time','<=',$return[1]);
+        }
 
         $list = $this->limit($model,'',$data);
         $list = $this->fillData($list,$user);
@@ -172,17 +194,17 @@ class ProductActivityService extends Service
         $data['end_time'] = $this->changeDateToDateMin($data['activity_time'][1]);
         if($is_add){
             $product = ProductActivityPrice::where('del_time',0)
-                ->where('start', '<=', $data['end_time'])
-                ->where('end', '>=', $data['start_time'])
+                ->where('start_time', '<=', $data['end_time'])
+                ->where('end_time', '>=', $data['start_time'])
                 ->select('product_id')
                 ->get()->toArray();
             $product = array_column($product,'product_id');
         }else{
             if(empty($data['id'])) return [false,'ID不能为空'];
             $product = ProductActivityPrice::where('del_time',0)
-                ->where('id','<>',$data['id'])
-                ->where('start', '<=', $data['end_time'])
-                ->where('end', '>=', $data['start_time'])
+                ->where('product_activity_id','<>',$data['id'])
+                ->where('start_time', '<=', $data['end_time'])
+                ->where('end_time', '>=', $data['start_time'])
                 ->select('product_id')
                 ->get()->toArray();
             $product = array_column($product,'product_id');
@@ -222,6 +244,9 @@ class ProductActivityService extends Service
             ->toArray();
 
         foreach ($data['data'] as $key => $value){
+            $start_time = $value['start_time'] ? date("Y-m-d H:i",$value['start_time']) : '';
+            $end_time = $value['end_time'] ? date("Y-m-d H:i",$value['end_time']) : '';
+            $data['data'][$key]['activity_time'] = $start_time . '——' . $end_time;
             $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
             $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
         }

+ 10 - 0
app/Service/ProductInventoryService.php

@@ -65,6 +65,7 @@ class ProductInventoryService extends Service
 
         $return = [];
         if(! empty($array)){
+            //todo
             $setting_map = Setting::where('setting_name','lock_number')
                 ->pluck('setting_value','setting_name')
                 ->toArray();
@@ -92,10 +93,18 @@ class ProductInventoryService extends Service
         return $return;
     }
 
+    public static function is_check(&$user,$data){
+        //是否校验库存
+        $top_depart_id = $user['head']['id'] ?? 0;//总公司id
+        if($data['top_depart_id'] == $top_depart_id) $user['is_check_stock'] = false;
+    }
+
     //更新锁定库存
     //$user 当前登录人的信息
     //$submit_total (提交的数据)  $save_total(保存过的数据)
     public static function changeLockNumber($user, $submit_total = [], $save_total = []){
+        dump($user['is_check_stock']);die;
+        if(empty($user['is_check_stock'])) return; //不校验库存
         if(empty($submit_total) && empty($save_total)) return;
 
         //是否使用锁定库存校验  默认使用
@@ -125,6 +134,7 @@ class ProductInventoryService extends Service
 
     //比较库存
     public static function compareStock($user, $product_id = [],$product_submit = [], $product_save = []){
+        if(empty($user['is_check_stock'])) return [true,'']; //不校验库存
         if(empty($product_id) || empty($product_submit)) return [false,'比较参数不能为空'];
 
         //库存

+ 5 - 4
app/Service/ProductService.php

@@ -594,8 +594,10 @@ class ProductService extends Service
         }
 
         //所属部门 以及 顶级部门
-        if(empty($data['depart_id'])) $data['depart_id'] = $this->getDepart($user);
-        $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
+        if(empty($data['depart_id'])) {
+            $data['depart_id'] = $this->getDepart($user);
+            $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
+        }
 
         if($is_add){
             $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}') AND top_depart_id = {$data['top_depart_id']}")
@@ -603,8 +605,7 @@ class ProductService extends Service
                 ->exists();
         }else{
             if(empty($data['id'])) return [false,'ID不能为空'];
-            $top_depart_id = Product::where('id',$data['id'])->value('top_depart_id');
-            $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}') AND top_depart_id = {$top_depart_id}")
+            $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}') AND top_depart_id = {$data['top_depart_id']}")
                 ->where('id','<>',$data['id'])
                 ->where('del_time',0)
                 ->exists();

+ 6 - 6
app/Service/PurchaseOrderService.php

@@ -70,9 +70,9 @@ class PurchaseOrderService extends Service
             PurchaseOrderFile::where('order_number',$data['order_number'])
                 ->where('del_time',0)
                 ->update(['del_time' => time()]);
-            if(! empty($data['img'])){
+            if(! empty($data['file'])){
                 $insert = [];
-                foreach ($data['img'] as $value){
+                foreach ($data['file'] as $value){
                     $insert[] = [
                         'purchase_order_id' => $material_model->id,
                         'order_number' => $data['order_number'],
@@ -140,9 +140,9 @@ class PurchaseOrderService extends Service
                 PurchaseOrderInfo::insert($sub);
             }
 
-            if(! empty($data['img'])){
+            if(! empty($data['file'])){
                 $insert = [];
-                foreach ($data['img'] as $value){
+                foreach ($data['file'] as $value){
                     $insert[] = [
                         'purchase_order_id' => $material_model->id,
                         'order_number' => $data['order_number'],
@@ -178,7 +178,7 @@ class PurchaseOrderService extends Service
             ->first();
         if(empty($order)) return [false, '采购订单不存在或已被删除'];
         $order = $order->toArray();
-        $order['img'] = [];
+        $order['file'] = [];
         $order['storehouse_title'] = Storehouse::where('id',$order['storehouse_id'])->value('title');
         $order['supplier_title'] = Supplier::where('id',$order['supplier'])->value('title');
         $order['order_type_title'] = PurchaseOrder::$order_type[$order['order_type']] ?? '';
@@ -216,7 +216,7 @@ class PurchaseOrderService extends Service
                     'url' => $value['file'],
                     'name' => $value['name'],
                 ];
-                $order['img'][] = $tmp;
+                $order['file'][] = $tmp;
             }
         }
         $order['crt_name'] = $emp_map[$order['crt_id']] ?? '';

+ 10 - 5
app/Service/ReturnExchangeOrderService.php

@@ -220,7 +220,7 @@ class ReturnExchangeOrderService extends Service
 
         $order = ReturnExchangeOrder::where('id',$data['id'])
             ->where('del_time',0)
-            ->select('id','order_number','model_type','sales_order_id','difference_amount','crt_id','mark','state','crt_time','storehouse_id')
+            ->select('id','order_number','model_type','sales_order_id','difference_amount','crt_id','mark','state','crt_time','storehouse_id','depart_id','top_depart_id')
             ->first();
         if(empty($order)) return [false, '退换货订单不存在或已被删除'];
         $order = $order->toArray();
@@ -366,6 +366,12 @@ class ReturnExchangeOrderService extends Service
         if(empty($sale)) return [false,'合同不存在或已被删除'];
         if($sale['sales_order_type'] != SalesOrder::Order_type_one) return [false, '非安装件合同'];
         if($sale['state'] < SalesOrder::State_two) return [false,'合同未施工,不能进行退换货操作'];
+        //所属部门 以及  顶级部门
+        if(empty($data['depart_id'])) {
+            $data['depart_id'] = $this->getDepart($user);
+            $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
+        }
+
         //退货
         $return_submit_add = [];
         if(empty($data['product_one'])) return [false,'退货产品不能为空'];
@@ -410,15 +416,14 @@ class ReturnExchangeOrderService extends Service
                 $product_id[] = $value['product_id'];
             }
 
+            //是否校验库存
+            ProductInventoryService::is_check($user,$data);
+
             $product_save_minus = $this->getSaveDetailMinus($id);
             list($status,$msg) = (new ProductInventoryService())->compareStock($user,$product_id, $product_submit_minus, $product_save_minus);
             if(! $status) return [false, $msg];
         }
 
-        //所属部门 以及  顶级部门
-        if(empty($data['depart_id'])) $data['depart_id'] = $this->getDepart($user);
-        $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
-
         if($is_check){
             $prefix = ReturnExchangeOrder::$prefix[$data['model_type']] ?? "";
             $order_number = (new OrderNoService())->createReturnExchangeOrderNumber($prefix);

+ 2 - 1
app/Service/SalesOrderService.php

@@ -645,10 +645,11 @@ class SalesOrderService extends Service
         $product = $fee = [];
         if(! empty($ergs['product'])){
             $sales_p_info = SalesOrderProductInfo::where('del_time',0)
-                ->where('sales_order_id',array_column($data['data'],'id'))
+                ->whereIn('sales_order_id',array_column($data['data'],'id'))
                 ->get()->toArray();
             $basic_price = BasicType::whereIn('id',array_unique(array_column($sales_p_info,'basic_type_id')))->pluck('title','id')->toArray();
             $map = (new ProductService())->getProductDetail(array_column($sales_p_info,'product_id'));
+
             foreach ($sales_p_info as $value){
                 $tmp = $map[$value['product_id']] ?? [];
                 $value['title'] = $tmp['title'] ?? "";

+ 5 - 4
app/Service/SupplierService.php

@@ -252,8 +252,10 @@ class SupplierService extends Service
     public function customerRule(&$data, $user, $is_add = true){
         if(empty($data['title'])) return [false,'供应商名称不能为空'];
         //所属部门 以及  顶级部门
-        if(empty($data['depart_id'])) $data['depart_id'] = $this->getDepart($user);
-        $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
+        if(empty($data['depart_id'])) {
+            $data['depart_id'] = $this->getDepart($user);
+            $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
+        }
 
         if($is_add){
             $bool = Supplier::where('del_time',0)
@@ -262,10 +264,9 @@ class SupplierService extends Service
                 ->exists();
         }else{
             if(empty($data['id'])) return [false,'ID不能为空'];
-            $top_depart_id = Supplier::where('id',$data['id'])->value('top_depart_id');
             $bool = Supplier::where('del_time',0)
                 ->where('id','<>',$data['id'])
-                ->where('top_depart_id',$top_depart_id)
+                ->where('top_depart_id',$data['top_depart_id'])
                 ->where('title',$data['title'])
                 ->exists();
         }