DistributionMemberValidate.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\validate\distribution;
  20. use app\common\model\User;
  21. use app\common\validate\BaseValidate;
  22. /**
  23. * 分销会员验证器
  24. * Class DistributionMemberValidate
  25. * @package app\adminapi\validate
  26. */
  27. class DistributionMemberValidate extends BaseValidate
  28. {
  29. protected $rule = [
  30. 'ids' => 'require|array',
  31. 'level_id' => 'require',
  32. 'user_id' => 'require|checkUserId',
  33. ];
  34. protected $message = [
  35. 'ids.require' => '参数缺失',
  36. 'ids.array' => '参数须为数组格式',
  37. 'level_id.require' => '请选择分销等级',
  38. 'user_id.require' => '参数缺失',
  39. ];
  40. /**
  41. * @notes 开通分销
  42. * @return DistributionMemberValidate
  43. * @author Tab
  44. * @date 2021/9/14 16:54
  45. */
  46. public function sceneOpen()
  47. {
  48. return $this->only(['ids', 'level_id']);
  49. }
  50. /**
  51. * @notes 查看分销商详情
  52. * @return DistributionMemberValidate
  53. * @author Tab
  54. * @date 2021/9/14 16:56
  55. */
  56. public function sceneDetail()
  57. {
  58. return $this->only(['user_id']);
  59. }
  60. /**
  61. * @notes 调整分销商等级界面
  62. * @return DistributionMemberValidate
  63. * @author Tab
  64. * @date 2021/9/14 18:45
  65. */
  66. public function sceneAdjustLevelInfo()
  67. {
  68. return $this->only(['user_id']);
  69. }
  70. /**
  71. * @notes 调整分销商等级
  72. * @return DistributionMemberValidate
  73. * @author Tab
  74. * @date 2021/9/14 18:57
  75. */
  76. public function sceneAdjustLevel()
  77. {
  78. return $this->only(['user_id', 'level_id']);
  79. }
  80. /**
  81. * @notes 冻结/解冻资格
  82. * @return DistributionMemberValidate
  83. * @author Tab
  84. * @date 2021/9/14 19:10
  85. */
  86. public function sceneFreeze()
  87. {
  88. return $this->only(['user_id']);
  89. }
  90. /**
  91. * @notes 查看下级
  92. * @return DistributionMemberValidate
  93. * @author Tab
  94. * @date 2021/9/14 19:23
  95. */
  96. public function sceneFans()
  97. {
  98. return $this->only(['user_id']);
  99. }
  100. /**
  101. * @notes 下级列表
  102. * @return DistributionMemberValidate
  103. * @author Tab
  104. * @date 2021/9/14 20:11
  105. */
  106. public function sceneFansLists()
  107. {
  108. return $this->only(['user_id']);
  109. }
  110. function checkUserId($user_id, $rule, $data)
  111. {
  112. $user = User::findOrEmpty($user_id);
  113. if (empty($user['id'])) {
  114. return '用户不存在';
  115. }
  116. if ($user['user_delete'] && (request()->isPost() || request()->isAjax())) {
  117. return '用户已注销,不能操作';
  118. }
  119. return true;
  120. }
  121. }