Explorar o código

入库预约取消超时校验

Zhouzhendong %!s(int64=4) %!d(string=hai) anos
pai
achega
091d1f1724

+ 10 - 16
app/Http/Controllers/DeliveryAppointmentController.php

@@ -529,24 +529,18 @@ html;
         if (!$number)return ["status"=>417];
         $period = app("DeliveryAppointmentService")->getPeriod();
         if ($period===false)return ["status"=>416]; //非法时段扫码
-        $mark = false;
-        mark:
-        $car = DeliveryAppointmentCar::query()->whereNull("delivery_time")->where("status",0)
+        $car = DeliveryAppointmentCar::query()->with("deliveryAppointment")->whereNull("delivery_time")->where("status",0)
             ->where("appointment_number",$number)->whereHas("deliveryAppointment",function (Builder $query)use($period){
-                $query->where("appointment_date",date("Y-m-d"))
-                ->where("date_period",$period)->whereIn("status",[0,3]);
+                $query->whereIn("status",[0,3]);
             })->first();
-        if (!$car && $period===1){$period = 0;$mark = true;goto mark;}
-        if ($mark && $car){
-            $car->load("deliveryAppointment");
+        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);
-            if ($available<$car->deliveryAppointment->capacity)$car = null;
+            if ($available<$car->deliveryAppointment->capacity)return ["status"=>417];
+            DeliveryAppointment::query()->where("id",$car->delivery_appointment_id)->update(["status" => 0]);
         }
-        if (!$car)return ["status"=>417];
-        $car->update(["delivery_time"=>date("Y-m-d H:i:s"),"status"=>1]);
-        /** @var DeliveryAppointmentCar $car */
-        if ($mark)DeliveryAppointment::query()->where("id",$car->delivery_appointment_id)->update(["status" => 0]);
-        else event(new DeliveryAppointmentEvent($car));
+        event(new DeliveryAppointmentEvent($car));
         return ["status"=>200,"k"=>$car->delivery_appointment_id];
     }
 
@@ -571,7 +565,7 @@ 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->deliveryAppointment->appointment_date!=date('Y-m-d'))$this->error("禁止越天逾期操作");
         $car->update(["status"=>2]);
         $status = app("DeliveryAppointmentService")->checkFull($car->delivery_appointment_id);
         event(new DeliveryAppointmentEvent($car));
@@ -587,7 +581,7 @@ html;
         if (!request("id"))$this->error("非法参数");
         /** @var DeliveryAppointmentCar|\stdClass $car */
         $car = DeliveryAppointmentCar::query()->whereHas("deliveryAppointment",function (Builder $query){
-            $query->where("appointment_date",date("Y-m-d"));
+            $query->whereIn("status",[0,3]);
         })->find(request("id"));
         if (!$car || !$car->deliveryAppointment)$this->error("单据不存在");
         $car->update(["status"=>1,"delivery_time"=>date("Y-m-d H:i:s")]);

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

@@ -8,6 +8,7 @@ use App\Commodity;
 use App\CommodityMaterialBoxModel;
 use App\Components\AsyncResponse;
 use App\Components\ErrorPush;
+use App\DeliveryAppointment;
 use App\ErrorTemp;
 use App\Feature;
 use App\Http\ApiControllers\LoginController;
@@ -99,6 +100,7 @@ class TestController extends Controller
         return call_user_func([$this, $method], $request);
     }
     public function test(){
+        dd(Carbon::now()->gt(Carbon::parse(date("Y-m-d")." ".explode("-",DeliveryAppointment::PERIOD[0])[1].":00:00")));
         DB::beginTransaction();
         try {
             foreach (DB::connection("was_test")->table("processes")->where("created_at",">=","2021-09-11 11:00:00")

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

@@ -16,61 +16,12 @@
             @can("入库管理-入库预约-质检")<button type="button" class="btn btn-outline-primary" @click="qualityInspectionMark()">质检</button>@endcan
         </div>
         <table class="table table-striped table-bordered table-hover text-nowrap td-min-width-80" id="table">
-<!--            <tr class="text-center">
-                <th>
-                    <label for="all" id="cloneCheckAll">
-                        <input id="all" type="checkbox" @click="checkAll($event)">全选
-                    </label>
-                </th>
-                <th>序号</th>
-                <th>操作</th>
-                <th>状态</th>
-                <th>预约号</th>
-                <th>ASN单号</th>
-                <th>预约时间</th>
-                <th>创建时间</th>
-                <th>操作/送达时间</th>
-                <th>货主</th>
-                <th>重量/吨</th>
-                <th>体积/立方</th>
-                <th>箱数</th>
-                <th>备注</th>
-                <th>车号/快递公司</th>
-                <th>车型/快递单号</th>-->
-<!--                <th>仓库</th>
-                <th>
-                    <div class="row" style="min-width: 800px">
-                        <div class="col-12">车辆信息</div>
-                    </div>
-                    <div class="row">
-                        <div class="col-2">预约号</div>
-                        <div class="col-2">车牌号</div>
-                        <div class="col-2">车型</div>
-                        <div class="col-1">司机姓名</div>
-                        <div class="col-2">司机电话</div>
-                        <div class="col-3">操作/送达时间</div>
-                    </div>
-                </th>
-                <th>快递公司</th>
-                <th>快递单号</th>
-                <th>采购单号</th>
-                <th>
-                    <div class="row">
-                        <div class="col-12 text-center">明细单</div>
-                    </div>
-                    <div class="row" style="min-width: 500px">
-                        <div class="col-5 text-center">商品名称</div>
-                        <div class="col-4 text-center">条码</div>
-                        <div class="col-2 text-center">数量</div>
-                    </div>
-                </th>-->
-<!--            </tr>-->
             <tr v-for="(info,i) in list" :id="'info-'+i">
                 <td><input class="checkItem" type="checkbox" :value="list.id"></td>
                 <td>@{{ i+1 }}</td>
                 <td>
                     <span>
-                         @can("入库管理-入库预约-预约管理-签到")<span v-if="(info.status==0 && info.appointment_date==today) && info.cars[0].status==0"><button class="btn btn-sm btn-outline-success" @click="signIn(i,0)">签到</button><br></span>@endcan
+                         @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>
@@ -129,68 +80,6 @@
                 <td><div class="text-overflow-replace-200">@{{ info.remark }}</div></td>
                 <td>@{{ info.logistic ? info.logistic.name : info.cars[0].license_plate_number }}</td>
                 <td>@{{ info.logistic ? info.logistic_number : (info.cars[0].car ? info.cars[0].car.name : '') }}</td>
-
-<!--                <td>
-                    <label v-if="!poolMapping.warehouses"></label>
-                    <label v-else>@{{ poolMapping.warehouses[info.warehouse_id] }}</label>
-                </td>
-                <td>
-                    <div v-if="info.cars.length>0" class="text-center">
-                        <div class="row">
-                            <div class="col-2 font-weight-bold">@{{ info.cars[0].appointment_number }}</div>
-                            <div class="col-2 text-secondary">@{{ info.cars[0].license_plate_number }}</div>
-                            <div class="col-2 text-secondary">@{{ info.cars[0].car ? info.cars[0].car.name : '' }}</div>
-                            <div class="col-1 text-secondary">@{{ info.cars[0].driver_name }}</div>
-                            <div class="col-2 text-secondary">@{{ info.cars[0].driver_phone }}</div>
-                            <div class="col-3">
-                                @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>
-                        </div>
-                        <div class="up" :id="'item-'+info.id" v-show="info.cars.length>1">
-                            <div class="row" v-for="(car,j) in info.cars" v-if="j!==0">
-                                <div class="col-2 font-weight-bold">@{{ car.appointment_number }}</div>
-                                <div class="col-2 text-secondary">@{{ car.license_plate_number }}</div>
-                                <div class="col-2 text-secondary">@{{ car.car ? car.car.name : '' }}</div>
-                                <div class="col-1 text-secondary">@{{ car.driver_name }}</div>
-                                <div class="col-2 text-secondary">@{{ car.driver_phone }}</div>
-                                <div class="col-3">
-                                    @can("入库管理-入库预约-预约管理-卸货完成")<button class="btn btn-sm btn-outline-success" @click="unloading(i,j)" v-if="car.status==1">卸货完成</button>@endcan
-                                    <div v-if="car.status==2">@{{ car.delivery_time }}</div>
-                                </div>
-                            </div>
-                        </div>
-                        <div class="text-center m-auto small cursor-pointer" v-if="info.cars.length>1" @click="upAll(info.id)">
-                            <span class="fa" :class="upList[info.id] ? 'fa-angle-double-down' : 'fa-angle-double-right'" style="margin-top: 2px;"></span>&nbsp;
-                            <span v-if="upList[info.id]">收起其余@{{ info.cars.length-1 }}条</span>
-                            <span v-else>展开其余@{{ info.cars.length-1 }}条</span>
-                        </div>
-                    </div>
-                </td>
-                <td>@{{ info.logistic ? info.logistic.name : '' }}</td>
-                <td>@{{ info.logistic_number }}</td>
-                <td><span v-html="warpText(info.procurement_number)"></span></td>
-                <td>
-                    <div v-if="info.details.length>0">
-                        <div class="row">
-                            <div class="col-5 font-weight-bold text-overflow-warp">@{{ info.details[0].commodity_id ? (info.details[0].commodity ? info.details[0].commodity.name : '') : info.details[0].name }}</div>
-                            <div class="col-4 text-secondary text-overflow-warp">@{{ info.details[0] | getCommodity }}</div>
-                            <div class="col-2 text-secondary">@{{ info.details[0].amount }}</div>
-                        </div>
-                        <div class="up" :id="'detail-'+info.id" v-show="info.details.length>1">
-                            <div class="row" v-for="(detail,i) in info.details" v-if="i!==0">
-                                <div class="col-5 font-weight-bold text-overflow-warp">@{{ detail.commodity_id ? (detail.commodity ? detail.commodity.name : '') : detail.name }}</div>
-                                <div class="col-4 text-secondary text-overflow-warp">@{{ detail | getCommodity }}</div>
-                                <div class="col-2 text-secondary">@{{ detail.amount }}</div>
-                            </div>
-                        </div>
-                        <div class="text-center m-auto small cursor-pointer" v-if="info.details.length>1" @click="upAllDetail(info.id)">
-                            <span class="fa" :class="upListDetail[info.id] ? 'fa-angle-double-down' : 'fa-angle-double-right'" style="margin-top: 2px;"></span>&nbsp;
-                            <span v-if="upListDetail[info.id]">收起其余@{{ info.details.length-1 }}条</span>
-                            <span v-else>展开其余@{{ info.details.length-1 }}条</span>
-                        </div>
-                    </div>
-                </td>-->
             </tr>
             <tr v-if="currentIndex!==undefined" id="await">
                 <td colspan="2"></td>
@@ -284,14 +173,6 @@
                 let dd = now.getDate();
                 this.today = yy+'-'+(mm<10 ? '0'+mm : mm)+'-'+(dd<10 ? '0'+dd : dd);
             },
-            /*watch:{
-                checkData:{
-                    handler(){
-                        document.querySelector('#all').checked = this.checkData.length === this.list.length;
-                    },
-                    deep:true
-                },
-            },*/
             methods: {
                 openDetails(index,isClose = false){
                     if (isClose){
@@ -403,8 +284,7 @@
                         window.tempTip.postBasicRequest("{{url('store/deliveryAppointment/unloading')}}",{id:this.list[i].cars[j].id},res=>{
                             this.list[i].cars[j].status = 2;
                             if (this.list[i].cars.every(car=>{
-                                if (car.status!=2)return false;
-                                return true
+                                return car.status==2
                             }))this.list[i].status = res;
                             return "成功确认";
                         })
@@ -426,14 +306,6 @@
                         })
                     })
                 },
-                /*checkAll(e){
-                    if (e.target.checked){
-                        this.checkData = [];
-                        this.list.forEach((el)=>{
-                            this.checkData.push(el.id);
-                        });
-                    }else this.checkData = [];
-                },*/
                 executeExport(isAll){
                     let url = '{{url('store/deliveryAppointment/export')}}';
                     let token='{{ csrf_token() }}';