|
|
@@ -50,6 +50,9 @@ public class LawyerUserServiceImpl extends ServiceImpl<LawyerUserMapper, LawyerU
|
|
|
|
|
|
private static final String LOGOUT_REASON_OTHER = "其他";
|
|
|
private static final int LOGOUT_CONTENT_MAX_LENGTH = 300;
|
|
|
+ private static final int LOGOUT_FLAG_COOLING = 2;
|
|
|
+ private static final int LOGOUT_COOLING_DAYS = 7;
|
|
|
+ private static final String CANCEL_REVOKE_NOT_IN_COOLING_MSG = "当前账号不在注销冷静期内,无法撤销";
|
|
|
|
|
|
private final LawyerUserMapper lawyerUserMapper;
|
|
|
private final LawyerServiceAreaService lawyerServiceAreaService;
|
|
|
@@ -536,18 +539,17 @@ public class LawyerUserServiceImpl extends ServiceImpl<LawyerUserMapper, LawyerU
|
|
|
return R.fail("律师不存在");
|
|
|
}
|
|
|
|
|
|
- String key = "lawyer_" + lawyerUser.getPhone();
|
|
|
- String redisVerificationCode = baseRedisService.getString(key);
|
|
|
- //对redisVerificationCode进行校验,如果不是空的话清除redis中的记录
|
|
|
-// if (redisVerificationCode != null) {
|
|
|
-// baseRedisService.delete(key);
|
|
|
-// }
|
|
|
// 检查是否已经注销
|
|
|
- if (lawyerUser.getLogoutFlag() != null && lawyerUser.getLogoutFlag() == 1 && lawyerUser.getDeleteFlag() == 1) {
|
|
|
+ if (lawyerUser.getLogoutFlag() != null && lawyerUser.getLogoutFlag() == 1 && lawyerUser.getDeleteFlag() != null && lawyerUser.getDeleteFlag() == 1) {
|
|
|
log.warn("注销律师用户失败:律师已注销,律师ID={}, 律师姓名={}", id, lawyerUser.getName());
|
|
|
return R.fail("该律师账号已注销,无需重复注销");
|
|
|
}
|
|
|
|
|
|
+ if (lawyerUser.getLogoutFlag() != null && lawyerUser.getLogoutFlag() == LOGOUT_FLAG_COOLING) {
|
|
|
+ log.warn("注销律师用户失败:律师已在注销冷静期中,律师ID={}", id);
|
|
|
+ return R.fail("账号已在注销冷静期中");
|
|
|
+ }
|
|
|
+
|
|
|
// 检查是否已删除
|
|
|
if (lawyerUser.getDeleteFlag() != null && lawyerUser.getDeleteFlag() == 1) {
|
|
|
log.warn("注销律师用户失败:律师已删除,律师ID={}, 律师姓名={}", id, lawyerUser.getName());
|
|
|
@@ -570,48 +572,29 @@ public class LawyerUserServiceImpl extends ServiceImpl<LawyerUserMapper, LawyerU
|
|
|
if (lawyerUser.getOrderReceivingStatus() != null) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(list) && lawyerUser.getOrderReceivingStatus() == 0) {
|
|
|
- // 设置注销相关字段
|
|
|
- lawyerUser.setLogoutFlag(2); // 注销标记:1-已注销
|
|
|
- lawyerUser.setLogoutTime(new Date()); // 注销时间
|
|
|
- lawyerUser.setLogoutReason(logoutContent);
|
|
|
- lawyerUser.setLogoutCode(logoutReason);
|
|
|
- lawyerUser.setStatus(0); // 状态设置为禁用
|
|
|
- lawyerUser.setOrderReceivingStatus(0); // 接单状态设置为不接单
|
|
|
- lawyerUser.setIsOnline(0); // 在线状态设置为离线
|
|
|
- lawyerUser.setIsRecommended(0); // 推荐状态设置为不推荐
|
|
|
+ // 进入注销冷静期(7天内可撤销)
|
|
|
+ lawyerUser.setLogoutFlag(LOGOUT_FLAG_COOLING);
|
|
|
+ lawyerUser.setLogoutTime(new Date());
|
|
|
+ lawyerUser.setLogoutReason(logoutReason);
|
|
|
+ lawyerUser.setLogoutCode(LOGOUT_REASON_OTHER.equals(logoutReason) ? logoutContent : null);
|
|
|
+ lawyerUser.setOrderReceivingStatus(0);
|
|
|
lawyerUser.setIsOnline(0);
|
|
|
- lawyerUser.setDeleteFlag(1);
|
|
|
- lawyerUser.setLastOnlineTime(new Date());
|
|
|
|
|
|
- // 执行更新操作
|
|
|
int result = lawyerUserMapper.updateLawyerUser(lawyerUser);
|
|
|
- if (result==0) {
|
|
|
+ if (result == 0) {
|
|
|
log.error("注销律师用户失败:更新数据库失败,律师ID={}", id);
|
|
|
return R.fail("注销失败,请稍后重试");
|
|
|
}
|
|
|
|
|
|
- //对redisVerificationCode进行校验,如果不是空的话清除redis中的记录
|
|
|
- if (redisVerificationCode != null) {
|
|
|
- baseRedisService.delete(key);
|
|
|
- }
|
|
|
-
|
|
|
- log.info("注销律师用户成功,律师ID={}, 律师姓名={}, 注销时间={}",
|
|
|
+ log.info("律师注销申请已提交,律师ID={}, 律师姓名={}, 注销时间={}",
|
|
|
id, lawyerUser.getName(), lawyerUser.getLogoutTime());
|
|
|
|
|
|
-
|
|
|
- LambdaUpdateWrapper<LifeNotice> noticeUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- lifeNoticeUtil.applyReceiverUpdate(noticeUpdateWrapper, key);
|
|
|
- noticeUpdateWrapper.set(LifeNotice::getDeleteFlag, 1);
|
|
|
- lifeNoticeMapper.update(null, noticeUpdateWrapper);
|
|
|
-
|
|
|
- // 构建返回结果
|
|
|
resultMap.put("id", lawyerUser.getId());
|
|
|
resultMap.put("name", lawyerUser.getName());
|
|
|
resultMap.put("phone", lawyerUser.getPhone());
|
|
|
resultMap.put("logoutFlag", lawyerUser.getLogoutFlag());
|
|
|
resultMap.put("logoutTime", lawyerUser.getLogoutTime());
|
|
|
- resultMap.put("status", lawyerUser.getStatus());
|
|
|
- resultMap.put("message", "律师账号注销成功");
|
|
|
+ resultMap.put("message", "律师账号注销申请已提交");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -619,6 +602,45 @@ public class LawyerUserServiceImpl extends ServiceImpl<LawyerUserMapper, LawyerU
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void cancelLogoutLawyerUser(Integer id) {
|
|
|
+ if (id == null) {
|
|
|
+ throw new IllegalArgumentException("律师ID不能为空");
|
|
|
+ }
|
|
|
+ LawyerUser lawyerUser = this.getById(id);
|
|
|
+ if (lawyerUser == null) {
|
|
|
+ throw new IllegalArgumentException("律师不存在");
|
|
|
+ }
|
|
|
+ boolean logoutFlagCooling = lawyerUser.getLogoutFlag() != null
|
|
|
+ && lawyerUser.getLogoutFlag() == LOGOUT_FLAG_COOLING;
|
|
|
+ if (!logoutFlagCooling && !isLawyerInLogoutCoolingPeriod(lawyerUser)) {
|
|
|
+ throw new IllegalArgumentException(CANCEL_REVOKE_NOT_IN_COOLING_MSG);
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<LawyerUser> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.eq(LawyerUser::getId, id)
|
|
|
+ .set(LawyerUser::getLogoutFlag, 0)
|
|
|
+ .set(LawyerUser::getLogoutTime, null)
|
|
|
+ .set(LawyerUser::getLogoutReason, null)
|
|
|
+ .set(LawyerUser::getLogoutCode, null);
|
|
|
+ int updated = lawyerUserMapper.update(null, updateWrapper);
|
|
|
+ if (updated == 0) {
|
|
|
+ throw new IllegalArgumentException("撤销注销失败,请稍后重试");
|
|
|
+ }
|
|
|
+ log.info("律师撤销注销成功,律师ID={}", id);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static boolean isLawyerInLogoutCoolingPeriod(LawyerUser lawyerUser) {
|
|
|
+ if (lawyerUser == null || lawyerUser.getLogoutTime() == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(lawyerUser.getLogoutTime());
|
|
|
+ calendar.add(Calendar.DAY_OF_YEAR, LOGOUT_COOLING_DAYS);
|
|
|
+ return !new Date().after(calendar.getTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public R<LawyerUserVo> getLawyerInfo(Integer lawyerId) {
|
|
|
log.info("LawyerUserServiceImpl.getLawyerInfo?lawyerId={}", lawyerId);
|
|
|
|