From 534d991ea9ad634ef42013e19b76444ae83bc17b Mon Sep 17 00:00:00 2001 From: weigang Date: Sat, 12 Sep 2020 14:38:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=95=86=E5=93=81=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E9=99=90=E5=88=B6=E5=85=88=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/GoodsRecommendController.php | 9 ++++++++- app/Service/v3/Implementations/SearchService.php | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Controller/v3/GoodsRecommendController.php b/app/Controller/v3/GoodsRecommendController.php index 95ee76d..59a1325 100644 --- a/app/Controller/v3/GoodsRecommendController.php +++ b/app/Controller/v3/GoodsRecommendController.php @@ -28,7 +28,11 @@ class GoodsRecommendController extends BaseController $page = $this->request->input('page', 1); $pagesize = $this->request->input('pagesize', 10); - $builder = Goods::query()->with('store')->where('market_id', $marketId); + $builder = Goods::query()->with('store') + ->where('market_id', $marketId) + ->where(function ($query) { + $query->where('inventory', '>', 0)->orWhere('is_infinite', '=', 1); + }); switch ($tab) { case Tabs::APPLET_INDEX_RECOMMEND: @@ -67,6 +71,9 @@ class GoodsRecommendController extends BaseController $goods = Goods::query() ->with(['store']) ->where('market_id', $marketId) + ->where(function ($query) { + $query->where('inventory', '>', 0)->orWhere('is_infinite', '=', 1); + }) ->inRandomOrder() ->limit(20) ->get()->toArray(); diff --git a/app/Service/v3/Implementations/SearchService.php b/app/Service/v3/Implementations/SearchService.php index 6b6a0b1..ca609bd 100644 --- a/app/Service/v3/Implementations/SearchService.php +++ b/app/Service/v3/Implementations/SearchService.php @@ -19,7 +19,9 @@ class SearchService implements \App\Service\v3\Interfaces\SearchServiceInterface return $query->select(['id', 'logo', 'name']); }]) ->where(['market_id' => $params['market_id']]) - ->where('inventory', '>', 0); + ->where(function ($query) { + $query->where('inventory', '>', 0)->orWhere('is_infinite', '=', 1); + });; if (isset($params['type_id']) && $params['type_id']) { $typeIds = explode(',', $params['type_id']);