Browse Source

送达时间

master
Lemon 5 years ago
parent
commit
f00a01d4cb
  1. 2
      app/Controller/v3/OrderOnlineController.php
  2. 17
      app/Service/v3/Implementations/AppointmentTimeService.php

2
app/Controller/v3/OrderOnlineController.php

@ -96,7 +96,7 @@ class OrderOnlineController extends BaseController
'distribution_price' => 0 'distribution_price' => 0
]; ];
//返回预约送达时间 数组 //返回预约送达时间 数组
$res['appointment_time'] = $this->appointmentTimeService->do($shopcartIds);
$res['appointment_time'] = $this->appointmentTimeService->get($shopcartIds);
$res['store_list'] = $this->shopCartService->getGoodsByShopcartId($shopcartIds); $res['store_list'] = $this->shopCartService->getGoodsByShopcartId($shopcartIds);
//获取用户优惠券 //获取用户优惠券

17
app/Service/v3/Implementations/AppointmentTimeService.php

@ -41,7 +41,6 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface
$time2Arr = []; $time2Arr = [];
$time3Arr = []; $time3Arr = [];
$time4Arr = []; $time4Arr = [];
// return $stores;
$nowTime = time(); $nowTime = time();
foreach($stores as $store){ foreach($stores as $store){
if($store['is_rest'] == 1){ if($store['is_rest'] == 1){
@ -69,18 +68,26 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface
} }
$time1Max = max($time1Arr); $time1Max = max($time1Arr);
$time2Min = min($time2Arr); $time2Min = min($time2Arr);
if(!empty($time3Max) && !empty($time3Arr)){
$endTime = $time2Min;
if(!empty($time3Arr) && !empty($time4Arr)){
$time3Max = max($time3Arr); $time3Max = max($time3Arr);
$time4Min = min($time4Arr); $time4Min = min($time4Arr);
$endTime = $time4Min;
} }
for($i = 1;$i<=5;$i++){
$time = time() + (30*60*$i);
if($nowTime > $time1Max){
$time1Max = $nowTime;
}
for($i = 1;$i<=10;$i++){
$time = time() + (30*60*$i);
if($time < $time2Min){ if($time < $time2Min){
$time5 = $time1Max + (30*60*$i); $time5 = $time1Max + (30*60*$i);
}else{ }else{
if(empty($time3Max)){
return $res;
}
$time5 = $time3Max + (30*60*$i); $time5 = $time3Max + (30*60*$i);
} }
if($time5 >= $time4Min){
if($time5 >= $endTime){
return $res; return $res;
} }
$res[] = date('h:i',$time5); $res[] = date('h:i',$time5);

Loading…
Cancel
Save