|
@@ -251,98 +251,196 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
|
|
|
/**
|
|
/**
|
|
|
* 查询咨询订单信息(律师端)
|
|
* 查询咨询订单信息(律师端)
|
|
|
*
|
|
*
|
|
|
- * @param pageNum 页码
|
|
|
|
|
- * @param pageSize 页容
|
|
|
|
|
- * @param startDate 开始时间
|
|
|
|
|
- * @param endDate 结束时间
|
|
|
|
|
- * @param lawyerId 律师ID
|
|
|
|
|
|
|
+ * @param pageNum 页码
|
|
|
|
|
+ * @param pageSize 页容量
|
|
|
|
|
+ * @param startDate 开始时间
|
|
|
|
|
+ * @param endDate 结束时间
|
|
|
|
|
+ * @param clientUserName 客户端用户名
|
|
|
|
|
+ * @param orderStatus 订单状态
|
|
|
|
|
+ * @param lawyerId 律师ID
|
|
|
* @return 订单信息Map,包含订单列表、总数、进行中数量、已完成数量
|
|
* @return 订单信息Map,包含订单列表、总数、进行中数量、已完成数量
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public Map<String, Object> getLawyerConsultationOrderInfo(int pageNum, int pageSize, String startDate, String endDate, String clientUserName, String orderStatus, String lawyerId) {
|
|
|
|
|
- log.info("LawyerConsultationOrderServiceImpl.getLawyerConsultationOrderInfo?pageNum={},pageSize={},startDate={},endDate={},clientUserName={},lawyerId={}",
|
|
|
|
|
- pageNum, pageSize, startDate, endDate, clientUserName, lawyerId);
|
|
|
|
|
|
|
+ public Map<String, Object> getLawyerConsultationOrderInfo(int pageNum, int pageSize, String startDate,
|
|
|
|
|
+ String endDate, String clientUserName,
|
|
|
|
|
+ String orderStatus, String lawyerId) {
|
|
|
|
|
+ log.info("查询咨询订单信息(律师端)- pageNum={}, pageSize={}, startDate={}, endDate={}, "
|
|
|
|
|
+ + "clientUserName={}, orderStatus={}, lawyerId={}",
|
|
|
|
|
+ pageNum, pageSize, startDate, endDate, clientUserName, orderStatus, lawyerId);
|
|
|
|
|
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
|
|
|
// 参数校验:律师ID不能为空
|
|
// 参数校验:律师ID不能为空
|
|
|
if (!StringUtils.hasText(lawyerId)) {
|
|
if (!StringUtils.hasText(lawyerId)) {
|
|
|
log.warn("查询咨询订单信息失败:律师ID为空");
|
|
log.warn("查询咨询订单信息失败:律师ID为空");
|
|
|
- Page<LawyerConsultationOrderVO> emptyPage = new Page<>(pageNum, pageSize);
|
|
|
|
|
- emptyPage.setRecords(Collections.emptyList());
|
|
|
|
|
- emptyPage.setTotal(0);
|
|
|
|
|
- resultMap.put("lawyerOrderCount", 0L);
|
|
|
|
|
- resultMap.put("lawyerInProgressOrderCount", 0);
|
|
|
|
|
- resultMap.put("lawyerCompleteOrderCount", 0);
|
|
|
|
|
- resultMap.put("lawyerConsultationOrderList", Collections.emptyList());
|
|
|
|
|
- return resultMap;
|
|
|
|
|
|
|
+ return buildEmptyResultMap(pageNum, pageSize);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 创建分页对象
|
|
// 创建分页对象
|
|
|
Page<LawyerConsultationOrderVO> page = new Page<>(pageNum, pageSize);
|
|
Page<LawyerConsultationOrderVO> page = new Page<>(pageNum, pageSize);
|
|
|
|
|
|
|
|
- // 构建查询条件:查询进行中(2)和已完成(3)状态的订单
|
|
|
|
|
|
|
+ // 构建查询条件
|
|
|
|
|
+ QueryWrapper<LawyerConsultationOrderVO> queryWrapper = buildOrderQueryWrapper(
|
|
|
|
|
+ lawyerId, orderStatus, clientUserName, startDate, endDate);
|
|
|
|
|
+ QueryWrapper<LawyerConsultationOrderVO> statisticsWrapper = buildStatisticsQueryWrapper(
|
|
|
|
|
+ lawyerId, clientUserName);
|
|
|
|
|
+
|
|
|
|
|
+ // 查询订单列表
|
|
|
|
|
+ IPage<LawyerConsultationOrderVO> voPage = consultationOrderMapper.getLawyerConsultationOrderList(
|
|
|
|
|
+ page, queryWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ // 填充律师问题场景信息
|
|
|
|
|
+ if (voPage != null) {
|
|
|
|
|
+ fillLawyerServiceArea(voPage);
|
|
|
|
|
+ // 为待支付订单计算倒计时(30分钟有效期)
|
|
|
|
|
+ calculateCountdownForPendingOrders(voPage);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取统计信息
|
|
|
|
|
+ statisticsWrapper.groupBy("lco.order_status");
|
|
|
|
|
+ List<Map<String, Object>> statisticsInfo = consultationOrderMapper.getLawyerStatisticsInfo(
|
|
|
|
|
+ statisticsWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ // 构建状态统计Map
|
|
|
|
|
+ Map<Integer, Integer> statusCountMap = buildStatusCountMap(statisticsInfo);
|
|
|
|
|
+
|
|
|
|
|
+ // 统计进行中订单数量
|
|
|
|
|
+ Integer inProgressStatus = LawyerStatusEnum.INPROGRESS.getStatus();
|
|
|
|
|
+ int inProgressCount = statusCountMap.getOrDefault(inProgressStatus, 0);
|
|
|
|
|
+
|
|
|
|
|
+ // 统计已完成订单数量
|
|
|
|
|
+ Integer completeStatus = LawyerStatusEnum.COMPLETE.getStatus();
|
|
|
|
|
+ int completeCount = statusCountMap.getOrDefault(completeStatus, 0);
|
|
|
|
|
+
|
|
|
|
|
+ // 构建返回结果
|
|
|
|
|
+ resultMap.put("lawyerInProgressOrderCount", inProgressCount);
|
|
|
|
|
+ resultMap.put("lawyerCompleteOrderCount", completeCount);
|
|
|
|
|
+ resultMap.put("lawyerOrderCount", (long) (inProgressCount + completeCount));
|
|
|
|
|
+
|
|
|
|
|
+ // 设置订单列表
|
|
|
|
|
+ List<LawyerConsultationOrderVO> orderList = (voPage != null && voPage.getRecords() != null)
|
|
|
|
|
+ ? voPage.getRecords() : Collections.emptyList();
|
|
|
|
|
+ resultMap.put("lawyerConsultationOrderList", orderList);
|
|
|
|
|
+
|
|
|
|
|
+ return resultMap;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建空结果Map
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param pageNum 页码
|
|
|
|
|
+ * @param pageSize 页容量
|
|
|
|
|
+ * @return 空结果Map
|
|
|
|
|
+ */
|
|
|
|
|
+ private Map<String, Object> buildEmptyResultMap(int pageNum, int pageSize) {
|
|
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
+ Page<LawyerConsultationOrderVO> emptyPage = new Page<>(pageNum, pageSize);
|
|
|
|
|
+ emptyPage.setRecords(Collections.emptyList());
|
|
|
|
|
+ emptyPage.setTotal(0);
|
|
|
|
|
+ resultMap.put("lawyerOrderCount", 0L);
|
|
|
|
|
+ resultMap.put("lawyerInProgressOrderCount", 0);
|
|
|
|
|
+ resultMap.put("lawyerCompleteOrderCount", 0);
|
|
|
|
|
+ resultMap.put("lawyerConsultationOrderList", Collections.emptyList());
|
|
|
|
|
+ return resultMap;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建订单查询条件
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param lawyerId 律师ID
|
|
|
|
|
+ * @param orderStatus 订单状态
|
|
|
|
|
+ * @param clientUserName 客户端用户名
|
|
|
|
|
+ * @param startDate 开始时间
|
|
|
|
|
+ * @param endDate 结束时间
|
|
|
|
|
+ * @return 查询条件包装器
|
|
|
|
|
+ */
|
|
|
|
|
+ private QueryWrapper<LawyerConsultationOrderVO> buildOrderQueryWrapper(String lawyerId, String orderStatus,
|
|
|
|
|
+ String clientUserName, String startDate,
|
|
|
|
|
+ String endDate) {
|
|
|
QueryWrapper<LawyerConsultationOrderVO> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<LawyerConsultationOrderVO> queryWrapper = new QueryWrapper<>();
|
|
|
- QueryWrapper<LawyerConsultationOrderVO> queryStatisticsWrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
|
|
- if(StringUtils.hasText(orderStatus)){
|
|
|
|
|
|
|
+ // 订单状态条件
|
|
|
|
|
+ if (StringUtils.hasText(orderStatus)) {
|
|
|
queryWrapper.in("lco.order_status", Collections.singletonList(orderStatus));
|
|
queryWrapper.in("lco.order_status", Collections.singletonList(orderStatus));
|
|
|
} else {
|
|
} else {
|
|
|
- queryWrapper.in("lco.order_status", Arrays.asList("2", "3"));
|
|
|
|
|
|
|
+ // 默认查询进行中和已完成的订单
|
|
|
|
|
+ Integer inProgressStatus = LawyerStatusEnum.INPROGRESS.getStatus();
|
|
|
|
|
+ Integer completeStatus = LawyerStatusEnum.COMPLETE.getStatus();
|
|
|
|
|
+ queryWrapper.in("lco.order_status", Arrays.asList(
|
|
|
|
|
+ String.valueOf(inProgressStatus), String.valueOf(completeStatus)));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 律师ID条件
|
|
|
queryWrapper.eq("lco.lawyer_user_id", lawyerId);
|
|
queryWrapper.eq("lco.lawyer_user_id", lawyerId);
|
|
|
- queryStatisticsWrapper.eq("lco.lawyer_user_id", lawyerId);
|
|
|
|
|
- if(StringUtils.hasText(clientUserName)){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 客户端用户名条件
|
|
|
|
|
+ if (StringUtils.hasText(clientUserName)) {
|
|
|
queryWrapper.like("lur.user_name", clientUserName);
|
|
queryWrapper.like("lur.user_name", clientUserName);
|
|
|
- queryStatisticsWrapper.like("lur.user_name", clientUserName);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 删除标记条件
|
|
|
queryWrapper.eq("lco.delete_flag", 0);
|
|
queryWrapper.eq("lco.delete_flag", 0);
|
|
|
- queryStatisticsWrapper.eq("lco.delete_flag", 0);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 排序条件
|
|
|
queryWrapper.orderByDesc("lco.created_time");
|
|
queryWrapper.orderByDesc("lco.created_time");
|
|
|
- // 时间范围查询:如果开始时间和结束时间都存在,则进行范围查询
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 时间范围查询
|
|
|
if (StringUtils.hasText(startDate) && StringUtils.hasText(endDate)) {
|
|
if (StringUtils.hasText(startDate) && StringUtils.hasText(endDate)) {
|
|
|
- queryWrapper.between("lco.payment_time", startDate + " 00:00:00", endDate + " 23:59:59");
|
|
|
|
|
|
|
+ String startDateTime = startDate + " 00:00:00";
|
|
|
|
|
+ String endDateTime = endDate + " 23:59:59";
|
|
|
|
|
+ queryWrapper.between("lco.payment_time", startDateTime, endDateTime);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 查询订单列表
|
|
|
|
|
- IPage<LawyerConsultationOrderVO> voPage = consultationOrderMapper.getLawyerConsultationOrderList(page, queryWrapper);
|
|
|
|
|
|
|
+ return queryWrapper;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 填充律师问题场景信息
|
|
|
|
|
- if (voPage != null) {
|
|
|
|
|
- fillLawyerServiceArea(voPage);
|
|
|
|
|
- // 为待支付订单计算倒计时(30分钟有效期)
|
|
|
|
|
- calculateCountdownForPendingOrders(voPage);
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建统计查询条件
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param lawyerId 律师ID
|
|
|
|
|
+ * @param clientUserName 客户端用户名
|
|
|
|
|
+ * @return 统计查询条件包装器
|
|
|
|
|
+ */
|
|
|
|
|
+ private QueryWrapper<LawyerConsultationOrderVO> buildStatisticsQueryWrapper(String lawyerId,
|
|
|
|
|
+ String clientUserName) {
|
|
|
|
|
+ QueryWrapper<LawyerConsultationOrderVO> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq("lco.lawyer_user_id", lawyerId);
|
|
|
|
|
+ queryWrapper.eq("lco.delete_flag", 0);
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.hasText(clientUserName)) {
|
|
|
|
|
+ queryWrapper.like("lur.user_name", clientUserName);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //获取统计信息
|
|
|
|
|
- queryStatisticsWrapper.groupBy("lco.order_status");
|
|
|
|
|
- List<Map<String, Object>> statisticsInfo = consultationOrderMapper.getLawyerStatisticsInfo(queryStatisticsWrapper);
|
|
|
|
|
|
|
+ return queryWrapper;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建状态统计Map
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param statisticsInfo 统计信息列表
|
|
|
|
|
+ * @return 状态统计Map,key为订单状态,value为订单数量
|
|
|
|
|
+ */
|
|
|
|
|
+ private Map<Integer, Integer> buildStatusCountMap(List<Map<String, Object>> statisticsInfo) {
|
|
|
Map<Integer, Integer> statusCountMap = new HashMap<>();
|
|
Map<Integer, Integer> statusCountMap = new HashMap<>();
|
|
|
- for (Map<String, Object> map : statisticsInfo) {
|
|
|
|
|
- Integer status = (Integer) map.get("order_status");
|
|
|
|
|
- Long countLong = (Long) map.get("order_count"); // COUNT(*) 返回类型可能是Long
|
|
|
|
|
- statusCountMap.put(status, countLong.intValue());
|
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(statisticsInfo)) {
|
|
|
|
|
+ return statusCountMap;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ for (Map<String, Object> map : statisticsInfo) {
|
|
|
|
|
+ Object statusObj = map.get("order_status");
|
|
|
|
|
+ Object countObj = map.get("order_count");
|
|
|
|
|
|
|
|
- // 统计进行中订单数量
|
|
|
|
|
- int inProgressCount = statusCountMap.getOrDefault(2, 0);
|
|
|
|
|
- resultMap.put("lawyerInProgressOrderCount", inProgressCount);
|
|
|
|
|
-
|
|
|
|
|
- // 统计已完成订单数量
|
|
|
|
|
- int completeCount = statusCountMap.getOrDefault(3, 0);
|
|
|
|
|
- resultMap.put("lawyerCompleteOrderCount", completeCount);
|
|
|
|
|
-
|
|
|
|
|
- // 统计订单总数
|
|
|
|
|
- resultMap.put("lawyerOrderCount", inProgressCount + completeCount);
|
|
|
|
|
|
|
+ if (statusObj == null || countObj == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 设置订单列表
|
|
|
|
|
- List<LawyerConsultationOrderVO> orderList = voPage != null && voPage.getRecords() != null
|
|
|
|
|
- ? voPage.getRecords() : Collections.emptyList();
|
|
|
|
|
- resultMap.put("lawyerConsultationOrderList", orderList);
|
|
|
|
|
|
|
+ Integer status = (Integer) statusObj;
|
|
|
|
|
+ // COUNT(*) 返回类型可能是Long
|
|
|
|
|
+ Long countLong = (Long) countObj;
|
|
|
|
|
+ statusCountMap.put(status, countLong.intValue());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return resultMap;
|
|
|
|
|
|
|
+ return statusCountMap;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|