Преглед на файлове

Merge branch 'zzd' of ssh://was.baoshi56.com:10022/var/git/bswas

LD преди 5 години
родител
ревизия
9fc2dd08b2

+ 22 - 15
app/Http/Controllers/DeliveryAppointmentController.php

@@ -20,6 +20,12 @@ use Illuminate\Support\Facades\Validator;
 class DeliveryAppointmentController extends Controller
 class DeliveryAppointmentController extends Controller
 {
 {
     use AsyncResponse;
     use AsyncResponse;
+
+    public function list()
+    {
+        $owners = app("UserService")->getPermittingOwnerIds(Auth::id());
+    }
+
     public function appointment()
     public function appointment()
     {
     {
         $owners = app("OwnerService")->getIntersectPermitting();
         $owners = app("OwnerService")->getIntersectPermitting();
@@ -43,9 +49,9 @@ class DeliveryAppointmentController extends Controller
         $errors = $this->appointmentValidator($model)->errors();
         $errors = $this->appointmentValidator($model)->errors();
         if (count($errors)>0)$this->success(["errors"=>$errors]);
         if (count($errors)>0)$this->success(["errors"=>$errors]);
         /** @var \stdClass $warehouse */
         /** @var \stdClass $warehouse */
-        $warehouse = Warehouse::query()->find(request("warehouse_id"));
-        $tonne = $model["tonne"];
-        $cubicMeter = $model["cubic_meter"];
+        $warehouse = Warehouse::query()->find($model["warehouse_id"]);
+        $tonne = $model["tonne"] ?? 0;
+        $cubicMeter = $model["cubic_meter"] ?? 0;
         $amount = request("detail_amount");
         $amount = request("detail_amount");
         $need = app("DeliveryAppointmentService")->calculateCapacity($tonne,$cubicMeter,$amount,$warehouse->reduced_production_capacity_coefficient);//所需产能
         $need = app("DeliveryAppointmentService")->calculateCapacity($tonne,$cubicMeter,$amount,$warehouse->reduced_production_capacity_coefficient);//所需产能
         $start = Carbon::tomorrow();
         $start = Carbon::tomorrow();
@@ -83,7 +89,7 @@ class DeliveryAppointmentController extends Controller
     public function submitAppointment()
     public function submitAppointment()
     {
     {
         $model = request("model");
         $model = request("model");
-        $selectDate = request("selectDate");
+        $selectDate = request("date");
         $details = request("details");
         $details = request("details");
         $errors = $this->appointmentValidator($model)->errors();
         $errors = $this->appointmentValidator($model)->errors();
         if (count($errors)>0)$this->success(["errors"=>$errors]);
         if (count($errors)>0)$this->success(["errors"=>$errors]);
@@ -93,7 +99,7 @@ class DeliveryAppointmentController extends Controller
         ])->errors();
         ])->errors();
         if (count($errors)>0)$this->error("未选定预约日期");
         if (count($errors)>0)$this->error("未选定预约日期");
 
 
-        DB::transaction(function ()use($model,$selectDate,$details){
+        DB::transaction(function ()use($model,$selectDate,$details,&$appointment){
             $result = DeliveryAppointment::query()->selectRaw("appointment_date,date_period,SUM(capacity) AS capacity")
             $result = DeliveryAppointment::query()->selectRaw("appointment_date,date_period,SUM(capacity) AS capacity")
                 ->where("appointment_date",$selectDate["date"])
                 ->where("appointment_date",$selectDate["date"])
                 ->where("date_period",$selectDate["time"])
                 ->where("date_period",$selectDate["time"])
@@ -104,7 +110,7 @@ class DeliveryAppointmentController extends Controller
             /** @var \stdClass $warehouse */
             /** @var \stdClass $warehouse */
             $warehouse = Warehouse::query()->find($model["warehouse_id"]);
             $warehouse = Warehouse::query()->find($model["warehouse_id"]);
             $need = app("DeliveryAppointmentService")->
             $need = app("DeliveryAppointmentService")->
-            calculateCapacity($model["tonne"],$model["cubic_meter"],count($details),
+            calculateCapacity($model["tonne"] ?? 0,$model["cubic_meter"] ?? 0,count($details),
                 $warehouse->reduced_production_capacity_coefficient);
                 $warehouse->reduced_production_capacity_coefficient);
             if ($result){
             if ($result){
                 $total = $warehouse->production_capacity*DeliveryAppointment::HOUR[$selectDate["time"]];
                 $total = $warehouse->production_capacity*DeliveryAppointment::HOUR[$selectDate["time"]];
@@ -115,12 +121,12 @@ class DeliveryAppointmentController extends Controller
             $appointment = DeliveryAppointment::query()->create([
             $appointment = DeliveryAppointment::query()->create([
                 "user_id"               => Auth::id(),
                 "user_id"               => Auth::id(),
                 "owner_id"              => $model["owner_id"],
                 "owner_id"              => $model["owner_id"],
-                "procurement_number"    => $model["procurement_number"],
-                "asn_number"            => $model["asn_number"],
+                "procurement_number"    => $model["procurement_number"] ?? null,
+                "asn_number"            => $model["asn_number"] ?? null,
                 "warehouse_id"          => $model["warehouse_id"],
                 "warehouse_id"          => $model["warehouse_id"],
-                "tonne"                 => $model["tonne"],
-                "cubic_meter"           => $model["cubic_meter"],
-                "box_amount"            => $model["box_amount"],
+                "tonne"                 => $model["tonne"] ?? 0,
+                "cubic_meter"           => $model["cubic_meter"] ?? 0,
+                "box_amount"            => $model["box_amount"] ?? 0,
                 "capacity"              => $need,
                 "capacity"              => $need,
                 "appointment_date"      => $selectDate["date"],
                 "appointment_date"      => $selectDate["date"],
                 "date_period"           => $selectDate["time"],
                 "date_period"           => $selectDate["time"],
@@ -144,10 +150,10 @@ class DeliveryAppointmentController extends Controller
                 ];
                 ];
             }
             }
             DeliveryAppointmentCar::query()->insert($insert);
             DeliveryAppointmentCar::query()->insert($insert);
-            //md5加密在密文第五位后插入
-            $md5 = substr_replace(md5(date("m-d")),$appointment->id,5,0);
-            $this->success(["key"=>$md5]);
         });
         });
+        //md5加密在密文第五位后插入
+        $md5 = substr_replace(md5(date("m-d")),$appointment->id,5,0);
+        $this->success(["key"=>$md5]);
     }
     }
 
 
     private function appointmentValidator(array $model)
     private function appointmentValidator(array $model)
@@ -188,8 +194,9 @@ class DeliveryAppointmentController extends Controller
         $key = request("k");
         $key = request("k");
         $len = strlen($key);
         $len = strlen($key);
         $id = substr($key,5,$len-32);
         $id = substr($key,5,$len-32);
-        $md5 = substr($id,0,5).substr($id,5+$len-32);
+        $md5 = substr($key,0,5).substr($key,5+$len-32);
         if ($md5!==md5(date("m-d")))return view("exception.404");
         if ($md5!==md5(date("m-d")))return view("exception.404");
+
         /** @var \stdClass $appointment */
         /** @var \stdClass $appointment */
         $appointment = DeliveryAppointment::query()->with("cars")->find($id);
         $appointment = DeliveryAppointment::query()->with("cars")->find($id);
         if (!$appointment || $appointment->user_id != Auth::id())return view("exception.404");
         if (!$appointment || $appointment->user_id != Auth::id())return view("exception.404");

+ 1 - 1
app/Services/OrderService.php

@@ -1058,7 +1058,7 @@ sql
      *
      *
      * @return int
      * @return int
      */
      */
-    public function getOrderQuantity($owner, $isToB)
+    public function getOrderQuantity($owner, $isToB = false)
     {
     {
         $date = date("Y-m");
         $date = date("Y-m");
         if ($isToB)$type = "|B|";
         if ($isToB)$type = "|B|";

+ 2 - 1
resources/views/store/deliveryAppointment/appointment.blade.php

@@ -305,10 +305,11 @@
                                     return true;
                                     return true;
                                 }
                                 }
                             });
                             });
+                            this.selectDate={};
                             window.tempTip.show("该预约时段已经被抢占了,请选择其他时段");
                             window.tempTip.show("该预约时段已经被抢占了,请选择其他时段");
                             return;
                             return;
                         }
                         }
-                        window.open("{{url('store/deliveryAppointment/showAppointmentInfo?k=')}}"+res.key);
+                        window.location.href = "{{url('store/deliveryAppointment/showAppointmentInfo?k=')}}"+res.key;
                     },true);
                     },true);
                 },
                 },
             },
             },

+ 5 - 1
resources/views/store/deliveryAppointment/menu.blade.php

@@ -4,7 +4,11 @@
             <ul class="nav nav-pills">
             <ul class="nav nav-pills">
                 @can('入库管理-客户预约-预约')
                 @can('入库管理-客户预约-预约')
                 <li class="nav-item">
                 <li class="nav-item">
-                    <a target="store/checkingReceive/mission" class="nav-link" href="{{url('store/deliveryAppointment/appointment')}}" :class="{active:isActive('appointment',3)}">客户预约</a>
+                    <a target="store/deliveryAppointment/appointment" class="nav-link" href="{{url('store/deliveryAppointment/appointment')}}" :class="{active:isActive('appointment',3)}">客户预约</a>
+                </li> @endcan
+                @can('入库管理-客户预约-预约管理')
+                <li class="nav-item">
+                    <a target="store/deliveryAppointment/list" class="nav-link" href="{{url('store/deliveryAppointment/list')}}" :class="{active:isActive('list',3)}">预约管理</a>
                 </li> @endcan
                 </li> @endcan
             </ul>
             </ul>
         </div>
         </div>

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

@@ -29,7 +29,7 @@
                     <span class="badge badge-pill badge-info">{{$car->appointment_number}}</span>
                     <span class="badge badge-pill badge-info">{{$car->appointment_number}}</span>
                 </span><br>
                 </span><br>
                 <span class="mt-1">预约时间:{{$appointment->appointment_date}}&nbsp;&nbsp;{{$appointment->period}}</span>
                 <span class="mt-1">预约时间:{{$appointment->appointment_date}}&nbsp;&nbsp;{{$appointment->period}}</span>
-                <span class="ml-4 mt-1">司机:{{$appointment->driver_name}}</span>
+                <span class="ml-4 mt-1">司机:{{$appointment->driver_name ?? '未知'}}</span>
             </div>
             </div>
             @endforeach
             @endforeach
             <div class="mt-5">
             <div class="mt-5">

+ 1 - 0
routes/web.php

@@ -423,6 +423,7 @@ Route::group(['prefix'=>'store'],function(){
         Route::post('getCapacity','DeliveryAppointmentController@getCapacity');
         Route::post('getCapacity','DeliveryAppointmentController@getCapacity');
         Route::post('submitAppointment','DeliveryAppointmentController@submitAppointment');
         Route::post('submitAppointment','DeliveryAppointmentController@submitAppointment');
         Route::get('showAppointmentInfo','DeliveryAppointmentController@showAppointmentInfo');
         Route::get('showAppointmentInfo','DeliveryAppointmentController@showAppointmentInfo');
+        Route::get('list','DeliveryAppointmentController@list');
         Route::group(['prefix'=>'appointment'],function(){
         Route::group(['prefix'=>'appointment'],function(){
             Route::post('import','DeliveryAppointmentController@import');
             Route::post('import','DeliveryAppointmentController@import');
         });
         });