UserFund1CheckValidator.php 861 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Module\Fund\Validators;
  3. use App\Module\Fund\Services\FundService;
  4. use UCore\Helper\Logger;
  5. use UCore\Validator;
  6. /**
  7. * 账户1检查
  8. *
  9. */
  10. class UserFund1CheckValidator extends Validator
  11. {
  12. // arg 0: user_idF, 1: field
  13. public function validate(mixed $value, array $data): bool
  14. {
  15. if($value < 0 ) {
  16. return false;
  17. }
  18. $user_idF = $this->args[0];
  19. $user_id = $data[$user_idF];
  20. $fund = new FundService($user_id, 1);
  21. $v2 = $value ;
  22. // dd($v2,$fund->balance());
  23. if ($fund->balance() < $v2) {
  24. Logger::error(" $user_id - fund-1 {$fund->balance()} < $value . ");
  25. return false;
  26. }
  27. $field = $this->args[1] ?? "";
  28. if ($field) {
  29. $this->validation->$field = $fund;
  30. }
  31. return true;
  32. }
  33. }