|
|
@@ -16,6 +16,8 @@ use App\Services\WaybillPayoffService;
|
|
|
use App\Services\WaybillPriceModelService;
|
|
|
use App\Services\WaybillService;
|
|
|
use App\Traits\ModelLogChanging;
|
|
|
+use App\Terminal;
|
|
|
+use App\TerminalPrinter;
|
|
|
use App\UploadFile;
|
|
|
use App\WaybillAuditLog;
|
|
|
use App\WaybillOnTop;
|
|
|
@@ -59,13 +61,19 @@ class WaybillController extends Controller
|
|
|
if(!Gate::allows('运输管理-运单-查询')){ return view("exception.authority"); }
|
|
|
$paginateParams = $request->input();
|
|
|
$waybills=app('waybillService')->paginate($request->input());
|
|
|
+ $mac_addr = getMacAddr();
|
|
|
+ $print = TerminalPrinter::with(['terminal','logistics'])
|
|
|
+ ->whereHas('terminal',function ($query)use($mac_addr){$query->where('ip',$mac_addr);})
|
|
|
+ ->whereHas('logistics',function ($query){$query->where('logistic_id',15);})
|
|
|
+ ->first();
|
|
|
+ $print = $print->printer_name??'EK100B';
|
|
|
return view('transport.waybill.index', [
|
|
|
'waybills' => $waybills,
|
|
|
'logistics' => $logisticService->getSelection(["id","name"],"物流"),
|
|
|
'owners' => $ownerService->getIntersectPermitting(),
|
|
|
"carTypes" => CarType::query()->get(),
|
|
|
'paginateParams'=>$paginateParams,
|
|
|
- 'uriType'=>$request->uriType??'']);
|
|
|
+ 'uriType'=>$request->uriType??'','print_name'=> $print]);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -770,10 +778,12 @@ SQL;
|
|
|
])->direct();
|
|
|
}
|
|
|
|
|
|
- private function deliveringQuery(Request $request): Builder
|
|
|
- {
|
|
|
- $waybills= Waybill::query()->where("type","专线")->with(["order","logistic"])
|
|
|
- ->whereNotNull("logistic_id")->whereNotNull("deliver_at")->whereIn("status",["已审核","待终审"]);
|
|
|
+ //发运
|
|
|
+ public function delivering(Request $request){
|
|
|
+ if (!Auth::user())return view('exception.login');
|
|
|
+ $waybills= Waybill::query()->where("type","专线")
|
|
|
+ ->whereNotNull("logistic_id")->whereNotIn("status",["未审核","待重审"])
|
|
|
+ ->orderByDesc("id");
|
|
|
if (!Auth::user()->isSuperAdmin()){
|
|
|
$carriersUsers=DB::table('logistic_user')->where('user_id',Auth::id())->get();
|
|
|
$carrierIds=array_column($carriersUsers->toArray(),'logistic_id');
|
|
|
@@ -783,31 +793,12 @@ SQL;
|
|
|
if ($searchText)$waybills->where(function ($query)use($searchText){
|
|
|
$query->where("waybill_number",'like','%'.$searchText.'%')->orWhere("carrier_bill",'like','%'.$searchText.'%');
|
|
|
});
|
|
|
- $lastId = $request->get("lastId","");
|
|
|
- if ($lastId)$waybills->where("id","<",$lastId);
|
|
|
- $date = $request->get("date");
|
|
|
- if ($date)$waybills->where("deliver_at",'like',$date."%");
|
|
|
- return $waybills;
|
|
|
- }
|
|
|
- //发运
|
|
|
- public function delivering(Request $request){
|
|
|
- $groups = $this->deliveringQuery($request)->selectRaw("date_format(deliver_at, '%Y-%m-%d') date")
|
|
|
- ->orderByDesc(DB::raw("date"))->groupByRaw("date")->get();
|
|
|
- $searchText = $request->get("searchText","");
|
|
|
- return view('transport.waybill.delivering',compact('groups',"searchText"));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 懒加载发运数据
|
|
|
- */
|
|
|
- public function loadData(Request $request)
|
|
|
- {
|
|
|
- if (!Auth::user())$this->error("登录信息失效");
|
|
|
- $this->success($this->deliveringQuery($request)->orderByDesc("id")->get());
|
|
|
+ $waybills = $waybills->get();
|
|
|
+ return view('transport.waybill.delivering',compact('waybills',"searchText"));
|
|
|
}
|
|
|
//承运商提交
|
|
|
public function storeCarrierBill(Request $request){
|
|
|
- if(!Gate::allows("运输管理-承运商调度"))return ["error"=>"无权操作!"];
|
|
|
+ //if(!Gate::allows("运输管理-承运商调度"))return ["error"=>"无权操作!"];
|
|
|
$errors=Validator::make($request->input(),[
|
|
|
'id'=>'required|integer',
|
|
|
'carrier_bill'=>'required',
|
|
|
@@ -833,16 +824,10 @@ 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->id);
|
|
|
- $request->offsetSet("carrier_weight_unit_id_other",$unit->id);
|
|
|
- $request->offsetSet("amount_unit_id",$unit1->id);
|
|
|
- $request->offsetSet("status","待终审");
|
|
|
+ $request->offsetSet("carrier_weight_unit_id",$unit2);
|
|
|
+ $request->offsetSet("carrier_weight_unit_id_other",$unit);
|
|
|
+ $request->offsetSet("amount_unit_id",$unit1);
|
|
|
$waybill->fill($request->input());
|
|
|
- WaybillAuditLog::query()->create([
|
|
|
- 'waybill_id'=>$waybill->id,
|
|
|
- 'audit_stage'=>'调度阶段',
|
|
|
- 'user_id'=>Auth::id(),
|
|
|
- ]);
|
|
|
$waybill->update();
|
|
|
return $waybill;
|
|
|
}
|
|
|
@@ -1119,9 +1104,11 @@ SQL;
|
|
|
for ($i=1;$i<$waybills->count();$i++){
|
|
|
//信息一致性校验
|
|
|
$identical = ($waybill->order && ($waybills[$i]->order->consignee_name!=$waybill->order->consignee_name
|
|
|
- || $waybills[$i]->order->consignee_phone!=$waybill->order->consignee_phone)) ||
|
|
|
+ || $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]->recipient_mobile!=$waybill->recipient_mobile
|
|
|
+ || $waybills[$i]->destination!=$waybill->destination));
|
|
|
if (array_search($waybills[$i]->status,["未审核","已审核"])===false
|
|
|
|| $identical)$this->error("信息不一致,无法进行合并");
|
|
|
$destroys[] = $waybills[$i]->id;
|
|
|
@@ -1274,7 +1261,8 @@ 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->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 : '';
|
|
|
@@ -1291,7 +1279,6 @@ 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);
|