From 30ec2db49c2d45d64e60bcce03f76eef42d55b81 Mon Sep 17 00:00:00 2001 From: weigang Date: Sun, 13 Sep 2020 11:59:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E7=8F=AD=E5=B8=A6=E9=A4=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/GoodsRecommendController.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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; }