AssetLeaseValidate.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\validate\asset;
  15. use app\common\validate\BaseValidate;
  16. use app\common\model\asset\AssetInfo;
  17. use app\common\model\asset\AssetLeaseInfo;
  18. /**
  19. * 资产租赁管理验证
  20. * Class ArticleValidate
  21. * @package app\adminapi\validate\article
  22. */
  23. class AssetLeaseValidate extends BaseValidate
  24. {
  25. protected $rule = [
  26. 'id' => 'require|checkAssetInfo',
  27. 'a_id' => 'require|checkAssetDataInfo',
  28. 'tenant_name' => 'require|length:1,50',
  29. 'tenant_mobile' => 'require|length:1,13',
  30. 'lease_contract_image' => 'require',
  31. 'lease_money' => 'require',
  32. 'lease_start_time' => 'require',
  33. 'referee_name'=>'require',
  34. 'first_status' => 'in:1,2,3',
  35. 'second_status' => 'in:0,1,2,3',
  36. 'approval_status'=>'in:1,2,3,4,5,6',
  37. 'is_pay'=>'require|in:1,0',
  38. ];
  39. protected $message = [
  40. 'id.require' => '租赁资产订单信息id必传',
  41. 'tenant_name.require' => '租赁人姓名必传!',
  42. 'tenant_name.length' => '资产名称长度须在1-50位字符',
  43. 'tenant_mobile.require' => '租赁人联系方式必传!',
  44. 'tenant_mobile.length' => '租赁人联系方式长度须在1-13位字符',
  45. 'lease_contract_image.require' => '合同照片必传',
  46. 'lease_money.require' => '租赁金额必传',
  47. 'referee_name.require' => '提审人不能为空',
  48. 'approval_status.in' => '审批状态值错误',
  49. 'is_pay.require' => '缴费状态必传',
  50. ];
  51. /**
  52. * @notes 添加场景
  53. * @return ArticleValidate
  54. * @author heshihu
  55. * @date 2022/2/22 9:57
  56. */
  57. public function sceneAdd()
  58. {
  59. return $this->remove(['id','is_pay'])
  60. ->remove('id','require|checkAssetInfo')
  61. ->remove('is_pay','require');
  62. }
  63. /**
  64. * @notes 详情场景
  65. * @return ArticleValidate
  66. * @author heshihu
  67. * @date 2022/2/22 10:15
  68. */
  69. public function sceneDetail()
  70. {
  71. return $this->only(['id']);
  72. }
  73. /**
  74. * @notes 更改状态场景
  75. * @return ArticleValidate
  76. * @author heshihu
  77. * @date 2022/2/22 10:18
  78. */
  79. public function sceneStatus()
  80. {
  81. return $this->only(['id', 'status']);
  82. }
  83. /**
  84. * @notes 更改支付状态场景
  85. * @return ArticleValidate
  86. * @author heshihu
  87. * @date 2022/2/22 10:18
  88. */
  89. public function scenePay()
  90. {
  91. return $this->only(['id', 'is_pay']);
  92. }
  93. public function sceneEdit()
  94. {
  95. return $this->only(['id']);
  96. }
  97. public function sceneDelete()
  98. {
  99. return $this->only(['id']);
  100. }
  101. public function sceneApprove(){
  102. return $this->only(['id', 'approval_status']);
  103. }
  104. public function sceneEnd(){
  105. return $this->only(['id']);
  106. }
  107. /**
  108. * @notes 检查指定资讯是否存在
  109. * @param $value
  110. * @return bool|string
  111. * @author heshihu
  112. * @date 2022/2/22 10:11
  113. */
  114. public function checkAssetInfo($value)
  115. {
  116. $article = AssetLeaseInfo::findOrEmpty($value);
  117. if ($article->isEmpty()) {
  118. return '租赁资产订单信息不存在';
  119. }
  120. return true;
  121. }
  122. public function checkAssetDataInfo($value){
  123. $article = AssetInfo::findOrEmpty($value);
  124. if ($article->isEmpty()) {
  125. return '资产不存在或已删除';
  126. }
  127. return true;
  128. }
  129. }