|
|
@@ -459,11 +459,21 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
|
|
|
if (vo.getId() == null && e.getId() != null) {
|
|
|
vo.setId(e.getId());
|
|
|
}
|
|
|
- // 取最早的 firstReplyTime + 同时记录主题/emailId
|
|
|
+ // 取最早的 firstReplyTime
|
|
|
if (e.getFirstReplyTime() != null) {
|
|
|
if (vo.getFirstReplyTime() == null || e.getFirstReplyTime().before(vo.getFirstReplyTime())) {
|
|
|
vo.setFirstReplyTime(e.getFirstReplyTime());
|
|
|
- vo.setReplyContent(e.getFirstReplyTheme());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 取最新且非空的回复主题(bestReplyContent 聚合)
|
|
|
+ String theme = e.getFirstReplyTheme();
|
|
|
+ if (theme != null && !theme.trim().isEmpty()) {
|
|
|
+ if (vo.getBestReplyContent() == null) {
|
|
|
+ vo.setBestReplyContent(theme);
|
|
|
+ } else if (e.getFirstReplyTime() != null
|
|
|
+ && (vo.getFirstReplyTime() == null || e.getFirstReplyTime().after(vo.getFirstReplyTime()))) {
|
|
|
+ // 当前记录的 firstReplyTime 比已记录的 firstReplyTime 更新时,更新 bestReplyContent
|
|
|
+ vo.setBestReplyContent(theme);
|
|
|
}
|
|
|
}
|
|
|
// MAX(has_protect) / MAX(has_suspend) 语义
|
|
|
@@ -475,10 +485,12 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // 默认未保护/未暂停为 0
|
|
|
+ // 默认未保护/未暂停为 0;bestReplyContent 写回 replyContent
|
|
|
for (com.storlead.trade.vo.MarketEmailsReplyVO vo : aggMap.values()) {
|
|
|
if (vo.getHasProtect() == null) vo.setHasProtect(0);
|
|
|
if (vo.getHasSuspend() == null) vo.setHasSuspend(0);
|
|
|
+ vo.setReplyContent(vo.getBestReplyContent());
|
|
|
+ vo.setBestReplyContent(null);
|
|
|
}
|
|
|
// 按首次回复时间倒序(最近回复的排前)
|
|
|
List<com.storlead.trade.vo.MarketEmailsReplyVO> voList = new java.util.ArrayList<>(aggMap.values());
|
|
|
@@ -492,7 +504,7 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
|
|
|
// 批量回填:客户名 / 客户等级 / 核心标签
|
|
|
if (!voList.isEmpty()) {
|
|
|
java.util.Set<Long> customerIdSet = new java.util.LinkedHashSet<>();
|
|
|
- for (com.storlead.trade.vo.MarketEmailsReplyVO v : voList) {
|
|
|
+ for (MarketEmailsReplyVO v : voList) {
|
|
|
if (v.getCustomerId() != null) customerIdSet.add(v.getCustomerId());
|
|
|
}
|
|
|
if (!customerIdSet.isEmpty()) {
|