新版仿ok交易所-后端
zyy
2025-09-19 69a9a663e1adde509f316f8c65522c094debba0a
trading-order-service/src/main/java/com/yami/trading/service/impl/UserServiceImpl.java
@@ -1541,5 +1541,45 @@
            userLevel = 1;
        }
        return userLevel;
    }
    @Override
    public void resetUserName(String userId, String username, String password, String safeword, String verifcode, String type) {
        User party = getById(userId);
        if (party == null) {
            throw new YamiShopBindException("账号不存在");
        }
        String authCode = identifyingCodeTimeWindowService.getAuthCode(username.trim());
        if ((authCode == null) || (!authCode.equals(verifcode))) {
            throw new YamiShopBindException("验证码不正确");
        }
        if (!passwordEncoder.matches(password, party.getLoginPassword())) {
            throw new YamiShopBindException("密码不正确!");
        }
        if (!passwordEncoder.matches(safeword, party.getSafePassword())) {
            throw new YamiShopBindException("资金密码不正确!");
        }
        if (findByUserName(username) != null) {
            throw new YamiShopBindException("用户名重复");
        }
        party.setUserName(username);
        save(party);
        if (type.equals("1")) {
            // 手机注册
//         if (StringUtils.isEmptyString(reg.getUsername()) || !Strings.isNumber(reg.getUsername()) || reg.getUsername().length() > 15) {
            if (StringUtils.isEmptyString(username) || username.length() > 20) {
                throw new YamiShopBindException("请输入正确的手机号码");
            }
            this.savePhone(username, party.getUserId());
        } else {
            // 邮箱注册
            if (!Strings.isEmail(username)) {
                throw new YamiShopBindException("请输入正确的邮箱地址");
            }
            if (findPartyByEmail(username) != null) {
                throw new YamiShopBindException("邮箱已重复");
            }
            this.saveEmail(username, party.getUserId());
        }
    }
}