|
|
@@ -16,11 +16,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import shop.alien.entity.result.R;
|
|
|
-import shop.alien.entity.store.LawyerConsultationOrder;
|
|
|
-import shop.alien.entity.store.LawyerServiceArea;
|
|
|
-import shop.alien.entity.store.LawyerUser;
|
|
|
-import shop.alien.entity.store.LifeNotice;
|
|
|
-import shop.alien.entity.store.LifeUser;
|
|
|
+import shop.alien.entity.store.*;
|
|
|
import shop.alien.entity.store.dto.LawyerConsultationOrderDto;
|
|
|
import shop.alien.entity.store.dto.PayStatusRequest;
|
|
|
import shop.alien.entity.store.vo.LawyerConsultationOrderVO;
|
|
|
@@ -31,12 +27,7 @@ import shop.alien.lawyer.service.LawyerClientConsultationOrderService;
|
|
|
import shop.alien.lawyer.service.LawyerConsultationOrderService;
|
|
|
import shop.alien.lawyer.service.LawyerUserService;
|
|
|
import shop.alien.lawyer.service.OrderExpirationService;
|
|
|
-import shop.alien.mapper.LawyerConsultationOrderMapper;
|
|
|
-import shop.alien.mapper.LawyerExpertiseAreaMapper;
|
|
|
-import shop.alien.mapper.LawyerServiceAreaMapper;
|
|
|
-import shop.alien.mapper.LawyerUserMapper;
|
|
|
-import shop.alien.mapper.LifeNoticeMapper;
|
|
|
-import shop.alien.mapper.LifeUserMapper;
|
|
|
+import shop.alien.mapper.*;
|
|
|
import shop.alien.util.common.constant.LawyerStatusEnum;
|
|
|
import shop.alien.util.common.constant.OrderActionType;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
@@ -70,6 +61,7 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
|
|
|
private final LifeNoticeMapper lifeNoticeMapper;
|
|
|
private final LifeUserMapper lifeUserMapper;
|
|
|
private final WebSocketProcess webSocketProcess;
|
|
|
+ private final LifeMessageMapper lifeMessageMapper;
|
|
|
|
|
|
/**
|
|
|
* 系统发送者ID常量
|
|
|
@@ -375,6 +367,8 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
|
|
|
fillLawyerServiceArea(voPage);
|
|
|
// 为待支付订单计算倒计时(30分钟有效期)
|
|
|
calculateCountdownForPendingOrders(voPage);
|
|
|
+ //填充未读消息
|
|
|
+ fillUnreadMessage(voPage,lawyerId);
|
|
|
}
|
|
|
|
|
|
// 获取统计信息
|
|
|
@@ -391,6 +385,54 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 填充未读消息数量
|
|
|
+ *
|
|
|
+ * @param voPage 订单VO分页对象
|
|
|
+ */
|
|
|
+ private void fillUnreadMessage(IPage<LawyerConsultationOrderVO> voPage,String lawyerId) {
|
|
|
+ List<LawyerConsultationOrderVO> orderList = voPage.getRecords();
|
|
|
+ if (CollectionUtils.isEmpty(orderList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 提取所有律师ID,并加上lawyer_前缀
|
|
|
+ List<String> lawyerIdList = orderList.stream()
|
|
|
+ .map(LawyerConsultationOrderVO::getLawyerPhone)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(phone -> "lawyer_" + phone)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(lawyerIdList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ LawyerUser lawyerUser = lawyerUserMapper.selectById(lawyerId);
|
|
|
+ String phone = lawyerUser.getPhone();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<LifeMessage> lifeMessageLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lifeMessageLambdaQueryWrapper.in(LifeMessage::getSenderId, lawyerIdList);
|
|
|
+ lifeMessageLambdaQueryWrapper.eq(LifeMessage::getDeleteFlag, 0);
|
|
|
+ lifeMessageLambdaQueryWrapper.eq(LifeMessage::getIsRead, 0);
|
|
|
+ lifeMessageLambdaQueryWrapper.eq(LifeMessage::getReceiverId, "lawyer_" + phone);
|
|
|
+ List<LifeMessage> lifeMessageList = lifeMessageMapper.selectList(lifeMessageLambdaQueryWrapper);
|
|
|
+
|
|
|
+ // 按照senderId进行分组,返回senderId和数量的map
|
|
|
+ Map<String, Long> senderIdCountMap = lifeMessageList.stream()
|
|
|
+ .collect(Collectors.groupingBy(LifeMessage::getSenderId, Collectors.counting()));
|
|
|
+
|
|
|
+ // 填充问题场景
|
|
|
+ orderList.forEach(order -> {
|
|
|
+ String userPhone = "user_" + order.getClientUserPhone();
|
|
|
+
|
|
|
+ if(!senderIdCountMap.isEmpty()&&senderIdCountMap.containsKey(userPhone)&&order.getOrderStatus() == 2){
|
|
|
+ long messageCount = senderIdCountMap.get(userPhone);
|
|
|
+ order.setUnreadMessage(messageCount);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 构建空结果Map
|
|
|
*
|
|
|
* @param pageNum 页码
|