瀏覽代碼

采购单不显示t9总社分类产品

cqp 2 月之前
父節點
當前提交
e1aba9d5bd
共有 2 個文件被更改,包括 12 次插入1 次删除
  1. 1 0
      app/Model/ProductCategory.php
  2. 11 1
      app/Service/ProductService.php

+ 1 - 0
app/Model/ProductCategory.php

@@ -17,5 +17,6 @@ class ProductCategory extends UseScopeBaseModel
     const Special_for_roll1 = 306; //改色膜
     const Special_for_roll2 = 313; //彩色车衣
     const Special_for_roll3 = 321; //脚垫
+    const Special_for_p = 449; //t9总社专用
     const Special_for_sn = 297; //车窗膜
 }

+ 11 - 1
app/Service/ProductService.php

@@ -147,6 +147,9 @@ class ProductService extends Service
             })
             ->where('product_category.del_time',0)
             ->where('product_category.top_depart_id', $head_top_depart_id)
+            ->when($head_top_depart_id != $now_top_depart_id, function ($query){
+                return $query->where('product_category.is_show',0);
+            })
             ->select('product_category.title','product_category.id','product_category.parent_id')
             ->orderByRaw('IF(a.sort IS NULL, product_category.id, a.sort) ASC') // 排序逻辑:优先按 a.sort 排序,没有关联时按主表 id 排序
             ->get()->toArray();
@@ -1207,11 +1210,18 @@ class ProductService extends Service
     }
 
     public function productGroupByList($data,$user){
+        $head_top_depart_id = $user['head']['id'] ?? 0;
+        $now_top_depart_id = $this->getDepart($user);
+        $p = ProductCategory::Special_for_p;
+
         $model = Product::ProductClear($user,$data);
         $model = $model->where('del_time',0)
             ->where('item_code','<>',"")
-            ->select('title','id','product_category_id','product_category','retail_price','product_attribute','item_code','unit','size','code','bar_code')
             ->where('is_use', Product::is_use_one)
+            ->when($head_top_depart_id != $now_top_depart_id, function ($query) use($p){
+                return $query->where('product_category','NOT LIKE', '%'.$p.'%');
+            })
+            ->select('title','id','product_category_id','product_category','retail_price','product_attribute','item_code','unit','size','code','bar_code')
             ->groupBy('item_code')
             ->orderByDesc('product_attribute')
             ->orderByDesc('item_code');