paginate(["unit"]); return response()->view('maintenance.priceModel.storage.index',compact("models")); } public function storageCreate() { if(!Gate::allows('计费模型-仓储-录入')){ return redirect('denied'); } $units = app('UnitService')->getSelection(); return response()->view('maintenance.priceModel.storage.create',compact("units")); } public function storageStore(Request $request) { if(!Gate::allows('计费模型-仓储-录入')){ return redirect('denied'); } $this->storageValidator($request->input())->validate(); app('OwnerStoragePriceModelService')->create($request->input()); return response()->redirectTo('maintenance/priceModel/storage')->with('successTip',"创建成功!"); } public function storageEdit($id) { if(!Gate::allows('计费模型-仓储-编辑')){ return redirect('denied'); } $model = app('OwnerStoragePriceModelService')->find($id); $units = app('UnitService')->getSelection(); return response()->view('maintenance.priceModel.storage.create',compact("units","model")); } public function storageUpdate(Request $request) { if(!Gate::allows('计费模型-仓储-编辑')){ return redirect('denied'); } app('OwnerStoragePriceModelService')->update(["id"=>$request->input("id")],[ "counting_type" => $request->input("counting_type"), "using_type" => $request->input("using_type"), "minimum_area" => $request->input("minimum_area"), "price" => $request->input("price"), "discount_type" => $request->input("discount_type"), "discount_value"=> $request->input("discount_value"), "unit_id" => $request->input("unit_id"), ]); return response()->redirectTo('maintenance/priceModel/storage')->with('successTip',"更新成功!"); } public function storageDestroy($id) { app("OwnerStoragePriceModelService")->destroy($id); return ["success"=>true]; } private function storageValidator(array $params) { return Validator::make($params,[ 'counting_type'=>['required'], 'using_type'=>['required'], 'minimum_area'=>['nullable','numeric','min:0'], 'discount_value'=>['nullable','numeric','min:0'], 'price'=>['required','numeric','min:0'], 'discount_type'=>['required'], 'unit_id'=>['required','integer'], ],[ 'required'=>':attribute 为必填项', 'min'=>':attribute 不得小于0', 'integer'=>':attribute 未选择', ],[ 'counting_type' =>"计费类型", 'using_type' =>"用仓类型", 'minimum_area' =>"最低起租面积", 'price' =>"单价", 'discount_type' =>"减免类型", 'discount_value'=>"减免值", 'unit_id' =>"单位", ]); } public function operationIndex(Request $request){ if(!Gate::allows('计费模型-作业-查询')){ return redirect('denied'); } $models = app('OwnerPriceOperationService')->paginate($request->input(),["ownerInStorageRule"=>function($query){$query->with("unit");}]); $owners = app("OwnerService")->getSelection(); return response()->view('maintenance.priceModel.operation.index',compact("models","owners")); } /* 获取出库模型规则 */ public function operationGetOutStorageRule(Request $request) { if(!Gate::allows('计费模型-作业-查询')){ return ["success"=>false,"data"=>"无权操作"]; } /** @var OwnerOutStorageRuleService $service */ $service = app('OwnerOutStorageRuleService'); $ownerOutStorageRules = $service->get(["owner_price_operation_id"=>$request->input("id")],["unit"],true)->append("featureFormat"); return ["success"=>true,"data"=>$ownerOutStorageRules]; } /* 修改出库模型规则 */ public function updateOutStorageRule(Request $request) { /** @var OwnerOutStorageRuleService $service */ $service = app('OwnerOutStorageRuleService'); $row = $service->update(["id"=>$request->input("id")],[ "amount"=>$request->input("amount"), "unit_id"=>$request->input("unit_id"), "priority"=>$request->input("priority"), "unit_price"=>$request->input("unit_price")]); if ($row == 1) return ["success"=>true]; return ["success"=>false,"data"=>"受影响数据数为:".$row]; } public function createOutStorageRule(Request $request) { /** @var OwnerOutStorageRuleService $service */ $service = app('OwnerOutStorageRuleService'); switch ($request->input("strategy")){ case "起步": $c = $service->isExist(["owner_price_operation_id"=>$request->input("owner_price_operation_id"),"strategy"=>"起步"]); if ($c > 0)return ["success"=>false,"data"=>"已存在起步策略"]; break; case "默认": $c = $service->isExist(["owner_price_operation_id"=>$request->input("owner_price_operation_id"),"strategy"=>"默认"]); if ($c > 0)return ["success"=>false,"data"=>"已存在默认策略"]; break; } $data = $service->create($request->input()); $data->load("unit"); return ["success"=>true,"data"=>$data]; } public function getFeatures(Request $request) { return ["success"=>true,"data"=>app("FeatureService")->translationFeature($request->input("feature"))]; } public function operationCreate(){ if(!Gate::allows('计费模型-作业-录入')){ return redirect('denied'); } return response()->view('maintenance.priceModel.operation.create'); } public function expressIndex(){ if(!Gate::allows('计费模型-快递-查询')){ return redirect('denied'); } return response()->view('maintenance.priceModel.express.index'); } public function expressCreate(){ if(!Gate::allows('计费模型-快递-录入')){ return redirect('denied'); } return response()->view('maintenance.priceModel.express.create'); } public function logisticIndex(){ if(!Gate::allows('计费模型-物流-查询')){ return redirect('denied'); } return response()->view('maintenance.priceModel.logistic.index'); } public function logisticCreate(){ if(!Gate::allows('计费模型-物流-录入')){ return redirect('denied'); } return response()->view('maintenance.priceModel.logistic.create'); } public function directLogisticIndex(){ if(!Gate::allows('计费模型-直发-查询')){ return redirect('denied'); } return response()->view('maintenance.priceModel.directLogistic.index'); } public function directLogisticCreate(){ if(!Gate::allows('计费模型-直发-录入')){ return redirect('denied'); } return response()->view('maintenance.priceModel.directLogistic.create'); } }