feat/multi-channel-framework [AC-INIT]合并功能代码 #12
|
|
@ -166,15 +166,15 @@ last_updated: "2026-02-24"
|
|||
- [x] 幂等性检查
|
||||
|
||||
### TASK-022: 重构 MessageProcessService
|
||||
- **状态**: ⏳ 待开始
|
||||
- **状态**: ✅ 已完成
|
||||
- **优先级**: P0
|
||||
- **关联 AC**: AC-MCA-08
|
||||
- **描述**: 将现有 MessageProcessService 逻辑迁移到 MessageRouterServiceImpl
|
||||
- **产出物**:
|
||||
- `src/main/java/com/wecom/robot/service/MessageProcessService.java` 更新或删除
|
||||
- **验收标准**:
|
||||
- [ ] 现有功能保持兼容
|
||||
- [ ] 微信专属逻辑移至 WeChatAdapter
|
||||
- [x] 现有功能保持兼容
|
||||
- [x] 微信专属逻辑移至 WeChatAdapter
|
||||
|
||||
### TASK-023: 更新 SessionManagerService
|
||||
- **状态**: ⏳ 待开始
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ public class Session implements Serializable {
|
|||
|
||||
private String kfId;
|
||||
|
||||
private String channelType;
|
||||
|
||||
private String status;
|
||||
|
||||
private Integer wxServiceState;
|
||||
|
|
@ -39,4 +41,8 @@ public class Session implements Serializable {
|
|||
public static final String STATUS_PENDING = "PENDING";
|
||||
public static final String STATUS_MANUAL = "MANUAL";
|
||||
public static final String STATUS_CLOSED = "CLOSED";
|
||||
|
||||
public static final String CHANNEL_WECHAT = "wechat";
|
||||
public static final String CHANNEL_DOUYIN = "douyin";
|
||||
public static final String CHANNEL_JD = "jd";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,11 @@ import java.time.LocalDateTime;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 会话管理服务
|
||||
*
|
||||
* <p>关联 AC: [AC-MCA-11] 会话管理, [AC-MCA-12] 渠道类型支持
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
|
|
@ -31,6 +36,10 @@ public class SessionManagerService {
|
|||
private final StringRedisTemplate redisTemplate;
|
||||
|
||||
public Session getOrCreateSession(String customerId, String kfId) {
|
||||
return getOrCreateSession(customerId, kfId, Session.CHANNEL_WECHAT);
|
||||
}
|
||||
|
||||
public Session getOrCreateSession(String customerId, String kfId, String channelType) {
|
||||
LambdaQueryWrapper<Session> query = new LambdaQueryWrapper<>();
|
||||
query.eq(Session::getCustomerId, customerId)
|
||||
.eq(Session::getKfId, kfId)
|
||||
|
|
@ -44,6 +53,7 @@ public class SessionManagerService {
|
|||
session.setSessionId(generateSessionId(customerId, kfId));
|
||||
session.setCustomerId(customerId);
|
||||
session.setKfId(kfId);
|
||||
session.setChannelType(channelType != null ? channelType : Session.CHANNEL_WECHAT);
|
||||
session.setStatus(Session.STATUS_AI);
|
||||
session.setWxServiceState(0);
|
||||
session.setCreatedAt(LocalDateTime.now());
|
||||
|
|
@ -51,6 +61,8 @@ public class SessionManagerService {
|
|||
sessionMapper.insert(session);
|
||||
|
||||
cacheSessionStatus(session.getSessionId(), Session.STATUS_AI);
|
||||
log.info("[AC-MCA-11] 创建新会话: sessionId={}, channelType={}",
|
||||
session.getSessionId(), session.getChannelType());
|
||||
}
|
||||
|
||||
return session;
|
||||
|
|
@ -199,6 +211,17 @@ public class SessionManagerService {
|
|||
return sessionMapper.selectList(query);
|
||||
}
|
||||
|
||||
public List<Session> getSessionsByChannelType(String channelType, String status, int limit) {
|
||||
LambdaQueryWrapper<Session> query = new LambdaQueryWrapper<>();
|
||||
query.eq(Session::getChannelType, channelType);
|
||||
if (status != null && !status.isEmpty() && !"all".equals(status)) {
|
||||
query.eq(Session::getStatus, status);
|
||||
}
|
||||
query.orderByDesc(Session::getUpdatedAt);
|
||||
query.last("LIMIT " + limit);
|
||||
return sessionMapper.selectList(query);
|
||||
}
|
||||
|
||||
public List<Session> getAllSessions(int limit) {
|
||||
LambdaQueryWrapper<Session> query = new LambdaQueryWrapper<>();
|
||||
query.orderByDesc(Session::getUpdatedAt);
|
||||
|
|
|
|||
|
|
@ -160,7 +160,8 @@ public class MessageRouterServiceImpl implements MessageRouterService {
|
|||
private Session getOrCreateSession(InboundMessage message) {
|
||||
return sessionManagerService.getOrCreateSession(
|
||||
message.getCustomerId(),
|
||||
message.getKfId()
|
||||
message.getKfId(),
|
||||
message.getChannelType()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue