chenqp 8 månader sedan
förälder
incheckning
727fc4c4a1

+ 50 - 0
app/Model/UseScopeBaseModel.php

@@ -568,6 +568,56 @@ class UseScopeBaseModel extends Model
         }
     }
 
+    //产品不可见 部门和顶级部门(公司)过滤
+    public function scopeProductClear2($query, $user, $search)
+    {
+        //是否所有部门
+        $is_all_depart = $user['is_all_depart'] ?? 0;
+        //权限范围内的部门
+        $depart_range = $user['depart_range'] ?? [];
+        //总社id
+        $top_depart_id = $user['head'] ?? [];
+        $top_depart = $top_depart_id['id'] ?? 0;
+
+        //可见范围方法
+        $model = $query->getModel(); // 获取模型的实例
+        $range_function = $model::range_function ?? ""; // 访问静态属性
+        $is_function_range = $this->hasMethod(new RangeService(),$range_function);
+
+        //顶级部门
+        $search_depart_id = $search['top_depart_id'] ?? 0; //顶级公司
+        if(empty($search_depart_id)){
+            //默认进来 自身顶级公司
+            $top_depart_id = $user['depart_top'][0] ?? [];
+            $top_depart_id = $top_depart_id['depart_id'] ?? 0;
+        }else{
+            //查询 顶级公司
+            $top_depart_id = $search_depart_id;
+        }
+
+        $id = [];
+        //产品 不可见范围
+        if($is_function_range) $id = RangeService::$range_function($user,$search);
+
+        if($is_all_depart){
+            //所有部门
+            if(empty($search_depart_id)){
+                //全部
+                $query->whereIn('depart_id', $depart_range);
+            }else{
+                //查看某个分社
+                $query->where('top_depart_id', $top_depart_id)
+                    ->orWhere('top_depart_id',$top_depart);
+            }
+        }else{
+            //某个分社全部 去掉不可见数
+            $query->where('top_depart_id', $top_depart_id)
+                ->whereIn('depart_id', $depart_range)
+                ->orWhere('top_depart_id',$top_depart)
+                ->whereNotIn('id', $id);
+        }
+    }
+
     //活动包 部门和顶级部门(公司)过滤
     public function scopeSportsBagClear($query, $user, $search)
     {

+ 1 - 1
app/Service/InvoiceOrderService.php

@@ -347,7 +347,7 @@ class InvoiceOrderService extends Service
         foreach ($data['product'] as $value){
             if(empty($value['number'])) return [false,'产品数量不能为空'];
             $res = $this->checkNumber($value['number']);
-            if(! $res) return [false,'请输入正确的产品量'];
+            if(! $res) return [false,'请输入正确的产品量'];
 
             $key = $value['product_id'] . ',' .$data['storehouse_id'];
             if(isset($product_submit[$value['product_id']])){

+ 8 - 0
app/Service/SportsBagService.php

@@ -373,6 +373,14 @@ class SportsBagService extends Service
         $res = $this->checkNumber($data['total_amount']);
         if(! $res) return [false,'活动包总金额请输入不超过两位小数并且大于0的数值'];
 
+        if(empty($data['product'])) return [false, '请选择产品'];
+        foreach ($data['product'] as $value){
+            if(empty($value['number'])) return [false,'产品数量不能为空'];
+            $res = $this->checkNumber($value['number']);
+            if(! $res) return [false,'请输入正确的产品数量'];
+
+        }
+
         //所属部门 以及  顶级部门
         if(empty($data['depart_id'])) $data['depart_id'] = $this->getDepart($user);
         $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;