浏览代码

合单允许地址差异

Zhouzhendong 4 年之前
父节点
当前提交
65a16c9b1b

+ 1 - 7
app/Http/Controllers/TestController.php

@@ -88,12 +88,6 @@ class TestController extends Controller
 
     public function test()
     {
-        $a = ["App\\Order:3910328","App\\Order:3923621","App\\Order:3923618","App\\Order:3923663","App\\Order:3923749","App\\Order:3923817","App\\Order:3923820","App\\Order:3923841","App\\Order:3923858","App\\Order:3923852","App\\Order:3923873","App\\Order:3923899","App\\Order:3923918","App\\Order:3923931","App\\Order:3923974","App\\Order:3923988","App\\Order:3924129","App\\Order:3924144","App\\Order:3924182","App\\Order:3924193","App\\Order:3924338","App\\Order:3924560","App\\Order:3924653","App\\Order:3924741","App\\Order:3924779","App\\Order:3924830","App\\Order:3924833","App\\Order:3924879","App\\Order:3924922","App\\Order:3924919","App\\Order:3924963","App\\Order:3925052","App\\Order:3925065","App\\Order:3925130","App\\Order:3925202","App\\Order:3925286","App\\Order:3925304","App\\Order:3925315","App\\Order:3925317","App\\Order:3925591","App\\Order:3925773","App\\Order:3926441","App\\Order:3926533","App\\Order:3926379","App\\Order:3926536","App\\Order:3926381","App\\Order:3926548","App\\Order:3926611","App\\Order:3926677","App\\Order:3926699"];
-        $order = [];
-        foreach ($a as $item){
-            $order[] = explode(":",$item)[1];
-        }
-        $orders = Order::query()->whereIn("id",$order)->get();
-        $this->dispatch(new OrderCreateInstantBill($orders));
+        Waybill::query()->whereIn("waybill_number",['BSZX2108243654','BSZX2108233588'])->update(["logistic_id"=>98]);
     }
 }

+ 13 - 7
app/Http/Controllers/WaybillController.php

@@ -15,6 +15,7 @@ use App\Services\UnitService;
 use App\Services\WaybillPayoffService;
 use App\Services\WaybillPriceModelService;
 use App\Services\WaybillService;
+use App\Traits\ModelLogChanging;
 use App\UploadFile;
 use App\WaybillAuditLog;
 use App\WaybillOnTop;
@@ -831,10 +832,16 @@ SQL;
         if (count($errors)>0)return ["errors"=>$errors];
         $waybill=Waybill::query()->find($request->input('id'));
         if (!$waybill)return ["error"=>"未找到该运单!"];
-        $request->offsetSet("carrier_weight_unit_id",$unit2);
-        $request->offsetSet("carrier_weight_unit_id_other",$unit);
-        $request->offsetSet("amount_unit_id",$unit1);
+        $request->offsetSet("carrier_weight_unit_id",$unit2->id);
+        $request->offsetSet("carrier_weight_unit_id_other",$unit->id);
+        $request->offsetSet("amount_unit_id",$unit1->id);
+        $request->offsetSet("status","待终审");
         $waybill->fill($request->input());
+        WaybillAuditLog::query()->create([
+            'waybill_id'=>$waybill->id,
+            'audit_stage'=>'调度阶段',
+            'user_id'=>Auth::id(),
+        ]);
         $waybill->update();
         return $waybill;
     }
@@ -1114,8 +1121,7 @@ SQL;
                         || $waybills[$i]->order->consignee_phone!=$waybill->order->consignee_phone
                         || $waybills[$i]->order->address!=$waybill->order->address)) ||
                 (!$waybill->order && ($waybills[$i]->recipient!=$waybill->recipient
-                    || $waybills[$i]->recipient_mobile!=$waybill->recipient_mobile
-                    || $waybills[$i]->destination!=$waybill->destination));
+                    || $waybills[$i]->recipient_mobile!=$waybill->recipient_mobile));
             if (array_search($waybills[$i]->status,["未审核","已审核"])===false
                 || $identical)$this->error("信息不一致,无法进行合并");
             $destroys[] = $waybills[$i]->id;
@@ -1268,8 +1274,7 @@ SQL;
                             || $item->order->consignee_phone!=$waybill->order->consignee_phone
                             || $item->order->address!=$waybill->order->address)) ||
                     (!$waybill->order && ($item->recipient!=$waybill->recipient
-                            || $item->recipient_mobile!=$waybill->recipient_mobile
-                            || $item->destination!=$waybill->destination));
+                            || $item->recipient_mobile!=$waybill->recipient_mobile));
                 if ($identical)$this->error("订单信息不一致,无法统一发货");
                 $destroys[] = $item->id;
                 $waybill->source_bill .= $item->source_bill ? ",".$item->source_bill : '';
@@ -1286,6 +1291,7 @@ SQL;
             $owner = array_unique($owner);
             if (count($owner)>1)$waybill->merge_owner = implode(',',$owner);
             $waybill->deliver_at = date("Y-m-d H:i:s");
+            $waybill->logistic_id = \request("logistic");
             if ($waybill->status=='未审核')$waybill->status = '已审核';
             $waybill->update();
             Waybill::destroy($destroys);

+ 12 - 1
resources/views/transport/waybill/index.blade.php

@@ -702,7 +702,18 @@
                         window.tempTip.show("至少选择两条运单进行合并");
                         return;
                     }
-                    window.tempTip.confirm("确定要合并选中运单吗?",()=>{
+                    let presetAddress = undefined;
+                    let isCheck = this.waybills.every(waybill=>{
+                        if (checkData.includes(waybill.id)){
+                            if (presetAddress===undefined){
+                                presetAddress = waybill.destination;
+                                return true;
+                            }
+                            if (presetAddress!==waybill.destination)return false;
+                        }
+                        return true;
+                    });
+                    window.tempTip.confirm(isCheck ? "确定要合并选中运单吗?" : "目的地址不一致确定仍要进行合并吗?",()=>{
                         window.tempTip.setDuration(5000);
                         window.tempTip.waitingTip("合并中,请稍等...");
                         window.tempTip.postBasicRequest("{{url('transport/waybill/waybillMerge')}}",{ids:checkData},res=>{