cqpCow hai 1 ano
pai
achega
a99432d66e

+ 3 - 1
app/Service/BasicTypeService.php

@@ -3,6 +3,7 @@
 namespace App\Service;
 
 use App\Model\BasicType;
+use App\Model\Supplier;
 
 /**
  * 基础分类设置相关
@@ -130,8 +131,9 @@ class BasicTypeService extends Service
                 $data['data'][$key]['top_depart_id'] = $data['top_depart_id'];
             }else{
                 if($this->isEmpty($data,'id')) return [false,'id不能为空!'];
+                $top_depart_id = BasicType::where('id',$data['id'])->value('top_depart_id');
                 $bool = BasicType::where('title',$value['title'])
-                    ->where('top_depart_id',$data['top_depart_id'])
+                    ->where('top_depart_id',$top_depart_id)
                     ->where('type',$value['type'])
                     ->where('id','<>',$data['id'])
                     ->where('del_time',0)

+ 3 - 0
app/Service/CustomerService.php

@@ -553,13 +553,16 @@ class CustomerService extends Service
 
         if($is_add){
             $bool = Customer::where('del_time',0)
+                ->where('top_depart_id',$data['top_depart_id'])
                 ->where('title',$data['title'])
                 ->where('model_type',$data['model_type'])
                 ->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('title',$data['title'])
                 ->where('model_type',$data['model_type'])
                 ->exists();

+ 2 - 1
app/Service/EmployeeService.php

@@ -409,8 +409,9 @@ class EmployeeService extends Service
             if($bool) return [false,'角色名称已存在!'];
         }else{
             if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
+            $top_depart_id = Role::where('id',$data['id'])->value('top_depart_id');
             $bool = Role::where('title',$data['title'])
-                ->where('top_depart_id',$data['top_depart_id'])
+                ->where('top_depart_id',$top_depart_id)
                 ->where('id','<>',$data['id'])
                 ->where('del_time',0)
                 ->exists();

+ 5 - 4
app/Service/ProductService.php

@@ -149,9 +149,9 @@ class ProductService extends Service
                     ->exists();
             }else{
                 if($this->isEmpty($data,'id')) return [false,'id不能为空!'];
-
+                $top_depart_id = ProductCategory::where('id',$data['id'])->value('top_depart_id');
                 $bool = ProductCategory::where('title',$value['title'])
-                    ->where('top_depart_id',$data['top_depart_id'])
+                    ->where('top_depart_id',$top_depart_id)
                     ->where('id','<>',$data['id'])
                     ->where('del_time',0)
                     ->exists();
@@ -597,12 +597,13 @@ class ProductService extends Service
         $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']}')")
+            $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}') AND top_depart_id = {$data['top_depart_id']}")
                 ->where('del_time',0)
                 ->exists();
         }else{
             if(empty($data['id'])) return [false,'ID不能为空'];
-            $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}')")
+            $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}")
                 ->where('id','<>',$data['id'])
                 ->where('del_time',0)
                 ->exists();

+ 2 - 0
app/Service/SupplierService.php

@@ -274,8 +274,10 @@ 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('title',$data['title'])
                 ->exists();
         }