|
@@ -99,6 +99,88 @@ public class LoginServiceImpl implements LoginService {
|
|
|
}
|
|
|
//处理比对密码
|
|
|
UserLoginVo baseUser = loginMapper.getLoginUserByMobileOrEmail(mobileOrEmail);
|
|
|
+ if (null != baseUser) {
|
|
|
+ String key = "login-" + baseUser.getUserId();
|
|
|
+ boolean exists = redisService.exists(key);
|
|
|
+ //如果30分钟内输入错误记录>=5,return该账号暂时被冻结,请(30-最前一次时间)分钟后重试或直接修改密码
|
|
|
+ if (exists) {
|
|
|
+ String val = (String) redisService.get(key);
|
|
|
+ String[] split = val.split(",");
|
|
|
+ int count = Integer.parseInt(split[0]);
|
|
|
+ if (count >= 5) {
|
|
|
+ long s = Long.parseLong(split[1]);
|
|
|
+ int l = (int) Math.floor((System.currentTimeMillis() - s) / 1000 / 60);
|
|
|
+ return ResponseJson.error("该账号暂时被冻结,请" + (30 - l) + "分钟后重试或直接修改密码", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果前端传入unionId,则存入返回前端
|
|
|
+ baseUser.setUnionId(unionId);
|
|
|
+ // 不是采美组织下
|
|
|
+ if (0 != baseUser.getOrganizeId()) {
|
|
|
+ if (1 == baseUser.getClubStatus()) {
|
|
|
+ return ResponseJson.error(-1, "账号待审核,请耐心等待审核结果", null);
|
|
|
+ }
|
|
|
+ if (92 == baseUser.getClubStatus()) {
|
|
|
+ return ResponseJson.error(-1, "账号审核未通过,请重新提交资料", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 比对密码
|
|
|
+ String md5Password = Md5Util.md5(password);
|
|
|
+ String dbPassword = baseUser.getPassword();
|
|
|
+ if (md5Password.equals(dbPassword)) {
|
|
|
+ if (baseUser.getUserIdentity() == 1) {
|
|
|
+ // 协销登录
|
|
|
+ return ResponseJson.success(baseUser);
|
|
|
+ } else {
|
|
|
+ // 返回登录校验结果
|
|
|
+ return logonVerify(baseUser);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 增加一次错误输入密码记录,30分钟内连续五次冻结
|
|
|
+ if (exists) {
|
|
|
+ String val = (String) redisService.get(key);
|
|
|
+ String[] split = val.split(",");
|
|
|
+ int count = Integer.parseInt(split[0]);
|
|
|
+ if (count < 5) {
|
|
|
+ count++;
|
|
|
+ String va = count + "," + System.currentTimeMillis();
|
|
|
+ redisService.set(key, va);
|
|
|
+ }
|
|
|
+ if (count >= 5) {
|
|
|
+ redisService.set(key, 5 + "," + System.currentTimeMillis(), 1800L);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String val = 1 + "," + System.currentTimeMillis();
|
|
|
+ redisService.set(key, val);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResponseJson.error("账户名与密码不匹配,请重新输入", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 登录(用户名,密码)
|
|
|
+ *
|
|
|
+ * @param loginPasswordDto {
|
|
|
+ * mobileOrEmail 手机号或邮箱
|
|
|
+ * password 密码
|
|
|
+ * unionId 微信unionId
|
|
|
+ * }
|
|
|
+ * @return BaseUser
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<UserLoginVo> passwordOrganizeLogin(LoginPasswordDto loginPasswordDto) throws ParseException {
|
|
|
+ String mobileOrEmail = loginPasswordDto.getMobileOrEmail();
|
|
|
+ String password = loginPasswordDto.getPassword();
|
|
|
+ String unionId = loginPasswordDto.getUnionId();
|
|
|
+ if (StringUtils.isBlank(mobileOrEmail)) {
|
|
|
+ return ResponseJson.error("请填写账户名", null);
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(password)) {
|
|
|
+ return ResponseJson.error("请填写密码", null);
|
|
|
+ }
|
|
|
+ //处理比对密码
|
|
|
+ UserLoginVo baseUser = loginMapper.getLoginOrganizeUserByMobileOrEmail(mobileOrEmail);
|
|
|
if (null != baseUser) {
|
|
|
// 绑定微信信息
|
|
|
Integer operationUser = loginMapper.getOperationUser(mobileOrEmail);
|
|
@@ -216,6 +298,63 @@ public class LoginServiceImpl implements LoginService {
|
|
|
redisService.remove("code:" + mobile);
|
|
|
// 根据手机号获取用户信息
|
|
|
UserLoginVo baseUser = loginMapper.getLoginUserByMobileOrEmail(mobile);
|
|
|
+ if (baseUser.getUserIdentity() == 1) {
|
|
|
+ // 协销登录
|
|
|
+ return ResponseJson.success(baseUser);
|
|
|
+ } else {
|
|
|
+ // 返回登录校验结果
|
|
|
+ return logonVerify(baseUser);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return ResponseJson.error("验证码不匹配,请重新输入");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return ResponseJson.error("验证码错误,请重新获取");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return ResponseJson.error("验证码错误,请重新获取");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param loginCodeDto {
|
|
|
+ * mobile 手机号
|
|
|
+ * code 短信验证码
|
|
|
+ * }
|
|
|
+ * @return
|
|
|
+ * @throws ParseException
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<UserLoginVo> codeOrganizeLogin(LoginCodeDto loginCodeDto) throws ParseException {
|
|
|
+ if (ObjectUtils.isEmpty(loginCodeDto.getMobile())) {
|
|
|
+ return ResponseJson.error("请填写手机号",null);
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isEmpty(loginCodeDto.getCode())) {
|
|
|
+ return ResponseJson.error("请输入短信验证码",null);
|
|
|
+ }
|
|
|
+ String mobile = loginCodeDto.getMobile();
|
|
|
+ String code = loginCodeDto.getCode();
|
|
|
+ String unionId = loginCodeDto.getUnionId();
|
|
|
+ String result = ValidateUtil.validateMobile(mobile);
|
|
|
+ if (result != null) {
|
|
|
+ return ResponseJson.error(result);
|
|
|
+ }
|
|
|
+ // 判断redis中是否存在
|
|
|
+ boolean exists = redisService.exists("code:" + mobile);
|
|
|
+ if (exists) {
|
|
|
+ // 查看验证码是否过期
|
|
|
+ long expireTime = redisService.getExpireTime("code:" + mobile);
|
|
|
+ if (expireTime < 0) {
|
|
|
+ return ResponseJson.error("验证码已失效,请重新获取");
|
|
|
+ }
|
|
|
+ // 获取redis手机短信验证码
|
|
|
+ Object randomCode = redisService.get("code:"+mobile);
|
|
|
+
|
|
|
+ if (!ObjectUtils.isEmpty(randomCode)) {
|
|
|
+ if (code.equals(randomCode.toString())) {
|
|
|
+ redisService.remove("code:" + mobile);
|
|
|
+ // 根据手机号获取用户信息
|
|
|
+ UserLoginVo baseUser = loginMapper.getLoginOrganizeUserByMobileOrEmail(mobile);
|
|
|
// 绑定微信信息
|
|
|
Integer operationUser = loginMapper.getOperationUser(mobile);
|
|
|
log.info("operationUser==="+operationUser);
|