Browse Source

送达时间

master
Lemon 5 years ago
parent
commit
e26b3d65bf
  1. 16
      app/Service/v3/Implementations/AppointmentTimeService.php

16
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);

Loading…
Cancel
Save