From 2d2fef1fee14e927a9a0ed002a2718617f5b56fb Mon Sep 17 00:00:00 2001 From: weigang Date: Wed, 16 Sep 2020 12:20:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=AB=99=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E4=BC=91=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/GoodsRecommendController.php | 29 +++++-------------- .../AppointmentTimeService.php | 2 +- .../Implementations/GoodsActivityService.php | 9 ++++++ .../v3/Implementations/GoodsService.php | 9 ++++++ .../v3/Implementations/SearchService.php | 8 ++--- config/config.php | 1 + 6 files changed, 31 insertions(+), 27 deletions(-) diff --git a/app/Controller/v3/GoodsRecommendController.php b/app/Controller/v3/GoodsRecommendController.php index 2f265d8..b5dd857 100644 --- a/app/Controller/v3/GoodsRecommendController.php +++ b/app/Controller/v3/GoodsRecommendController.php @@ -52,17 +52,11 @@ class GoodsRecommendController extends BaseController ->where(function ($query) use ($goodsTable) { $query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1); }) - ->where('time1', '<=', date('H:i')) + /*->where('time1', '<=', date('H:i')) ->where(function ($query) { $query->where('time2', '>=', date('H:i')) ->orWhere('time4', '>=', date('H:i')); - }); - - // $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: @@ -127,24 +121,15 @@ class GoodsRecommendController extends BaseController ->where(function ($query) use ($goodsTable) { $query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1); }) - ->where('time1', '<=', date('H:i')) - ->where(function ($query) { - $query->where('time2', '>=', date('H:i')) - ->orWhere('time4', '>=', date('H:i')); - }) + // ->where('time1', '<=', date('H:i')) + // ->where(function ($query) { + // $query->where('time2', '>=', date('H:i')) + // ->orWhere('time4', '>=', date('H:i')); + // }) ->inRandomOrder() ->limit(20) ->get()->toArray(); - // $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(); return $this->success(['has_more_pages' => false, 'tab_data' => $goods]); } diff --git a/app/Service/v3/Implementations/AppointmentTimeService.php b/app/Service/v3/Implementations/AppointmentTimeService.php index 5c18d2b..7ff97e3 100644 --- a/app/Service/v3/Implementations/AppointmentTimeService.php +++ b/app/Service/v3/Implementations/AppointmentTimeService.php @@ -44,7 +44,7 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface $nowTime = time(); //服务站最晚营业时间 if (env('APP_ENV') === 'prod') { - $closedTime = strtotime('19:30'); + $closedTime = strtotime(config('market_rest_time')); if($nowTime > $closedTime){ throw new ErrorCodeException(ErrorCode::MARKET_REST); } diff --git a/app/Service/v3/Implementations/GoodsActivityService.php b/app/Service/v3/Implementations/GoodsActivityService.php index f2a5a5b..1bbd217 100644 --- a/app/Service/v3/Implementations/GoodsActivityService.php +++ b/app/Service/v3/Implementations/GoodsActivityService.php @@ -5,6 +5,7 @@ namespace App\Service\v3\Implementations; use App\Constants\v3\ActivityType; use App\Constants\v3\ErrorCode; use App\Constants\v3\SsdbKeys; +use App\Exception\ErrorCodeException; use App\Service\v3\Interfaces\GoodsActivityServiceInterface; use App\TaskWorker\SSDBTask; use App\Constants\v3\Store; @@ -59,6 +60,14 @@ class GoodsActivityService implements GoodsActivityServiceInterface return ErrorCode::GOODS_ACTIVITY_BUY; } + //服务站最晚营业时间 + if (env('APP_ENV') === 'prod') { + $closedTime = strtotime(config('market_rest_time')); + if(time() > $closedTime){ + throw new ErrorCodeException(ErrorCode::MARKET_REST); + } + } + return true; } diff --git a/app/Service/v3/Implementations/GoodsService.php b/app/Service/v3/Implementations/GoodsService.php index 40ed706..bf240f3 100644 --- a/app/Service/v3/Implementations/GoodsService.php +++ b/app/Service/v3/Implementations/GoodsService.php @@ -3,6 +3,7 @@ namespace App\Service\v3\Implementations; use App\Constants\v3\ErrorCode; +use App\Exception\ErrorCodeException; use App\Service\v3\Interfaces\GoodsServiceInterface; use Hyperf\DbConnection\Db; use App\Model\v3\Goods; @@ -42,6 +43,14 @@ class GoodsService implements GoodsServiceInterface return ErrorCode::GOODS_RESTRICT_LIMIT; } + //服务站最晚营业时间 + if (env('APP_ENV') === 'prod') { + $closedTime = strtotime(config('market_rest_time')); + if(time() > $closedTime){ + throw new ErrorCodeException(ErrorCode::MARKET_REST); + } + } + return true; } diff --git a/app/Service/v3/Implementations/SearchService.php b/app/Service/v3/Implementations/SearchService.php index 151a601..3f43a52 100644 --- a/app/Service/v3/Implementations/SearchService.php +++ b/app/Service/v3/Implementations/SearchService.php @@ -39,11 +39,11 @@ class SearchService implements SearchServiceInterface ->where(function ($query) use ($goodsTable) { $query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1); }) - ->where('time1', '<=', date('H:i')) + /*->where('time1', '<=', date('H:i')) ->where(function ($query) { $query->where('time2', '>=', date('H:i')) ->orWhere('time4', '>=', date('H:i')); - }); + })*/; if (isset($params['store_id']) && $params['store_id']) { $builder->where([''.$goodsTable.'.store_id' => $params['store_id']]); @@ -108,11 +108,11 @@ class SearchService implements SearchServiceInterface }) ->whereRaw(''.$goodsTable.'.deleted_at IS NULL') ->where([''.$storeTable.'.market_id' => $params['market_id']]) - ->where('time1', '<=', date('H:i')) + /*->where('time1', '<=', date('H:i')) ->where(function ($query) { $query->where('time2', '>=', date('H:i')) ->orWhere('time4', '>=', date('H:i')); - }); + })*/; if (isset($params['store_id']) && $params['store_id']) { $builder->where([''.$storeTable.'.store_id' => $params['store_id']]); diff --git a/config/config.php b/config/config.php index 86de642..d2ef628 100644 --- a/config/config.php +++ b/config/config.php @@ -55,4 +55,5 @@ return [ 'lgoin' => [ 'authkey' => env('STORE_LOGIN_AUTHKEY', ''), ], + 'market_rest_time' => env('MARKET_REST_TIME', '19:30') ];