新版仿ok交易所-后端
zyy
2025-09-19 69a9a663e1adde509f316f8c65522c094debba0a
重置账号
3 files modified
142 ■■■■ changed files
trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiUserController.java 43 ●●●●● patch | view | raw | blame | history
trading-order-service/src/main/java/com/yami/trading/service/impl/UserServiceImpl.java 96 ●●●● patch | view | raw | blame | history
trading-order-service/src/main/java/com/yami/trading/service/user/UserService.java 3 ●●●●● patch | view | raw | blame | history
trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiUserController.java
@@ -211,6 +211,49 @@
    }
    /**
     * 重置登录账号
     */
    @RequestMapping("resetUserName")
    public Object resetUserName(String username, String password, String safeword, String verifcode, String type) {
        String userId = SecurityUtils.getUser().getUserId();
        if (StringUtils.isEmptyString(userId)) {
            throw new YamiShopBindException("请先登录");
        }
        // 重置类型:1/手机;2/邮箱;
        String error = this.validateParam(username, verifcode, password, type);
        if (!StringUtils.isNullOrEmpty(error)) {
            throw new YamiShopBindException(error);
        }
        if (StringUtils.isEmptyString(safeword)) {
            throw new YamiShopBindException("资金密码不能为空");
        }
        userService.resetUserName(userId ,username, password, safeword, verifcode, type);
        User secUser = userService.findByUserName(username);
        Log log = new Log();
        log.setCategory(Constants.LOG_CATEGORY_SECURITY);
        log.setLog("用户重置登录账号,ip[" + IPHelper.getIpAddr() + "]");
        log.setUserId(secUser.getUserId());
        log.setUsername(username);
        logService.save(log);
        UserInfoInTokenBO userInfoInToken = new UserInfoInTokenBO();
        userInfoInToken.setUserId(secUser.getUserId());
        userInfoInToken.setSysType(SysTypeEnum.ORDINARY.value());
        userInfoInToken.setEnabled(secUser.getStatus() == 1);
        tokenStore.deleteAllToken(String.valueOf(SysTypeEnum.ORDINARY.value()), String.valueOf(secUser.getUserId()));
        TokenInfoVO tokenInfoVO = tokenStore.storeAndGetVo(userInfoInToken);
        this.userService.online(secUser.getUserId());
        this.ipMenuService.saveIpMenuWhite(IPHelper.getIpAddr());
        Map<String, Object> data = new HashMap<String, Object>();
        data.put("token", tokenInfoVO.getAccessToken());
        data.put("username", secUser.getUserName());
        data.put("usercode", secUser.getUserName());
        secUser.setUserLastip(IPHelper.getIpAddr());
        userService.updateById(secUser);
        return Result.succeed(data);
    }
    /**
     * 设置资金密码(注册时)
     */
    @PostMapping("/setSafewordReg")
trading-order-service/src/main/java/com/yami/trading/service/impl/UserServiceImpl.java
@@ -82,14 +82,14 @@
    }
    @Override
    public Page<UserDto> listUser(Page page, List<String> roleNames, String userCode, String userName,List<String> checkedList) {
        return baseMapper.listUser(page, roleNames, userCode, userName,checkedList);
    public Page<UserDto> listUser(Page page, List<String> roleNames, String userCode, String userName, List<String> checkedList) {
        return baseMapper.listUser(page, roleNames, userCode, userName, checkedList);
    }
    @Override
    public Page<UserDataDto> listUserAndRecom(Page page, List<String> roleNames, String userCode, String userName, String lastIp,List<String> checkedList) {
    public Page<UserDataDto> listUserAndRecom(Page page, List<String> roleNames, String userCode, String userName, String lastIp, List<String> checkedList) {
        return baseMapper.listUserAndRecom(page, roleNames, userCode,
                userName, lastIp,checkedList);
                userName, lastIp, checkedList);
    }
    @Override
@@ -164,12 +164,12 @@
        Page<AgentUserDto> page = new Page(current, size);
        List children = null;
        if (!StringUtils.isNullOrEmpty(targetPartyId)) {
            children=userRecomService.findRecomsToPartyId(targetPartyId);
            children = userRecomService.findRecomsToPartyId(targetPartyId);
            if (children.size() == 0) {
                return new Page();
            }
        }
            baseMapper.getAgentAllStatistics(page, userName,children);
        baseMapper.getAgentAllStatistics(page, userName, children);
        /**
         * 页面查询第一层partyId级
         */
@@ -511,7 +511,7 @@
        User party_reco = findUserByUserCode(recoUserCode);
//        用户注册是否需要推荐码
        if ("true".equals(sysparaService.find("register_need_usercode").getSvalue())) {
            if (StringUtils.isNotEmpty(recoUserCode)){
            if (StringUtils.isNotEmpty(recoUserCode)) {
                if (party_reco == null) {
                    throw new YamiShopBindException("请输入正确的推荐码");
                }
@@ -589,7 +589,7 @@
                    throw new YamiShopBindException("操作失败!修正后账户余额小于0。");
                }
                walletService.update(wallet.getUserId().toString(), gift_sum);
                userDataService.saveGiftMoneyHandle(wallet.getUserId(),gift_sum);
                userDataService.saveGiftMoneyHandle(wallet.getUserId(), gift_sum);
                /*
                 * 保存账变日志
@@ -739,7 +739,7 @@
                    throw new YamiShopBindException("操作失败!修正后账户余额小于0。");
                }
                this.walletService.update(wallet.getUserId().toString(), gift_sum);
                userDataService.saveGiftMoneyHandle(wallet.getUserId(),gift_sum);
                userDataService.saveGiftMoneyHandle(wallet.getUserId(), gift_sum);
                // 保存账变日志
//                MoneyLog moneyLog = new MoneyLog();
@@ -847,23 +847,23 @@
        //推荐人
        if (StrUtil.isNotBlank(userCode)) {
//            if ("true".equals(this.sysparaService.find("register_need_usercode").getSvalue())) {
                if (null == recomUser) {
                    throw new YamiShopBindException("推荐码不正确");
                }
                if (UserConstants.SECURITY_ROLE_TEST.equals(recomUser.getRoleName())) {
                    throw new YamiShopBindException("推荐人无权限推荐");
                }
                if (recomUser.getStatus() == 0) {
                    throw new YamiShopBindException("推荐人无权限推荐");
                }
                UserRecom userRecom = new UserRecom();
                userRecom.setUserId(recomUser.getUserId());
                // 父类partyId
                userRecom.setRecomUserId(user.getUserId());
                userRecomService.save(userRecom);
                user.setUserRecom(recomUser.getUserId());
                updateById(user);
           // }
            if (null == recomUser) {
                throw new YamiShopBindException("推荐码不正确");
            }
            if (UserConstants.SECURITY_ROLE_TEST.equals(recomUser.getRoleName())) {
                throw new YamiShopBindException("推荐人无权限推荐");
            }
            if (recomUser.getStatus() == 0) {
                throw new YamiShopBindException("推荐人无权限推荐");
            }
            UserRecom userRecom = new UserRecom();
            userRecom.setUserId(recomUser.getUserId());
            // 父类partyId
            userRecom.setRecomUserId(user.getUserId());
            userRecomService.save(userRecom);
            user.setUserRecom(recomUser.getUserId());
            updateById(user);
            // }
        }
        return user;
    }
@@ -1234,7 +1234,7 @@
            recomUser = findUserByUserCode(userCode);
            if ("true".equals(this.sysparaService.find("register_need_usercode").getSvalue())) {
                if (StrUtil.isEmpty(userCode)){
                if (StrUtil.isEmpty(userCode)) {
                    throw new YamiShopBindException("请输入推荐码");
                }
                if (null == recomUser) {
@@ -1376,7 +1376,7 @@
                if (Arith.add(gift_sum, walletExtend.getMoney().doubleValue()) < 0.0D) {
                    throw new YamiShopBindException("操作失败!修正后账户余额小于0。");
                }
                userDataService.saveGiftMoneyHandle(user.getUserId(),gift_sum);
                userDataService.saveGiftMoneyHandle(user.getUserId(), gift_sum);
                this.walletService.update(wallet.getUserId(), gift_sum);
                // 保存账变日志
//                MoneyLog moneyLog = new MoneyLog();
@@ -1542,4 +1542,44 @@
        }
        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());
        }
    }
}
trading-order-service/src/main/java/com/yami/trading/service/user/UserService.java
@@ -139,4 +139,7 @@
    Page  getAgentAllStatistics(long current,long size,String startTime, String endTime,String userName,
                                String userId);
    void resetUserName(String userId, String username, String password, String safeword, String verifcode, String type);
}