UserFundCheck1000Validator.php 616 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Module\Fund\Validators;
  3. use App\Module\Fund\Services\FundService;
  4. use UCore\Validator;
  5. /**
  6. * 账户余额检查
  7. * 数额*1000的
  8. *
  9. */
  10. class UserFundCheck1000Validator extends Validator
  11. {
  12. public function validate(mixed $value, array $data): bool
  13. {
  14. if ($value < 0) {
  15. return false;
  16. }
  17. $value = $value * 1000;
  18. $user_id = $this->args[0];
  19. $fund_id = $this->args[1];
  20. $fund = new FundService($user_id, $fund_id);
  21. if ($fund->balance() < $value) {
  22. return false;
  23. }
  24. return true;
  25. }
  26. }