|
@@ -7,6 +7,7 @@ import com.caimei365.user.components.RedisService;
|
|
|
import com.caimei365.user.mapper.BaseMapper;
|
|
|
import com.caimei365.user.mapper.LoginMapper;
|
|
|
import com.caimei365.user.mapper.SuperVipMapper;
|
|
|
+import com.caimei365.user.mapper.UserCenterMapper;
|
|
|
import com.caimei365.user.model.ResponseJson;
|
|
|
import com.caimei365.user.model.dto.MobileDto;
|
|
|
import com.caimei365.user.model.dto.PasswordDto;
|
|
@@ -55,6 +56,8 @@ public class BaseServiceImpl implements BaseService {
|
|
|
private String profile;
|
|
|
@Resource
|
|
|
private RemoteCallService remoteCallService;
|
|
|
+ @Resource
|
|
|
+ private UserCenterMapper userCenterMapper;
|
|
|
|
|
|
/**
|
|
|
* 获取图片验证码
|
|
@@ -568,6 +571,64 @@ public class BaseServiceImpl implements BaseService {
|
|
|
return ResponseJson.success("密码修改成功", "");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改密码(找回密码)
|
|
|
+ *
|
|
|
+ * @param passwordDto {
|
|
|
+ * mobileOrEmail 手机号或邮箱
|
|
|
+ * smsCode 短信验证码(旧:activationCode)
|
|
|
+ * password 密码
|
|
|
+ * confirmPwd 确认密码
|
|
|
+ * status 1:手机号找回,2:邮箱找回
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson updateOrganizePassword(PasswordDto passwordDto) {
|
|
|
+ String mobileOrEmail = passwordDto.getMobileOrEmail();
|
|
|
+ String smsCode = passwordDto.getSmsCode();
|
|
|
+ String passWord = passwordDto.getPassword();
|
|
|
+ String confirmPwd = passwordDto.getPasswordConfirm();
|
|
|
+ Integer status = passwordDto.getStatus();
|
|
|
+ // 验证手机号
|
|
|
+ String result = ValidateUtil.validateMobile(mobileOrEmail);
|
|
|
+ if (result != null) {
|
|
|
+ return ResponseJson.error(result);
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(smsCode)) {
|
|
|
+ return ResponseJson.error("请输入验证码");
|
|
|
+ }
|
|
|
+ String redisSmsCode = (String) redisService.get("code:" + mobileOrEmail);
|
|
|
+ // 开发 和 测试环境 固定短信验证码 666666
|
|
|
+ if ("dev".equals(profile) || "beta".equals(profile)) {
|
|
|
+ redisSmsCode = (null != redisSmsCode && !"null".equals(redisSmsCode) ? redisSmsCode : "666666");
|
|
|
+ }
|
|
|
+ if (!smsCode.equals(redisSmsCode)) {
|
|
|
+ return ResponseJson.error("验证码错误");
|
|
|
+ }
|
|
|
+ // 查找用户表是否存在
|
|
|
+ Integer dbUserId = baseMapper.getUserIdOrganizeByMobile(mobileOrEmail);
|
|
|
+
|
|
|
+ if (dbUserId == null) {
|
|
|
+ return ResponseJson.error("该手机号尚未注册");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(passWord)) {
|
|
|
+ return ResponseJson.error("请输入新密码");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(confirmPwd)) {
|
|
|
+ return ResponseJson.error("请确认密码");
|
|
|
+ }
|
|
|
+ if (!passWord.equals(confirmPwd)) {
|
|
|
+ return ResponseJson.error("两次输入的密码不一致");
|
|
|
+ }
|
|
|
+ // 设置密码
|
|
|
+ String dbPassword = Md5Util.md5(passWord);
|
|
|
+ baseMapper.updatePasswordByUserId(dbPassword, dbUserId);
|
|
|
+ //重新设置密码后将登录失败表中近30分钟记录置为删除
|
|
|
+ redisService.remove("login-"+dbUserId);
|
|
|
+ return ResponseJson.success("密码修改成功", "");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 更换手机号
|
|
|
*
|
|
@@ -591,18 +652,21 @@ public class BaseServiceImpl implements BaseService {
|
|
|
if (null == mobileDto.getUserId()) {
|
|
|
return ResponseJson.error("参数异常:用户Id不能为空!");
|
|
|
}
|
|
|
- // 旧手机号与验证码校验
|
|
|
- String result = ValidateUtil.validateMobile(mobileDto.getMobile());
|
|
|
- if (result != null) {
|
|
|
- return ResponseJson.error(result);
|
|
|
- }
|
|
|
- if (0 == mobileDto.getOrganizeId()) {
|
|
|
+ // 获取用户组织Id
|
|
|
+ Integer organizeId = userCenterMapper.getUserOrganizeId(mobileDto.getUserId());
|
|
|
+ String result = "";
|
|
|
+ if (0 == organizeId) {
|
|
|
if (StringUtils.isBlank(mobileDto.getMobile())) {
|
|
|
return ResponseJson.error("参数异常:旧手机号不能为空!");
|
|
|
}
|
|
|
if (StringUtils.isBlank(mobileDto.getSmsCode())) {
|
|
|
return ResponseJson.error("参数异常:旧手机号验证码不能为空!");
|
|
|
}
|
|
|
+ // 旧手机号与验证码校验
|
|
|
+ result = ValidateUtil.validateMobile(mobileDto.getMobile());
|
|
|
+ if (result != null) {
|
|
|
+ return ResponseJson.error(result);
|
|
|
+ }
|
|
|
String smsCode = (String) redisService.get("code:" + mobileDto.getMobile());
|
|
|
// 开发 和 测试环境 固定短信验证码 666666
|
|
|
if ("dev".equals(profile) || "beta".equals(profile)) {
|