From aca26c095dcf16a40cad6d49fa6ff04261bf73a3 Mon Sep 17 00:00:00 2001 From: weigang Date: Mon, 14 Sep 2020 21:12:14 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=90=E8=97=8F=E5=A4=B1=E6=95=88=E5=95=86?= =?UTF-8?q?=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/GoodsRecommendController.php | 13 +++++++++++-- app/Service/v3/Implementations/SearchService.php | 10 ++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/Controller/v3/GoodsRecommendController.php b/app/Controller/v3/GoodsRecommendController.php index 40efde5..7528c17 100644 --- a/app/Controller/v3/GoodsRecommendController.php +++ b/app/Controller/v3/GoodsRecommendController.php @@ -2,6 +2,7 @@ namespace App\Controller\v3; +use App\Constants\v3\Goods as GoodsConstants; use App\Constants\v3\Store as StoreConstants; use App\Constants\v3\Tabs; use App\Controller\BaseController; @@ -43,7 +44,11 @@ class GoodsRecommendController extends BaseController ''.$storeTable.'.is_rest' => StoreConstants::IS_REST_NO ]) ->with(['store']) - ->where([''.$goodsTable.'.market_id' => $marketId]) + ->where([ + ''.$goodsTable.'.market_id' => $marketId, + ''.$goodsTable.'.on_sale' => GoodsConstants::ON_SALE_YES + ]) + ->whereRaw(''.$goodsTable.'.deleted_at IS NULL') ->where(function ($query) use ($goodsTable) { $query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1); }); @@ -109,7 +114,11 @@ class GoodsRecommendController extends BaseController ''.$storeTable.'.is_rest' => StoreConstants::IS_REST_NO ]) ->with(['store']) - ->where([''.$goodsTable.'.market_id' => $marketId]) + ->where([ + ''.$goodsTable.'.market_id' => $marketId, + ''.$goodsTable.'.on_sale' => GoodsConstants::ON_SALE_YES + ]) + ->whereRaw(''.$goodsTable.'.deleted_at IS NULL') ->where(function ($query) use ($goodsTable) { $query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1); }) diff --git a/app/Service/v3/Implementations/SearchService.php b/app/Service/v3/Implementations/SearchService.php index 7b260f3..4bc658a 100644 --- a/app/Service/v3/Implementations/SearchService.php +++ b/app/Service/v3/Implementations/SearchService.php @@ -30,8 +30,12 @@ class SearchService implements SearchServiceInterface ''.$storeTable.'.status' => StoreConstants::STATUS_PASS, ''.$storeTable.'.is_rest' => StoreConstants::IS_REST_NO ]) + ->where([ + ''.$goodsTable.'.market_id' => $params['market_id'], + ''.$goodsTable.'.on_sale' => GoodsConstants::ON_SALE_YES + ]) + ->whereRaw(''.$goodsTable.'.deleted_at IS NULL') ->with(['store']) - ->where([''.$goodsTable.'.market_id' => $params['market_id']]) ->where(function ($query) use ($goodsTable) { $query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1); }); @@ -97,9 +101,7 @@ class SearchService implements SearchServiceInterface ->where(function ($query) use ($goodsTable) { $query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1); }) - // ->with(['goods' => function($query) { - // return $query->select(['*'])->addSelect(['sales as total_sales']); - // }]) + ->whereRaw(''.$goodsTable.'.deleted_at IS NULL') ->where([''.$storeTable.'.market_id' => $params['market_id']]); if (isset($params['store_id']) && $params['store_id']) {