|
@@ -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');
|