| | |
| | | // if (reg.getUsername().indexOf("@") == -1) { |
| | | if (type.equals("1")) { |
| | | // 手机注册 |
| | | rejectMainlandChinaPhoneRegister(username); |
| | | // if (StringUtils.isEmptyString(reg.getUsername()) || !Strings.isNumber(reg.getUsername()) || reg.getUsername().length() > 15) { |
| | | if (StringUtils.isEmptyString(username) || username.length() > 20) { |
| | | throw new YamiShopBindException("请输入正确的手机号码"); |
| | |
| | | User user = null; |
| | | // 手机 |
| | | if (type == 1) { |
| | | rejectMainlandChinaPhoneRegister(userName); |
| | | if (!isValidPhone(userName)) { |
| | | throw new YamiShopBindException("手机号格式不正常"); |
| | | } |
| | |
| | | return user; |
| | | } |
| | | |
| | | /** |
| | | * 禁止大陆 +86 / 86 前缀手机号注册(与风控一致) |
| | | */ |
| | | private void rejectMainlandChinaPhoneRegister(String phoneRaw) { |
| | | if (StringUtils.isEmptyString(phoneRaw)) { |
| | | return; |
| | | } |
| | | String phone = phoneRaw.trim(); |
| | | if (phone.startsWith("+86")) { |
| | | throw new YamiShopBindException("不支持+86大陆手机号注册"); |
| | | } |
| | | if (phone.matches("^86(1[3-9])\\d{9}$")) { |
| | | throw new YamiShopBindException("不支持86前缀大陆手机号注册"); |
| | | } |
| | | } |
| | | |
| | | // 手机号校验 |
| | | private boolean isValidPhone(String username) { |
| | | Pattern p = Pattern.compile("[0-9]*"); |