You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
namespace App\Service\v3\Implementations;
use App\Model\v3\ShoppingCart;use App\Model\v3\Store;use App\Service\v3\Interfaces\AppointmentTimeServiceInterface;use phpDocumentor\Reflection\Types\Object_;
class AppointmentTimeService implements AppointmentTimeServiceInterface{ public function do() { return [ '尽快送达', '08:30 - 09:00', '09:00 - 09:30', '09:30 - 10:00', '10:00 - 10:30' ]; }
public function check() { // TODO: Implement check() method.
}
public function undo() { // TODO: Implement undo() method.
}
public function get($shopcartIds) { $shopcartIds = explode(',',$shopcartIds); $sotreIds = ShoppingCart::query()->whereIn('id',$shopcartIds)->pluck('store_id'); $stores = Store::query()->whereIn('id',$sotreIds)->get()->toArray(); $startTimeArr = []; $endTimeArr = []; $time1Arr = []; $time2Arr = []; $time3Arr = []; $time4Arr = []; // return $stores;
$nowTime = time(); foreach($stores as $store){ if($store['is_rest'] == 1){ return $store['name'].'店铺已打烊'; } $time1 = strtotime(($store['time1'])); if($nowTime < $time1){ return $store['name'].'店铺已打烊'; } $time2 = strtotime(($store['time2'])); if(!empty($store['time3']) && !empty($store['time4'])){ $time3 = strtotime(($store['time3'])); $time4 = strtotime(($store['time4'])); array_push($time3Arr,$time3); array_push($time4Arr,$time4); $endTime = $time4; }else{ $endTime = $time2; } if($nowTime > $endTime){ return $store['name'].'店铺已打烊'; } array_push($time1Arr,$time1); array_push($time2Arr,$time2); } $time1Max = max($time1Arr); $time2Min = min($time2Arr); if(!empty($time3Max) && !empty($time3Arr)){ $time3Max = max($time3Arr); $time4Min = min($time4Arr); } for($i = 1;$i<=5;$i++){ $time = time() + (30*60*$i); if($time < $time2Min){ $time5 = $time1Max + (30*60*$i); }else{ $time5 = $time3Max + (30*60*$i); } if($time5 >= $time4Min){ return $res; } $res[] = date('h:i',$time5); } // foreach ($stores as $store){
//
// }
return $res; }}
|