|
|
@@ -296,14 +296,11 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
|
|
|
*/
|
|
|
@Override
|
|
|
public Map<String, Object> getLawyerConsultationOrderInfo(int pageNum, int pageSize, String startDate,
|
|
|
- String endDate, String clientUserName,
|
|
|
- String orderStatus, String lawyerId) {
|
|
|
+ String endDate, String clientUserName, String orderStatus, String lawyerId) {
|
|
|
log.info("查询咨询订单信息(律师端)- pageNum={}, pageSize={}, startDate={}, endDate={}, "
|
|
|
- + "clientUserName={}, orderStatus={}, lawyerId={}",
|
|
|
+ + "clientUserName={}, orderStatus={}, lawyerId={}",
|
|
|
pageNum, pageSize, startDate, endDate, clientUserName, orderStatus, lawyerId);
|
|
|
|
|
|
- Map<String, Object> resultMap = new HashMap<>();
|
|
|
-
|
|
|
// 参数校验:律师ID不能为空
|
|
|
if (!StringUtils.hasText(lawyerId)) {
|
|
|
log.warn("查询咨询订单信息失败:律师ID为空");
|
|
|
@@ -335,38 +332,12 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
|
|
|
List<Map<String, Object>> statisticsInfo = consultationOrderMapper.getLawyerStatisticsInfo(
|
|
|
statisticsWrapper);
|
|
|
|
|
|
- // 构建状态统计Map
|
|
|
+ // 构建状态统计Map并计算各状态订单数量
|
|
|
Map<Integer, Integer> statusCountMap = buildStatusCountMap(statisticsInfo);
|
|
|
-
|
|
|
- // 统计待接单订单数量
|
|
|
- Integer waitAcceptStatus = LawyerStatusEnum.WAIT_ACCEPT.getStatus();
|
|
|
- int waitAcceptStatusCount = statusCountMap.getOrDefault(waitAcceptStatus, 0);
|
|
|
-
|
|
|
- // 统计进行中订单数量
|
|
|
- Integer inProgressStatus = LawyerStatusEnum.INPROGRESS.getStatus();
|
|
|
- int inProgressCount = statusCountMap.getOrDefault(inProgressStatus, 0);
|
|
|
-
|
|
|
- // 统计已完成订单数量
|
|
|
- Integer completeStatus = LawyerStatusEnum.COMPLETE.getStatus();
|
|
|
- int completeCount = statusCountMap.getOrDefault(completeStatus, 0);
|
|
|
-
|
|
|
- // 统计已退款订单数量
|
|
|
- Integer refundedStatus = LawyerStatusEnum.REFUNDED.getStatus();
|
|
|
- int refundedStatusCount = statusCountMap.getOrDefault(refundedStatus, 0);
|
|
|
+ Map<String, Integer> orderStatistics = calculateOrderStatistics(statusCountMap);
|
|
|
|
|
|
// 构建返回结果
|
|
|
- resultMap.put("lawyerInProgressOrderCount", inProgressCount);
|
|
|
- resultMap.put("lawyerCompleteOrderCount", completeCount);
|
|
|
- resultMap.put("lawyerWaitAcceptStatusOrderCount", waitAcceptStatusCount);
|
|
|
- resultMap.put("lawyerRefundedStatusOrderCount", refundedStatusCount);
|
|
|
- resultMap.put("lawyerOrderCount", (long) (inProgressCount + completeCount + waitAcceptStatusCount + refundedStatusCount));
|
|
|
-
|
|
|
- // 设置订单列表
|
|
|
- List<LawyerConsultationOrderVO> orderList = (voPage != null && voPage.getRecords() != null)
|
|
|
- ? voPage.getRecords() : Collections.emptyList();
|
|
|
- resultMap.put("lawyerConsultationOrderList", orderList);
|
|
|
-
|
|
|
- return resultMap;
|
|
|
+ return buildResultMap(voPage, orderStatistics);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -384,11 +355,66 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
|
|
|
resultMap.put("lawyerOrderCount", 0L);
|
|
|
resultMap.put("lawyerInProgressOrderCount", 0);
|
|
|
resultMap.put("lawyerCompleteOrderCount", 0);
|
|
|
+ resultMap.put("lawyerWaitAcceptStatusOrderCount", 0);
|
|
|
+ resultMap.put("lawyerRefundedStatusOrderCount", 0);
|
|
|
resultMap.put("lawyerConsultationOrderList", Collections.emptyList());
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 计算订单统计信息
|
|
|
+ *
|
|
|
+ * @param statusCountMap 状态统计Map
|
|
|
+ * @return 订单统计信息Map
|
|
|
+ */
|
|
|
+ private Map<String, Integer> calculateOrderStatistics(Map<Integer, Integer> statusCountMap) {
|
|
|
+ Map<String, Integer> statistics = new HashMap<>();
|
|
|
+ Integer waitAcceptStatus = LawyerStatusEnum.WAIT_ACCEPT.getStatus();
|
|
|
+ Integer inProgressStatus = LawyerStatusEnum.INPROGRESS.getStatus();
|
|
|
+ Integer completeStatus = LawyerStatusEnum.COMPLETE.getStatus();
|
|
|
+ Integer refundedStatus = LawyerStatusEnum.REFUNDED.getStatus();
|
|
|
+
|
|
|
+ int waitAcceptCount = statusCountMap.getOrDefault(waitAcceptStatus, 0);
|
|
|
+ int inProgressCount = statusCountMap.getOrDefault(inProgressStatus, 0);
|
|
|
+ int completeCount = statusCountMap.getOrDefault(completeStatus, 0);
|
|
|
+ int refundedCount = statusCountMap.getOrDefault(refundedStatus, 0);
|
|
|
+
|
|
|
+ statistics.put("waitAcceptCount", waitAcceptCount);
|
|
|
+ statistics.put("inProgressCount", inProgressCount);
|
|
|
+ statistics.put("completeCount", completeCount);
|
|
|
+ statistics.put("refundedCount", refundedCount);
|
|
|
+ statistics.put("totalCount", waitAcceptCount + inProgressCount + completeCount + refundedCount);
|
|
|
+
|
|
|
+ return statistics;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建返回结果Map
|
|
|
+ *
|
|
|
+ * @param voPage 订单分页对象
|
|
|
+ * @param orderStatistics 订单统计信息
|
|
|
+ * @return 结果Map
|
|
|
+ */
|
|
|
+ private Map<String, Object> buildResultMap(IPage<LawyerConsultationOrderVO> voPage,
|
|
|
+ Map<String, Integer> orderStatistics) {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+
|
|
|
+ // 设置统计信息
|
|
|
+ resultMap.put("lawyerInProgressOrderCount", orderStatistics.get("inProgressCount"));
|
|
|
+ resultMap.put("lawyerCompleteOrderCount", orderStatistics.get("completeCount"));
|
|
|
+ resultMap.put("lawyerWaitAcceptStatusOrderCount", orderStatistics.get("waitAcceptCount"));
|
|
|
+ resultMap.put("lawyerRefundedStatusOrderCount", orderStatistics.get("refundedCount"));
|
|
|
+ resultMap.put("lawyerOrderCount", (long) orderStatistics.get("totalCount"));
|
|
|
+
|
|
|
+ // 设置订单列表
|
|
|
+ List<LawyerConsultationOrderVO> orderList = (voPage != null && voPage.getRecords() != null)
|
|
|
+ ? voPage.getRecords() : Collections.emptyList();
|
|
|
+ resultMap.put("lawyerConsultationOrderList", orderList);
|
|
|
+
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 构建订单查询条件
|
|
|
*
|
|
|
* @param lawyerId 律师ID
|
|
|
@@ -399,19 +425,18 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
|
|
|
* @return 查询条件包装器
|
|
|
*/
|
|
|
private QueryWrapper<LawyerConsultationOrderVO> buildOrderQueryWrapper(String lawyerId, String orderStatus,
|
|
|
- String clientUserName, String startDate,
|
|
|
- String endDate) {
|
|
|
+ String clientUserName, String startDate, String endDate) {
|
|
|
QueryWrapper<LawyerConsultationOrderVO> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
|
// 订单状态条件
|
|
|
if (StringUtils.hasText(orderStatus)) {
|
|
|
queryWrapper.in("lco.order_status", Collections.singletonList(orderStatus));
|
|
|
} else {
|
|
|
- // 默认查询非待支付的订单
|
|
|
+ // 默认查询非待支付和已取消的订单
|
|
|
Integer waitPayStatus = LawyerStatusEnum.WAIT_PAY.getStatus();
|
|
|
Integer cancelStatus = LawyerStatusEnum.CANCEL.getStatus();
|
|
|
- queryWrapper.notIn("lco.order_status", Arrays.asList(
|
|
|
- String.valueOf(cancelStatus), String.valueOf(waitPayStatus)));
|
|
|
+ queryWrapper.notIn("lco.order_status",
|
|
|
+ Arrays.asList(String.valueOf(cancelStatus), String.valueOf(waitPayStatus)));
|
|
|
}
|
|
|
|
|
|
// 律师ID条件
|
|
|
@@ -425,9 +450,7 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
|
|
|
// 删除标记条件
|
|
|
queryWrapper.eq("lco.delete_flag", 0);
|
|
|
|
|
|
- // 排序条件
|
|
|
- queryWrapper.orderByDesc("lco.created_time");
|
|
|
-
|
|
|
+ // 时间范围条件
|
|
|
if (StringUtils.hasText(startDate)) {
|
|
|
queryWrapper.ge("lco.payment_time", startDate);
|
|
|
}
|
|
|
@@ -436,7 +459,8 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
|
|
|
queryWrapper.le("lco.payment_time", endDate);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ // 排序条件
|
|
|
+ queryWrapper.orderByDesc("lco.created_time");
|
|
|
|
|
|
return queryWrapper;
|
|
|
}
|
|
|
@@ -449,7 +473,7 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
|
|
|
* @return 统计查询条件包装器
|
|
|
*/
|
|
|
private QueryWrapper<LawyerConsultationOrderVO> buildStatisticsQueryWrapper(String lawyerId,
|
|
|
- String clientUserName) {
|
|
|
+ String clientUserName) {
|
|
|
QueryWrapper<LawyerConsultationOrderVO> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("lco.lawyer_user_id", lawyerId);
|
|
|
queryWrapper.eq("lco.delete_flag", 0);
|