|
|
@@ -58,7 +58,6 @@ class WaybillController extends Controller
|
|
|
*/
|
|
|
public function index(Request $request,OwnerService $ownerService,LogisticService $logisticService)
|
|
|
{
|
|
|
- if(!Gate::allows('运输管理-运单-查询')){ return view("exception.authority"); }
|
|
|
$paginateParams = $request->input();
|
|
|
$waybills=app('waybillService')->paginate($request->input());
|
|
|
$mac_addr = getMacAddr();
|
|
|
@@ -778,12 +777,10 @@ SQL;
|
|
|
])->direct();
|
|
|
}
|
|
|
|
|
|
- //发运
|
|
|
- public function delivering(Request $request){
|
|
|
- if (!Auth::user())return view('exception.login');
|
|
|
- $waybills= Waybill::query()->where("type","专线")
|
|
|
- ->whereNotNull("logistic_id")->whereNotIn("status",["未审核","待重审"])
|
|
|
- ->orderByDesc("id");
|
|
|
+ private function deliveringQuery(Request $request): Builder
|
|
|
+ {
|
|
|
+ $waybills= Waybill::query()->where("type","专线")->with(["order","logistic"])
|
|
|
+ ->whereNotNull("logistic_id")->whereNotNull("deliver_at")->whereIn("status",["已审核","待终审"]);
|
|
|
if (!Auth::user()->isSuperAdmin()){
|
|
|
$carriersUsers=DB::table('logistic_user')->where('user_id',Auth::id())->get();
|
|
|
$carrierIds=array_column($carriersUsers->toArray(),'logistic_id');
|
|
|
@@ -793,12 +790,34 @@ SQL;
|
|
|
if ($searchText)$waybills->where(function ($query)use($searchText){
|
|
|
$query->where("waybill_number",'like','%'.$searchText.'%')->orWhere("carrier_bill",'like','%'.$searchText.'%');
|
|
|
});
|
|
|
- $waybills = $waybills->get();
|
|
|
- return view('transport.waybill.delivering',compact('waybills',"searchText"));
|
|
|
+ $lastId = $request->get("lastId","");
|
|
|
+ if ($lastId)$waybills->where("id","<",$lastId);
|
|
|
+ $deliverAt = $request->get("deliverAt");
|
|
|
+ if ($deliverAt)$waybills->where("deliver_at",$deliverAt);
|
|
|
+ $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)->limit(10)->orderByDesc("id")->get());
|
|
|
+ $this->success($this->deliveringQuery($request)->orderByDesc("id")->get());
|
|
|
}
|
|
|
//承运商提交
|
|
|
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',
|