|
|
@@ -1,7 +1,8 @@
|
|
|
package shop.alien.lawyer.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@@ -9,7 +10,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang.math.RandomUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -17,28 +17,22 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import shop.alien.entity.result.R;
|
|
|
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;
|
|
|
import shop.alien.entity.store.vo.WebSocketVo;
|
|
|
import shop.alien.lawyer.config.WebSocketProcess;
|
|
|
import shop.alien.lawyer.feign.AlienStoreFeign;
|
|
|
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.*;
|
|
|
import shop.alien.util.common.constant.LawyerStatusEnum;
|
|
|
import shop.alien.util.common.constant.OrderActionType;
|
|
|
-import com.alibaba.fastjson2.JSON;
|
|
|
-import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* 咨询订单 服务实现类
|
|
|
@@ -367,8 +361,6 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
|
|
|
fillLawyerServiceArea(voPage);
|
|
|
// 为待支付订单计算倒计时(30分钟有效期)
|
|
|
calculateCountdownForPendingOrders(voPage);
|
|
|
- //填充未读消息
|
|
|
- fillUnreadMessage(voPage,lawyerId);
|
|
|
}
|
|
|
|
|
|
// 获取统计信息
|
|
|
@@ -385,58 +377,6 @@ 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::getClientUserPhone)
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .map(phone -> "user_" + 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 = new HashMap<>();
|
|
|
- if(CollectionUtils.isNotEmpty(lifeMessageList)){
|
|
|
- senderIdCountMap = lifeMessageList.stream()
|
|
|
- .collect(Collectors.groupingBy(LifeMessage::getSenderId, Collectors.counting()));
|
|
|
- }
|
|
|
-
|
|
|
- for(LawyerConsultationOrderVO lawyerConsultationOrderVO : voPage.getRecords()){
|
|
|
- String lawyerPhone = "user_" + lawyerConsultationOrderVO.getClientUserPhone();
|
|
|
- if(!senderIdCountMap.isEmpty() && senderIdCountMap.containsKey(lawyerPhone) && lawyerConsultationOrderVO.getOrderStatus() == 2){
|
|
|
- long messageCount = senderIdCountMap.get(lawyerPhone);
|
|
|
- lawyerConsultationOrderVO.setUnreadMessage(messageCount);
|
|
|
- } else {
|
|
|
- lawyerConsultationOrderVO.setUnreadMessage(0L);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 构建空结果Map
|
|
|
*
|
|
|
* @param pageNum 页码
|