cqpCow 1 年之前
父节点
当前提交
38ef4506e1
共有 1 个文件被更改,包括 5 次插入2 次删除
  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;
             $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){
         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)
                 ->where('del_time',0)
                 ->exists();
                 ->exists();
         }else{
         }else{
             if(empty($data['id'])) return [false,'ID不能为空'];
             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('id','<>',$data['id'])
                 ->where('del_time',0)
                 ->where('del_time',0)
                 ->exists();
                 ->exists();