BankAccountForm.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace common\forms;
  3. use common\enums\AccountTypeEnum;
  4. use common\enums\StatusEnum;
  5. use common\helpers\ArrayHelper;
  6. use common\models\member\BankAccount;
  7. /**
  8. * Class BankAccountForm
  9. * @package common\models\forms
  10. * @author jianyan74 <751393839@qq.com>
  11. */
  12. class BankAccountForm extends BankAccount
  13. {
  14. /**
  15. * @return array
  16. */
  17. public function rules()
  18. {
  19. return ArrayHelper::merge(parent::rules(), [
  20. ['account_type', 'verifyAccountType']
  21. ]);
  22. }
  23. /**
  24. * @param $attribute
  25. */
  26. public function verifyAccountType($attribute)
  27. {
  28. if ($this->status == StatusEnum::DELETE) {
  29. return;
  30. }
  31. if ($this->account_type == AccountTypeEnum::UNION) {
  32. !$this->account_number && $this->addError($attribute, '请填写银行账号');
  33. !$this->bank_name && $this->addError($attribute, '请填写支行信息');
  34. }
  35. if ($this->account_type == AccountTypeEnum::ALI) {
  36. !$this->account_number && $this->addError($attribute, '请填写支付宝账号');
  37. }
  38. }
  39. }
粤ICP备19079148号