Merge remote-tracking branch '群晖/master'

This commit is contained in:
雷欧(林平凡)
2025-06-25 14:16:12 +08:00

View File

@@ -1932,7 +1932,7 @@ public class JDUtil {
try { try {
String fetchUrl = "http://192.168.8.6:5000/fetch_comments?product_id=" + product_id; String fetchUrl = "http://192.168.8.6:5000/fetch_comments?product_id=" + product_id;
// 用hutool发起post请求 // 用hutool发起post请求
HttpResponse response = HttpRequest.post(fetchUrl).timeout(60000).execute(); HttpResponse response = HttpRequest.post(fetchUrl).timeout(1000 * 60).execute();
logger.info("fetchUrl: {}", fetchUrl); logger.info("fetchUrl: {}", fetchUrl);
// code = 200 表示成功,-200 表示失败 // code = 200 表示成功,-200 表示失败
@@ -1946,18 +1946,20 @@ public class JDUtil {
commentToUse = availableComments.get(0); commentToUse = availableComments.get(0);
} }
} else if (response.getStatus() == -200) { } else if (response.getStatus() == -200) {
wxUtil.sendTextMessage(fromWxid, "暂时无法获取新的评论,请稍后再试", 1, fromWxid, false); wxUtil.sendTextMessage(fromWxid, "请求响应:暂无新的评论。为您随机选取使用过的评论", 1, fromWxid, false);
return; // 随机选取一个使用过的评论
Collections.shuffle(usedComments);
commentToUse = usedComments.get(0);
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("调用外部接口获取评论失败", e); logger.error("调用外部接口获取评论失败", e);
wxUtil.sendTextMessage(fromWxid, "调用外部接口获取评论失败", 1, fromWxid, false); wxUtil.sendTextMessage(fromWxid, "请求响应响应超时60s。为您随机选取使用过的评论", 1, fromWxid, false);
return; commentToUse = usedComments.get(0);
} }
} }
if (commentToUse == null) { if (commentToUse == null) {
wxUtil.sendTextMessage(fromWxid, "没有找到可用的评论数据", 1, fromWxid, false); wxUtil.sendTextMessage(fromWxid, "本地和京东均无可用的评论数据请检查sku", 1, fromWxid, false);
return; return;
} }
wxUtil.sendTextMessage(fromWxid, commentToUse.getCommentText(), 1, fromWxid, true); wxUtil.sendTextMessage(fromWxid, commentToUse.getCommentText(), 1, fromWxid, true);