From e26b3d65bfda38105a323071f25f6d4c27fa824b Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Tue, 15 Sep 2020 09:28:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=81=E8=BE=BE=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implementations/AppointmentTimeService.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/Service/v3/Implementations/AppointmentTimeService.php b/app/Service/v3/Implementations/AppointmentTimeService.php index 7359bce..6e876d1 100644 --- a/app/Service/v3/Implementations/AppointmentTimeService.php +++ b/app/Service/v3/Implementations/AppointmentTimeService.php @@ -2,6 +2,8 @@ namespace App\Service\v3\Implementations; +use App\Constants\v3\ErrorCode; +use App\Exception\ErrorCodeException; use App\Model\v3\ShoppingCart; use App\Model\v3\Store; use App\Service\v3\Interfaces\AppointmentTimeServiceInterface; @@ -40,17 +42,23 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface $time3Arr = []; $time4Arr = []; $nowTime = time(); + $closedTime = strtotime('19:30'); //取得所有店铺营业时间交集 foreach($stores as $store){ //店铺手动 点击歇业 if($store['is_rest'] == 1){ - return $store['name'].'店铺已打烊'; + throw new ErrorCodeException(ErrorCode::STORE_REST); } //当前时间小于 开始营业时间 $time1 = strtotime(($store['time1'])); - if($nowTime < ($time1+60*30)){ - return $store['name'].'店铺已打烊'; + if($nowTime < $time1){ + throw new ErrorCodeException(ErrorCode::STORE_REST); } + + if($nowTime > $closedTime){ + throw new ErrorCodeException(ErrorCode::STORE_REST); + } + $time2 = strtotime(($store['time2'])); if(!empty($store['time3']) && !empty($store['time4'])){ $time3 = strtotime(($store['time3'])); @@ -62,7 +70,7 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface $endTime = $time2; } if(($nowTime+60*30) > $endTime){ - return $store['name'].'店铺已打烊'; + throw new ErrorCodeException(ErrorCode::STORE_REST); } array_push($time1Arr,$time1); array_push($time2Arr,$time2);