cqpCow 1 year ago
parent
commit
38ef4506e1
1 changed files with 5 additions and 2 deletions
  1. 5 2
      app/Service/ProductService.php

+ 5 - 2
app/Service/ProductService.php

@@ -518,13 +518,16 @@ class ProductService extends Service
             $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
         }
 
+        //总社id
+        $top_depart_id = $user['head'] ?? [];
+        $top_depart_id = $top_depart_id['id'] ?? 0;
         if($is_add){
-            $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}') AND top_depart_id = {$data['top_depart_id']}")
+            $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}') AND (top_depart_id = {$data['top_depart_id']} OR top_depart_id = {$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']}') AND top_depart_id = {$data['top_depart_id']}")
+            $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}') AND (top_depart_id = {$data['top_depart_id']} OR top_depart_id = {$top_depart_id})")
                 ->where('id','<>',$data['id'])
                 ->where('del_time',0)
                 ->exists();