This commit is contained in:
Leo
2026-01-16 18:12:18 +08:00
parent 7c7076f4ef
commit 3dabd23dd7

View File

@@ -230,12 +230,28 @@ public class JDInnerController {
// 添加评论统计信息到响应中
JSONObject stats = new JSONObject();
if (!isTb) {
// 查询最后一条京东评论的创建时间
List<Comment> allComments = commentRepository.findByProductIdAndPictureUrlsIsNotNull(productId);
java.time.LocalDateTime lastCommentUpdateTime = null;
if (!allComments.isEmpty()) {
lastCommentUpdateTime = allComments.stream()
.map(Comment::getCreatedAt)
.filter(createdAt -> createdAt != null)
.max(java.time.LocalDateTime::compareTo)
.orElse(null);
}
stats.put("source", "京东评论");
stats.put("productType", productType);
stats.put("newAdded", addCommentCount);
stats.put("used", usedCommentCount);
stats.put("available", canUseCommentCount);
stats.put("total", allCommentCount);
if (lastCommentUpdateTime != null) {
// 转换为Date格式前端期望的格式
java.util.Date updateDate = java.sql.Timestamp.valueOf(lastCommentUpdateTime);
stats.put("lastCommentUpdateTime", updateDate.getTime());
}
stats.put("statisticsText",
"京东评论统计:\n" +
"型号 " + productType + "\n" +
@@ -244,11 +260,27 @@ public class JDInnerController {
"可用:" + canUseCommentCount + "\n" +
"总数:" + allCommentCount);
} else {
// 查询最后一条淘宝评论的创建时间
List<TaobaoComment> allTbComments = taobaoCommentRepository.findByProductIdAndPictureUrlsIsNotNull(taobaoProductId);
java.time.LocalDateTime lastCommentUpdateTime = null;
if (!allTbComments.isEmpty()) {
lastCommentUpdateTime = allTbComments.stream()
.map(TaobaoComment::getCreatedAt)
.filter(createdAt -> createdAt != null)
.max(java.time.LocalDateTime::compareTo)
.orElse(null);
}
stats.put("source", "淘宝评论");
stats.put("productType", productType);
stats.put("used", usedTbCommentCount);
stats.put("available", canUseTbCommentCount);
stats.put("total", allTbCommentCount);
if (lastCommentUpdateTime != null) {
// 转换为Date格式前端期望的格式
java.util.Date updateDate = java.sql.Timestamp.valueOf(lastCommentUpdateTime);
stats.put("lastCommentUpdateTime", updateDate.getTime());
}
stats.put("statisticsText",
"淘宝评论统计:\n" +
"型号 " + productType + "\n" +