|
|
@@ -55,29 +55,145 @@ class WaybillsController extends Controller
|
|
|
if ($request->input('created_at_end')){
|
|
|
$waybills=$waybills->where('created_at','<',$request->input('created_at_end'));
|
|
|
}
|
|
|
- if ($request->input('type')){
|
|
|
- $waybills=$waybills->where('type','=',$request->input('type'));
|
|
|
- }
|
|
|
$waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50);
|
|
|
+ if (!$waybills&&$request->input('waybill_number')){
|
|
|
+ $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
|
|
|
+ return $query->with('user');
|
|
|
+ }])->orderBy('id','DESC')->where('type','专线')->where('waybill_number',$request->input('waybill_number'))
|
|
|
+ ->paginate($request->input('paginate')?$request->input('paginate'):50);
|
|
|
+ }
|
|
|
$carries = Carrier::get();
|
|
|
$owners = Owner::get();
|
|
|
- return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data]);
|
|
|
+ return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'']);
|
|
|
} else {
|
|
|
$waybills = Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
|
|
|
return $query->with('user');
|
|
|
}])->paginate(50);
|
|
|
$carries = Carrier::get();
|
|
|
$owners = Owner::get();
|
|
|
- return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data]);
|
|
|
+ return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'']);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function indexZF(Request $request){
|
|
|
+ if(!Gate::allows('运单管理-查询')){ return redirect(url('/')); }
|
|
|
+ $data=$request->input();
|
|
|
+ if ($data != null ) {
|
|
|
+ $today=Carbon::now()->subDays(15);
|
|
|
+ $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
|
|
|
+ return $query->with('user');
|
|
|
+ }])->orderBy('id','DESC')->where('type','直发车');
|
|
|
+ if ($request->input('waybill_number')){
|
|
|
+ $waybills =$waybills->where('waybill_number','like','%'.$request->input('waybill_number').'%')->where('created_at','>',$today->format('Y-m-d'));
|
|
|
+ }
|
|
|
+ if ($request->input('carrier_bill')){
|
|
|
+ $waybills=$waybills->where('carrier_bill','like','%'.$request->input('carrier_bill').'%')->where('created_at','>',$today->format('Y-m-d'));
|
|
|
+ }
|
|
|
+ if ($request->input('carrier_id')){
|
|
|
+ $waybills=$waybills->where('carrier_id','=',$request->input('carrier_id'));
|
|
|
+ }
|
|
|
+ if ($request->input('owner_id')){
|
|
|
+ $waybills=$waybills->where('owner_id','=',$request->input('owner_id'));
|
|
|
+ }
|
|
|
+ if ($request->input('wms_bill_number')){
|
|
|
+ $waybills=$waybills->where('wms_bill_number','like','$'.$request->input('wms_bill_number').'%')->where('created_at','>',$today->format('Y-m-d'));
|
|
|
+ }
|
|
|
+ if ($request->input('created_at_start')){
|
|
|
+ $waybills=$waybills->where('created_at','>',$request->input('created_at_start'));
|
|
|
+ }
|
|
|
+ if ($request->input('created_at_end')){
|
|
|
+ $waybills=$waybills->where('created_at','<',$request->input('created_at_end'));
|
|
|
+ }
|
|
|
+ $waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50);
|
|
|
+ if (!$waybills&&$request->input('waybill_number')){
|
|
|
+ $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
|
|
|
+ return $query->with('user');
|
|
|
+ }])->orderBy('id','DESC')->where('type','专线')->where('waybill_number',$request->input('waybill_number'))
|
|
|
+ ->paginate($request->input('paginate')?$request->input('paginate'):50);
|
|
|
+ }
|
|
|
+ $carries = Carrier::get();
|
|
|
+ $owners = Owner::get();
|
|
|
+ return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'ZF']);
|
|
|
+ } else {
|
|
|
+ $waybills = Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
|
|
|
+ return $query->with('user');
|
|
|
+ }])->where('type','直发车')->paginate(50);
|
|
|
+ $carries = Carrier::get();
|
|
|
+ $owners = Owner::get();
|
|
|
+ return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'ZF']);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public function indexZX(Request $request){
|
|
|
+ if(!Gate::allows('运单管理-查询')){ return redirect(url('/')); }
|
|
|
+ $data=$request->input();
|
|
|
+ if ($data != null ) {
|
|
|
+ $today=Carbon::now()->subDays(15);
|
|
|
+ $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
|
|
|
+ return $query->with('user');
|
|
|
+ }])->orderBy('id','DESC')->where('type','专线');
|
|
|
+ if ($request->input('waybill_number')){
|
|
|
+ $waybills =$waybills->where('waybill_number','like','%'.$request->input('waybill_number').'%')->where('created_at','>',$today->format('Y-m-d'));
|
|
|
+ }
|
|
|
+ if ($request->input('carrier_bill')){
|
|
|
+ $waybills=$waybills->where('carrier_bill','like','%'.$request->input('carrier_bill').'%')->where('created_at','>',$today->format('Y-m-d'));
|
|
|
+ }
|
|
|
+ if ($request->input('carrier_id')){
|
|
|
+ $waybills=$waybills->where('carrier_id','=',$request->input('carrier_id'));
|
|
|
+ }
|
|
|
+ if ($request->input('owner_id')){
|
|
|
+ $waybills=$waybills->where('owner_id','=',$request->input('owner_id'));
|
|
|
+ }
|
|
|
+ if ($request->input('wms_bill_number')){
|
|
|
+ $waybills=$waybills->where('wms_bill_number','like','$'.$request->input('wms_bill_number').'%')->where('created_at','>',$today->format('Y-m-d'));
|
|
|
+ }
|
|
|
+ if ($request->input('created_at_start')){
|
|
|
+ $waybills=$waybills->where('created_at','>',$request->input('created_at_start'));
|
|
|
+ }
|
|
|
+ if ($request->input('created_at_end')){
|
|
|
+ $waybills=$waybills->where('created_at','<',$request->input('created_at_end'));
|
|
|
+ }
|
|
|
+ $waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50);
|
|
|
+ if (!$waybills&&$request->input('waybill_number')){
|
|
|
+ $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
|
|
|
+ return $query->with('user');
|
|
|
+ }])->orderBy('id','DESC')->where('type','专线')->where('waybill_number',$request->input('waybill_number'))
|
|
|
+ ->paginate($request->input('paginate')?$request->input('paginate'):50);
|
|
|
+ }
|
|
|
+ $carries = Carrier::get();
|
|
|
+ $owners = Owner::get();
|
|
|
+ return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'ZX']);
|
|
|
+ } else {
|
|
|
+ $waybills = Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
|
|
|
+ return $query->with('user');
|
|
|
+ }])->where('type','专线')->paginate(50);
|
|
|
+ $carries = Carrier::get();
|
|
|
+ $owners = Owner::get();
|
|
|
+ return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'ZX']);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function create()
|
|
|
{
|
|
|
if(!Gate::allows('运单管理-录入')){ return redirect(url('/')); }
|
|
|
$owners=Owner::get();
|
|
|
return view('waybill.create',['owners'=>$owners]);
|
|
|
}
|
|
|
+ public function createZF()
|
|
|
+ {
|
|
|
+ if(!Gate::allows('运单管理-录入')){ return redirect(url('/')); }
|
|
|
+ $owners=Owner::get();
|
|
|
+ return view('waybill.create',['owners'=>$owners,'type'=>'直发车']);
|
|
|
+ }
|
|
|
+ public function createZX()
|
|
|
+ {
|
|
|
+ if(!Gate::allows('运单管理-录入')){ return redirect(url('/')); }
|
|
|
+ $owners=Owner::get();
|
|
|
+ return view('waybill.create',['owners'=>$owners,'type'=>'专线']);
|
|
|
+ }
|
|
|
|
|
|
public function store(Request $request)
|
|
|
{
|
|
|
@@ -96,7 +212,7 @@ class WaybillsController extends Controller
|
|
|
'recipient'=>$data['recipient'],
|
|
|
'recipient_mobile'=>$data['recipient_mobile'],
|
|
|
'charge'=>$data['charge'],
|
|
|
- 'collect_fee'=>$data['charge'],
|
|
|
+ 'collect_fee'=>isset($data['collect_fee'])?$data['collect_fee']:0,
|
|
|
'ordering_remark'=>$data['ordering_remark']
|
|
|
]);
|
|
|
$waybill->save();
|
|
|
@@ -263,26 +379,32 @@ class WaybillsController extends Controller
|
|
|
]);
|
|
|
$waybillAuditLog->save();
|
|
|
$waybillAuditLog['user']=Auth::user();
|
|
|
- $waybillPayoff=WaybillPayoff::where('waybill_id','=',$id)->first();
|
|
|
- $waybillPayoff->load(["waybill"]);
|
|
|
- $waybillPayoff->waybill->load(["owner","carrier","origination_city","destination_city","warehouse_weight_unit","carrier_weight_unit","carType","waybillAuditLogs"]);
|
|
|
- $waybillPayoff->waybill->waybillAuditLogs->load(["user"]);
|
|
|
- $waybillPayoffJson=json_encode($waybillPayoff,JSON_UNESCAPED_UNICODE);
|
|
|
- if ($waybill->waybill_price_model_id){
|
|
|
+ if ($waybill->waybill_price_model_id||$waybill->type=='直发车'){
|
|
|
+ $waybill->state='完结';
|
|
|
+ $result=$waybill->save();
|
|
|
+ $waybillPayoff=WaybillPayoff::where('waybill_id','=',$id)->first();
|
|
|
+ $waybillPayoff->load(["waybill"]);
|
|
|
+ $waybillPayoff->waybill->load(["owner","carrier","origination_city","destination_city","warehouse_weight_unit","carrier_weight_unit","carType","waybillAuditLogs"]);
|
|
|
+ $waybillPayoff->waybill->waybillAuditLogs->load(["user"]);
|
|
|
+ $waybillPayoffJson=json_encode($waybillPayoff,JSON_UNESCAPED_UNICODE);
|
|
|
WaybillFinancialSnapshot::create([
|
|
|
'waybill_id'=>$id,
|
|
|
'json_content'=>$waybillPayoffJson,
|
|
|
]);
|
|
|
- $waybill->state='完结';
|
|
|
+
|
|
|
}else{
|
|
|
+ $waybill->state='未定义计费模型';
|
|
|
+ $result=$waybill->save();
|
|
|
+ $waybillPayoff=WaybillPayoff::where('waybill_id','=',$id)->first();
|
|
|
+ $waybillPayoff->load(["waybill"]);
|
|
|
+ $waybillPayoff->waybill->load(["owner","carrier","origination_city","destination_city","warehouse_weight_unit","carrier_weight_unit","carType","waybillAuditLogs"]);
|
|
|
+ $waybillPayoff->waybill->waybillAuditLogs->load(["user"]);
|
|
|
+ $waybillPayoffJson=json_encode($waybillPayoff,JSON_UNESCAPED_UNICODE);
|
|
|
WaybillFinancialExcepted::create([
|
|
|
'waybill_id'=>$id,
|
|
|
'json_content'=>$waybillPayoffJson,
|
|
|
]);
|
|
|
- $waybill->state='未定义计费模型';
|
|
|
}
|
|
|
-
|
|
|
- $result=$waybill->save();
|
|
|
$this->log(__METHOD__,__FUNCTION__,$waybillPayoffJson,Auth::user()['id']);
|
|
|
return ['success'=>$result,'state'=>$waybill->state,'waybillAuditLog'=>$waybillAuditLog];
|
|
|
}
|
|
|
@@ -311,6 +433,7 @@ class WaybillsController extends Controller
|
|
|
'carrier_weight'=>'承运商计重(抛)',
|
|
|
'carrier_weight_unit'=>'承运商计重单位',
|
|
|
'carType'=>'车型',
|
|
|
+ 'car_owner_info'=>'车辆信息',
|
|
|
'fee'=>'运费(元)',
|
|
|
'pick_up_fee'=>'提货费(元)',
|
|
|
'other_fee'=>'其他费用(元)',
|
|
|
@@ -357,6 +480,7 @@ class WaybillsController extends Controller
|
|
|
'carrier_weight'=>isset($waybill->carrier_weight)?$waybill->carrier_weight:'',
|
|
|
'carrier_weight_unit'=>isset($waybill->carrier_weight_unit_name)?$waybill->carrier_weight_unit_name:'',
|
|
|
'carType'=>isset($waybill->carType->name)?$waybill->carType->name.($waybill->carType->length.'米'):'',
|
|
|
+ 'car_owner_info'=>isset($waybill->car_owner_info)?$waybill->car_owner_info:'',
|
|
|
'fee'=>isset($waybill->fee)?$waybill->fee:'',
|
|
|
'pick_up_fee'=>isset($waybill->pick_up_fee)?$waybill->pick_up_fee:'',
|
|
|
'other_fee'=>isset($waybill->other_fee)?$waybill->other_fee:'',
|
|
|
@@ -378,7 +502,7 @@ class WaybillsController extends Controller
|
|
|
'origination'=>'required|max:255',
|
|
|
'destination'=>'required|max:255',
|
|
|
'recipient'=>'required|max:50',
|
|
|
- 'recipient_mobile'=>['required','regex:/^(0\d{6,10})|(1[3|4|5|7|8][0-9]\d{4,8})$/'],
|
|
|
+ 'recipient_mobile'=>['required','regex:/^(\d{7,11})|(1[3|4|5|7|8][0-9]\d{4,8})$/'],
|
|
|
'charge'=>'required|min:0|numeric',
|
|
|
'collect_fee'=>'nullable|min:0|numeric',
|
|
|
],[
|