|
@@ -20,6 +20,8 @@ import shop.alien.store.service.LifeMessageService;
|
|
|
import shop.alien.store.service.LifeUserService;
|
|
import shop.alien.store.service.LifeUserService;
|
|
|
import shop.alien.util.common.JwtUtil;
|
|
import shop.alien.util.common.JwtUtil;
|
|
|
import shop.alien.util.common.constant.LawyerStatusEnum;
|
|
import shop.alien.util.common.constant.LawyerStatusEnum;
|
|
|
|
|
+import shop.alien.util.type.LifeNoticeUtil;
|
|
|
|
|
+import shop.alien.util.type.PhoneTypeIdResult;
|
|
|
import shop.alien.util.type.TypeUtil;
|
|
import shop.alien.util.type.TypeUtil;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -48,8 +50,9 @@ public class LifeMessageServiceImpl extends ServiceImpl<LifeMessageMapper, LifeM
|
|
|
private final LawyerUserMapper lawyerUserMapper;
|
|
private final LawyerUserMapper lawyerUserMapper;
|
|
|
private final LawyerConsultationOrderMapper lawyerConsultationOrderMapper;
|
|
private final LawyerConsultationOrderMapper lawyerConsultationOrderMapper;
|
|
|
|
|
|
|
|
|
|
+ private final TypeUtil typeUtil;
|
|
|
|
|
|
|
|
- private TypeUtil typeUtil;
|
|
|
|
|
|
|
+ private final LifeNoticeUtil lifeNoticeUtil;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<LifeMessageVo> getMessageList(String receiverId, int friendType, String search ,String userName) throws Exception {
|
|
public List<LifeMessageVo> getMessageList(String receiverId, int friendType, String search ,String userName) throws Exception {
|
|
@@ -558,17 +561,17 @@ public class LifeMessageServiceImpl extends ServiceImpl<LifeMessageMapper, LifeM
|
|
|
notDisturbList.addAll(lifeBlacklistVoList);
|
|
notDisturbList.addAll(lifeBlacklistVoList);
|
|
|
String notDisturbIdsStr = "'" + String.join("','", notDisturbList) + "'";
|
|
String notDisturbIdsStr = "'" + String.join("','", notDisturbList) + "'";
|
|
|
|
|
|
|
|
- // 查询未读消息数量
|
|
|
|
|
|
|
+ // 查询未读消息数量(life_message 按 receiver_user_type + receiver_ref_id)
|
|
|
LambdaQueryWrapper<LifeMessage> messageWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<LifeMessage> messageWrapper = new LambdaQueryWrapper<>();
|
|
|
- messageWrapper.eq(LifeMessage::getReceiverId, receiverId);
|
|
|
|
|
|
|
+ applyReceiverIdentityFilter(messageWrapper, receiverId);
|
|
|
messageWrapper.eq(LifeMessage::getIsRead, 0);
|
|
messageWrapper.eq(LifeMessage::getIsRead, 0);
|
|
|
messageWrapper.notIn(LifeMessage::getSenderId, notDisturbIdsStr);
|
|
messageWrapper.notIn(LifeMessage::getSenderId, notDisturbIdsStr);
|
|
|
messageWrapper.apply("(instr(delete_phone_id, '" + receiverId + "') is null or instr(delete_phone_id, '" + receiverId + "') = 0)");
|
|
messageWrapper.apply("(instr(delete_phone_id, '" + receiverId + "') is null or instr(delete_phone_id, '" + receiverId + "') = 0)");
|
|
|
int noReadMessageCount = lifeMessageMapper.selectCount(messageWrapper);
|
|
int noReadMessageCount = lifeMessageMapper.selectCount(messageWrapper);
|
|
|
|
|
|
|
|
- // 查询未读通知数量
|
|
|
|
|
|
|
+ // 查询未读通知数量(life_notice 按 receiver_user_type + receiver_ref_id)
|
|
|
LambdaQueryWrapper<LifeNotice> noticeWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<LifeNotice> noticeWrapper = new LambdaQueryWrapper<>();
|
|
|
- noticeWrapper.eq(LifeNotice::getReceiverId, receiverId);
|
|
|
|
|
|
|
+ lifeNoticeUtil.applyReceiverQuery(noticeWrapper, receiverId);
|
|
|
noticeWrapper.eq(LifeNotice::getIsRead, 0);
|
|
noticeWrapper.eq(LifeNotice::getIsRead, 0);
|
|
|
int noReadNoticeCount = lifeNoticeMapper.selectCount(noticeWrapper);
|
|
int noReadNoticeCount = lifeNoticeMapper.selectCount(noticeWrapper);
|
|
|
|
|
|
|
@@ -600,4 +603,19 @@ public class LifeMessageServiceImpl extends ServiceImpl<LifeMessageMapper, LifeM
|
|
|
return lifeUserMapper.selectOne(wrapper).getIsBanned() == 1;
|
|
return lifeUserMapper.selectOne(wrapper).getIsBanned() == 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 按接收人 userType + refId 过滤消息;解析失败时回退 receiver_id。
|
|
|
|
|
+ */
|
|
|
|
|
+ private void applyReceiverIdentityFilter(LambdaQueryWrapper<LifeMessage> wrapper, String receiverId) {
|
|
|
|
|
+ PhoneTypeIdResult resolved = typeUtil.resolveTypeAndId(receiverId);
|
|
|
|
|
+ if (resolved != null && resolved.getType() != null && resolved.getId() != null) {
|
|
|
|
|
+ wrapper.and(w -> w.nested(n -> n.eq(LifeMessage::getReceiverUserType, resolved.getType())
|
|
|
|
|
+ .eq(LifeMessage::getReceiverRefId, resolved.getId()))
|
|
|
|
|
+ .or()
|
|
|
|
|
+ .eq(LifeMessage::getReceiverId, receiverId));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ wrapper.eq(LifeMessage::getReceiverId, receiverId);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|