|
@@ -293,8 +293,17 @@ class DeliveryAppointmentController extends Controller
|
|
|
{
|
|
{
|
|
|
$this->gate("入库管理-客户预约-预约管理");
|
|
$this->gate("入库管理-客户预约-预约管理");
|
|
|
$list = [];
|
|
$list = [];
|
|
|
- DeliveryAppointmentCar::query()->whereNotNull("delivery_time")->whereHas("deliveryAppointment",function (Builder $query){
|
|
|
|
|
- $query->where("appointment_date",date("Y-m-d"));
|
|
|
|
|
|
|
+ $hour = date("H");
|
|
|
|
|
+ $index = null;
|
|
|
|
|
+ foreach (DeliveryAppointment::PERIOD as $key=>$period){
|
|
|
|
|
+ $arr = explode("-",$period);
|
|
|
|
|
+ if (count($arr)!=2)continue;
|
|
|
|
|
+ if ($hour<$arr[1])$index = $key;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($index===null)$this->success([]);
|
|
|
|
|
+ DeliveryAppointmentCar::query()->whereNotNull("delivery_time")->whereHas("deliveryAppointment",function (Builder $query)use($index){
|
|
|
|
|
+ $query->where("appointment_date",date("Y-m-d"))->whereIn("status",[0,2])
|
|
|
|
|
+ ->where("date_period",">=",$index);
|
|
|
})->orderByDesc("id")->limit(10)->get()->each(function ($car)use(&$list){
|
|
})->orderByDesc("id")->limit(10)->get()->each(function ($car)use(&$list){
|
|
|
$diff = (strtotime($car->delivery_time)+1799)-time();
|
|
$diff = (strtotime($car->delivery_time)+1799)-time();
|
|
|
$list[] = [
|
|
$list[] = [
|
|
@@ -304,7 +313,14 @@ class DeliveryAppointmentController extends Controller
|
|
|
"diff" => $diff>0 ? $diff*1000 : 0,
|
|
"diff" => $diff>0 ? $diff*1000 : 0,
|
|
|
];
|
|
];
|
|
|
});
|
|
});
|
|
|
- $this->success($list);
|
|
|
|
|
|
|
+ $result = ["list"=>$list];
|
|
|
|
|
+ $nextTime = DeliveryAppointment::PERIOD[$index+1] ?? null;
|
|
|
|
|
+ if ($nextTime){
|
|
|
|
|
+ $nextTime = explode("-",$nextTime)[0];
|
|
|
|
|
+ $timestamp = strtotime(date("Y-m-d")." ".$nextTime.":00:00");
|
|
|
|
|
+ $result["refresh"] = (($timestamp-time())*1000) ?? 1000;
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success($result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function getKey()
|
|
public function getKey()
|
|
@@ -371,7 +387,7 @@ html;
|
|
|
$car = DeliveryAppointmentCar::query()->whereNull("delivery_time")
|
|
$car = DeliveryAppointmentCar::query()->whereNull("delivery_time")
|
|
|
->where("appointment_number",$number)->whereHas("deliveryAppointment",function (Builder $query)use($period){
|
|
->where("appointment_number",$number)->whereHas("deliveryAppointment",function (Builder $query)use($period){
|
|
|
$query->where("appointment_date",date("Y-m-d"))
|
|
$query->where("appointment_date",date("Y-m-d"))
|
|
|
- ->where("date_period",$period);
|
|
|
|
|
|
|
+ ->where("date_period",$period)->where("status",0);
|
|
|
})->first();
|
|
})->first();
|
|
|
if (!$car)return ["status"=>417];
|
|
if (!$car)return ["status"=>417];
|
|
|
$car->update(["delivery_time"=>date("Y-m-d H:i:s")]);
|
|
$car->update(["delivery_time"=>date("Y-m-d H:i:s")]);
|