|
|
@@ -4,7 +4,10 @@ namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
use App\Services\CarrierService;
|
|
|
+use App\Services\CarTypeService;
|
|
|
+use App\Services\CityService;
|
|
|
use App\Services\OwnerService;
|
|
|
+use App\Services\UnitService;
|
|
|
use App\Services\WaybillService;
|
|
|
use App\UploadFile;
|
|
|
use App\WaybillAuditLog;
|
|
|
@@ -70,50 +73,24 @@ class WaybillsController extends Controller
|
|
|
if(!Gate::allows('运输管理-录入')){ return redirect(url('/')); }
|
|
|
$id=false;
|
|
|
$this->validatorWaybill($request,$id)->validate();
|
|
|
- $data=$request->input();
|
|
|
-
|
|
|
- $waybill=new Waybill([
|
|
|
- 'type'=>$data['type'],
|
|
|
- 'status'=>'未审核',
|
|
|
- 'waybill_number'=>Uuid::uuid1(),
|
|
|
- 'owner_id'=>$data['owner_id'],
|
|
|
- 'wms_bill_number'=>$data['wms_bill_number'],
|
|
|
- 'origination'=>$data['origination'],
|
|
|
- 'destination'=>$data['destination'],
|
|
|
- 'recipient'=>$data['recipient'],
|
|
|
- 'recipient_mobile'=>$data['recipient_mobile'],
|
|
|
- 'charge'=>$data['charge'],
|
|
|
- 'ordering_remark'=>$data['ordering_remark']
|
|
|
- ]);
|
|
|
- if (isset($data['collect_fee'])&&$data['collect_fee']>0)$waybill->collect_fee=$data['collect_fee'];
|
|
|
- $waybill->save();
|
|
|
- $number_id=$waybill->id;
|
|
|
- if ($data['type']=='直发车'){
|
|
|
- $waybill_number='BSZF'.date ("ymd").str_pad($number_id>99999?$number_id%99999:$number_id,4,"0",STR_PAD_LEFT);
|
|
|
- $waybill->waybill_number=$waybill_number;
|
|
|
- $waybill->update();
|
|
|
- }else{
|
|
|
- $waybill_number='BSZX'.date ("ymd").str_pad($number_id>99999?$number_id%99999:$number_id,4,"0",STR_PAD_LEFT);
|
|
|
- $waybill->waybill_number=$waybill_number;
|
|
|
- $waybill->update();
|
|
|
- }
|
|
|
+ $waybill=app('waybillService')->store($request);
|
|
|
$this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
|
|
|
- return redirect('waybill/index')->with('successTip','新运单“'.$waybill_number.'”录入成功');
|
|
|
+ return redirect('waybill/index')->with('successTip','新运单“'.$waybill->waybill_number.'”录入成功');
|
|
|
}
|
|
|
|
|
|
- public function edit($id)
|
|
|
+ public function edit($id,CarrierService $carrierService,CarTypeService $carTypeService,
|
|
|
+ CityService $cityService,UnitService $unitService)
|
|
|
{
|
|
|
if(!Gate::allows('运输管理-编辑')){ return redirect(url('/')); }
|
|
|
- $waybill=Waybill::find($id);
|
|
|
+ $waybill = app('waybillService')->find($id);
|
|
|
if ($waybill->deliver_at){
|
|
|
$waybill->deliver_at_date=Carbon::parse($waybill->deliver_at)->format('Y-m-d');
|
|
|
$waybill->deliver_at_time=Carbon::parse($waybill->deliver_at)->format('H:i:s');
|
|
|
}
|
|
|
- $carriers=Carrier::get();
|
|
|
- $cities=City::get();
|
|
|
- $units=Unit::get();
|
|
|
- $carTypes=CarType::get();
|
|
|
- return view('waybill/edit',['waybill'=>$waybill,'carriers'=>$carriers,'cities'=>$cities,'units'=>$units,'carTypes'=>$carTypes]);
|
|
|
+ $cities=$cityService->selectGet();
|
|
|
+ $units=$unitService->selectGet();
|
|
|
+ $carTypes=$carTypeService->selectGet();
|
|
|
+ return view('waybill/edit',['waybill'=>$waybill,'carriers'=>$carrierService->selectGet(),'cities'=>$cities,'units'=>$units,'carTypes'=>$carTypes]);
|
|
|
}
|
|
|
|
|
|
public function update(Request $request, $id)
|