1
zj
9 hours ago f658569891db433854221b80f0a9fa99608cff64
trading-order-service/src/main/java/com/yami/trading/service/impl/UserServiceImpl.java
@@ -1011,6 +1011,7 @@
//      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("请输入正确的手机号码");
@@ -1617,6 +1618,7 @@
        User user = null;
        // 手机
        if (type == 1) {
            rejectMainlandChinaPhoneRegister(userName);
            if (!isValidPhone(userName)) {
                throw new YamiShopBindException("手机号格式不正常");
            }
@@ -1778,6 +1780,22 @@
        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]*");