Selaa lähdekoodia

预约管理,修改时间,展览面板
新增签到时间与卸货时间

Zhouzhendong 4 vuotta sitten
vanhempi
commit
6c31b79436

+ 3 - 3
app/DeliveryAppointment.php

@@ -33,9 +33,9 @@ class DeliveryAppointment extends Model
     ];
     //时段 映射date_period字段 必须有序 否则展示数据错乱
     const PERIOD=[
-        0 => "09-11",
-        1 => "12-14",
-        2 => "14-18",
+        0 => "09-12",
+        1 => "13-15",
+        2 => "15-17",
     ];
     //时长 映射PERIOD常量
     const HOUR=[

+ 1 - 0
app/DeliveryAppointmentCar.php

@@ -19,6 +19,7 @@ class DeliveryAppointmentCar extends Model
         "appointment_number",
         "delivery_time",
         "status",
+        "unloaded_at",
     ];
     const STATUS = [
         0 => "未送达",

+ 1 - 1
app/Events/DeliveryAppointmentEvent.php

@@ -46,7 +46,7 @@ class DeliveryAppointmentEvent implements ShouldBroadcastNow
         $delivery->period = isset($delivery->deliveryAppointment->date_period) ? ($delivery->deliveryAppointment->date_period==0 ? '上午' : '下午') : '';
         $delivery->delivery_time = $delivery->delivery_time ? substr($delivery->delivery_time,11,5) : '';
 
-        $delivery->morrow = $delivery->deliveryAppointment->appointment_date == date('Y-m-d',strtotime("+1 day"));
+        $delivery->morrow = $delivery->deliveryAppointment->appointment_date != date('Y-m-d'/*,strtotime("+1 day")*/);
         $this->delivery = $delivery->withoutRelations();
     }
 

+ 11 - 7
app/Http/Controllers/DeliveryAppointmentController.php

@@ -190,8 +190,8 @@ class DeliveryAppointmentController extends Controller
             DeliveryAppointmentCar::query()->insert($insert);
         });
         dispatch(new DeliveryAppointmentCheck($appointment->id))->delay(Carbon::parse($appointment->appointment_date." ".(explode("-",DeliveryAppointment::PERIOD[$appointment->date_period])[1]).":00:01"));
-        //当日或次日预约单广播
-        if (strtotime(date('Y-m-d',strtotime("+2 day")))>strtotime($appointment->appointment_date." 00:00:00")){
+        // x当日或次日预约单广播  √大于当前时间的都广播
+        if (strtotime($appointment->appointment_date." 00:00:00")>strtotime(date('Y-m-d'))){
             $appointment->load("cars");
             event(new DeliveryAppointmentEvent($appointment->cars[0]));
         }
@@ -246,7 +246,7 @@ class DeliveryAppointmentController extends Controller
         //当日或次日预约单广播
         $old = $appointment->appointment_date == date('Y-m-d') ? 0 : ($appointment->appointment_date == date('Y-m-d',strtotime('+1 day') ? 1 : 2));
         $new = $selectDate["date"] == date('Y-m-d') ? 0 : ($selectDate["date"] == date('Y-m-d',strtotime('+1 day') ? 1 : 2));
-        if ($old==2 && $new==2)$this->success(); //超过广播区间不推送
+        //if ($old==2 && $new==2)$this->success(); //超过广播区间不推送
         if (($old-$new)!=0 || $appointment->date_period!=$selectDate["time"]){
             $appointment->cars[0]->change = true;
             $appointment->cars[0]->old = $old;
@@ -385,8 +385,12 @@ class DeliveryAppointmentController extends Controller
             $query->withCount("cars")->with("owner");
         }])->whereHas("deliveryAppointment",function ($query)use($period,$warehouse,$date){
             /** @var Builder $query */
-            $query->where("appointment_date",$date)
-                ->where("warehouse_id",$warehouse)->whereIn("status",[0,2]);
+            if ($date){
+                $query->where("appointment_date",$date);
+            }else{
+                $query->where("appointment_date",">",date("Y-m-d"));
+            }
+            $query->where("warehouse_id",$warehouse)->whereIn("status",[0,2]);
         })->where(function ($query)use($period){
             /** @var Builder $query */
             $query->where("status",1)->orWhereHas("deliveryAppointment",function (Builder $query)use($period){
@@ -457,7 +461,7 @@ class DeliveryAppointmentController extends Controller
                     break;
             }
         }
-        $result = ["list"=>$list,"success"=>$success,"work"=>$work,"notReached"=>$notReached,"nextDay"=>$this->carList(0,date("Y-m-d",strtotime("+1 day")),$warehouse)];
+        $result = ["list"=>$list,"success"=>$success,"work"=>$work,"notReached"=>$notReached,"nextDay"=>$this->carList(0,/*date("Y-m-d",strtotime("+1 day"))*/null,$warehouse)];
         $nextTime = DeliveryAppointment::PERIOD[$index+1] ?? null;
         if ($nextTime){
             $nextTime = explode("-",$nextTime)[0];
@@ -567,7 +571,7 @@ html;
         if (!$car || !$car->deliveryAppointment)$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]);
+        $car->update(["status"=>2,"unloaded_at"=>date("Y-m-d H:i:s")]);
         $status = app("DeliveryAppointmentService")->checkFull($car->delivery_appointment_id);
         event(new DeliveryAppointmentEvent($car));
         $this->success($status);

+ 32 - 0
database/migrations/2021_12_21_161432_change_delivery_appointment_table.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeDeliveryAppointmentTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('delivery_appointment_cars', function (Blueprint $table) {
+            $table->timestamp("unloaded_at")->nullable()->comment("卸货完成时间");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('delivery_appointment_cars', function (Blueprint $table) {
+            $table->dropColumn("unloaded_at");
+        });
+    }
+}

+ 1 - 1
resources/views/store/deliveryAppointment/exhibition.blade.php

@@ -147,7 +147,7 @@
             </div>
             <div class="col-4">
                 <div class="w-100 text-center">
-                    <h2 class="font-weight-bold">次日预约</h2>
+                    <h2 class="font-weight-bold">后续预约</h2>
                 </div>
                 <table class="table w-100 h4">
                     <tr>

+ 8 - 2
resources/views/store/deliveryAppointment/list.blade.php

@@ -66,10 +66,15 @@
                 <td><span v-html="warpText(info.asn_number)"></span></td>
                 <td class="text-primary">@{{ info.appointment_date }}&nbsp;&nbsp;@{{ info.period }}</td>
                 <td>@{{ info.created_at }}</td>
+                <td>
+                    <div>
+                        @{{ info.cars[0].delivery_time }}
+                    </div>
+                </td>
                 <td>
                     <div>
                         @can("入库管理-入库预约-预约管理-卸货完成")<button class="btn btn-sm btn-outline-success" @click="unloading(i,0)" v-if="info.cars[0].status==1">卸货完成</button>@endcan
-                        <div v-if="info.cars[0].status==2">@{{ info.cars[0].delivery_time }}</div>
+                        <div v-if="info.cars[0].status==2">@{{ info.cars[0].unloaded_at }}</div>
                     </div>
                 </td>
                 <td>
@@ -248,7 +253,8 @@
                         {name:'asn_number',value: 'ASN单号', class:"td-warm"},
                         {name:'appointment_date',value: '预约时间', class:"td-warm"},
                         {name:'created_at',value: '创建时间', class:"td-warm"},
-                        {name:'delivery_time',value: '操作/送达时间', neglect: true, class:"td-warm"},
+                        {name:'delivery_time',value: '签到时间', neglect: true, class:"td-warm"},
+                        {name:'unloaded_at',value: '卸货时间', neglect: true, class:"td-warm"},
                         {name:'owner_id',value: '货主', class:"td-warm"},
                         {name:'tonne',value: '重量/吨', class:"td-warm"},
                         {name:'cubic_meter',value: '体积/立方', class:"td-warm"},