|
|
@@ -9,16 +9,15 @@ import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import shop.alien.entity.result.R;
|
|
|
-import shop.alien.entity.store.LawyerLegalProblemScenario;
|
|
|
-import shop.alien.entity.store.LawyerServiceArea;
|
|
|
-import shop.alien.entity.store.LawyerUser;
|
|
|
-import shop.alien.entity.store.LawyerUserSearchHistory;
|
|
|
+import shop.alien.entity.store.*;
|
|
|
import shop.alien.lawyer.service.LawyerLegalProblemScenarioService;
|
|
|
import shop.alien.lawyer.service.LawyerServiceAreaService;
|
|
|
import shop.alien.lawyer.service.LawyerUserSearchHistoryService;
|
|
|
import shop.alien.lawyer.service.LawyerUserService;
|
|
|
+import shop.alien.mapper.LawyerConsultationOrderMapper;
|
|
|
import shop.alien.mapper.LawyerUserMapper;
|
|
|
|
|
|
import java.util.*;
|
|
|
@@ -40,6 +39,7 @@ public class LawyerUserServiceImpl extends ServiceImpl<LawyerUserMapper, LawyerU
|
|
|
private final LawyerServiceAreaService lawyerServiceAreaService;
|
|
|
private final LawyerUserSearchHistoryService userSearchHistoryService;
|
|
|
private final LawyerLegalProblemScenarioService lawyerLegalProblemScenarioService;
|
|
|
+ private final LawyerConsultationOrderMapper lawyerConsultationOrderMapper;
|
|
|
|
|
|
@Override
|
|
|
public R<IPage<LawyerUser>> getLawyerUserList(int pageNum, int pageSize, String name, String phone, Integer status) {
|
|
|
@@ -394,5 +394,100 @@ public class LawyerUserServiceImpl extends ServiceImpl<LawyerUserMapper, LawyerU
|
|
|
|
|
|
return R.data(pageResult);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 注销律师用户
|
|
|
+ * <p>
|
|
|
+ * 注销前会进行以下校验:
|
|
|
+ * 1. 参数校验:律师ID不能为空
|
|
|
+ * 2. 律师存在性校验:律师必须存在
|
|
|
+ * 3. 注销状态校验:已注销的律师不允许重复注销
|
|
|
+ * 4. 设置注销相关字段:注销标记、注销时间、状态等
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param id 律师ID
|
|
|
+ * @return 注销结果,包含注销信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R<Map<String, Object>> logOutLawyerUser(Integer id) {
|
|
|
+ log.info("开始注销律师用户,律师ID={}", id);
|
|
|
+
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+
|
|
|
+ // 参数校验
|
|
|
+ if (id == null) {
|
|
|
+ log.warn("注销律师用户失败:律师ID为空");
|
|
|
+ return R.fail("律师ID不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询律师信息
|
|
|
+ LawyerUser lawyerUser = this.getById(id);
|
|
|
+ if (lawyerUser == null) {
|
|
|
+ log.warn("注销律师用户失败:律师不存在,律师ID={}", id);
|
|
|
+ return R.fail("律师不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查是否已经注销
|
|
|
+ if (lawyerUser.getLogoutFlag() != null && lawyerUser.getLogoutFlag() == 1) {
|
|
|
+ log.warn("注销律师用户失败:律师已注销,律师ID={}, 律师姓名={}", id, lawyerUser.getName());
|
|
|
+ return R.fail("该律师账号已注销,无需重复注销");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查是否已删除
|
|
|
+ if (lawyerUser.getDeleteFlag() != null && lawyerUser.getDeleteFlag() == 1) {
|
|
|
+ log.warn("注销律师用户失败:律师已删除,律师ID={}, 律师姓名={}", id, lawyerUser.getName());
|
|
|
+ return R.fail("该律师账号已删除");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<LawyerConsultationOrder> list=lawyerConsultationOrderMapper.selectOrder(null, id);
|
|
|
+
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty( list)){
|
|
|
+ // 提示前端有未完成订单 1:有未完成订单 0:无未完成订单
|
|
|
+ resultMap.put("unfinishedOrder", 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (lawyerUser.getOrderReceivingStatus() != null && lawyerUser.getOrderReceivingStatus() == 1){
|
|
|
+ // 提示前端接单状态为接单中 1:接单中 0:未接单
|
|
|
+ resultMap.put("orderReceivingStatus", 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty( list) || lawyerUser.getStatus() == 0){
|
|
|
+ // 设置注销相关字段
|
|
|
+ lawyerUser.setLogoutFlag(1); // 注销标记:1-已注销
|
|
|
+ lawyerUser.setLogoutTime(new Date()); // 注销时间
|
|
|
+ lawyerUser.setStatus(0); // 状态设置为禁用
|
|
|
+ lawyerUser.setOrderReceivingStatus(0); // 接单状态设置为不接单
|
|
|
+ lawyerUser.setIsOnline(0); // 在线状态设置为离线
|
|
|
+ lawyerUser.setIsRecommended(0); // 推荐状态设置为不推荐
|
|
|
+ lawyerUser.setLastOnlineTime(new Date());
|
|
|
+
|
|
|
+ // 如果传入了注销原因,可以在这里设置
|
|
|
+// lawyerUser.setLogoutReason(logoutReason);
|
|
|
+// lawyerUser.setLogoutCode(logoutCode);
|
|
|
+
|
|
|
+ // 执行更新操作
|
|
|
+ boolean result = this.updateById(lawyerUser);
|
|
|
+ if (!result) {
|
|
|
+ log.error("注销律师用户失败:更新数据库失败,律师ID={}", id);
|
|
|
+ return R.fail("注销失败,请稍后重试");
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("注销律师用户成功,律师ID={}, 律师姓名={}, 注销时间={}",
|
|
|
+ id, lawyerUser.getName(), lawyerUser.getLogoutTime());
|
|
|
+
|
|
|
+ // 构建返回结果
|
|
|
+ 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", "律师账号注销成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.data(resultMap);
|
|
|
+ }
|
|
|
}
|
|
|
|