|
|
@@ -562,17 +562,14 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
|
|
|
*/
|
|
|
@Override
|
|
|
public Map<String, Object> getConsultationOrderListById(int pageNum, int pageSize,
|
|
|
- String userId, String orderStatus,
|
|
|
- String lawyerName) {
|
|
|
- log.info("查询咨询订单信息(律师端)- pageNum={}, pageSize={}, userId={},"
|
|
|
- + "orderStatus={}, lawyerName={}",
|
|
|
- pageNum, pageSize,userId, orderStatus, lawyerName);
|
|
|
-
|
|
|
- Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ String userId, String orderStatus,
|
|
|
+ String lawyerName) {
|
|
|
+ log.info("查询咨询订单信息(律师端)- pageNum={}, pageSize={}, userId={}, orderStatus={}, lawyerName={}",
|
|
|
+ pageNum, pageSize, userId, orderStatus, lawyerName);
|
|
|
|
|
|
// 参数校验:用户ID不能为空
|
|
|
if (!StringUtils.hasText(userId)) {
|
|
|
- log.warn("查询咨询订单信息失败:用户ID不为空");
|
|
|
+ log.warn("查询咨询订单信息失败:用户ID为空");
|
|
|
return buildEmptyResultMap(pageNum, pageSize);
|
|
|
}
|
|
|
|
|
|
@@ -589,10 +586,9 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
|
|
|
IPage<LawyerConsultationOrderVO> voPage = consultationOrderMapper.getLawyerConsultationOrderList(
|
|
|
page, queryWrapper);
|
|
|
|
|
|
- // 填充法律场景信息
|
|
|
+ // 填充法律场景信息和倒计时
|
|
|
if (voPage != null) {
|
|
|
fillLegalSceneArea(voPage);
|
|
|
- // 为待支付订单计算倒计时(30分钟有效期)
|
|
|
calculateCountdownForPendingOrders(voPage);
|
|
|
}
|
|
|
|
|
|
@@ -601,41 +597,55 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
|
|
|
List<Map<String, Object>> statisticsInfo = consultationOrderMapper.getLawyerStatisticsInfo(
|
|
|
statisticsWrapper);
|
|
|
|
|
|
- // 构建状态统计Map
|
|
|
+ // 构建状态统计Map并填充返回结果
|
|
|
Map<Integer, Integer> statusCountMap = buildStatusCountMap(statisticsInfo);
|
|
|
+ Map<String, Object> resultMap = buildOrderStatisticsResult(statusCountMap, voPage);
|
|
|
+
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
|
|
|
- // 统计待支付订单数量
|
|
|
+ /**
|
|
|
+ * 构建订单统计结果Map
|
|
|
+ *
|
|
|
+ * @param statusCountMap 状态统计Map
|
|
|
+ * @param voPage 订单分页对象
|
|
|
+ * @return 订单统计结果Map
|
|
|
+ */
|
|
|
+ private Map<String, Object> buildOrderStatisticsResult(Map<Integer, Integer> statusCountMap,
|
|
|
+ IPage<LawyerConsultationOrderVO> voPage) {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>(16);
|
|
|
+
|
|
|
+ // 获取各状态订单数量
|
|
|
Integer waitPayStatus = LawyerStatusEnum.WAIT_PAY.getStatus();
|
|
|
int waitPayStatusCount = statusCountMap.getOrDefault(waitPayStatus, 0);
|
|
|
|
|
|
- // 统计待接单订单数量
|
|
|
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 cancelStatus = LawyerStatusEnum.CANCEL.getStatus();
|
|
|
int cancelStatusCount = statusCountMap.getOrDefault(cancelStatus, 0);
|
|
|
|
|
|
- // 统计已退款订单数量
|
|
|
Integer refundedStatus = LawyerStatusEnum.REFUNDED.getStatus();
|
|
|
int refundedStatusCount = statusCountMap.getOrDefault(refundedStatus, 0);
|
|
|
|
|
|
- // 构建返回结果
|
|
|
+ // 计算订单总数
|
|
|
+ long totalOrderCount = (long) (waitPayStatusCount + waitAcceptStatusCount + inProgressCount
|
|
|
+ + completeCount + cancelStatusCount + refundedStatusCount);
|
|
|
+
|
|
|
+ // 填充返回结果
|
|
|
resultMap.put("lawyerWaitPayStatusOrderCount", waitPayStatusCount);
|
|
|
resultMap.put("lawyerWaitAcceptStatusOrderCount", waitAcceptStatusCount);
|
|
|
resultMap.put("lawyerInProgressOrderCount", inProgressCount);
|
|
|
resultMap.put("lawyerCompleteOrderCount", completeCount);
|
|
|
resultMap.put("lawyerCancelStatusOrderCount", cancelStatusCount);
|
|
|
resultMap.put("lawyerRefundedStatusOrderCount", refundedStatusCount);
|
|
|
- resultMap.put("lawyerOrderCount", (long) (waitPayStatusCount + waitAcceptStatusCount + inProgressCount + completeCount + cancelStatusCount + refundedStatusCount));
|
|
|
+ resultMap.put("lawyerOrderCount", totalOrderCount);
|
|
|
|
|
|
// 设置订单列表
|
|
|
List<LawyerConsultationOrderVO> orderList = (voPage != null && voPage.getRecords() != null)
|
|
|
@@ -652,7 +662,7 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
|
|
|
* @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<>(16);
|
|
|
if (CollectionUtils.isEmpty(statisticsInfo)) {
|
|
|
return statusCountMap;
|
|
|
}
|
|
|
@@ -677,17 +687,17 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
|
|
|
/**
|
|
|
* 构建统计查询条件
|
|
|
*
|
|
|
- * @param lawyerName 律师ID
|
|
|
- * @param userId 客户端用户名
|
|
|
+ * @param lawyerName 律师名称
|
|
|
+ * @param userId 客户端用户ID
|
|
|
* @return 统计查询条件包装器
|
|
|
*/
|
|
|
private QueryWrapper<LawyerConsultationOrderVO> buildStatisticsQueryWrapper(String lawyerName,
|
|
|
String userId) {
|
|
|
QueryWrapper<LawyerConsultationOrderVO> queryWrapper = new QueryWrapper<>();
|
|
|
- if(StringUtils.hasText(lawyerName)){
|
|
|
+ if (StringUtils.hasText(lawyerName)) {
|
|
|
queryWrapper.like("lu.name", lawyerName);
|
|
|
}
|
|
|
- queryWrapper.like("lco.client_user_id", userId);
|
|
|
+ queryWrapper.eq("lco.client_user_id", userId);
|
|
|
queryWrapper.eq("lco.delete_flag", 0);
|
|
|
return queryWrapper;
|
|
|
}
|
|
|
@@ -701,13 +711,17 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
|
|
|
* @return 空结果Map
|
|
|
*/
|
|
|
private Map<String, Object> buildEmptyResultMap(int pageNum, int pageSize) {
|
|
|
- Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ Map<String, Object> resultMap = new HashMap<>(16);
|
|
|
Page<LawyerConsultationOrderVO> emptyPage = new Page<>(pageNum, pageSize);
|
|
|
emptyPage.setRecords(Collections.emptyList());
|
|
|
emptyPage.setTotal(0);
|
|
|
- resultMap.put("lawyerOrderCount", 0L);
|
|
|
+ resultMap.put("lawyerWaitPayStatusOrderCount", 0);
|
|
|
+ resultMap.put("lawyerWaitAcceptStatusOrderCount", 0);
|
|
|
resultMap.put("lawyerInProgressOrderCount", 0);
|
|
|
resultMap.put("lawyerCompleteOrderCount", 0);
|
|
|
+ resultMap.put("lawyerCancelStatusOrderCount", 0);
|
|
|
+ resultMap.put("lawyerRefundedStatusOrderCount", 0);
|
|
|
+ resultMap.put("lawyerOrderCount", 0L);
|
|
|
resultMap.put("lawyerConsultationOrderList", Collections.emptyList());
|
|
|
return resultMap;
|
|
|
}
|
|
|
@@ -715,9 +729,9 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
|
|
|
/**
|
|
|
* 构建订单查询条件
|
|
|
*
|
|
|
- * @param lawyerName 律师名称
|
|
|
- * @param orderStatus 订单状态
|
|
|
- * @param userId 客户端用户名
|
|
|
+ * @param lawyerName 律师名称
|
|
|
+ * @param orderStatus 订单状态
|
|
|
+ * @param userId 客户端用户ID
|
|
|
* @return 查询条件包装器
|
|
|
*/
|
|
|
private QueryWrapper<LawyerConsultationOrderVO> buildOrderQueryWrapper(String lawyerName, String orderStatus,
|
|
|
@@ -730,17 +744,17 @@ public class LawyerConsultationOrderServiceImpl extends ServiceImpl<LawyerConsul
|
|
|
}
|
|
|
|
|
|
// 律师名称条件
|
|
|
- if(StringUtils.hasText(lawyerName)){
|
|
|
+ if (StringUtils.hasText(lawyerName)) {
|
|
|
queryWrapper.like("lu.name", lawyerName);
|
|
|
}
|
|
|
|
|
|
- // 客户端用户名条件
|
|
|
+ // 客户端用户ID条件
|
|
|
queryWrapper.eq("lco.client_user_id", userId);
|
|
|
|
|
|
// 删除标记条件
|
|
|
queryWrapper.eq("lco.delete_flag", 0);
|
|
|
|
|
|
- // 排序条件
|
|
|
+ // 排序条件:按创建时间倒序
|
|
|
queryWrapper.orderByDesc("lco.created_time");
|
|
|
return queryWrapper;
|
|
|
}
|