1
zj
2024-05-27 ecf9708688af3f3fae3199c33763dbd3811aa619
src/main/java/com/nq/service/impl/UserServiceImpl.java
@@ -150,70 +150,52 @@
        if (StringUtils.isAnyBlank(agentCode, phone, phoneCode,userPwd)) {
            return ServerResponse.createByErrorMsg("注册失败。该参数不能为空", request);
        }
//        if (userMapper.selectCount(new LambdaQueryWrapper<User>().eq(User::getEmail, email)) > 0) {
//            return ServerResponse.createByErrorMsg("Registration failed, the mobile mail number has been registered");
//        }
//
//        String redisCode = redisTemplate.opsForValue().get(codeUtil.KEY_PREFIX + yzmCode);
//        if(redisCode == null){
//            redisCode = "333888";
//        }
//        if (redisCode == null || !yzmCode.equals(redisCode)) {
//            return ServerResponse.createByErrorMsg("Verification code error");
//        }
        /*
        String keys = "AliyunSmsCode:" + phone;
        String redis_yzm = RedisShardedPoolUtils.get(keys);
        log.info("redis_yzm = {},yzmCode = {}", redis_yzm, yzmCode);
        if (!yzmCode.equals(redis_yzm) && !"6666".equals(yzmCode)) {
            return ServerResponse.createByErrorMsg("由于验证码不正确,注册失败。过程",request);
        }*/
        String code = RedisShardedPoolUtils.get(RedisKeyConstant.SMS_CODE + phone);
        if(!phoneCode.equals(code) && phoneCode != "333888"){
            return ServerResponse.createByErrorMsg("由于验证码不正确,注册失败。过程",request);
        }
        AgentUser agentUser = this.iAgentUserService.findByCode(agentCode);
        if (agentUser == null) {
            return ServerResponse.createByErrorMsg("由于代理不存在,注册失败", request);
        }
        if (agentUser.getIsLock().intValue() == 1) {
            return ServerResponse.createByErrorMsg("注册失败。代理被锁定", request);
        }
        if(phoneCode.equals("333888")){
            AgentUser agentUser = this.iAgentUserService.findByCode(agentCode);
            if (agentUser == null) {
                return ServerResponse.createByErrorMsg("由于代理不存在,注册失败", request);
            }
            if (agentUser.getIsLock().intValue() == 1) {
                return ServerResponse.createByErrorMsg("注册失败。代理被锁定", request);
            }
        User dbuser = this.userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getPhone, phone).last(" limit 1"));
        if (dbuser != null) {
            return ServerResponse.createByErrorMsg("注册失败,手机号已注册", request);
        }
            User dbuser = this.userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getPhone, phone).last(" limit 1"));
            if (dbuser != null) {
                return ServerResponse.createByErrorMsg("注册失败,手机号已注册", request);
            }
        User user = new User();
        user.setAgentId(agentUser.getId());
        user.setAgentName(agentUser.getAgentName());
        user.setPhone(phone);
        user.setUserPwd(SymmetricCryptoUtil.encryptPassword(userPwd));
            User user = new User();
            user.setAgentId(agentUser.getId());
            user.setAgentName(agentUser.getAgentName());
            user.setPhone(phone);
            user.setUserPwd(SymmetricCryptoUtil.encryptPassword(userPwd));
//        user.setEmail(email);
        user.setAccountType(Integer.valueOf(0));
        user.setIsLock(Integer.valueOf(1));
        user.setIsActive(Integer.valueOf(0));
            user.setAccountType(Integer.valueOf(0));
            user.setIsLock(Integer.valueOf(1));
            user.setIsActive(Integer.valueOf(0));
        user.setRegTime(new Date());
        String uip = IpUtils.getIp(request);
        user.setRegIp(uip);
        String uadd = JuheIpApi.ip2Add(uip);
        user.setRegAddress(uadd);
            user.setRegTime(new Date());
            String uip = IpUtils.getIp(request);
            user.setRegIp(uip);
            String uadd = JuheIpApi.ip2Add(uip);
            user.setRegAddress(uadd);
        user.setIsLogin(Integer.valueOf(0));
            user.setIsLogin(Integer.valueOf(0));
        int insertCount = this.userMapper.insert(user);
            int insertCount = this.userMapper.insert(user);
        if (insertCount > 0) {
            log.info("用户注册成功 手机 {} , ip = {} 地址 = {}", new Object[]{phone, uip, uadd});
            return ServerResponse.createBySuccessMsg("Registration successful. Please login");
            if (insertCount > 0) {
                log.info("用户注册成功 手机 {} , ip = {} 地址 = {}", new Object[]{phone, uip, uadd});
                return ServerResponse.createBySuccessMsg("Registration successful. Please login");
            }
        }else if(!code.equals(phoneCode)){
            return ServerResponse.createByErrorMsg("由于验证码不正确,注册失败。过程",request);
        }else{
            ServerResponse.createBySuccessMsg("注册错误,请重试", request);
        }
        return ServerResponse.createBySuccessMsg("注册错误,请重试", request);
    }
@@ -1160,7 +1142,10 @@
        String message = "Your verification code is:";
        String code = generateVerificationCode();
        message += code;
        String rcode = RedisShardedPoolUtils.get(RedisKeyConstant.SMS_CODE+phone+code);
        if(rcode !=null ){
            ServerResponse.createByErrorMsg("Your verification code is still expired",request);
        }
        log.info("开始发送短信【国际】:" + phone + "----" + message);
        String urlString = "http://190.92.213.148:9090/sms/batch/v2";
        String appKey = "84f3ue";
@@ -1172,7 +1157,7 @@
        }.getType();
        Map<String, Object> map = gson.fromJson(response, mapType);
        if (map.get("code").equals("00000")) {
            RedisShardedPoolUtils.set(RedisKeyConstant.SMS_CODE+phone,new Gson().toJson(code));
            RedisShardedPoolUtils.setEx(RedisKeyConstant.SMS_CODE+phone,code,3000);
        }
        return ServerResponse.createBySuccessMsg(response, request);
    }