|
@@ -83,6 +83,13 @@ public class BindTaskServiceImpl implements BindTaskService {
|
|
|
if (StrUtil.isNotBlank(user.getOpenId())) {
|
|
if (StrUtil.isNotBlank(user.getOpenId())) {
|
|
|
bindPhone.setUserId(userId);
|
|
bindPhone.setUserId(userId);
|
|
|
}
|
|
}
|
|
|
|
|
+ if (bindPhone.getPhoneUserId() == null) {
|
|
|
|
|
+ User phoneUser = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
|
|
|
|
|
+ .eq(User::getLoginPhone, phone).last("limit 1"));
|
|
|
|
|
+ if (phoneUser != null) {
|
|
|
|
|
+ bindPhone.setPhoneUserId(phoneUser.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
bindPhone.setPhone(phone);
|
|
bindPhone.setPhone(phone);
|
|
|
if (bindPhone.getId() == null) {
|
|
if (bindPhone.getId() == null) {
|
|
|
if (redisService.setNx(RedisService.key.USER_BIND_ACCOUNT_INFO_KEY.getName() + phone, phone, RedisService.key.USER_BIND_ACCOUNT_INFO_KEY.getTimeout())) {
|
|
if (redisService.setNx(RedisService.key.USER_BIND_ACCOUNT_INFO_KEY.getName() + phone, phone, RedisService.key.USER_BIND_ACCOUNT_INFO_KEY.getTimeout())) {
|
|
@@ -114,19 +121,30 @@ public class BindTaskServiceImpl implements BindTaskService {
|
|
|
throw BusinessRuntimeException.getInstance("该手机号已被绑定");
|
|
throw BusinessRuntimeException.getInstance("该手机号已被绑定");
|
|
|
}
|
|
}
|
|
|
checkPhoneCode(phone, code);
|
|
checkPhoneCode(phone, code);
|
|
|
|
|
+ User phoneUser = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
|
|
|
|
|
+ .eq(User::getPhone, phone).last("limit 1"));
|
|
|
|
|
+ if (phoneUser == null) {
|
|
|
|
|
+ bindPhone.setPhoneUserId(null);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ bindPhone.setPhoneUserId(phoneUser.getId());
|
|
|
|
|
+ }
|
|
|
bindPhone.setPhone(phone);
|
|
bindPhone.setPhone(phone);
|
|
|
- userBindDetailMapper.updateById(bindPhone);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ userBindDetailMapper.update(null, Wrappers.lambdaUpdate(UserBindDetail.class)
|
|
|
|
|
+ .set(UserBindDetail::getPhone, phone)
|
|
|
|
|
+ .set(UserBindDetail::getPhoneUserId, bindPhone.getPhoneUserId())
|
|
|
|
|
+ .eq(UserBindDetail::getId, bindPhone.getId()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void updateBindEmail(User user, String email, String inputCode) {
|
|
public void updateBindEmail(User user, String email, String inputCode) {
|
|
|
Long userId = user.getId();
|
|
Long userId = user.getId();
|
|
|
- UserBindDetail bindPhone = userBindDetailMapper.selectOne(Wrappers.lambdaQuery(UserBindDetail.class)
|
|
|
|
|
|
|
+ UserBindDetail bindDetail = userBindDetailMapper.selectOne(Wrappers.lambdaQuery(UserBindDetail.class)
|
|
|
.eq(UserBindDetail::getUserId, userId).last("limit 1"));
|
|
.eq(UserBindDetail::getUserId, userId).last("limit 1"));
|
|
|
- if (bindPhone == null || StrUtil.isEmpty(bindPhone.getEmail())) {
|
|
|
|
|
|
|
+ if (bindDetail == null || StrUtil.isEmpty(bindDetail.getEmail())) {
|
|
|
throw BusinessRuntimeException.getInstance("您未绑定邮箱");
|
|
throw BusinessRuntimeException.getInstance("您未绑定邮箱");
|
|
|
}
|
|
}
|
|
|
- if (bindPhone.getEmail().equals(email)) {
|
|
|
|
|
|
|
+ if (bindDetail.getEmail().equals(email)) {
|
|
|
throw BusinessRuntimeException.getInstance("换绑邮箱重复");
|
|
throw BusinessRuntimeException.getInstance("换绑邮箱重复");
|
|
|
}
|
|
}
|
|
|
UserBindDetail other = userBindDetailMapper.selectOne(Wrappers.lambdaQuery(UserBindDetail.class)
|
|
UserBindDetail other = userBindDetailMapper.selectOne(Wrappers.lambdaQuery(UserBindDetail.class)
|
|
@@ -135,8 +153,19 @@ public class BindTaskServiceImpl implements BindTaskService {
|
|
|
throw BusinessRuntimeException.getInstance("该邮箱已被绑定");
|
|
throw BusinessRuntimeException.getInstance("该邮箱已被绑定");
|
|
|
}
|
|
}
|
|
|
checkEmailCode(email, inputCode);
|
|
checkEmailCode(email, inputCode);
|
|
|
- bindPhone.setEmail(email);
|
|
|
|
|
- userBindDetailMapper.updateById(bindPhone);
|
|
|
|
|
|
|
+ User emailUser = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
|
|
|
|
|
+ .eq(User::getEmail, email).last("limit 1"));
|
|
|
|
|
+ if (emailUser == null) {
|
|
|
|
|
+ bindDetail.setEmailUserId(null);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ bindDetail.setEmailUserId(emailUser.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ bindDetail.setEmail(email);
|
|
|
|
|
+
|
|
|
|
|
+ userBindDetailMapper.update(null, Wrappers.lambdaUpdate(UserBindDetail.class)
|
|
|
|
|
+ .set(UserBindDetail::getEmail, email)
|
|
|
|
|
+ .set(UserBindDetail::getEmailUserId, bindDetail.getEmailUserId())
|
|
|
|
|
+ .eq(UserBindDetail::getId, bindDetail.getId()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -170,6 +199,13 @@ public class BindTaskServiceImpl implements BindTaskService {
|
|
|
if (StrUtil.isNotBlank(user.getOpenId())) {
|
|
if (StrUtil.isNotBlank(user.getOpenId())) {
|
|
|
bindPhone.setUserId(userId);
|
|
bindPhone.setUserId(userId);
|
|
|
}
|
|
}
|
|
|
|
|
+ if (bindPhone.getEmailUserId() == null) {
|
|
|
|
|
+ User emailUser = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
|
|
|
|
|
+ .eq(User::getEmail, account).last("limit 1"));
|
|
|
|
|
+ if (emailUser != null) {
|
|
|
|
|
+ bindPhone.setEmailUserId(emailUser.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
if (bindPhone.getId() == null) {
|
|
if (bindPhone.getId() == null) {
|
|
|
if (redisService.setNx(RedisService.key.USER_BIND_ACCOUNT_INFO_KEY.getName() + account, account, RedisService.key.USER_BIND_ACCOUNT_INFO_KEY.getTimeout())) {
|
|
if (redisService.setNx(RedisService.key.USER_BIND_ACCOUNT_INFO_KEY.getName() + account, account, RedisService.key.USER_BIND_ACCOUNT_INFO_KEY.getTimeout())) {
|
|
|
userBindDetailMapper.insert(bindPhone);
|
|
userBindDetailMapper.insert(bindPhone);
|