CashOut.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\validate\member;
  12. use app\dict\member\MemberAccountTypeDict;
  13. use app\dict\pay\TransferDict;
  14. use think\Validate;
  15. /**
  16. * 提现验证类
  17. */
  18. class CashOut extends Validate
  19. {
  20. protected $rule = [
  21. 'apply_money' => 'min:0.01', // 提现金额
  22. 'account_type' => 'checkAccountType',
  23. 'transfer_type' => 'checkTransferType',
  24. 'account_id' => 'checkAccountId'
  25. ];
  26. protected $message = [
  27. 'apply_money.min' => 'validate_member_cash_out.apply_money_min',
  28. ];
  29. protected $scene = [
  30. 'apply' => ['apply_money', 'account_type', 'transfer_type', 'account_id'],
  31. ];
  32. protected function checkAccountId($value, $rule, $data = [])
  33. {
  34. if ($data['transfer_type'] == TransferDict::WECHAT) {
  35. return true;
  36. } else {
  37. return !empty($value) ? true : 'validate_member_cash_out.account_id_require';
  38. }
  39. }
  40. protected function checkTransferType($value)
  41. {
  42. return array_key_exists($value, TransferDict::getTransferType()) ? true : 'validate_member_cash_out.not_support_transfer_type';
  43. }
  44. protected function checkAccountType($value)
  45. {
  46. $account_type = [MemberAccountTypeDict::MONEY, MemberAccountTypeDict::COMMISSION];
  47. return in_array($value, $account_type) ? true : 'validate_member_cash_out.not_support_account_type';
  48. }
  49. }