|
|
@@ -12,6 +12,7 @@ import lombok.extern.log4j.Log4j2;
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.Collection;
|
|
|
import java.util.Date;
|
|
|
@@ -100,17 +101,33 @@ public class MktMailStatusServiceImpl extends MyBaseServiceImpl<MktMailStatusMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void markReplied(Long mailId) {
|
|
|
+ public void markReplied(Long mailId, Long firstReplyEmailId, String firstReplyTheme) {
|
|
|
if (mailId == null) {
|
|
|
return;
|
|
|
}
|
|
|
ensureMinimalRow(mailId);
|
|
|
+ MktMailStatusEntity existing = getByMailId(mailId);
|
|
|
Date now = new Date();
|
|
|
LambdaUpdateWrapper<MktMailStatusEntity> update = new LambdaUpdateWrapper<>();
|
|
|
update.eq(MktMailStatusEntity::getMailId, mailId);
|
|
|
update.eq(MktMailStatusEntity::getIsDelete, CommonConstant.DEL_FLAG_0);
|
|
|
update.set(MktMailStatusEntity::getReplied, 1);
|
|
|
update.setSql("first_reply_time = IFNULL(first_reply_time, NOW())");
|
|
|
+ // 仅首次写入回复邮件 ID / 主题
|
|
|
+ if (existing == null || existing.getFirstReplyEmailId() == null) {
|
|
|
+ if (firstReplyEmailId != null) {
|
|
|
+ update.set(MktMailStatusEntity::getFirstReplyEmailId, firstReplyEmailId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (existing == null || !StringUtils.hasText(existing.getFirstReplyTheme())) {
|
|
|
+ if (StringUtils.hasText(firstReplyTheme)) {
|
|
|
+ String theme = firstReplyTheme.trim();
|
|
|
+ if (theme.length() > 512) {
|
|
|
+ theme = theme.substring(0, 512);
|
|
|
+ }
|
|
|
+ update.set(MktMailStatusEntity::getFirstReplyTheme, theme);
|
|
|
+ }
|
|
|
+ }
|
|
|
update.set(MktMailStatusEntity::getStatusUpdatedAt, now);
|
|
|
update.set(MktMailStatusEntity::getUpdateTime, now);
|
|
|
this.update(update);
|