Преглед изворни кода

Merge branch 'waybill_ZD'

# Conflicts:
#	resources/views/waybill/index.blade.php
LD пре 6 година
родитељ
комит
54a431fdc4
35 измењених фајлова са 1254 додато и 152 уклоњено
  1. 29 2
      app/Http/Controllers/MeasureMonitorController.php
  2. 21 10
      app/Http/Controllers/MeasuringMachineController.php
  3. 108 0
      app/Http/Controllers/PackageController.php
  4. 1 0
      app/Http/Controllers/WaybillPriceModelsController.php
  5. 29 14
      app/Http/Controllers/WaybillsController.php
  6. 5 5
      app/Listeners/WaybillPriceModelListener.php
  7. 25 0
      app/Package.php
  8. 1 1
      app/Waybill.php
  9. 12 0
      database/factories/PackagesFactory.php
  10. 0 2
      database/migrations/2019_11_22_094057_create_waybill_payoffs_table.php
  11. 1 1
      database/migrations/2019_11_22_094311_create_waybill_price_models_table.php
  12. 1 1
      database/migrations/2019_11_28_152321_create_waybill_audit_logs_table.php
  13. 3 3
      database/migrations/2019_12_27_105125_create_paper_boxes_table.php
  14. 11 1
      database/migrations/2019_12_30_114648_add_weigh_authority.php
  15. 2 2
      database/migrations/2019_12_30_143601_create_measuring_machines_table.php
  16. 42 0
      database/migrations/2019_12_30_171202_create_packages_table.php
  17. 34 0
      database/migrations/2020_01_02_102517_change_waybill_status.php
  18. 32 0
      database/migrations/2020_01_02_172739_change_waybill_price_model_field.php
  19. BIN
      public/icon/off.png
  20. BIN
      public/icon/on.png
  21. 2 2
      resources/views/maintenance/measuringMachine/edit.blade.php
  22. 1 1
      resources/views/waybill/edit.blade.php
  23. 7 7
      resources/views/waybill/index.blade.php
  24. 63 23
      resources/views/weigh/measureMonitor/index.blade.php
  25. 1 1
      resources/views/weigh/menu.blade.php
  26. 169 0
      resources/views/weigh/package/index.blade.php
  27. 10 0
      resources/views/weigh/package/menu.blade.php
  28. 1 0
      routes/web.php
  29. 53 0
      tests/Unit/MeasureMonitorTest.php
  30. 142 0
      tests/Unit/MeasuringMachineTest.php
  31. 88 0
      tests/Unit/PackageTest.php
  32. 156 0
      tests/Unit/PaperBoxTest.php
  33. 14 14
      tests/Unit/WaybillPriceModelTest.php
  34. 189 61
      tests/Unit/WaybillTest.php
  35. 1 1
      tests/codeCoverage/Waybill.php.html

+ 29 - 2
app/Http/Controllers/MeasureMonitorController.php

@@ -2,7 +2,11 @@
 
 namespace App\Http\Controllers;
 
+use App\MeasuringMachine;
+use App\Package;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Gate;
 
 class MeasureMonitorController extends Controller
 {
@@ -11,9 +15,32 @@ class MeasureMonitorController extends Controller
      *
      * @return \Illuminate\Http\Response
      */
-    public function index()
+    public function index(Request $request)
     {
-        return view('weigh.measureMonitor.index');
+        if(!Gate::allows('包裹信息-查询')){ return redirect(url('/'));  }
+        /*$sql='SELECT a.* FROM packages a WHERE id = (SELECT MAX(id) FROM packages WHERE measuring_machine_id = a.measuring_machine_id) ORDER BY a.id';
+        $packages=DB::table(DB::raw("($sql) as t"))->get();*/
+        $measuring_machine_id=[];
+        /*        for ($i=0;$i<count($measuringMachine);$i++){
+            $measuring_machine_id[$i]=$measuringMachine[$i]->id;
+        }
+        dd($measuring_machine_id);*/
+        $measuring_machine_id=$request->input('id');
+        $measuringMachines=MeasuringMachine::select('id','name','code')->get();
+        if (empty($measuringMachines)){
+            dd($measuringMachines);
+            if (!$measuring_machine_id){
+                $package=Package::with('owner','paperBox','measuringMachine')->where('measuring_machine_id',$measuringMachines[0]->id)->orderBy('id','DESC')->first();
+            }else{
+                $package=Package::with('owner','paperBox','measuringMachine')->where('measuring_machine_id',$measuring_machine_id)->orderBy('id','DESC')->first();
+                if (!$package){
+                    $measuringMachine=MeasuringMachine::where('id',$measuring_machine_id)->first();
+                    $package=new Package();
+                    if ($measuringMachine)$package->measuringMachine=$measuringMachine;
+                }
+            }
+        }
+        return view('weigh.measureMonitor.index',['package'=>isset($package)?$package:null,'measuringMachines'=>$measuringMachines]);
     }
 
     /**

+ 21 - 10
app/Http/Controllers/MeasuringMachineController.php

@@ -4,6 +4,8 @@ namespace App\Http\Controllers;
 
 use App\MeasuringMachine;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Gate;
 use Illuminate\Support\Facades\Validator;
 
 class MeasuringMachineController extends Controller
@@ -15,6 +17,7 @@ class MeasuringMachineController extends Controller
      */
     public function index()
     {
+        if(!Gate::allows('测量设备-查询')){ return redirect(url('/'));  }
         $measuringMachines=MeasuringMachine::orderBy('id','DESC')->paginate(50);
         return view('maintenance.measuringMachine.index',['measuringMachines'=>$measuringMachines]);
     }
@@ -26,6 +29,7 @@ class MeasuringMachineController extends Controller
      */
     public function create()
     {
+        if(!Gate::allows('测量设备-录入')){ return redirect(url('/'));  }
         return view('maintenance.measuringMachine.create');
     }
 
@@ -37,6 +41,7 @@ class MeasuringMachineController extends Controller
      */
     public function store(Request $request)
     {
+        if(!Gate::allows('测量设备-录入')){ return redirect(url('/'));  }
         $id=false;
         $this->validator($request,$id)->validate();
         MeasuringMachine::create($request->input());
@@ -57,35 +62,41 @@ class MeasuringMachineController extends Controller
     /**
      * Show the form for editing the specified resource.
      *
-     * @param  \App\MeasuringMachine  $measuringMachine
      * @return \Illuminate\Http\Response
      */
-    public function edit(MeasuringMachine $measuringMachine)
+    public function edit($id)
     {
-        //
+        if(!Gate::allows('测量设备-编辑')){ return redirect(url('/'));  }
+        $measuringMachine=MeasuringMachine::find($id);
+        return view('maintenance.measuringMachine.edit',['measuringMachine'=>$measuringMachine]);
     }
 
     /**
      * Update the specified resource in storage.
      *
      * @param  \Illuminate\Http\Request  $request
-     * @param  \App\MeasuringMachine  $measuringMachine
      * @return \Illuminate\Http\Response
      */
-    public function update(Request $request, MeasuringMachine $measuringMachine)
+    public function update(Request $request, $id)
     {
-        //
+        if(!Gate::allows('测量设备-编辑')){ return redirect(url('/'));  }
+        $this->validator($request,$id)->validate();
+        $measuringMachine=MeasuringMachine::find($id);
+        $measuringMachine->fill($request->input());
+        $measuringMachine->save();
+        return redirect('maintenance/measuringMachine')->with('successTip','新设备“'.$request->input('name').'”更新成功');
     }
 
     /**
      * Remove the specified resource from storage.
      *
-     * @param  \App\MeasuringMachine  $measuringMachine
-     * @return \Illuminate\Http\Response
      */
-    public function destroy(MeasuringMachine $measuringMachine)
+    public function destroy($id)
     {
-        //
+        if(!Gate::allows('测量设备-删除')){ return redirect(url('/'));  }
+        $measuringMachine=MeasuringMachine::find($id)->delete();
+        $this->log(__METHOD__,__FUNCTION__,json_encode($measuringMachine),Auth::user()['id']);
+        if ($measuringMachine)return ['success'=>true];
     }
 
     public function validator(Request $request,$id){

+ 108 - 0
app/Http/Controllers/PackageController.php

@@ -0,0 +1,108 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Owner;
+use App\Package;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Gate;
+
+class PackageController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index(Request $request)
+    {
+        if(!Gate::allows('包裹信息-查询')){ return redirect(url('/'));  }
+        if ($request->input()){
+            $packages=Package::with('owner','paperBox','measuringMachine')->orderBy('id','DESC');
+            if ($request->input('logistic_number')){
+                $packages=$packages->where('logistic_number',$request->input('logistic_number'));
+            }
+            if ($request->input('type')){
+                $packages=$packages->where('type',$request->input('type'));
+            }
+            if ($request->input('status')){
+                $packages=$packages->where('status',$request->input('status'));
+            }
+            if ($request->input('owner_id')){
+                $packages=$packages->where('owner_id',$request->input('owner_id'));
+            }
+            $packages=$packages->paginate($request->input('paginate')?$request->input('paginate'):50);
+            $owners=Owner::select('id','name')->get();
+            return view('weigh.package.index',['packages'=>$packages,'owners'=>$owners]);
+        }
+        $packages=Package::with('owner','paperBox','measuringMachine')->orderBy('id','DESC')->paginate(50);
+        $owners=Owner::select('id','name')->get();
+        return view('weigh.package.index',['packages'=>$packages,'owners'=>$owners]);
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\Package  $packages
+     * @return \Illuminate\Http\Response
+     */
+    public function show(Package $packages)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\Package  $packages
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(Package $packages)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\Package  $packages
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, Package $packages)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\Package  $packages
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(Package $packages)
+    {
+        //
+    }
+}

+ 1 - 0
app/Http/Controllers/WaybillPriceModelsController.php

@@ -153,6 +153,7 @@ class WaybillPriceModelsController extends Controller
                 $exception=Cache::get('exception');
                 $a='';
                 for ($i=0;$i<count($exception);$i++){$a.=implode(',',$exception[$i]).'&#10'; };
+                $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
                 return '<h1 class="text-danger">导入Excel成功<br><textarea style="width: 50%;height: 50%">'.$a.'</textarea></h1>';
             }
         }else{

+ 29 - 14
app/Http/Controllers/WaybillsController.php

@@ -61,8 +61,8 @@ class WaybillsController extends Controller
             if ($request->input('created_at_end')){
                 $waybills=$waybills->where('created_at','<',$request->input('created_at_end'));
             }
-            if ($request->input('state')){
-                $waybills=$waybills->where('state',$request->input('state'));
+            if ($request->input('status')){
+                $waybills=$waybills->where('status',$request->input('status'));
             }
             $waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50);
             if (!$waybills&&$request->input('waybill_number')){
@@ -114,8 +114,8 @@ class WaybillsController extends Controller
             if ($request->input('created_at_end')){
                 $waybills=$waybills->where('created_at','<',$request->input('created_at_end'));
             }
-            if ($request->input('state')){
-                $waybills=$waybills->where('state',$request->input('state'));
+            if ($request->input('status')){
+                $waybills=$waybills->where('status',$request->input('status'));
             }
             $waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50);
             if (!$waybills&&$request->input('waybill_number')){
@@ -167,8 +167,8 @@ class WaybillsController extends Controller
             if ($request->input('created_at_end')){
                 $waybills=$waybills->where('created_at','<',$request->input('created_at_end'));
             }
-            if ($request->input('state')){
-                $waybills=$waybills->where('state',$request->input('state'));
+            if ($request->input('status')){
+                $waybills=$waybills->where('status',$request->input('status'));
             }
             $waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50);
             if (!$waybills&&$request->input('waybill_number')){
@@ -219,7 +219,7 @@ class WaybillsController extends Controller
 
         $waybill=new Waybill([
             'type'=>$data['type'],
-            'state'=>'未审核',
+            'status'=>'未审核',
             'waybill_number'=>Uuid::uuid1(),
             'owner_id'=>$data['owner_id'],
             'wms_bill_number'=>$data['wms_bill_number'],
@@ -281,6 +281,9 @@ class WaybillsController extends Controller
                     }else{
                         $fee=(($waybillPriceModel->unit_price)*$carrier_weight)+$carrier->delivery_fee;
                     }
+                    if ($waybillPriceModel->base_fee&&$fee<$waybillPriceModel->base_fee){
+                        $fee=$waybillPriceModel->base_fee;
+                    }
                     $waybill->fee=$fee;
                     $waybill->waybill_price_model_id=$waybillPriceModel_id;
                 }
@@ -314,6 +317,7 @@ class WaybillsController extends Controller
     }
 
     public function checkWaybillPriceModel($carrier_id,$destination_city_id,$carrier_weight,$carrier_weight_unit_id){
+        //确保承运商计数与计数单位为一个数组且长度2
         if(!$carrier_id)return false;
         if(!$destination_city_id)return false;
         if(!$carrier_weight)return false;
@@ -408,6 +412,13 @@ class WaybillsController extends Controller
         return false;
     }
 
+    /*三层条件:无优先级,找到第一个直接返回
+     *      无论是否为KG||T,计数单位一为KG,计数单位一为T,计数单位二为KG,计数单位二为T
+     *          计数一与计数二同时存在取最贵价格:
+     *          计数一存在,二不存在:
+     *          计数二存在,一不存在:
+     *              城市价格区间不为空,城市价格区间都为空,城市为空,价格区间为空
+     * */
     public function isWaybillPriceModel(Request $request){
         $carrier_id=$request->input('carrier_id');
         $destination_city_id=$request->input('destination_city_id');
@@ -422,21 +433,25 @@ class WaybillsController extends Controller
                 $carrier_weight_unit_id[0]=$unitT->id;
                 $carrier_weight[0]=$carrier_weight[0]/1000;
                 $result=$this->checkWaybillPriceModel($carrier_id,$destination_city_id,$carrier_weight,$carrier_weight_unit_id);
+                if ($result)return ['success'=>$result];
             }
             if ($carrier_weight_unit_id[1]==$unitKG->id){
                 $carrier_weight_unit_id[1]=$unitT->id;
                 $carrier_weight[1]=$carrier_weight[1]/1000;
                 $result=$this->checkWaybillPriceModel($carrier_id,$destination_city_id,$carrier_weight,$carrier_weight_unit_id);
+                if ($result)return ['success'=>$result];
             }
             if ($carrier_weight_unit_id[0]==$unitT->id){
                 $carrier_weight_unit_id[0]=$unitKG->id;
                 $carrier_weight[0]=$carrier_weight[0]*1000;
                 $result=$this->checkWaybillPriceModel($carrier_id,$destination_city_id,$carrier_weight,$carrier_weight_unit_id);
+                if ($result)return ['success'=>$result];
             }
             if ($carrier_weight_unit_id[1]==$unitT->id){
                 $carrier_weight_unit_id[1]=$unitKG->id;
                 $carrier_weight[1]=$carrier_weight[1]*1000;
                 $result=$this->checkWaybillPriceModel($carrier_id,$destination_city_id,$carrier_weight,$carrier_weight_unit_id);
+                if ($result)return ['success'=>$result];
             }
         }
         return ['success'=>$result];
@@ -468,10 +483,10 @@ class WaybillsController extends Controller
             ]);
             $waybillAuditLog->save();
             $waybillAuditLog['user']=Auth::user();
-            $waybill->state='已审核';
+            $waybill->status='已审核';
             $result=$waybill->save();
             $this->log(__METHOD__,__FUNCTION__,json_encode($waybill),Auth::user()['id']);
-            return ['success'=>$result,'state'=>$waybill->state,'waybillAuditLog'=>$waybillAuditLog];
+            return ['success'=>$result,'status'=>$waybill->status,'waybillAuditLog'=>$waybillAuditLog];
         }
         return ['exception'=>'请勿重复审核!'];
     }
@@ -487,10 +502,10 @@ class WaybillsController extends Controller
         $id=$request->input('id');
         $waybill=Waybill::find($id);
         WaybillAuditLog::whereRaw('waybill_id = ? and audit_stage = ?',[$id,"运单阶段"])->delete();
-        $waybill->state='待重审';
+        $waybill->status='待重审';
         $result=$waybill->save();
         $this->log(__METHOD__,__FUNCTION__,json_encode($waybill),Auth::user()['id']);
-        return ['success'=>$result,'state'=>$waybill->state];
+        return ['success'=>$result,'status'=>$waybill->status];
     }
     public function waybillEndAudit(Request $request){
         if(!Gate::allows('运输管理-调度审核')){ return redirect(url('/'));  }
@@ -512,7 +527,7 @@ class WaybillsController extends Controller
             $waybillAuditLog->save();
             $waybillAuditLog['user']=Auth::user();
             if ($waybill->waybill_price_model_id||$waybill->type=='直发车'){
-                $waybill->state='已完结';
+                $waybill->status='已完结';
                 $result=$waybill->save();
                 $waybillPayoff=WaybillPayoff::where('waybill_id','=',$id)->first();
                 $waybillPayoff->load(["waybill"]);
@@ -524,7 +539,7 @@ class WaybillsController extends Controller
                     'json_content'=>$waybillPayoffJson,
                 ]);
             }else{
-                $waybill->state='未定义计费模型';
+                $waybill->status='无模型';
                 $result=$waybill->save();
                 $waybillPayoff=WaybillPayoff::where('waybill_id','=',$id)->first();
                 if ($waybillPayoff){
@@ -539,7 +554,7 @@ class WaybillsController extends Controller
                 }
             }
             $this->log(__METHOD__,__FUNCTION__,$waybillPayoffJson,Auth::user()['id']);
-            return ['success'=>$result,'state'=>$waybill->state,'waybillAuditLog'=>$waybillAuditLog];
+            return ['success'=>$result,'status'=>$waybill->status,'waybillAuditLog'=>$waybillAuditLog];
         }
         return ['exception'=>'请勿重复审核!'];
     }

+ 5 - 5
app/Listeners/WaybillPriceModelListener.php

@@ -36,7 +36,7 @@ class WaybillPriceModelListener
             //市不存在,价格区间不存在
             if (!$waybillPriceModel->range_max){
                 $waybills=Waybill::where('carrier_id',$waybillPriceModel->carrier_id)->whereIn('destination_city_id',$cityIds)
-                    ->where('type','专线')->where('state','!=','已完结')->where('carrier_weight_unit_id',$waybillPriceModel->unit_id)
+                    ->where('type','专线')->where('status','!=','已完结')->where('carrier_weight_unit_id',$waybillPriceModel->unit_id)
                     ->orWhere('carrier_weight_unit_id_other',$waybillPriceModel->unit_id)->get();
             }
             //市不存在,价格区间存在
@@ -44,7 +44,7 @@ class WaybillPriceModelListener
                 $waybills=Waybill::where('carrier_id',$waybillPriceModel->carrier_id)->whereIn('destination_city_id',$cityIds)
                     ->whereRaw('carrier_weight <= ? AND carrier_weight > ? AND carrier_weight_unit_id = ?',[$waybillPriceModel->range_max,$waybillPriceModel->range_min,$waybillPriceModel->unit_id])
                     ->orWhereRaw('carrier_weight_other <= ? AND carrier_weight_other > ? AND carrier_weight_unit_id_other = ?',[$waybillPriceModel->range_max,$waybillPriceModel->range_min,$waybillPriceModel->unit_id])
-                    ->where('type','专线')->where('state','!=','已完结')->get();
+                    ->where('type','专线')->where('status','!=','已完结')->get();
             }
         }
 
@@ -53,13 +53,13 @@ class WaybillPriceModelListener
             $waybills=Waybill::where('carrier_id',$waybillPriceModel->carrier_id)->where('destination_city_id',$waybillPriceModel->city_id)
                 ->whereRaw('carrier_weight <= ? AND carrier_weight > ? AND carrier_weight_unit_id = ?',[$waybillPriceModel->range_max,$waybillPriceModel->range_min,$waybillPriceModel->unit_id])
                 ->orWhereRaw('carrier_weight_other <= ? AND carrier_weight_other > ? AND carrier_weight_unit_id_other = ?',[$waybillPriceModel->range_max,$waybillPriceModel->range_min,$waybillPriceModel->unit_id])
-                ->where('type','专线')->where('state','!=','完结')->get();
+                ->where('type','专线')->where('status','!=','完结')->get();
         }
 
         //市存在,价格区间不存在
         if ($waybillPriceModel->city_id&&!$waybillPriceModel->range_max){
             $waybills=Waybill::where('carrier_id',$waybillPriceModel->carrier_id)->where('destination_city_id',$waybillPriceModel->city_id)
-                ->where('type','专线')->where('state','!=','完结')->where('carrier_weight_unit_id',$waybillPriceModel->unit_id)
+                ->where('type','专线')->where('status','!=','完结')->where('carrier_weight_unit_id',$waybillPriceModel->unit_id)
                 ->orWhere('carrier_weight_unit_id_other',$waybillPriceModel->unit_id)->get();
         }
         return $waybills;
@@ -110,7 +110,7 @@ class WaybillPriceModelListener
                     $waybillFinancialExcepted=WaybillFinancialExcepted::where('waybill_id',$waybill->id)->first();
                     if ($waybillFinancialExcepted){
                         $waybillFinancialExcepted->delete();
-                        $waybill->state='完结';
+                        $waybill->status='完结';
                         $waybillPayoff=WaybillPayoff::where('waybill_id','=',$waybillFinancialExcepted->waybill_id)->first();
                         $waybillPayoff->load(["waybill"]);
                         $waybillPayoff->waybill->load(["owner","carrier","origination_city","destination_city","warehouse_weight_unit","carrier_weight_unit","carType","waybillAuditLogs"]);

+ 25 - 0
app/Package.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Package extends Model
+{
+    protected $fillable=[
+        'logistic_number','type','weight','length','width','height','owner_id','paper_box_id',
+        'measuring_machine_id','recipient','status'
+    ];
+
+    public function owner(){
+        return $this->belongsTo('App\Owner','owner_id','id');
+    }
+
+    public function paperBox(){
+        return $this->belongsTo('App\paperBox','paper_box_id','id');
+    }
+
+    public function measuringMachine(){
+        return $this->belongsTo('App\measuringMachine','measuring_machine_id','id');
+    }
+}

+ 1 - 1
app/Waybill.php

@@ -8,7 +8,7 @@ class Waybill extends Model
 {
 
     protected $fillable=[
-        'state','type','waybill_number','owner_id','wms_bill_number','origination','destination','recipient','recipient_mobile','charge','ordering_remark',
+        'status','type','waybill_number','owner_id','wms_bill_number','origination','destination','recipient','recipient_mobile','charge','ordering_remark',
         'carrier_id','carrier_bill','origination_city_id','destination_city_id','warehouse_weight','warehouse_weight_unit_id','carrier_weight','carrier_weight_unit_id','carType_id',
         'car_owner_info','fee','pick_up_fee','other_fee','collect_fee','dispatch_remark','waybill_price_model_id','warehouse_weight_other','warehouse_weight_unit_id_other'
         ,'carrier_weight_other','carrier_weight_unit_id_other',

+ 12 - 0
database/factories/PackagesFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\Package;
+use Faker\Generator as Faker;
+
+$factory->define(Package::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 0 - 2
database/migrations/2019_11_22_094057_create_waybill_payoffs_table.php

@@ -21,8 +21,6 @@ class CreateWaybillPayoffsTable extends Migration
             $table->decimal('total_receivable')->comment('应收运费');
             $table->decimal('gross_margin')->comment('毛利');
             $table->decimal('gross_profit_rate',10,8)->comment('毛利率');
-
-
         });
     }
 

+ 1 - 1
database/migrations/2019_11_22_094311_create_waybill_price_models_table.php

@@ -18,7 +18,7 @@ class CreateWaybillPriceModelsTable extends Migration
             $table->timestamps();
             $table->bigInteger('carrier_id')->index()->comment('承运商');
             $table->bigInteger('province_id')->index()->comment('省份');
-            $table->bigInteger('city_id')->index()->comment('城市');
+            $table->bigInteger('city_id')->nullable()->index()->comment('城市');
             $table->bigInteger('unit_id')->index()->comment('货物单位');
             $table->decimal('range_min')->index()->nullable()->comment('区间最小值');
             $table->decimal('range_max')->index()->nullable()->comment('区间最大值');

+ 1 - 1
database/migrations/2019_11_28_152321_create_waybill_audit_logs_table.php

@@ -32,6 +32,6 @@ class CreateWaybillAuditLogsTable extends Migration
      */
     public function down()
     {
-        Schema::dropIfExists('waybillAuditLogs');
+        Schema::dropIfExists('waybill_audit_logs');
     }
 }

+ 3 - 3
database/migrations/2019_12_27_105125_create_paper_boxes_table.php

@@ -16,9 +16,9 @@ class CreatePaperBoxesTable extends Migration
         Schema::create('paper_boxes', function (Blueprint $table) {
             $table->bigIncrements('id');
             $table->string('model')->unique()->comment('模型');
-            $table->decimal('length')->comment('长(cm)');
-            $table->decimal('width')->comment('宽(cm)');
-            $table->decimal('height')->comment('高(cm)');
+            $table->decimal('length')->index()->comment('长(cm)');
+            $table->decimal('width')->index()->comment('宽(cm)');
+            $table->decimal('height')->index()->comment('高(cm)');
             $table->timestamps();
         });
     }

+ 11 - 1
database/migrations/2019_12_30_114648_add_weigh_authority.php

@@ -24,6 +24,11 @@ class AddWeighAuthority extends Migration
         (new Authority(['name'=>'测量设备-录入','alias_name'=>'测量设备-录入']))->save();
         (new Authority(['name'=>'测量设备-编辑','alias_name'=>'测量设备-编辑']))->save();
         (new Authority(['name'=>'测量设备-删除','alias_name'=>'测量设备-删除']))->save();
+        (new Authority(['name'=>'包裹信息','alias_name'=>'包裹信息']))->save();
+        (new Authority(['name'=>'包裹信息-查询','alias_name'=>'包裹信息-查询']))->save();
+        (new Authority(['name'=>'包裹信息-录入','alias_name'=>'包裹信息-录入']))->save();
+        (new Authority(['name'=>'包裹信息-编辑','alias_name'=>'包裹信息-编辑']))->save();
+        (new Authority(['name'=>'包裹信息-删除','alias_name'=>'包裹信息-删除']))->save();
     }
 
     /**
@@ -41,7 +46,12 @@ class AddWeighAuthority extends Migration
         Authority::where('name','测量设备')->delete();
         Authority::where('name','测量设备-查询')->delete();
         Authority::where('name','测量设备-录入')->delete();
-        Authority::where('name','测量设备编辑')->delete();
+        Authority::where('name','测量设备-编辑')->delete();
         Authority::where('name','测量设备-删除')->delete();
+        Authority::where('name','包裹信息')->delete();
+        Authority::where('name','包裹信息-查询')->delete();
+        Authority::where('name','包裹信息-录入')->delete();
+        Authority::where('name','包裹信息-编辑')->delete();
+        Authority::where('name','包裹信息-删除')->delete();
     }
 }

+ 2 - 2
database/migrations/2019_12_30_143601_create_measuring_machines_table.php

@@ -15,8 +15,8 @@ class CreateMeasuringMachinesTable extends Migration
     {
         Schema::create('measuring_machines', function (Blueprint $table) {
             $table->bigIncrements('id');
-            $table->string('name')->comment('设备名');
-            $table->string('code')->comment('设备ID');
+            $table->string('name')->index()->comment('设备名');
+            $table->string('code')->unique()->comment('设备ID');
             $table->enum('status',['在线','离线'])->default('离线')->comment('设备状态');
             $table->timestamps();
         });

+ 42 - 0
database/migrations/2019_12_30_171202_create_packages_table.php

@@ -0,0 +1,42 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreatePackagesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('packages', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->string('logistic_number')->unique()->comment('快递单号');
+            $table->enum('type',['普通波次','活动波次'])->default('普通波次')->index()->comment('波次类型');
+            $table->decimal('weight')->comment('重KG');
+            $table->decimal('length')->index()->comment('长(cm)');
+            $table->decimal('width')->index()->comment('宽(cm)');
+            $table->decimal('height')->index()->comment('高(cm)');
+            $table->bigInteger('owner_id')->index()->comment('外键货主');
+            $table->bigInteger('paper_box_id')->index()->comment('外键纸箱');
+            $table->bigInteger('measuring_machine_id')->index()->comment('外键设备');
+            $table->string('recipient')->comment('收件人');
+            $table->enum('status',['无','未上传','已上传','异常'])->default('无')->comment('包裹信息状态');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('packages');
+    }
+}

+ 34 - 0
database/migrations/2020_01_02_102517_change_waybill_status.php

@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class ChangeWaybillStatus extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('waybills', function (Blueprint $table) {
+            $table->dropColumn('state');
+            $table->enum('status',['未审核','已审核','待重审','待终审','已完结','无模型'])->default('未审核')->index()->comment('状态');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('waybills', function (Blueprint $table) {
+            $table->dropColumn('status');
+            $table->string('state',20)->nullable()->comment('状态');
+        });
+    }
+}

+ 32 - 0
database/migrations/2020_01_02_172739_change_waybill_price_model_field.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class ChangeWaybillPriceModelField extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('waybill_price_models', function (Blueprint $table) {
+            $table->bigInteger('city_id')->nullable()->change();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('waybill_price_models', function (Blueprint $table) {
+            $table->bigInteger('city_id')->index()->comment('外键城市')->change();
+        });
+    }
+}

BIN
public/icon/off.png


BIN
public/icon/on.png


+ 2 - 2
resources/views/maintenance/measuringMachine/edit.blade.php

@@ -4,7 +4,7 @@
     <div id="nav2">
         @component('maintenance.menu')
         @endcomponent
-        @component('maintenance.province.menu')
+        @component('maintenance.measuringMachine.menu')
                 <li class="nav-item">
                     <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('edit',4)}">修改</a>
                 </li>
@@ -13,7 +13,7 @@
     <div class="container-fluid mt-3">
         <div class="card">
             <div class="card-body">
-                <form method="POST" action='{{url("maintenance/province/{$province->id}")}}'>
+                <form method="POST" action='{{url("maintenance/measuringMachine/{$measuringMachine->id}")}}'>
                     @csrf
                     @method('PUT')
                     <div class="form-group row">

+ 1 - 1
resources/views/waybill/edit.blade.php

@@ -302,7 +302,7 @@
                             @enderror
                         </div>
                     </div>
-                    <input type="hidden" name="state" value="待终审">
+                    <input type="hidden" name="status" value="待终审">
                     <input type="hidden" name="waybillPriceModel" id="waybillPriceModel">
                     <div class="form-group row">
                         <div class="col-8 offset-2">

+ 7 - 7
resources/views/waybill/index.blade.php

@@ -224,7 +224,7 @@
                         @foreach($waybills as $waybill)
                     {
                         id:'{{$waybill->id}}',created_at:'{{$waybill->created_at}}',updated_at:'{{$waybill->updated_at}}',
-                        state:'{{$waybill->state}}',type:'{{$waybill->type}}',waybill_number:'{{$waybill->waybill_number}}',
+                        status:'{{$waybill->status}}',type:'{{$waybill->type}}',waybill_number:'{{$waybill->waybill_number}}',
                         owner:'{{$waybill->owner_name}}',wms_bill_number:'{{$waybill->wms_bill_number}}',origination:'{{$waybill->origination}}',
                         destination:'{{$waybill->destination}}',recipient:'{{$waybill->recipient}}',recipient_mobile:'{{$waybill->recipient_mobile}}',
                         charge:'{{$waybill->charge}}',ordering_remark:'{{$waybill->ordering_remark}}',carrier:'{{$waybill->carrier_name}}',
@@ -248,7 +248,7 @@
                         ,carrier_bill:'',carrier_id:''
                         ,owner_id:'',wms_bill_number:''
                         ,created_at_start:'',created_at_end:''
-                        ,type:'',state:'',origination:'',destination:'',},
+                        ,type:'',status:'',origination:'',destination:'',},
 
             },
             computed:{
@@ -267,7 +267,7 @@
             watch:{
                 checkData:{
                     handler(){
-                        if (this.checkData.length == this.waybills.length){
+                        if (this.checkData.length === this.waybills.length){
                             document.querySelector('#all').checked = true;
                         }else {
                             document.querySelector('#all').checked = false;
@@ -305,7 +305,7 @@
                                 if (response.data.success){
                                     _this.waybills.forEach(function (waybill) {
                                         if (waybill.id===id){
-                                            waybill.state=response.data.state;
+                                            waybill.status=response.data.status;
                                             waybill.waybillAuditLogs.push(response.data.waybillAuditLog);
                                             w=waybill.waybill_number;
                                         }
@@ -339,7 +339,7 @@
                                 if (response.data.success){
                                     _this.waybills.forEach(function (waybill){
                                         if (waybill.id===id){
-                                            waybill.state=response.data.state;
+                                            waybill.status=response.data.status;
                                             waybill.waybillAuditLogs=[];
                                             w=waybill.waybill_number;
                                         }
@@ -370,7 +370,7 @@
                                 if (response.data.success){
                                     _this.waybills.forEach(function (s) {
                                         if (s.id===id){
-                                            s.state=response.data.state;
+                                            s.status=response.data.status;
                                             s.waybillAuditLogs.push(response.data.waybillAuditLog);
                                             w=s.waybill_number;
                                         }
@@ -411,7 +411,7 @@
                     form.submit();
                 },
                 setState:function (e) {
-                    this.filterData.state=e.target.value;
+                    this.filterData.status=e.target.value;
                     var form = document.getElementById("optionSubmit");
                     form.submit();
                 },

+ 63 - 23
resources/views/weigh/measureMonitor/index.blade.php

@@ -5,42 +5,61 @@
     <div class="page-holder w-100 d-flex flex-wrap" id="list">
         <div class="container-fluid px-xl-5">
             <section class="py-5">
-                <div class="row" v-for="tests in test">
+                <div class="row">
                     <div class="col-lg-12 mb-4">
                         <div class="card">
                             <div class="card-header">
-                                <h6 class="text-uppercase mb-0"></h6>
+                                <div class="form-inline">
+                                <img src="@if($package&&$package->measuringMachine->status=='在线'){{asset('icon/on.png')}}@else{{asset('icon/off.png')}}@endif"/>
+                                <h6 class="text-uppercase mb-0 dropdown-toggle" data-toggle="dropdown">@{{package.measuringMachine}}</h6>
+                                    <div class="dropdown-menu" id="selected">
+                                        <a class="dropdown-item" v-for="measuringMachine in measuringMachines" @click="selectedMachine(measuringMachine.id)">@{{measuringMachine.name}}</a>
+                                    </div>
+                                </div>
+
                             </div>
                             <div class="card-body">
                                 <table class="table card-text">
-                                    <thead>
                                     <tr>
-                                        <th>#</th>
-                                        <th>First Name</th>
-                                        <th>Last Name</th>
-                                        <th>Username</th>
+                                        <th scope="row">快递单号</th>
+                                        <td >@{{package.logistic_number}}</td>
+                                    </tr>
+                                    <tr>
+                                        <th scope="row">类型</th>
+                                        <td>@{{package.type}}</td>
+                                    </tr>
+                                    <tr>
+                                        <th scope="row">重(KG)</th>
+                                        <td>@{{package.weight}}</td>
+                                    </tr>
+                                    <tr>
+                                        <th scope="row">长(CM)</th>
+                                        <td>@{{package.length}}</td>
                                     </tr>
-                                    </thead>
-                                    <tbody>
                                     <tr>
-                                        <th scope="row">1</th>
-                                        <td>Mark</td>
-                                        <td>Otto</td>
-                                        <td>@mdo</td>
+                                        <th scope="row">宽(CM)</th>
+                                        <td>@{{package.width}}</td>
                                     </tr>
                                     <tr>
-                                        <th scope="row">2</th>
-                                        <td>Jacob</td>
-                                        <td>Thornton</td>
-                                        <td>@fat</td>
+                                        <th scope="row">高(CM)</th>
+                                        <td>@{{package.height}}</td>
                                     </tr>
                                     <tr>
-                                        <th scope="row">3</th>
-                                        <td>Larry</td>
-                                        <td>the Bird</td>
-                                        <td>@twitter</td>
+                                        <th scope="row">货主</th>
+                                        <td>@{{package.owner}}</td>
+                                    </tr>
+                                    <tr>
+                                        <th scope="row">纸箱</th>
+                                        <td>@{{package.paperBox}}</td>
+                                    </tr>
+                                    <tr>
+                                        <th scope="row">状态</th>
+                                        <td>@{{package.status}}</td>
+                                    </tr>
+                                    <tr>
+                                        <th scope="row">称重时间</th>
+                                        <td>@{{package.created_at}}</td>
                                     </tr>
-                                    </tbody>
                                 </table>
                             </div>
                         </div>
@@ -52,11 +71,32 @@
 @endsection
 
 @section('lastScript')
+    <style>
+        #selected a:hover{background-color: #4aa0e6;display: block;cursor:pointer}
+    </style>
     <script>
         let vue=new Vue({
             el:'#list',
             data:{
-                test:[{a:'1'},{a:'1'},{a:'1'},{a:'1'}],
+                package:
+                    {@if($package)id:'{{$package->id}}',logistic_number:'{{$package->logistic_number}}',type:'{{$package->type}}',
+                    weight:'{{$package->weight}}',length:'{{$package->length}}',width:'{{$package->width}}',
+                    height:'{{$package->height}}',owner:'{{$package->owner?$package->owner->name:''}}',paperBox:'{{$package->paperBox?$package->paperBox->model:''}}',
+                    measuringMachine:'{{$package->measuringMachine?$package->measuringMachine->name:''}}',recipient:'{{$package->recipient}}',
+                    status:'{{$package->status}}',created_at:'{{$package->created_at}}'@endif},
+                measuringMachines:[
+                    @foreach($measuringMachines as $measuringMachine)
+                        @if($package&&$measuringMachine->name!=$package->measuringMachine->name)
+                            {id:'{{$measuringMachine->id}}',name:'{{$measuringMachine->name}}',code:'{{$measuringMachine->code}}'},
+                        @endif
+                    @endforeach
+                ]
+            },
+            methods:{
+                selectedMachine(id){
+                    let url='{{url('weigh/measureMonitor')}}';
+                    location.href=url+'?id='+id;
+                },
             },
         });
     </script>

+ 1 - 1
resources/views/weigh/menu.blade.php

@@ -8,7 +8,7 @@
                 </li> @endcan
             @can('测量记录管理-查询')
                 <li class="nav-item">
-                    <a class="nav-link" href="{{url('waybill/index')}}" :class="{active:isActive('index',2)}">测量记录管理</a>
+                    <a class="nav-link" href="{{url('weigh/package')}}" :class="{active:isActive('package',2)}">测量记录管理</a>
                 </li>
                 <li class="nav-item">
                     <a class="nav-link text-dark" href="{{url('weigh/relating')}}" :class="{active:isActive('relating',2)}">相关设置</a>

+ 169 - 0
resources/views/weigh/package/index.blade.php

@@ -0,0 +1,169 @@
+
+@extends('layouts.app')
+
+@section('content')
+    <span id="nav2">
+        @component('weigh.menu')@endcomponent
+        @component('weigh.package.menu')@endcomponent
+    </span>
+    <div id="list">
+        <div class="container mt-3">
+            <div class="card">
+                <div>
+                    <form  method="GET" action="{{url('weigh/package')}}" style="margin-top: 1%" id="optionSubmit">
+                        <table class="table  table-sm table-bordered table-hover text-nowrap ">
+                            <tr>
+                                <td colspan="4"><div class="col" v-if="isBeingFilterConditions" style="padding:0">
+                                        <a  href="{{url('weigh/package')}}"><span class="btn btn-warning text-dark">清除过滤条件</span></a>
+                                    </div></td>
+                            </tr>
+                            <tr>
+                                <td  style="width:200px;"> <label style="margin-left: 2%" class="form-inline">页显示条数:
+                                    <select name="paginate" v-model="filterData.paginate" class="form-control" @change="setPaginate">
+                                        <option value="50">50行</option>
+                                        <option value="100">100行</option>
+                                        <option value="200">200行</option>
+                                        <option value="500">500行</option>
+                                        <option value="1000">1000行</option>
+                                    </select></label></td>
+                                <td style="width:300px;"> <label class="form-inline" style="margin-left: 2%">快递单号:
+                                        <input type="text" name="logistic_number" class="form-control  " v-model="filterData.logistic_number" style="vertical-align: middle"></label></td>
+                                <td style="width:200px;"> <label class="form-inline" style="margin-left: 2%">波次类型:
+                                    <select name="type" v-model="filterData.type" class="form-control"  @change="setType">
+                                        <option >    </option>
+                                        <option value="普通波次">普通波次</option>
+                                        <option value="活动波次">活动波次</option>
+
+                                    </select></label></td>
+                                <td style="width:200px;"><label class="form-inline" style="margin-left: 2%">状态:
+                                    <select name="status" v-model="filterData.status" class="form-control" @change="setStatus">
+                                        <option>  </option>
+                                        <option value="无">无</option>
+                                        <option value="未上传">未上传</option>
+                                        <option value="已上传">已上传</option>
+                                        <option value="异常">异常</option>
+                                    </select></label></td>
+                                <td style="width:200px;"> <label class="form-inline" style="margin-left: 2%">货主:
+                                        <select name="owner_id" v-model="filterData.owner_id" class="form-control"  @change="setOwner">
+                                            <option >    </option>
+                                            @foreach($owners as $owner)
+                                                <option value="{{$owner->id}}">{{$owner->name}}</option>
+                                            @endforeach
+                                        </select></label><input hidden type="submit" value="kk"></td>
+                                <td></td>
+                            </tr>
+                        </table>
+                    </form>
+                </div>
+            <div class="card-body">
+                <table class="table table-striped table-sm">
+                    <tr>
+                        <th>ID</th>
+                        <th>快递单号</th>
+                        <th>波次类型</th>
+                        <th>当前状态</th>
+                        <th>重(KG)</th>
+                        <th>长(CM)</th>
+                        <th>宽(CM)</th>
+                        <th>高(CM)</th>
+                        <th>货主</th>
+                        <th>纸箱</th>
+                        <th>设备</th>
+                        <th>收件人</th>
+                        <th>称重时间</th>
+                    </tr>
+                    <tr v-for="package in packages">
+                        <td class="text-muted">@{{package.id}}</td>
+                        <td>@{{package.logistic_number}}</td>
+                        <td>@{{package.type}}</td>
+                        <td>@{{package.status}}</td>
+                        <td>@{{package.weight}}</td>
+                        <td>@{{package.length}}</td>
+                        <td>@{{package.width}}</td>
+                        <td>@{{package.height}}</td>
+                        <td>@{{package.owner}}</td>
+                        <td>@{{package.paperBox}}</td>
+                        <td>@{{package.measuringMachine}}</td>
+                        <td>@{{package.recipient}}</td>
+                        <td class="text-muted">@{{package.created_at}}</td>
+                    </tr>
+                </table>
+                {{$packages->links()}}
+            </div>
+        </div>
+    </div>
+    </div>
+@endsection
+
+@section('lastScript')
+    <script>
+        new Vue({
+            el:"#list",
+            data:{
+                packages:[
+                    @foreach($packages as $package)
+                        {id:'{{$package->id}}',logistic_number:'{{$package->logistic_number}}',type:'{{$package->type}}',
+                        weight:'{{$package->weight}}', length:'{{$package->length}}',width:'{{$package->width}}',height:'{{$package->height}}',
+                        owner:'{{$package->owner?$package->owner->name:''}}',paperBox:'{{$package->paperBox?$package->paperBox->name:''}}',
+                        measuringMachine:'{{$package->measuringMachine?$package->measuringMachine->name:''}}',recipient:'{{$package->recipient}}',
+                        status:'{{$package->status}}',created_at:'{{$package->created_at}}'},
+                    @endforeach
+                ],
+                filterData:
+                    {paginate:'50',logistic_number:'',type: '',status: '',owner_id: ''},
+            },
+            mounted:function(){
+                this.initInputs();
+            },
+            computed:{
+                isBeingFilterConditions:function(){
+
+                    for(let key in this.filterData){
+                        if(this.filterData[key]){
+                            if(key==='paginate')continue;
+                            return true
+                        }
+                    }
+                    return false;
+                },
+
+            },
+            methods:{
+                initInputs:function(){
+                    let data=this;
+                    let uriParts =decodeURI(location.href).split("?");
+                    if(uriParts.length>1){
+                        let params = uriParts[1].split('&');
+                        params.forEach(function(paramPair){
+                            let pair=paramPair.split('=');
+                            let key = pair[0], val = pair[1];
+                            $('input[name="'+key+'"]').val(val);
+                            $('select[name="'+key+'"]').val(val);
+                            decodeURI(data.filterData[key]=val);
+                        });
+                    }
+                },
+                setPaginate:function(e){
+                    this.filterData.paginate=e.target.value;
+                    var form = document.getElementById("optionSubmit");
+                    form.submit();
+                },
+                setType:function (e){
+                    this.filterData.type=e.target.value;
+                    var form = document.getElementById("optionSubmit");
+                    form.submit();
+                },
+                setStatus:function (e){
+                    this.filterData.status=e.target.value;
+                    var form = document.getElementById("optionSubmit");
+                    form.submit();
+                },
+                setOwner:function (e){
+                    this.filterData.owner_id=e.target.value;
+                    var form = document.getElementById("optionSubmit");
+                    form.submit();
+                },
+            }
+        });
+    </script>
+@endsection

+ 10 - 0
resources/views/weigh/package/menu.blade.php

@@ -0,0 +1,10 @@
+<div class="container">
+    <div class="card menu-third" style="background: #f9f0f0;transform: scale(0.95)">
+        <ul class="nav nav-pills">
+            @can('包裹信息-查询')
+                <li class="nav-item">
+                    <a class="nav-link" href="{{url('weigh/package')}}" :class="{active:isActive('',3)}">查询</a>
+                </li> @endcan
+        </ul>
+    </div>
+</div>

+ 1 - 0
routes/web.php

@@ -76,6 +76,7 @@ Route::post('waybillPriceModel/excel/import','WaybillPriceModelsController@impor
 
 
 Route::resource('weigh/measureMonitor','MeasureMonitorController');
+Route::resource('weigh/package','PackageController');
 Route::get('weigh/relating', function () {return view('weigh.menuWeigh');});
 
 Route::post('rejectedBill/{rejectedBill}/edit', 'RejectedBillController@edit');

+ 53 - 0
tests/Unit/MeasureMonitorTest.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace Tests\Unit;
+
+use App\Authority;
+use App\Role;
+use App\User;
+use Illuminate\Support\Facades\DB;
+use Tests\TestCase;
+use Illuminate\Foundation\Testing\WithFaker;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+
+class MeasureMonitorTest extends TestCase
+{
+    public function testUserMark(){
+        $userMark=factory(User::class)->create();
+        $this->assertNotEmpty($userMark->id);
+        return $userMark;
+    }
+
+    public function testRole(){
+        $role=Role::create([
+            'name'=>'测试admin'
+        ]);
+        $this->assertNotEmpty($role->id);
+        $authorities= Authority::get();
+        foreach ($authorities as $authority){
+            DB::table('authority_role')->insert(['id_authority'=>$authority->id,'id_role'=>$role->id]);
+        }
+        return $role;
+    }
+
+    /**
+     * @depends testRole
+     */
+    public function testUser(Role $role){
+        $user=factory(User::class)->create();
+        DB::table('user_role')->insert(['id_user'=>$user->id,'id_role'=>$role->id]);
+        $this->assertNotEmpty($user->id);
+        return $user;
+    }
+
+    /**
+     * @depends testUserMark
+     * @depends testUser
+     */
+    public function testIndex(User $userMark,User $user){
+        $response=$this->actingAs($user)->get('weigh/measureMonitor');
+        $response->assertOk();
+        $response=$this->actingAs($userMark)->get('weigh/measureMonitor');
+        $response->assertStatus(302)->assertRedirect('/');
+    }
+}

+ 142 - 0
tests/Unit/MeasuringMachineTest.php

@@ -0,0 +1,142 @@
+<?php
+
+namespace Tests\Unit;
+
+use App\Authority;
+use App\MeasuringMachine;
+use App\Role;
+use App\User;
+use Illuminate\Support\Facades\DB;
+use Tests\TestCase;
+use Illuminate\Foundation\Testing\WithFaker;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+
+class MeasuringMachineTest extends TestCase
+{
+    public function testUserMark(){
+        $userMark=factory(User::class)->create();
+        $this->assertNotEmpty($userMark->id);
+        return $userMark;
+    }
+
+    public function testRole(){
+        $role=Role::create([
+            'name'=>'测试admin'
+        ]);
+        $this->assertNotEmpty($role->id);
+        $authorities= Authority::get();
+        foreach ($authorities as $authority){
+            DB::table('authority_role')->insert(['id_authority'=>$authority->id,'id_role'=>$role->id]);
+        }
+        return $role;
+    }
+
+    /**
+     * @depends testRole
+     */
+    public function testUser(Role $role){
+        $user=factory(User::class)->create();
+        DB::table('user_role')->insert(['id_user'=>$user->id,'id_role'=>$role->id]);
+        $this->assertNotEmpty($user->id);
+        return $user;
+    }
+
+    public function testAddMeasuringMachine(){
+        $measuringMachine=MeasuringMachine::create([
+            'name'=>'tests1',
+            'code'=>'testK8',
+        ]);
+        $this->assertNotEmpty($measuringMachine);
+        return $measuringMachine;
+    }
+
+
+    /**
+     * @depends testUser
+     * @depends testAddMeasuringMachine
+     * @depends testUserMark
+     */
+    public function testIndex(User $user,MeasuringMachine $measuringMachine,User $userMark){
+        $response=$this->actingAs($user)->get('maintenance/measuringMachine');
+        $response->assertOk()->assertSee('tests1');
+        $responseMark=$this->actingAs($userMark)->get('maintenance/measuringMachine');
+        $responseMark->assertStatus(302)->assertRedirect('/');
+    }
+
+    /**
+     * @depends testUser
+     * @depends testUserMark
+     */
+    public function testCreate(User $user,User $userMark){
+        $measuringMachine=$this->actingAs($user)->get('maintenance/measuringMachine/create');
+        $measuringMachine->assertOk();
+        $measuringMachine=$this->actingAs($userMark)->get('maintenance/measuringMachine/create');
+        $measuringMachine->assertStatus(302)->assertRedirect('/');
+    }
+
+    /**
+     * @depends testUser
+     * @depends testUserMark
+     */
+    public function testStore(User $user,User $userMark){
+        $response=$this->actingAs($user)->post('maintenance/measuringMachine',[
+            'name'=>'testx15',
+            'code'=>'testx15',
+        ]);
+        $response->assertStatus(302)->assertRedirect('maintenance/measuringMachine')->assertSessionHas('successTip');
+        $measuringMachine=MeasuringMachine::where('code','testx15')->first();
+        $result=$measuringMachine->delete();
+        $this->assertTrue($result);
+        $responseFalse=$this->actingAs($userMark)->post('maintenance/measuringMachine',[
+            'name'=>'testx15',
+            'code'=>'testx15',
+        ]);
+        $responseFalse->assertStatus(302)->assertRedirect('/');
+    }
+
+    /**
+     * @depends testUser
+     * @depends testAddMeasuringMachine
+     * @depends testUserMark
+     */
+    public function testEdit(User $user,MeasuringMachine $measuringMachine,User $userMark){
+        $response=$this->actingAs($user)->get("maintenance/measuringMachine/$measuringMachine->id/edit");
+        $response->assertOk()->assertSee('tests1');
+        $responseMark=$this->actingAs($userMark)->get("maintenance/measuringMachine/$measuringMachine->id/edit");
+        $responseMark->assertStatus(302)->assertRedirect('/');
+    }
+
+    /**
+     * @depends testUser
+     * @depends testAddMeasuringMachine
+     * @depends testUserMark
+     */
+    public function testUpdate(User $user,MeasuringMachine $measuringMachine,User $userMark){
+        $response=$this->actingAs($user)->put("maintenance/measuringMachine/$measuringMachine->id",[
+            'name'=>'testUpdate',
+            'code'=>'test',
+        ]);
+        $response->assertStatus(302)->assertRedirect('maintenance/measuringMachine')->assertSessionHas('successTip');
+        $responseMark=$this->actingAs($userMark)->put("maintenance/measuringMachine/$measuringMachine->id",[
+            'name'=>'testUpdate',
+            'code'=>'test',
+        ]);
+        $responseMark->assertStatus(302)->assertRedirect('/');
+    }
+
+    /**
+     * @depends testUser
+     * @depends testAddMeasuringMachine
+     * @depends testUserMark
+     */
+    public function testDestroy(User $user,MeasuringMachine $measuringMachine,User $userMark){
+        $response=$this->actingAs($user)->delete("maintenance/measuringMachine/$measuringMachine->id");
+        $response->assertOk()->assertJson(['success'=>true]);
+        $response=$this->actingAs($userMark)->delete("maintenance/measuringMachine/$measuringMachine->id");
+        $response->assertStatus(302)->assertRedirect('/');
+        $resultUser=$user->delete();
+        $resultUserMark=$userMark->delete();
+        $this->assertTrue($resultUser);
+        $this->assertTrue($resultUserMark);
+    }
+}

+ 88 - 0
tests/Unit/PackageTest.php

@@ -0,0 +1,88 @@
+<?php
+
+namespace Tests\Unit;
+
+use App\Authority;
+use App\Package;
+use App\Role;
+use App\User;
+use Illuminate\Support\Facades\DB;
+use Tests\TestCase;
+use Illuminate\Foundation\Testing\WithFaker;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+
+class PackageTest extends TestCase
+{
+    public function testUserMark(){
+        $userMark=factory(User::class)->create();
+        $this->assertNotEmpty($userMark->id);
+        return $userMark;
+    }
+
+    public function testRole(){
+        $role=Role::create([
+            'name'=>'测试admin'
+        ]);
+        $this->assertNotEmpty($role->id);
+        $authorities= Authority::get();
+        foreach ($authorities as $authority){
+            DB::table('authority_role')->insert(['id_authority'=>$authority->id,'id_role'=>$role->id]);
+        }
+        return $role;
+    }
+
+    /**
+     * @depends testRole
+     */
+    public function testUser(Role $role){
+        $user=factory(User::class)->create();
+        DB::table('user_role')->insert(['id_user'=>$user->id,'id_role'=>$role->id]);
+        $this->assertNotEmpty($user->id);
+        return $user;
+    }
+
+    public function testAddPackage(){
+        $package=Package::create([
+            'logistic_number'=>'test214',
+            ',type'=>'普通波次',
+            'weight'=>20,
+            'length'=>38,
+            'width'=>30,
+            'height'=>25,
+            'owner_id'=>'1',
+            'paper_box_id'=>'1',
+            'measuring_machine_id'=>'1',
+            'recipient'=>'Test浏览量',
+            'status'=>'无',
+        ]);
+        $this->assertNotEmpty($package);
+        return $package;
+    }
+
+    /**
+     * @depends testUser
+     * @depends testUserMark
+     * @depends testAddPackage
+     */
+    public function testIndex(User $user,User $userMark,Package $package){
+        $response=$this->actingAs($user)->get('weigh/package');
+        $response->assertOk()->assertSee('Test浏览量');
+        $response=$this->actingAs($userMark)->get('weigh/package');
+        $response->assertStatus(302)->assertRedirect('/');
+    }
+
+    /**
+     * @depends testUser
+     * @depends testUserMark
+     * @depends testAddPackage
+     */
+    public function testDestroy(User $user,User $userMark,Package $package){
+        $resultUser=$user->delete();
+        $resultUserMark=$userMark->delete();
+        $resultPackage=$package->delete();
+        $this->assertTrue($resultUser);
+        $this->assertTrue($resultUserMark);
+        $this->assertTrue($resultPackage);
+    }
+
+}

+ 156 - 0
tests/Unit/PaperBoxTest.php

@@ -0,0 +1,156 @@
+<?php
+
+namespace Tests\Unit;
+
+use App\Authority;
+use App\PaperBox;
+use App\Role;
+use App\User;
+use Illuminate\Support\Facades\DB;
+use Tests\TestCase;
+use Illuminate\Foundation\Testing\WithFaker;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+
+class PaperBoxTest extends TestCase
+{
+    public function testUserMark(){
+        $userMark=factory(User::class)->create();
+        $this->assertNotEmpty($userMark->id);
+        return $userMark;
+    }
+
+    public function testRole(){
+        $role=Role::create([
+            'name'=>'测试admin'
+        ]);
+        $this->assertNotEmpty($role->id);
+        $authorities= Authority::get();
+        foreach ($authorities as $authority){
+            DB::table('authority_role')->insert(['id_authority'=>$authority->id,'id_role'=>$role->id]);
+        }
+        return $role;
+    }
+
+    /**
+     * @depends testRole
+     */
+    public function testUser(Role $role){
+        $user=factory(User::class)->create();
+        DB::table('user_role')->insert(['id_user'=>$user->id,'id_role'=>$role->id]);
+        $this->assertNotEmpty($user->id);
+        return $user;
+    }
+
+    public function testAddPaperBox(){
+        $paperBox=PaperBox::create([
+            'model'=>'test',
+            'length'=>50,
+            'height'=>40,
+            'width'=>30,
+        ]);
+        $this->assertNotEmpty($paperBox);
+        return $paperBox;
+    }
+
+    /**
+     * @depends testUser
+     * @depends testAddPaperBox
+     * @depends testUserMark
+     */
+    public function testIndex(User $user,PaperBox $paperBox,User $userMark){
+        $model=$this->actingAs($user)->get('maintenance/paperBox/index/model');
+        $owner=$this->actingAs($user)->get('maintenance/paperBox/index/owner');
+        $model->assertOk()->assertSee('test');
+        $owner->assertOk();
+        $modelFalse=$this->actingAs($userMark)->get('maintenance/paperBox/index/model');
+        $ownerFalse=$this->actingAs($userMark)->get('maintenance/paperBox/index/owner');
+        $modelFalse->assertStatus(302)->assertRedirect('/');
+        $ownerFalse->assertStatus(302)->assertRedirect('/');
+    }
+
+    /**
+     * @depends testUser
+     * @depends testUserMark
+     */
+    public function testCreate(User $user,User $userMark){
+        $paperBox=$this->actingAs($user)->get('maintenance/paperBox/create');
+        $paperBox->assertOk()->assertSee('选择货主');
+        $paperBox=$this->actingAs($userMark)->get('maintenance/paperBox/create');
+        $paperBox->assertStatus(302)->assertRedirect('/');
+    }
+
+    /**
+     * @depends testUser
+     * @depends testUserMark
+     */
+    public function testStore(User $user,User $userMark){
+        $response=$this->actingAs($user)->post('maintenance/paperBox',[
+            'model'=>'测试纸箱',
+            'length'=>2,
+            'width'=>10,
+            'height'=>80,
+        ]);
+        $response->assertStatus(302)->assertRedirect('maintenance/paperBox/index/model')->assertSessionHas('successTip');
+        $paperBox=PaperBox::where('model','测试纸箱')->first();
+        $this->assertEquals(80,$paperBox->length);
+        $this->assertEquals(10,$paperBox->width);
+        $this->assertEquals(2,$paperBox->height);
+        $result=$paperBox->delete();
+        $this->assertTrue($result);
+        $responseFalse=$this->actingAs($userMark)->post('maintenance/paperBox',[
+            'model'=>'测试纸箱',
+            'length'=>2,
+            'width'=>10,
+            'height'=>80,
+        ]);
+        $responseFalse->assertStatus(302)->assertRedirect('/');
+    }
+
+    /**
+     * @depends testUser
+     * @depends testAddPaperBox
+     * @depends testUserMark
+     */
+    public function testEdit(User $user,PaperBox $paperBox,User $userMark){
+        $response=$this->actingAs($user)->get("maintenance/paperBox/$paperBox->id/edit");
+        $response->assertOk()->assertSee('test');
+        $responseMark=$this->actingAs($userMark)->get("maintenance/paperBox/$paperBox->id/edit");
+        $responseMark->assertStatus(302)->assertRedirect('/');
+    }
+
+    /**
+     * @depends testUser
+     * @depends testAddPaperBox
+     * @depends testUserMark
+     */
+    public function testUpdate(User $user,PaperBox $paperBox,User $userMark){
+        $response=$this->actingAs($user)->put("maintenance/paperBox/$paperBox->id",[
+            'model'=>'test','length'=>'50','width'=>'20','height'=>'40'
+        ]);
+        $response->assertStatus(302)->assertRedirect('maintenance/paperBox/index/model')->assertSessionHas('successTip');
+        $paperSelect=PaperBox::find($paperBox->id);
+        $this->assertEquals(50,$paperSelect->length);
+        $this->assertEquals(40,$paperSelect->width);
+        $this->assertEquals(20,$paperSelect->height);
+        $responseMark=$this->actingAs($userMark)->put("maintenance/paperBox/$paperBox->id",[
+            'model'=>'test','length'=>'50','width'=>'20','height'=>'40'
+        ]);
+        $responseMark->assertStatus(302)->assertRedirect('/');
+    }
+
+    /**
+     * @depends testUser
+     * @depends testAddPaperBox
+     * @depends testUserMark
+     */
+    public function testDestroy(User $user,PaperBox $paperBox,User $userMark){
+        $response=$this->actingAs($user)->delete("maintenance/paperBox/$paperBox->id");
+        $response->assertOk()->assertJson(['success'=>true]);
+        $response=$this->actingAs($userMark)->delete("maintenance/paperBox/$paperBox->id");
+        $response->assertStatus(302)->assertRedirect('/');
+        $resultUser=$user->delete();
+        $resultUserMark=$userMark->delete();
+        $this->assertTrue($resultUser);
+        $this->assertTrue($resultUserMark);
+    }
+}

+ 14 - 14
tests/Unit/WaybillPriceModelTest.php

@@ -65,9 +65,9 @@ class WaybillPriceModelTest extends TestCase
      * @depends testUserMark
      */
     public function testIndex(WaybillPriceModel $waybillPriceModel,User $user,User $userMark){
-        $response=$this->actingAs($user)->get('waybill/waybillPriceModel');
+        $response=$this->actingAs($user)->get('maintenance/waybillPriceModel');
         $response->assertStatus(200)->assertSee('5000');
-        $responseMark=$this->actingAs($userMark)->get('waybill/waybillPriceModel');
+        $responseMark=$this->actingAs($userMark)->get('maintenance/waybillPriceModel');
         $responseMark->assertStatus(302)->assertRedirect('/');
         $waybillPriceModel=WaybillPriceModel::paginate(50);
         $this->assertNotEmpty($waybillPriceModel);
@@ -78,9 +78,9 @@ class WaybillPriceModelTest extends TestCase
      * @depends testUserMark
      */
     public function testCreate(User $user,User $userMark){
-        $response=$this->actingAs($user)->get('waybill/waybillPriceModel/create');
+        $response=$this->actingAs($user)->get('maintenance/waybillPriceModel/create');
         $response->assertOk();
-        $responseMark=$this->actingAs($userMark)->get('waybill/waybillPriceModel/create');
+        $responseMark=$this->actingAs($userMark)->get('maintenance/waybillPriceModel/create');
         $responseMark->assertStatus(302)->assertRedirect('/');
     }
 
@@ -90,7 +90,7 @@ class WaybillPriceModelTest extends TestCase
      * @depends testUserMark
      */
     public function testStore(User $user,User $userMark){
-        $response=$this->actingAs($user)->post('waybill/waybillPriceModel',['WaybillPriceModel'=>[
+        $response=$this->actingAs($user)->post('maintenance/waybillPriceModel',['WaybillPriceModel'=>[
             'carrier_id'=>12,
             'province_id'=>4,
             'city_id'=>1,
@@ -101,8 +101,8 @@ class WaybillPriceModelTest extends TestCase
             'base_fee'=>null,
             'initial_weight'=>10
         ]]);
-        $response->assertStatus(302)->assertRedirect('waybill/waybillPriceModel')->assertSessionHas('successTip');
-        $responseMark=$this->actingAs($userMark)->post('waybill/waybillPriceModel',['WaybillPriceModel'=>[
+        $response->assertStatus(302)->assertRedirect('maintenance/waybillPriceModel')->assertSessionHas('successTip');
+        $responseMark=$this->actingAs($userMark)->post('maintenance/waybillPriceModel',['WaybillPriceModel'=>[
             'carrier_id'=>12,
             'province_id'=>4,
             'city_id'=>3,
@@ -128,9 +128,9 @@ class WaybillPriceModelTest extends TestCase
      * @depends testUserMark
      */
     public function testEdit(User $user,WaybillPriceModel $waybillPriceModel,User $userMark){
-        $response=$this->actingAs($user)->get("waybill/waybillPriceModel/$waybillPriceModel->id/edit");
+        $response=$this->actingAs($user)->get("maintenance/waybillPriceModel/$waybillPriceModel->id/edit");
         $response->assertOk();
-        $responseMark=$this->actingAs($userMark)->get("waybill/waybillPriceModel/$waybillPriceModel->id/edit");
+        $responseMark=$this->actingAs($userMark)->get("maintenance/waybillPriceModel/$waybillPriceModel->id/edit");
         $responseMark->assertStatus(302)->assertRedirect('/');
     }
 
@@ -140,7 +140,7 @@ class WaybillPriceModelTest extends TestCase
      * @depends testUserMark
      */
     public function testUpdate(WaybillPriceModel $waybillPriceModel,User $user,User $userMark){
-        $response=$this->actingAs($user)->put('waybill/waybillPriceModel/'.$waybillPriceModel->id,['WaybillPriceModel'=>[
+        $response=$this->actingAs($user)->put('maintenance/waybillPriceModel/'.$waybillPriceModel->id,['WaybillPriceModel'=>[
             'carrier_id'=>2,
             'province_id'=>2,
             'city_id'=>11,
@@ -151,8 +151,8 @@ class WaybillPriceModelTest extends TestCase
             'base_fee'=>null,
             'initial_weight'=>5
         ]]);
-        $response->assertStatus(302)->assertRedirect('waybill/waybillPriceModel')->assertSessionHas('successTip');
-        $responseMark=$this->actingAs($userMark)->put('waybill/waybillPriceModel/'.$waybillPriceModel->id,['WaybillPriceModel'=>[
+        $response->assertStatus(302)->assertRedirect('maintenance/waybillPriceModel')->assertSessionHas('successTip');
+        $responseMark=$this->actingAs($userMark)->put('maintenance/waybillPriceModel/'.$waybillPriceModel->id,['WaybillPriceModel'=>[
             'carrier_id'=>2,
             'province_id'=>2,
             'city_id'=>11,
@@ -173,9 +173,9 @@ class WaybillPriceModelTest extends TestCase
      * @depends testRole
      */
     public function testDestroy(WaybillPriceModel $waybillPriceModel,User $user,User $userMark,Role $role){
-        $response=$this->actingAs($user)->json('delete','waybill/waybillPriceModel/'.$waybillPriceModel->id,['id'=>$waybillPriceModel->id]);
+        $response=$this->actingAs($user)->json('delete','maintenance/waybillPriceModel/'.$waybillPriceModel->id,['id'=>$waybillPriceModel->id]);
         $response->assertOk();
-        $responseMark=$this->actingAs($userMark)->json('delete','waybill/waybillPriceModel/'.$waybillPriceModel->id,['id'=>$waybillPriceModel->id]);
+        $responseMark=$this->actingAs($userMark)->json('delete','maintenance/waybillPriceModel/'.$waybillPriceModel->id,['id'=>$waybillPriceModel->id]);
         $responseMark->assertStatus(302)->assertRedirect('/');
         $response->assertJson(['success'=>true]);
         $result=$user->delete();

+ 189 - 61
tests/Unit/WaybillTest.php

@@ -2,6 +2,7 @@
 
 namespace Tests\Unit;
 
+use App\Carrier;
 use App\WaybillAuditLog;
 use App\Authority;
 use App\WaybillPriceModel;
@@ -50,39 +51,102 @@ class WaybillTest extends TestCase
     public function testAddWaybill(){
         $waybill=new Waybill([
             'type'=>'直发车',
-            'state'=>'未审核',
-            'waybill_number'=>'BSZX12345848854',
-            'owner_id'=>2,
-            'wms_bill_number'=>'zx1858545465',
-            'origination'=>'上海松江',
-            'destination'=>'郑州中原',
-            'recipient'=>'elder sister',
-            'recipient_mobile'=>'18458741254',
-            'charge'=>586,
-            'ordering_remark'=>''
+            'waybill_number'=>'TestBSZF12345848854',
+            'owner_id'=>1,
+            'wms_bill_number'=>'test1858545465',
+            'origination'=>'test',
+            'destination'=>'test',
+            'recipient'=>'test sister',
+            'recipient_mobile'=>'025487456',
+            'charge'=>586.5,
+            'collect_fee'=>30,
+            'ordering_remark'=>'test'
         ]);
         $result=$waybill->save();
         $this->assertTrue($result);
-        $this->assertNotEmpty($waybill);
+        $this->assertNotEmpty($waybill->charge);
         return $waybill;
     }
 
+    public function testAddWaybillZX(){
+        $waybillZX=new Waybill([
+            'type'=>'专线',
+            'status'=>'未审核',
+            'waybill_number'=>'testBSZX123451468',
+            'owner_id'=>1,
+            'wms_bill_number'=>'test01547860548',
+            'origination'=>'上海',
+            'destination'=>'郑州',
+            'recipient'=>'elder sister',
+            'recipient_mobile'=>'12364851478',
+            'charge'=>586,
+            'ordering_remark'=>'禁'
+        ]);
+        $waybillZX->save();
+        $this->assertNotEmpty($waybillZX);
+        return $waybillZX;
+    }
+
+    public function testAddWaybillPriceModel(){
+        $waybillPriceModel=WaybillPriceModel::create([
+            'carrier_id'=>1,
+            'province_id'=>1,
+            'city_id'=>1,
+            'unit_id'=>1,
+            'range_min'=>0,
+            'range_max'=>2000,
+            'unit_price'=>5,
+            'base_fee'=>10,
+            'initial_weight'=>10
+        ]);
+        $this->assertNotEmpty($waybillPriceModel);
+        return $waybillPriceModel;
+    }
+
+    public function testAddWaybillPriceModelTwo(){
+        $waybillPriceModelTwo=WaybillPriceModel::create([
+            'carrier_id'=>1,
+            'province_id'=>1,
+            'unit_id'=>3,
+            'unit_price'=>5,
+            'base_fee'=>10,
+            'initial_weight'=>10
+        ]);
+        $this->assertNotEmpty($waybillPriceModelTwo);
+        return $waybillPriceModelTwo;
+    }
+
+    public function testAddCarrier(){
+        $carrier=Carrier::create([
+            'name'=>'test承运商',
+            'mobile'=>'000005416',
+            'remark'=>'test',
+            'delivery_fee'=>170
+        ]);
+        $this->assertNotEmpty($carrier);
+        return $carrier;
+    }
+
     /**
      * @depends testUser
      * @depends testAddWaybill
      * @depends testUserMark
      */
    public function testIndex(User $user,Waybill $waybill,User $userMark){
-        $responseFalse=$this->actingAs($user)->get('waybill',[
-            'waybill_number'=>'BSZX12345848854'
+        $responseFalse=$this->actingAs($user)->get('waybill/index',[
+            'waybill_number'=>'TestBSZF12345848854'
         ]);
-       $responseFalse->assertOk()->assertSee('BSZX12345848854');
-       $responseMark=$this->actingAs($userMark)->get('waybill',[
-           'waybill_number'=>'BSZX12345848854'
+       $responseFalseZX=$this->actingAs($user)->get('waybill/index/ZX');
+       $responseFalseZF=$this->actingAs($user)->get('waybill/index/ZF');
+       $responseFalseZX->assertOk();
+       $responseFalseZF->assertOk();
+       $responseFalse->assertOk()->assertSee('TestBSZF12345848854');
+       $responseMark=$this->actingAs($userMark)->get('waybill/index',[
+           'waybill_number'=>'TestBSZF12345848854'
        ]);
        $responseMark->assertStatus(302)->assertRedirect('/');
        $responseTrue=$this->actingAs($user)->get('waybill');
-       $responseTrue->assertOk()->assertSee('BSZX12345848854');
+       $responseTrue->assertOk()->assertSee('TestBSZF12345848854');
    }
 
     /**
@@ -90,9 +154,11 @@ class WaybillTest extends TestCase
      * @depends testUserMark
      */
    public function testCreate(User $user,User $userMark){
-        $response=$this->actingAs($user)->get('waybill/createZX');
+        $response=$this->actingAs($user)->get('waybill/create/ZX');
         $response->assertOk()->assertSee('WMS单号');
-       $responseMark=$this->actingAs($userMark)->get('waybill/createZX');
+       $responseZF=$this->actingAs($user)->get('waybill/create/ZF');
+       $responseZF->assertOk();
+       $responseMark=$this->actingAs($userMark)->get('waybill/create/ZX');
        $responseMark->assertStatus(302)->assertRedirect('/');
    }
 
@@ -105,24 +171,24 @@ class WaybillTest extends TestCase
             'type'=>'专线',
             'owner_id'=>1,
             'wms_bill_number'=>'ad544da6584',
-            'origination'=>'上海',
-            'destination'=>'商丘',
-            'recipient'=>'周某',
+            'origination'=>'test上海',
+            'destination'=>'test商丘',
+            'recipient'=>'test周某',
             'recipient_mobile'=>'01547896548',
             'charge'=>58.6,
-            'ordering_remark'=>''
+            'ordering_remark'=>'test'
         ]);
         $response->assertStatus(302)->assertRedirect('waybill')->assertSessionHas('successTip');
         $responseMark=$this->actingAs($userMark)->post('waybill',[
             'type'=>'专线',
             'owner_id'=>1,
             'wms_bill_number'=>'ad544da6584',
-            'origination'=>'上海',
-            'destination'=>'商丘',
-            'recipient'=>'周某',
+            'origination'=>'test上海',
+            'destination'=>'test商丘',
+            'recipient'=>'test周某',
             'recipient_mobile'=>'01547896548',
             'charge'=>58.6,
-            'ordering_remark'=>''
+            'ordering_remark'=>'test'
         ]);
         $responseMark->assertStatus(302)->assertRedirect('/');
     }
@@ -134,17 +200,50 @@ class WaybillTest extends TestCase
      */
     public function testEdit(User $user,Waybill $waybill,User $userMark){
         $response=$this->actingAs($user)->get('waybill/'.$waybill->id.'/edit');
-        $response->assertOk()->assertSee('BSZX12345848854');
+        $response->assertOk()->assertSee('TestBSZF12345848854');
         $responseMark=$this->actingAs($userMark)->get('waybill/'.$waybill->id.'/edit');
         $responseMark->assertStatus(302)->assertRedirect('/');
     }
 
+    /**
+     * @depends testUser
+     * @depends testAddWaybillPriceModel
+     * @depends testAddWaybillPriceModelTwo
+     */
+    public function testIsWaybillPriceModel(User $user,WaybillPriceModel $waybillPriceModel,WaybillPriceModel $waybillPriceModelTwo){
+        $response=$this->actingAs($user)->post('waybill/is/waybillPriceModel',[
+            'carrier_id'=>'1',
+            'destination_city_id'=>'1',
+            'carrier_weight'=>['50','20'],
+            'carrier_weight_unit_id'=>['1','1'],
+        ]);
+        $response->assertOk()->assertJson(['success'=>$waybillPriceModel->id]);
+        $response=$this->actingAs($user)->post('waybill/is/waybillPriceModel',[
+            'carrier_id'=>'2',
+            'destination_city_id'=>'2',
+            'carrier_weight'=>['50','20'],
+            'carrier_weight_unit_id'=>['1','1'],
+        ]);
+        $response->assertOk()->assertJson(['success'=>false]);
+        $response=$this->actingAs($user)->post('waybill/is/waybillPriceModel',[
+            'carrier_id'=>'1',
+            'destination_city_id'=>'2',
+            'carrier_weight'=>['50','20'],
+            'carrier_weight_unit_id'=>['1','1'],
+        ]);
+        $response->assertOk()->assertJson(['success'=>$waybillPriceModelTwo->id]);
+    }
+
+
     /**
      * @depends testUser
      * @depends testAddWaybill
      * @depends testUserMark
+     * @depends testAddWaybillZX
+     * @depends testAddWaybillPriceModel
+     * @depends testAddCarrier
      */
-    public function testUpdate(User $user,Waybill $waybill,User $userMark){
+    public function testUpdate(User $user,Waybill $waybill,User $userMark,Waybill $waybillZX,WaybillPriceModel $waybillPriceModel,Carrier $carrier){
 //直发车数据校验通过
         $responseZFTrue=$this->actingAs($user)->put('waybill/'.$waybill->id,[
             'type'=>'直发车',
@@ -171,8 +270,8 @@ class WaybillTest extends TestCase
         $waybillPayoffs=WaybillPayoff::where('waybill_id','=',$waybill->id)->first();
         $this->assertNotEmpty($waybillPayoffs);
         $this->assertEquals(490.00,$waybillPayoffs->total_expense);
-        $this->assertEquals(586.00,$waybillPayoffs->total_receivable);
-        $this->assertEquals(96.00,$waybillPayoffs->gross_margin);
+        $this->assertEquals(586.50,$waybillPayoffs->total_receivable);
+        $this->assertEquals(96.50,$waybillPayoffs->gross_margin);
 //直发车数据校验失败
         $responseZFFalse=$this->actingAs($user)->put('waybill/'.$waybill->id,[
             'type'=>'直发车',
@@ -183,23 +282,7 @@ class WaybillTest extends TestCase
             'dispatch_remark'=>''
         ]);
         $responseZFFalse->assertStatus(302)->assertRedirect('/');          //保留
-//专线
-        $waybillZX=new Waybill([
-            'type'=>'专线',
-            'state'=>'未审核',
-            'waybill_number'=>'BSZX12345146854854',
-            'owner_id'=>2,
-            'wms_bill_number'=>'01547860548',
-            'origination'=>'上海',
-            'destination'=>'郑州',
-            'recipient'=>'elder sister',
-            'recipient_mobile'=>'12364851478',
-            'charge'=>586,
-            'ordering_remark'=>'禁'
-        ]);
-        $waybillZX->save();
-        $this->assertNotEmpty($waybillZX);
-//未定义计费模型
+//无模型
         $responseZXFalse=$this->actingAs($user)->put('waybill/'.$waybillZX->id,[
             'type'=>'专线',
             'carrier_id'=>1,
@@ -232,12 +315,29 @@ class WaybillTest extends TestCase
         $responseZXMark->assertStatus(302)->assertRedirect('/');
         $fee=Waybill::find($waybillZX->id);
         $this->assertEquals(null,$fee->fee);
-        $waybillPayoffsZX=WaybillPayoff::where('waybill_id','=',$waybillZX->id)->first();
-        $this->assertNotEmpty($waybillPayoffsZX);
-        $waybillPayoffsZX->delete();
-//清除冗余数据
-        $result=$waybillZX->delete();
-        $this->assertTrue($result);
+//有模型
+        $responseZX=$this->actingAs($user)->put('waybill/'.$waybillZX->id,[
+            'type'=>'专线',
+            'carrier_id'=>$carrier->id,
+            'carrier_bill'=>'test01547860548',
+            'origination_city_id'=>1,
+            'destination_city_id'=>1,
+            'warehouse_weight'=>25,
+            'warehouse_weight_unit_id'=>1,
+            'carrier_weight'=>50,
+            'carrier_weight_unit_id'=>1,
+            'carrier_weight_other'=>5,
+            'carrier_weight_unit_id_other'=>2,
+            'pick_up_fee'=>20,
+            'other_fee'=>20,
+            'waybillPriceModel'=>$waybillPriceModel->id,
+            'dispatch_remark'=>''
+        ]);
+        $responseZX->assertStatus(302)->assertRedirect('waybill');
+        $waybillPayoff=WaybillPayoff::where('waybill_id',$waybillZX->id)->first();
+        $this->assertNotEmpty($waybillPayoff);
+        $this->assertEquals(460.00,$waybillPayoff->total_expense);
+        $this->assertEquals(126.00,$waybillPayoff->gross_margin);
     }
 
     /**
@@ -278,7 +378,7 @@ class WaybillTest extends TestCase
     public function testWaybillAudit(User $user,Waybill $waybill,User $userMark){
         //第一次请求成功
         $response=$this->actingAs($user)->json('post','waybill/waybillAudit',['id'=>$waybill->id]);
-        $response->assertJson(['success'=>true,'state'=>'已审核']);
+        $response->assertJson(['success'=>true,'status'=>'已审核']);
         $responseMark=$this->actingAs($userMark)->json('post','waybill/waybillAudit',['id'=>$waybill->id]);
         $responseMark->assertStatus(302)->assertRedirect('/');
         //第二次请求拦截
@@ -293,7 +393,7 @@ class WaybillTest extends TestCase
      */
     public function testWaybillEdit(User $user,Waybill $waybill,User $userMark){
         $response=$this->actingAs($user)->get('waybill/waybillEdit/'.$waybill->id);
-        $response->assertOk()->assertSee('上海松江');
+        $response->assertOk();
         $responseMark=$this->actingAs($userMark)->get('waybill/waybillEdit/'.$waybill->id);
         $responseMark->assertStatus(302)->assertRedirect('/');
     }
@@ -305,7 +405,7 @@ class WaybillTest extends TestCase
      */
     public function testWaybillRetreatAudit(User $user,Waybill $waybill,User $userMark){
         $response=$this->actingAs($user)->json('post','waybill/waybillRetreatAudit',['id'=>$waybill->id]);
-        $response->assertJson(['success'=>true,'state'=>'待重审']);
+        $response->assertJson(['success'=>true,'status'=>'待重审']);
         $responseMark=$this->actingAs($userMark)->json('post','waybill/waybillRetreatAudit',['id'=>$waybill->id]);
         $responseMark->assertStatus(302)->assertRedirect('/');
     }
@@ -314,13 +414,19 @@ class WaybillTest extends TestCase
      * @depends testUser
      * @depends testAddWaybill
      * @depends testUserMark
+     * @depends testAddWaybillZX
      */
-    public function testWaybillEndAudit(User $user,Waybill $waybill,User $userMark){
+    public function testWaybillEndAudit(User $user,Waybill $waybill,User $userMark,Waybill $waybillZX){
         //第一次请求成功
         $response=$this->actingAs($user)->json('post','waybill/waybillEndAudit',['id'=>$waybill->id]);
-        $response->assertJson(['success'=>true,'state'=>'未定义计费模型']);
+        $response->assertJson(['success'=>true]);
         $responseMark=$this->actingAs($userMark)->json('post','waybill/waybillEndAudit',['id'=>$waybill->id]);
         $responseMark->assertStatus(302)->assertRedirect('/');
+        //异常时
+        $waybillZX->waybill_price_model_id=null;
+        $waybillZX->save();
+        $response=$this->actingAs($user)->json('post','waybill/waybillEndAudit',['id'=>$waybillZX->id]);
+        $response->assertJson(['success'=>true]);
         //第二次请求拦截
         $responseRe=$this->actingAs($user)->json('post','waybill/waybillEndAudit',['id'=>$waybill->id]);
         $responseRe->assertJson(['exception'=>'请勿重复审核!']);
@@ -332,8 +438,13 @@ class WaybillTest extends TestCase
      * @depends testUser
      * @depends testUserMark
      * @depends testRole
+     * @depends testAddWaybillZX
+     * @depends testAddWaybillZX
+     * @depends testAddWaybillPriceModel
+     * @depends testAddCarrier
+     * @depends testAddWaybillPriceModelTwo
      */
-    public function testDestroy(Waybill $waybill,User $user,User $userMark,Role $role){
+    public function testDestroy(Waybill $waybill,User $user,User $userMark,Role $role,Waybill $waybillZX,WaybillPriceModel $waybillPriceModel,Carrier $carrier,WaybillPriceModel $waybillPriceModelTwo){
         $this->assertNotEmpty($waybill);
         $result=$waybill->delete();
         $this->assertTrue($result);
@@ -345,9 +456,26 @@ class WaybillTest extends TestCase
         $this->assertNotEmpty($waybillStore);
         $resultWaybillStore=$waybillStore->delete();
         $this->assertTrue($resultWaybillStore);
-        $waybillFinancialSnapshots=WaybillFinancialExcepted::where('waybill_id','=',$waybill->id)->first();
+        $waybillPayoffsZX=WaybillPayoff::where('waybill_id','=',$waybillZX->id)->first();
+        $this->assertNotEmpty($waybillPayoffsZX);
+        $waybillPayoffsZX->delete();
+        $result=$waybillZX->delete();
+        $this->assertTrue($result);
+        $this->assertNotEmpty($waybillPriceModel);
+        $resultWaybillPriceModel=$waybillPriceModel->delete();
+        $this->assertTrue($resultWaybillPriceModel);
+        $this->assertNotEmpty($waybillPriceModelTwo);
+        $resultWaybillPriceModelTwo=$waybillPriceModelTwo->delete();
+        $this->assertTrue($resultWaybillPriceModelTwo);
+        $this->assertNotEmpty($carrier);
+        $resultCarrier=$carrier->delete();
+        $this->assertTrue($resultCarrier);
+        $waybillFinancialSnapshots=WaybillFinancialSnapshot::where('waybill_id','=',$waybill->id)->first();
         $r=$waybillFinancialSnapshots->delete();
         $this->assertTrue($r);
+        $waybillFinancialSnapshotsZX=WaybillFinancialExcepted::where('waybill_id','=',$waybillZX->id)->first();
+        $resultZX=$waybillFinancialSnapshotsZX->delete();
+        $this->assertTrue($resultZX);
         $isAudit=WaybillAuditLog::withTrashed()->whereRaw('waybill_id = ? and audit_stage = ?',[$waybill->id,"运单阶段"])->first();
         $resultWaybillAuditLogWaybill=$isAudit->forceDelete();
         $this->assertTrue($resultWaybillAuditLogWaybill);

+ 1 - 1
tests/codeCoverage/Waybill.php.html

@@ -409,7 +409,7 @@
      <tr><td><div align="right"><a name="8"></a><a href="#8">8</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
      <tr><td><div align="right"><a name="9"></a><a href="#9">9</a></div></td><td class="codeLine"></td></tr>
      <tr><td><div align="right"><a name="10"></a><a href="#10">10</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">protected</span><span class="default">&nbsp;</span><span class="default">$fillable</span><span class="keyword">=</span><span class="keyword">[</span></td></tr>
-     <tr><td><div align="right"><a name="11"></a><a href="#11">11</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'state'</span><span class="keyword">,</span><span class="default">'type'</span><span class="keyword">,</span><span class="default">'waybill_number'</span><span class="keyword">,</span><span class="default">'owner_id'</span><span class="keyword">,</span><span class="default">'wms_bill_number'</span><span class="keyword">,</span><span class="default">'origination'</span><span class="keyword">,</span><span class="default">'destination'</span><span class="keyword">,</span><span class="default">'recipient'</span><span class="keyword">,</span><span class="default">'recipient_mobile'</span><span class="keyword">,</span><span class="default">'charge'</span><span class="keyword">,</span><span class="default">'ordering_remark'</span><span class="keyword">,</span></td></tr>
+     <tr><td><div align="right"><a name="11"></a><a href="#11">11</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'status'</span><span class="keyword">,</span><span class="default">'type'</span><span class="keyword">,</span><span class="default">'waybill_number'</span><span class="keyword">,</span><span class="default">'owner_id'</span><span class="keyword">,</span><span class="default">'wms_bill_number'</span><span class="keyword">,</span><span class="default">'origination'</span><span class="keyword">,</span><span class="default">'destination'</span><span class="keyword">,</span><span class="default">'recipient'</span><span class="keyword">,</span><span class="default">'recipient_mobile'</span><span class="keyword">,</span><span class="default">'charge'</span><span class="keyword">,</span><span class="default">'ordering_remark'</span><span class="keyword">,</span></td></tr>
      <tr><td><div align="right"><a name="12"></a><a href="#12">12</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'carrier_id'</span><span class="keyword">,</span><span class="default">'carrier_bill'</span><span class="keyword">,</span><span class="default">'origination_city_id'</span><span class="keyword">,</span><span class="default">'destination_city_id'</span><span class="keyword">,</span><span class="default">'warehouse_weight'</span><span class="keyword">,</span><span class="default">'warehouse_weight_unit_id'</span><span class="keyword">,</span><span class="default">'carrier_weight'</span><span class="keyword">,</span><span class="default">'carrier_weight_unit_id'</span><span class="keyword">,</span><span class="default">'carType_id'</span><span class="keyword">,</span></td></tr>
      <tr><td><div align="right"><a name="13"></a><a href="#13">13</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'fee'</span><span class="keyword">,</span><span class="default">'pick_up_fee'</span><span class="keyword">,</span><span class="default">'other_fee'</span><span class="keyword">,</span><span class="default">'collect_fee'</span><span class="keyword">,</span><span class="default">'dispatch_remark'</span></td></tr>
      <tr><td><div align="right"><a name="14"></a><a href="#14">14</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>