diff --git a/app/Controller/v3/GoodsRecommendController.php b/app/Controller/v3/GoodsRecommendController.php index 59a1325..e96b29f 100644 --- a/app/Controller/v3/GoodsRecommendController.php +++ b/app/Controller/v3/GoodsRecommendController.php @@ -5,6 +5,7 @@ namespace App\Controller\v3; use App\Constants\v3\Tabs; use App\Controller\BaseController; use App\Model\v3\Goods; +use App\Model\v3\GoodsCategory; /** * 推荐商品相关 @@ -45,7 +46,14 @@ class GoodsRecommendController extends BaseController $builder = $builder->orderBy('price', 'asc'); break; case Tabs::APPLET_INDEX_OFFICE: - $builder = $builder->whereIn('category_id', [142,146]); + $categoryIds = [97,98]; + var_dump('ids', $categoryIds); + // 查询出三级分类 + $goodsCategoryIds = GoodsCategory::query()->whereIn('category_id', $categoryIds)->pluck('id'); + $builder = $builder->where(function ($query) use ($categoryIds, $goodsCategoryIds) { + $query->whereIn('category_id', $categoryIds) + ->orWhereIn('goods_category_id', $goodsCategoryIds); + }); break; }