|
|
@@ -289,23 +289,28 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
|
|
|
return R.fail("失败");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据用户ID查询订单列表(包含律师信息)
|
|
|
+ *
|
|
|
+ * @param pageNum 页码
|
|
|
+ * @param pageSize 页容量
|
|
|
+ * @param userId 用户ID
|
|
|
+ * @param orderStatus 订单状态
|
|
|
+ * @param lawyerName 律师姓名(支持模糊查询)
|
|
|
+ * @return 分页订单列表
|
|
|
+ */
|
|
|
@Override
|
|
|
- public R<IPage<LawyerConsultationOrderVO>> getConsultationOrderListById(int pageNum, int pageSize, String userId, String orderStatus ,String lawyerName) {
|
|
|
-
|
|
|
+ public R<IPage<LawyerConsultationOrderVO>> getConsultationOrderListById(int pageNum, int pageSize,
|
|
|
+ String userId, String orderStatus,
|
|
|
+ String lawyerName) {
|
|
|
Page<LawyerConsultationOrderVO> page = new Page<>(pageNum, pageSize);
|
|
|
- // 如果按律師姓名搜索,先查詢匹配的律師ID列表
|
|
|
+
|
|
|
+ // 如果按律师姓名搜索,先查询匹配的律师ID列表
|
|
|
List<Integer> lawyerUserIds = null;
|
|
|
if (StringUtils.hasText(lawyerName)) {
|
|
|
- LambdaQueryWrapper<LawyerUser> lawyerQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lawyerQueryWrapper.eq(LawyerUser::getDeleteFlag, 0);
|
|
|
- lawyerQueryWrapper.like(LawyerUser::getName, lawyerName);
|
|
|
- List<LawyerUser> lawyerUsers = lawyerUserService.list(lawyerQueryWrapper);
|
|
|
- if (lawyerUsers != null && !lawyerUsers.isEmpty()) {
|
|
|
- lawyerUserIds = lawyerUsers.stream()
|
|
|
- .map(LawyerUser::getId)
|
|
|
- .collect(Collectors.toList());
|
|
|
- } else {
|
|
|
- // 如果沒有找到匹配的律師,返回空結果
|
|
|
+ lawyerUserIds = queryLawyerIdsByName(lawyerName);
|
|
|
+ // 如果没有找到匹配的律师,返回空结果
|
|
|
+ if (CollectionUtils.isEmpty(lawyerUserIds)) {
|
|
|
Page<LawyerConsultationOrderVO> emptyPage = new Page<>(pageNum, pageSize);
|
|
|
emptyPage.setRecords(Collections.emptyList());
|
|
|
emptyPage.setTotal(0);
|
|
|
@@ -316,44 +321,113 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
|
|
|
// 查询订单列表
|
|
|
IPage<LawyerConsultationOrderVO> voPage = consultationOrderMapper.getConsultationOrderListById(
|
|
|
page, userId, orderStatus, lawyerUserIds);
|
|
|
- List<LawyerConsultationOrderVO> lawyerConsultationOrderVOS = voPage.getRecords();
|
|
|
- if(CollectionUtils.isNotEmpty(lawyerConsultationOrderVOS)){
|
|
|
- List<Integer> lawyerIdList = lawyerConsultationOrderVOS.stream()
|
|
|
- .map(LawyerConsultationOrderVO::getLawyerUserId)
|
|
|
- .collect(Collectors.toList());
|
|
|
- Map<String, List<String>> lawyerLegalProblemScenarioLawyer = getLawyerServiceArea(lawyerIdList);
|
|
|
-
|
|
|
- if(!lawyerLegalProblemScenarioLawyer.isEmpty()){
|
|
|
- voPage.getRecords().forEach(entity -> {
|
|
|
- String lawyerUserId = String.valueOf(entity.getLawyerUserId());
|
|
|
- if(lawyerLegalProblemScenarioLawyer.containsKey(lawyerUserId)){
|
|
|
- entity.setLawyerLegalProblemScenarioList(lawyerLegalProblemScenarioLawyer.get(lawyerUserId));
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ // 填充律师服务领域信息
|
|
|
+ fillLawyerServiceArea(voPage);
|
|
|
+
|
|
|
return R.data(voPage);
|
|
|
}
|
|
|
|
|
|
- private Map<String, List<String>> getLawyerServiceArea(List<Integer> lawyerIdList) {
|
|
|
- Map<String, List<String>> lawyerLegalProblemScenarioLawyer = new HashMap<>();
|
|
|
- if(CollectionUtils.isNotEmpty(lawyerIdList)){
|
|
|
- QueryWrapper<LawyerServiceArea> wrapper = new QueryWrapper<>();
|
|
|
- wrapper.in("lsa.lawyer_user_id", lawyerIdList);
|
|
|
- wrapper.in("lsa.delete_flag", 0);
|
|
|
- wrapper.in("lsa.status", 1);
|
|
|
-
|
|
|
- List<Map<String, Object>> lawyerLegalProblemScenarioData = lawyerServiceAreaMapper.getLawyerLegalProblemScenarioList(wrapper);
|
|
|
- for (Map<String, Object> row : lawyerLegalProblemScenarioData) {
|
|
|
- String lawyerUserId = String.valueOf(row.get("lawyer_user_id"));
|
|
|
- String ScenarioName = (String) row.get("name");
|
|
|
- if (lawyerUserId != null) {
|
|
|
- lawyerLegalProblemScenarioLawyer.computeIfAbsent(lawyerUserId, k -> new ArrayList<>())
|
|
|
- .add(ScenarioName != null ? ScenarioName : "");
|
|
|
+ /**
|
|
|
+ * 根据律师姓名查询律师ID列表
|
|
|
+ *
|
|
|
+ * @param lawyerName 律师姓名
|
|
|
+ * @return 律师ID列表
|
|
|
+ */
|
|
|
+ private List<Integer> queryLawyerIdsByName(String lawyerName) {
|
|
|
+ LambdaQueryWrapper<LawyerUser> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(LawyerUser::getDeleteFlag, 0)
|
|
|
+ .like(LawyerUser::getName, lawyerName);
|
|
|
+ List<LawyerUser> lawyerUsers = lawyerUserService.list(queryWrapper);
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(lawyerUsers)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ return lawyerUsers.stream()
|
|
|
+ .map(LawyerUser::getId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 填充律师服务领域信息到订单VO列表
|
|
|
+ *
|
|
|
+ * @param voPage 订单VO分页对象
|
|
|
+ */
|
|
|
+ private void fillLawyerServiceArea(IPage<LawyerConsultationOrderVO> voPage) {
|
|
|
+ List<LawyerConsultationOrderVO> orderList = voPage.getRecords();
|
|
|
+ if (CollectionUtils.isEmpty(orderList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 提取所有律师ID
|
|
|
+ List<Integer> lawyerIdList = orderList.stream()
|
|
|
+ .map(LawyerConsultationOrderVO::getLawyerUserId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(lawyerIdList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 批量查询律师服务领域
|
|
|
+ Map<String, List<String>> serviceAreaMap = getLawyerServiceArea(lawyerIdList);
|
|
|
+ if (serviceAreaMap.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 填充服务领域信息
|
|
|
+ orderList.forEach(order -> {
|
|
|
+ Integer lawyerUserId = order.getLawyerUserId();
|
|
|
+ if (lawyerUserId != null) {
|
|
|
+ String lawyerUserIdStr = String.valueOf(lawyerUserId);
|
|
|
+ List<String> serviceAreaList = serviceAreaMap.get(lawyerUserIdStr);
|
|
|
+ if (CollectionUtils.isNotEmpty(serviceAreaList)) {
|
|
|
+ order.setLawyerLegalProblemScenarioList(serviceAreaList);
|
|
|
}
|
|
|
}
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量查询律师服务领域信息
|
|
|
+ *
|
|
|
+ * @param lawyerIdList 律师ID列表
|
|
|
+ * @return 律师服务领域Map,key为律师ID(String),value为服务领域名称列表
|
|
|
+ */
|
|
|
+ private Map<String, List<String>> getLawyerServiceArea(List<Integer> lawyerIdList) {
|
|
|
+ Map<String, List<String>> serviceAreaMap = new HashMap<>();
|
|
|
+ if (CollectionUtils.isEmpty(lawyerIdList)) {
|
|
|
+ return serviceAreaMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<LawyerServiceArea> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.in("lsa.lawyer_user_id", lawyerIdList)
|
|
|
+ .eq("lsa.delete_flag", 0)
|
|
|
+ .eq("lsa.status", 1);
|
|
|
+
|
|
|
+ List<Map<String, Object>> serviceAreaDataList = lawyerServiceAreaMapper.getLawyerLegalProblemScenarioList(wrapper);
|
|
|
+ if (CollectionUtils.isEmpty(serviceAreaDataList)) {
|
|
|
+ return serviceAreaMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Map<String, Object> row : serviceAreaDataList) {
|
|
|
+ Object lawyerUserIdObj = row.get("lawyer_user_id");
|
|
|
+ if (lawyerUserIdObj == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String lawyerUserId = String.valueOf(lawyerUserIdObj);
|
|
|
+ String scenarioName = (String) row.get("name");
|
|
|
+ String scenarioNameValue = StringUtils.hasText(scenarioName) ? scenarioName : "";
|
|
|
+
|
|
|
+ serviceAreaMap.computeIfAbsent(lawyerUserId, k -> new ArrayList<>())
|
|
|
+ .add(scenarioNameValue);
|
|
|
}
|
|
|
- return lawyerLegalProblemScenarioLawyer;
|
|
|
+
|
|
|
+ return serviceAreaMap;
|
|
|
}
|
|
|
|
|
|
/**
|