|
|
@@ -5,7 +5,6 @@ namespace App\Http\Controllers;
|
|
|
|
|
|
use App\CarType;
|
|
|
use App\Components\AsyncResponse;
|
|
|
-use App\Logistic;
|
|
|
use App\Owner;
|
|
|
use App\Region;
|
|
|
use App\Services\CarTypeService;
|
|
|
@@ -844,6 +843,7 @@ SQL;
|
|
|
'logistic_id'=>'required_without:order_id|integer',
|
|
|
'carrier_bill'=>"sometimes|required|max:50|unique:waybills,carrier_bill,$id",
|
|
|
'fee'=>'sometimes|nullable|min:0|numeric|max:999999',
|
|
|
+ 'inquire_tel'=>'required',
|
|
|
'carType_id'=>'sometimes|required|integer',
|
|
|
'other_fee'=>'sometimes|nullable|min:0|numeric|max:999999',
|
|
|
'charge'=>'sometimes|nullable|min:0|numeric|max:999999',
|
|
|
@@ -879,6 +879,7 @@ SQL;
|
|
|
'integer'=>':attribute 必须为数字',
|
|
|
],[
|
|
|
'logistic_id'=>'承运商',
|
|
|
+ 'inquire_tel'=>'查件电话',
|
|
|
'carrier_bill'=>'承运商单号',
|
|
|
'fee'=>'运费',
|
|
|
'other_fee'=>'其他费用',
|
|
|
@@ -1198,4 +1199,78 @@ SQL;
|
|
|
}
|
|
|
$this->error('打印失败');
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 运输发货在PC-APP上临时入口
|
|
|
+ */
|
|
|
+ public function shipment()
|
|
|
+ {
|
|
|
+ $logistics = app("LogisticService")->getSelection(['id','name','tag'],"物流");
|
|
|
+ return view("transport.waybill.android.shipment",compact("logistics"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发货与合并
|
|
|
+ */
|
|
|
+ public function shipmentAndMerge()
|
|
|
+ {
|
|
|
+ $waybill = Waybill::query()->where("waybill_number",\request("waybill"))->whereNull("deliver_at")
|
|
|
+ ->whereNotIn("status",["已完结","无模型"])->first();
|
|
|
+ if (!$waybill)$this->error("运单禁止操作");
|
|
|
+ $codes = explode("\n",\request("order"));
|
|
|
+ $waybills = Waybill::query()->whereIn("wms_bill_number",$codes)
|
|
|
+ ->where("id","!=",$waybill->id)
|
|
|
+ ->whereNull("deliver_at")
|
|
|
+ ->whereNotIn("status",["已完结","无模型"])->get();
|
|
|
+ if ($waybills->count()){
|
|
|
+ if ($waybills->count()<count($codes)-1)$this->error("存在非法订单");
|
|
|
+ $destroys = [];
|
|
|
+ $owner = [$waybill->owner_id];
|
|
|
+ foreach ($waybills as $item){
|
|
|
+ //信息一致性校验
|
|
|
+ $identical = ($waybill->order && ($item->order->consignee_name!=$waybill->order->consignee_name
|
|
|
+ || $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));
|
|
|
+ if ($identical)$this->error("订单信息不一致,无法统一发货");
|
|
|
+ $destroys[] = $item->id;
|
|
|
+ $waybill->source_bill .= $item->source_bill ? ",".$item->source_bill : '';
|
|
|
+ $waybill->wms_bill_number .= $item->wms_bill_number ? ",".$item->wms_bill_number : '';
|
|
|
+ $waybill->charge += (double)$item->charge;
|
|
|
+ $waybill->collect_fee += (double)$item->collect_fee;
|
|
|
+ $waybill->other_fee += (double)$item->other_fee;
|
|
|
+ $waybill->warehouse_weight_other += (double)$item->warehouse_weight_other;
|
|
|
+ $waybill->warehouse_weight += (double)$item->warehouse_weight;
|
|
|
+ $waybill->ordering_remark = $waybill->ordering_remark ? $waybill->ordering_remark.",".$item->ordering_remark : $item->ordering_remark;
|
|
|
+ $owner[] = $item->owner_id;
|
|
|
+ }
|
|
|
+ if (strlen($waybill->source_bill)>191 || strlen($waybill->wms_bill_number)>191)$this->error("单号超长,无法合并");
|
|
|
+ $owner = array_unique($owner);
|
|
|
+ if (count($owner)>1)$waybill->merge_owner = implode(',',$owner);
|
|
|
+ $waybill->deliver_at = date("Y-m-d H:i:s");
|
|
|
+ $waybill->update();
|
|
|
+ Waybill::destroy($destroys);
|
|
|
+ WaybillAuditLog::query()->create([
|
|
|
+ 'waybill_id'=>$waybill->id,
|
|
|
+ 'audit_stage'=>'合并运单',
|
|
|
+ 'user_id'=>Auth::id(),
|
|
|
+ ]);
|
|
|
+ WaybillAuditLog::query()->create([
|
|
|
+ 'waybill_id'=>$waybill->id,
|
|
|
+ 'audit_stage'=>'合单发货',
|
|
|
+ 'user_id'=>Auth::id(),
|
|
|
+ ]);
|
|
|
+ }else $waybill->update(["deliver_at"=>date("Y-m-d H:i:s")]);
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 运输发货在PC-APP上临时入口
|
|
|
+ */
|
|
|
+ public function waybillDispatch()
|
|
|
+ {
|
|
|
+ return view("transport.waybill.android.dispatch");
|
|
|
+ }
|
|
|
}
|