|
|
@@ -1,6 +1,7 @@
|
|
|
package org.dromara.main.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import java.util.Arrays;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
@@ -293,9 +294,7 @@ public class CsMessageServiceImpl implements ICsMessageService {
|
|
|
}
|
|
|
|
|
|
private void enrichRealtimeMessageVo(CsMessageVo vo, CsSession session) {
|
|
|
- CsSeatConfig seat = session != null && session.getSeatId() != null
|
|
|
- ? seatConfigMapper.selectById(session.getSeatId())
|
|
|
- : null;
|
|
|
+ CsSeatConfig seat = resolveSeat(session);
|
|
|
Map<Long, SysUser> waiterMap = Collections.emptyMap();
|
|
|
if (vo != null && Objects.equals(vo.getSenderType(), 2) && vo.getSenderId() != null) {
|
|
|
SysUser waiter = sysUserMapper.selectById(vo.getSenderId());
|
|
|
@@ -312,12 +311,42 @@ public class CsMessageServiceImpl implements ICsMessageService {
|
|
|
return records;
|
|
|
}
|
|
|
Map<Long, SysUser> waiterMap = loadWaiterMap(records);
|
|
|
- CsSeatConfig seat = session != null && session.getSeatId() != null ? seatConfigMapper.selectById(session.getSeatId()) : null;
|
|
|
+ CsSeatConfig seat = resolveSeat(session);
|
|
|
MainCompanyApply companyApply = loadCompanyApply(session);
|
|
|
records.forEach(item -> enrichMessageVo(item, session, seat, companyApply, waiterMap));
|
|
|
return records;
|
|
|
}
|
|
|
|
|
|
+ private CsSeatConfig resolveSeat(CsSession session) {
|
|
|
+ if (session == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ // 优先通过 seatId 获取
|
|
|
+ if (session.getSeatId() != null) {
|
|
|
+ return seatConfigMapper.selectById(session.getSeatId());
|
|
|
+ }
|
|
|
+ // seatId 为空时,根据 sessionType 查询匹配的坐席配置
|
|
|
+ List<String> moduleCandidates = session.getSessionType() != null && session.getSessionType() == 2
|
|
|
+ ? Arrays.asList("merchant", "all", "官网", "商家", "3")
|
|
|
+ : Arrays.asList("mini", "all", "小程序", "1", "2");
|
|
|
+ List<CsSeatConfig> seats = seatConfigMapper.selectList(
|
|
|
+ Wrappers.lambdaQuery(CsSeatConfig.class)
|
|
|
+ .eq(CsSeatConfig::getStatus, 1)
|
|
|
+ .in(CsSeatConfig::getModule, moduleCandidates)
|
|
|
+ .orderByAsc(CsSeatConfig::getId)
|
|
|
+ );
|
|
|
+ if (!seats.isEmpty()) {
|
|
|
+ return seats.get(0);
|
|
|
+ }
|
|
|
+ // 兜底:查询所有启用的坐席
|
|
|
+ List<CsSeatConfig> allSeats = seatConfigMapper.selectList(
|
|
|
+ Wrappers.lambdaQuery(CsSeatConfig.class)
|
|
|
+ .eq(CsSeatConfig::getStatus, 1)
|
|
|
+ .orderByAsc(CsSeatConfig::getId)
|
|
|
+ );
|
|
|
+ return allSeats.isEmpty() ? null : allSeats.get(0);
|
|
|
+ }
|
|
|
+
|
|
|
private void enrichMessageVo(CsMessageVo vo, CsSession session, CsSeatConfig seat, MainCompanyApply companyApply, Map<Long, SysUser> waiterMap) {
|
|
|
if (vo == null) {
|
|
|
return;
|