TransferInValidation.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Module\Transfer\Validations;
  3. use App\Module\Transfer\Validators\TransferOrderInValidator;
  4. use UCore\ValidationCore;
  5. /**
  6. * 转入验证类
  7. */
  8. class TransferInValidation extends ValidationCore
  9. {
  10. /** @var \App\Module\Transfer\Models\TransferApp|null 转账应用对象,由验证器设置 */
  11. public ?\App\Module\Transfer\Models\TransferApp $transfer_app = null;
  12. /**
  13. * 验证规则
  14. */
  15. public function rules($rules = []): array
  16. {
  17. return [
  18. // 基础验证
  19. [ 'transfer_app_id,out_order_id,user_id', 'required' ],
  20. [ 'transfer_app_id,user_id', 'integer', 'min' => 1 ],
  21. [ 'out_order_id', 'string', 'max' => 100 ],
  22. [ 'amount', 'required' ],
  23. [ 'amount', 'float', 'min' => 0.1, 'max' => 10000000 ], // 限制最大金额为1000万,防止异常大金额
  24. [ 'out_user_id', 'string', 'max' => 50 ],
  25. [ 'remark', 'string', 'max' => 255 ],
  26. [ 'callback_data', 'array' ],
  27. [
  28. 'out_order_id', new TransferOrderInValidator($this, []),
  29. 'msg' => '外部订单号重复'
  30. ]
  31. ];
  32. }
  33. /**
  34. * 默认值
  35. */
  36. public function default(): array
  37. {
  38. return [];
  39. }
  40. }