|
@@ -208,6 +208,18 @@ class GoodsService
|
|
|
$pageSize = $request->get('pageSize');
|
|
|
$goodsName = $request->get('goods_name', '');
|
|
|
|
|
|
+ $categorySuperId = $request->get('category_super_id', '');
|
|
|
+ $categoryIds = $request->get('category_id', []);
|
|
|
+ if (!empty($categorySuperId)) {
|
|
|
+ $category = SysCategory::where('category_id', $categorySuperId)->first();
|
|
|
+ if (empty($category->category_super_path)) {
|
|
|
+ $category->category_super_path = '#' . $categorySuperId . '#';
|
|
|
+ } else {
|
|
|
+ $category->category_super_path = $category->category_super_path . '#' . $categorySuperId . '#';
|
|
|
+ }
|
|
|
+ $categoryIds = SysCategory::where('category_super_path', 'like', '%' . $category->category_super_path)->pluck('category_id');
|
|
|
+ }
|
|
|
+
|
|
|
$rows = Goods::with([
|
|
|
'category' => function ($query) {
|
|
|
$query->select('category_id', 'category_name');
|
|
@@ -224,8 +236,7 @@ class GoodsService
|
|
|
$q->where('goods_name', 'like', '%' . $goodsName . '%')
|
|
|
->OrWhere('goods_title', 'like', '%' . $goodsName . '%');
|
|
|
});
|
|
|
- })->where('goods_classify', 'GOODS')
|
|
|
- ->where('goods_category', '生态园')
|
|
|
+ })->whereIn('join_goods_category_id', $categoryIds)
|
|
|
->orderBy('goods_addtimes', 'DESC')
|
|
|
->forPage($page, $pageSize)
|
|
|
->get()
|
|
@@ -235,8 +246,7 @@ class GoodsService
|
|
|
$q->where('goods_name', 'like', '%' . $goodsName . '%')
|
|
|
->OrWhere('goods_title', 'like', '%' . $goodsName . '%');
|
|
|
});
|
|
|
- })->where('goods_classify', 'SERVICE')
|
|
|
- ->where('goods_category', 'FARM')
|
|
|
+ })->whereIn('join_goods_category_id', $categoryIds)
|
|
|
->count();
|
|
|
|
|
|
foreach ($rows as &$row) {
|