| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace App\Module\Transfer\Validations;
- use UCore\ValidationCore;
- use App\Module\Transfer\Validators\TransferBalanceValidator;
- /**
- * 第三方应用转出验证类
- * 专门为第三方应用提取请求设计,跳过密码验证
- */
- class TransferOutThirdPartyValidation extends ValidationCore
- {
- /** @var \App\Module\Transfer\Models\TransferApp|null 转账应用对象,由验证器设置 */
- public ?\App\Module\Transfer\Models\TransferApp $transfer_app = null;
- /**
- * 验证规则
- */
- public function rules($rules = []): array
- {
- return [
- // 基础验证
- ['transfer_app_id,user_id', 'required'],
- ['transfer_app_id,user_id', 'integer', 'min' => 1],
- ['amount', 'required'],
- ['amount', 'string'], // 第三方应用金额作为字符串处理,避免精度问题
- // 余额验证:确保用户余额充足
- ['amount', new TransferBalanceValidator($this), 'msg' => '用户余额不足'],
- // 注意:这里不要求password字段,因为第三方应用不需要密码验证
- ['google_code', 'string', 'size' => 6],
- ['out_user_id', 'string', 'max' => 50],
- ['remark', 'string', 'max' => 255],
- ['callback_data', 'array'],
- ];
- }
- /**
- * 默认值
- */
- public function default(): array
- {
- return [];
- }
- }
|