'require|in:wechat,alipay,bank', 'amount' => 'require|float|gt:0', 'account_id' => 'require|integer|gt:0', 'withdraw_sn' => 'require', 'status' => 'integer|in:-3,-2,-1,0,1,2', 'page' => 'integer|egt:1', 'page_size' => 'integer|between:1,100', 'year_month' => 'checkYearMonth', ]; protected $message = [ 'type.require' => '请选择提现类型', 'type.in' => '请选择正确的提现类型', 'amount.require' => '请输入提现金额', 'amount.float' => '请输入正确的提现金额', 'amount.gt' => '请输入正确的提现金额', 'account_id.require' => '请选择提现账户', 'account_id.integer' => '账户ID必须为整数', 'account_id.gt' => '请选择正确的提现账户', 'withdraw_sn.require' => '未找到您的提现信息', 'status.integer' => '状态必须为整数', 'status.in' => '请选择正确的状态', 'page.integer' => '页码必须为整数', 'page.egt' => '页码必须大于等于1', 'page_size.integer' => '分页大小必须为整数', 'page_size.between' => '分页大小必须在1-100之间', 'year_month.checkYearMonth' => '年月格式错误,请使用YYYY-MM格式,如2025-08', ]; protected $scene = [ 'index' => ['status', 'page', 'page_size', 'year_month'], 'apply' => ['type', 'amount', 'account_id'], 'transfer' => ['type', 'withdraw_sn'], 'retry' => ['type', 'withdraw_sn'], 'cancel' => ['type', 'withdraw_sn'], ]; /** * 验证年月格式 (YYYY-MM) * @param string $value * @param string $rule * @param array $data * @return bool|string */ protected function checkYearMonth($value, $rule, $data) { if (empty($value)) { return true; // 允许为空 } // 验证格式 YYYY-MM if (!preg_match('/^\d{4}-\d{2}$/', $value)) { return '年月格式错误,请使用YYYY-MM格式,如2025-08'; } list($year, $month) = explode('-', $value); $year = (int)$year; $month = (int)$month; // 验证年份范围(不限制具体范围,只要是4位数字即可) if ($year < 1000 || $year > 9999) { return '年份必须是4位数字'; } // 验证月份范围 if ($month < 1 || $month > 12) { return '月份必须在01-12之间'; } return true; } }