| | |
| | | return ServerResponse.createByErrorMsg("注册失败, 参数不能为空"); |
| | | } |
| | | |
| | | if (!com.nq.utils.PhoneUtil.isValidChinaMobile(phone)) { |
| | | return ServerResponse.createByErrorMsg("注册失败, 手机号格式不正确"); |
| | | } |
| | | phone = com.nq.utils.PhoneUtil.normalizeChinaMobile(phone); |
| | | |
| | | // 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("注册失败, 验证码错误"); |
| | | // } |
| | | if (com.nq.utils.sms.SmsConstants.isVerifyEnabled()) { |
| | | if (StringUtils.isBlank(yzmCode)) { |
| | | return ServerResponse.createByErrorMsg("注册失败, 请输入短信验证码"); |
| | | } |
| | | |
| | | String keys = com.nq.utils.sms.SmsConstants.SMS_CODE_PREFIX + phone; |
| | | String redis_yzm = RedisShardedPoolUtils.get(keys); |
| | | |
| | | log.info("redis_yzm = {},yzmCode = {}", redis_yzm, yzmCode); |
| | | if (StringUtils.isBlank(redis_yzm) || !yzmCode.equals(redis_yzm)) { |
| | | return ServerResponse.createByErrorMsg("注册失败, 验证码错误或已过期"); |
| | | } |
| | | RedisShardedPoolUtils.del(keys); |
| | | } |
| | | |
| | | AgentUser agentUser = this.iAgentUserService.findByCode(agentCode); |
| | | if (agentUser == null) { |
| | |
| | | user.setIsActive(Integer.valueOf(0)); |
| | | |
| | | user.setRegTime(new Date()); |
| | | // String uip = IpUtils.getIp(request); |
| | | // user.setRegIp(uip); |
| | | // // IP地址查询改为异步处理,避免阻塞注册接口 |
| | | // final String finalUip = uip; |
| | | // final String finalPhone = phone; |
| | | // new Thread(() -> { |
| | | // try { |
| | | // String uadd = JuheIpApi.ip2Add(finalUip); |
| | | // log.info("用户注册IP地址查询完成 手机 {} , ip = {} 地址 = {}", finalPhone, finalUip, uadd); |
| | | // } catch (Exception e) { |
| | | // log.error("IP地址查询异常", e); |
| | | // } |
| | | // }).start(); |
| | | String uip = IpUtils.getIp(request); |
| | | user.setRegIp(StringUtils.isBlank(uip) ? "--" : uip); |
| | | String uadd = JuheIpApi.ip2Add(uip); |
| | | user.setRegAddress(StringUtils.isBlank(uadd) ? "未知" : uadd); |
| | | |
| | | user.setIsLogin(Integer.valueOf(0)); |
| | | |
| | |
| | | String newAgentCode = generateUniqueAgentCode(); |
| | | agentUser.setAgentCode(newAgentCode); |
| | | iAgentUserService.updateAgentCode(agentUser); |
| | | log.info("用户注册成功 手机 {} , ip = {}", phone, "123123"); |
| | | log.info("用户注册成功 手机 {} , ip = {}", phone, uip); |
| | | return ServerResponse.createBySuccessMsg("注册成功.请登录"); |
| | | } |
| | | return ServerResponse.createBySuccessMsg("注册出错, 请重试"); |
| | |
| | | if (StringUtils.isBlank(phone) || StringUtils.isBlank(userPwd)) { |
| | | return ServerResponse.createByErrorMsg("手机号和密码不能为空"); |
| | | } |
| | | if (!com.nq.utils.PhoneUtil.isValidChinaMobile(phone)) { |
| | | return ServerResponse.createByErrorMsg("手机号格式不正确"); |
| | | } |
| | | phone = com.nq.utils.PhoneUtil.normalizeChinaMobile(phone); |
| | | userPwd = SymmetricCryptoUtil.encryptPassword(userPwd); |
| | | User user = this.userMapper.login(phone, userPwd); |
| | | if (user != null) { |
| | |
| | | |
| | | |
| | | public ServerResponse checkPhone(String phone) { |
| | | if (!com.nq.utils.PhoneUtil.isValidChinaMobile(phone)) { |
| | | return ServerResponse.createByErrorMsg("手机号格式不正确"); |
| | | } |
| | | phone = com.nq.utils.PhoneUtil.normalizeChinaMobile(phone); |
| | | User user = this.userMapper.findByPhone(phone); |
| | | if (user != null) { |
| | | return ServerResponse.createBySuccessMsg("用户已存在"); |
| | |
| | | |
| | | |
| | | public ServerResponse updatePwd(String phone, String code, String newPwd) { |
| | | if (StringUtils.isBlank(phone) || |
| | | StringUtils.isBlank(code) || |
| | | StringUtils.isBlank(newPwd)) { |
| | | if (StringUtils.isBlank(phone) || StringUtils.isBlank(newPwd)) { |
| | | return ServerResponse.createByErrorMsg("参数不能为空"); |
| | | } |
| | | if (com.nq.utils.sms.SmsConstants.isVerifyEnabled() && StringUtils.isBlank(code)) { |
| | | return ServerResponse.createByErrorMsg("参数不能为空"); |
| | | } |
| | | if (!com.nq.utils.PhoneUtil.isValidChinaMobile(phone)) { |
| | | return ServerResponse.createByErrorMsg("手机号格式不正确"); |
| | | } |
| | | phone = com.nq.utils.PhoneUtil.normalizeChinaMobile(phone); |
| | | |
| | | if (com.nq.utils.sms.SmsConstants.isVerifyEnabled()) { |
| | | String keys = "AliyunSmsCode:" + phone; |
| | | String redis_yzm = RedisShardedPoolUtils.get(keys); |
| | | |
| | | String keys = "AliyunSmsCode:" + phone; |
| | | String redis_yzm = RedisShardedPoolUtils.get(keys); |
| | | |
| | | log.info("redis_yzm = {} , code = {}", redis_yzm, code); |
| | | if (!code.equals(redis_yzm)) { |
| | | return ServerResponse.createByErrorMsg("修改密码失败,验证码错误"); |
| | | log.info("redis_yzm = {} , code = {}", redis_yzm, code); |
| | | if (!code.equals(redis_yzm)) { |
| | | return ServerResponse.createByErrorMsg("修改密码失败,验证码错误"); |
| | | } |
| | | } |
| | | |
| | | User user = this.userMapper.findByPhone(phone); |