PriceModelController.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Support\Facades\Gate;
  5. use Illuminate\Support\Facades\Validator;
  6. class PriceModelController extends Controller
  7. {
  8. public function storageIndex()
  9. {
  10. if(!Gate::allows('计费模型-仓储')){ return redirect('denied'); }
  11. $models = app('OwnerStoragePriceModelService')->paginate(["unit"]);
  12. return response()->view('maintenance.priceModel.storage.index',compact("models"));
  13. }
  14. public function storageCreate()
  15. {
  16. if(!Gate::allows('计费模型-仓储-录入')){ return redirect('denied'); }
  17. $units = app('UnitService')->getSelection();
  18. return response()->view('maintenance.priceModel.storage.create',compact("units"));
  19. }
  20. public function storageStore(Request $request)
  21. {
  22. if(!Gate::allows('计费模型-仓储-录入')){ return redirect('denied'); }
  23. $this->storageValidator($request->input())->validate();
  24. app('OwnerStoragePriceModelService')->create($request->input());
  25. return response()->redirectTo('maintenance/priceModel/storage')->with('successTip',"创建成功!");
  26. }
  27. public function storageEdit($id)
  28. {
  29. if(!Gate::allows('计费模型-仓储-编辑')){ return redirect('denied'); }
  30. $model = app('OwnerStoragePriceModelService')->find($id);
  31. $units = app('UnitService')->getSelection();
  32. return response()->view('maintenance.priceModel.storage.create',compact("units","model"));
  33. }
  34. public function storageUpdate(Request $request)
  35. {
  36. if(!Gate::allows('计费模型-仓储-编辑')){ return redirect('denied'); }
  37. app('OwnerStoragePriceModelService')->update(["id"=>$request->input("id")],[
  38. "counting_type" => $request->input("counting_type"),
  39. "using_type" => $request->input("using_type"),
  40. "minimum_area" => $request->input("minimum_area"),
  41. "price" => $request->input("price"),
  42. "discount_type" => $request->input("discount_type"),
  43. "discount_value"=> $request->input("discount_value"),
  44. "unit_id" => $request->input("unit_id"),
  45. ]);
  46. return response()->redirectTo('maintenance/priceModel/storage')->with('successTip',"更新成功!");
  47. }
  48. public function storageDestroy($id)
  49. {
  50. app("OwnerStoragePriceModelService")->destroy($id);
  51. return ["success"=>true];
  52. }
  53. private function storageValidator(array $params)
  54. {
  55. return Validator::make($params,[
  56. 'counting_type'=>['required'],
  57. 'using_type'=>['required'],
  58. 'minimum_area'=>['nullable','numeric','min:0'],
  59. 'discount_value'=>['nullable','numeric','min:0'],
  60. 'price'=>['required','numeric','min:0'],
  61. 'discount_type'=>['required'],
  62. 'unit_id'=>['required','integer'],
  63. ],[
  64. 'required'=>':attribute 为必填项',
  65. 'min'=>':attribute 不得小于0',
  66. 'integer'=>':attribute 未选择',
  67. ],[
  68. 'counting_type' =>"计费类型",
  69. 'using_type' =>"用仓类型",
  70. 'minimum_area' =>"最低起租面积",
  71. 'price' =>"单价",
  72. 'discount_type' =>"减免类型",
  73. 'discount_value'=>"减免值",
  74. 'unit_id' =>"单位",
  75. ]);
  76. }
  77. public function operationIndex(Request $request){
  78. if(!Gate::allows('计费模型-作业-查询')){ return redirect('denied'); }
  79. $models = app('OwnerPriceOperationService')->paginate($request->input(),["ownerInStorageRules","ownerOutStorageRules"]);
  80. $owners = app("OwnerService")->getSelection();
  81. return response()->view('maintenance.priceModel.operation.index',compact("models","owners"));
  82. }
  83. public function operationCreate(){
  84. if(!Gate::allows('计费模型-作业-录入')){ return redirect('denied'); }
  85. return response()->view('maintenance.priceModel.operation.create');
  86. }
  87. public function expressIndex(){
  88. if(!Gate::allows('计费模型-快递-查询')){ return redirect('denied'); }
  89. return response()->view('maintenance.priceModel.express.index');
  90. }
  91. public function expressCreate(){
  92. if(!Gate::allows('计费模型-快递-录入')){ return redirect('denied'); }
  93. return response()->view('maintenance.priceModel.express.create');
  94. }
  95. public function logisticIndex(){
  96. if(!Gate::allows('计费模型-物流-查询')){ return redirect('denied'); }
  97. return response()->view('maintenance.priceModel.logistic.index');
  98. }
  99. public function logisticCreate(){
  100. if(!Gate::allows('计费模型-物流-录入')){ return redirect('denied'); }
  101. return response()->view('maintenance.priceModel.logistic.create');
  102. }
  103. public function directLogisticIndex(){
  104. if(!Gate::allows('计费模型-直发-查询')){ return redirect('denied'); }
  105. return response()->view('maintenance.priceModel.directLogistic.index');
  106. }
  107. public function directLogisticCreate(){
  108. if(!Gate::allows('计费模型-直发-录入')){ return redirect('denied'); }
  109. return response()->view('maintenance.priceModel.directLogistic.create');
  110. }
  111. }