Эх сурвалжийг харах

预约管理的日期更改与提交

Zhouzhendong 4 жил өмнө
parent
commit
59d5f8a791

+ 2 - 2
app/DeliveryAppointment.php

@@ -35,13 +35,13 @@ class DeliveryAppointment extends Model
     const PERIOD=[
         0 => "09-11",
         1 => "12-14",
-        2 => "14-17",
+        2 => "14-18",
     ];
     //时长 映射PERIOD常量
     const HOUR=[
         0 => 3,
         1 => 3,
-        2 => 4,
+        2 => 5,
     ];
     //状态
     const STATUS=[

+ 6 - 3
app/Http/Controllers/DeliveryAppointmentController.php

@@ -536,7 +536,7 @@ html;
         if (!$car || !$car->deliveryAppointment)return ["status"=>417];
         $car->update(["delivery_time"=>date("Y-m-d H:i:s"),"status"=>1]);
         if (Carbon::now()->gt(Carbon::parse($car->deliveryAppointment->appointment_date." ".explode("-",DeliveryAppointment::PERIOD[$car->deliveryAppointment->date_period])[1].":00:00"))){
-            $available = app("DeliveryAppointmentService")->getAvailableCapacity($car->deliveryAppointment->appointment_date,$car->deliveryAppointment->date_period,$car->deliveryAppointment->warehouse_id);
+            $available = app("DeliveryAppointmentService")->getAvailableCapacity(date("Y-m-d"),$period,$car->deliveryAppointment->warehouse_id);
             if ($available<$car->deliveryAppointment->capacity)return ["status"=>417];
             DeliveryAppointment::query()->where("id",$car->delivery_appointment_id)->update(["status" => 0]);
         }
@@ -565,7 +565,8 @@ html;
         /** @var DeliveryAppointmentCar|\stdClass $car */
         $car = DeliveryAppointmentCar::query()->with("deliveryAppointment")->where("status",1)->find(request("id"));
         if (!$car || !$car->deliveryAppointment)$this->error("单据不存在");
-        //if ($car->deliveryAppointment->appointment_date!=date('Y-m-d'))$this->error("禁止越天逾期操作");
+        if (!$car->delivery_time)$this->error("尚未签到");
+        if (mb_substr($car->delivery_time,0,10)!=date('Y-m-d'))$this->error("禁止越天逾期操作");
         $car->update(["status"=>2]);
         $status = app("DeliveryAppointmentService")->checkFull($car->delivery_appointment_id);
         event(new DeliveryAppointmentEvent($car));
@@ -579,6 +580,8 @@ html;
     {
         $this->gate("入库管理-入库预约-预约管理-签到");
         if (!request("id"))$this->error("非法参数");
+        $period = app("DeliveryAppointmentService")->getPeriod();
+        if ($period===false)$this->error("当前非工作时间,请在指定时间内送货");
         /** @var DeliveryAppointmentCar|\stdClass $car */
         $car = DeliveryAppointmentCar::query()->whereHas("deliveryAppointment",function (Builder $query){
             $query->whereIn("status",[0,3]);
@@ -586,7 +589,7 @@ html;
         if (!$car || !$car->deliveryAppointment)$this->error("单据不存在");
         $car->update(["status"=>1,"delivery_time"=>date("Y-m-d H:i:s")]);
         if (Carbon::now()->gt(Carbon::parse($car->deliveryAppointment->appointment_date." ".explode("-",DeliveryAppointment::PERIOD[$car->deliveryAppointment->date_period])[1].":00:00"))){
-            $available = app("DeliveryAppointmentService")->getAvailableCapacity($car->deliveryAppointment->appointment_date,$car->deliveryAppointment->date_period,$car->deliveryAppointment->warehouse_id);
+            $available = app("DeliveryAppointmentService")->getAvailableCapacity(date("Y-m-d"),$period,$car->deliveryAppointment->warehouse_id);
             if ($available<$car->deliveryAppointment->capacity)$this->error("仓库产能不足,请另择日期送货");
             DeliveryAppointment::query()->where("id",$car->delivery_appointment_id)->update(["status" => 0]);
         }

+ 2 - 0
app/Http/Controllers/TestController.php

@@ -143,6 +143,8 @@ sql;
 
     public function test()
     {
+        $a = "2021-09-13 00:00:00";
+        dd(mb_substr($a,0,10));
         $models = app("MaterialBoxModelService")->getModelSortedByOwner(null);
         foreach ($models as $model){
             $box = app("MaterialBoxService")->getAnEmptyBox($model,[],2);

+ 14 - 10
resources/views/store/deliveryAppointment/list.blade.php

@@ -21,22 +21,26 @@
                 <td>@{{ i+1 }}</td>
                 <td>
                     <span>
-                         @can("入库管理-入库预约-预约管理-签到")<span v-if="info.status==0 || info.status==3"><button class="btn btn-sm btn-outline-success" @click="signIn(i,0)">签到</button><br></span>@endcan
-                        <span v-if="info.status==0">
-                            <button type="button" @click="cancel(info.id,i)" class="btn btn-sm btn-outline-danger">取消预约</button><br>
-                            <button type="button" @click="updateDeliveryDate(info,i)" class="btn btn-sm btn-outline-primary">修改预约</button>
+                        <span v-if="info.cars[0].status==0">
+                            @can("入库管理-入库预约-预约管理-签到")
+                                <span v-if="info.status==0 || info.status==3"><button class="btn btn-sm btn-outline-success" @click="signIn(i,0)">签到</button><br></span>
+                            @endcan
+                            <span v-if="info.status==0">
+                                <button type="button" @click="cancel(info.id,i)" class="btn btn-sm btn-outline-danger">取消预约</button><br>
+                                <button type="button" @click="updateDeliveryDate(info,i)" class="btn btn-sm btn-outline-primary">修改预约</button>
+                            </span>
+                             <span v-if="info.status==3">
+                                 <button type="button" @click="reschedule(info,i)" class="btn btn-sm btn-outline-primary">重新预约</button>
+                             </span>
                         </span>
-                        <span v-if="info.status==2">
+                        <span v-if="info.status==2 || info.status==4">
                             <button type="button" @click="printReceipt(info)" class="btn btn-sm btn-outline-success"><i class="fa fa-print"></i>&nbsp;打印</button>
                         </span>
-                         <span v-if="info.status==3">
-                             <button type="button" @click="reschedule(info,i)" class="btn btn-sm btn-outline-primary">重新预约</button>
-                         </span>
-                         <span v-if="info.details.length>0">
+                        <span v-if="info.details.length>0">
                              <br>
                              <button class="btn btn-sm btn-dark" v-if="currentIndex===i" @click="openDetails(i,true);">关闭明细</button>
                              <button class="btn btn-sm btn-outline-info" v-else  @click="openDetails(i);">查看明细</button>
-                         </span>
+                        </span>
                     </span>
                 </td>
                 <td>