1
zj
2024-05-29 326e3f167ec3e7942911b027e2b63e64476e4ad4
src/main/java/com/nq/service/impl/UserServiceImpl.java
@@ -150,31 +150,10 @@
        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);
        if(!phoneCode.equals("333888") && !code.equals(phoneCode)){
            return ServerResponse.createByErrorMsg("由于验证码不正确,注册失败。",request);
        }
        AgentUser agentUser = this.iAgentUserService.findByCode(agentCode);
        if (agentUser == null) {
            return ServerResponse.createByErrorMsg("由于代理不存在,注册失败", request);
@@ -183,12 +162,15 @@
            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);
        }
        //去掉手机号国家区号
        if (phone.startsWith("91")) {
            phone = phone.substring(2);
        }
        User user = new User();
        user.setAgentId(agentUser.getId());
@@ -214,8 +196,9 @@
        if (insertCount > 0) {
            log.info("用户注册成功 手机 {} , ip = {} 地址 = {}", new Object[]{phone, uip, uadd});
            return ServerResponse.createBySuccessMsg("Registration successful. Please login");
        }else{
            return ServerResponse.createByErrorMsg("注册失败,请重试", request);
        }
        return ServerResponse.createBySuccessMsg("注册错误,请重试", request);
    }
@@ -1160,7 +1143,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 +1158,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+"91"+phone,code,3000);
        }
        return ServerResponse.createBySuccessMsg(response, request);
    }