京粉备注

This commit is contained in:
雷欧(林平凡)
2025-05-08 10:03:02 +08:00
parent a40cb9a8f0
commit 531a9df7f1
2 changed files with 8 additions and 10 deletions

View File

@@ -1271,8 +1271,7 @@ public class JDUtil {
try {
priceList = extractPrices(message);
finallyMessage.put("priceList", priceList);
} catch (Exception ignored) {
}
} catch (Exception ignored) { }
}
for (String url : urls) {
try {
@@ -1633,11 +1632,10 @@ public class JDUtil {
public void sendOrderToWxByOrderP(String order, String fromWxid) {
logger.info("sendOrderToWxByOrderP.order {}", order);
getProductTypeMap();
// 检查是否命中“评”指令
if (!productTypeMap.containsKey(order.trim())) {
try {
getProductTypeMap();
StringBuilder productTypeStr = new StringBuilder();
for (Map.Entry<String, String> entry : productTypeMap.entrySet()) {
String k = entry.getKey();
@@ -1661,7 +1659,7 @@ public class JDUtil {
public void getProductTypeMap() {
Map<Object, Object> rawMap = redisTemplate.opsForHash().entries(PRODUCT_TYPE_MAP_PREFIX);
if (rawMap != null && !rawMap.isEmpty()) {
if (!rawMap.isEmpty()) {
productTypeMap.clear();
for (Map.Entry<Object, Object> entry : rawMap.entrySet()) {
productTypeMap.put(entry.getKey().toString(), entry.getValue().toString());
@@ -1700,7 +1698,7 @@ public class JDUtil {
* 生成评论内容
*/
private synchronized void generateComment(String fromWxid, String productType) {
wxUtil.sendTextMessage(fromWxid, "已接收到评论生成指令,等候过程请勿重复输入", 1, fromWxid, false);
wxUtil.sendTextMessage(fromWxid, "已接收到评论生成指令,等候过程请勿重复输入", 1, fromWxid, true);
// 获取产品ID
getProductTypeMap();
@@ -1724,7 +1722,7 @@ public class JDUtil {
Collections.shuffle(availableComments);
commentToUse = availableComments.get(0);
} else {
wxUtil.sendTextMessage(fromWxid, "没有本地评论,调用外部接口抓取", 1, fromWxid, false);
wxUtil.sendTextMessage(fromWxid, "没有本地评论,调用外部接口抓取", 1, fromWxid, true);
// 没有本地评论,调用外部接口抓取
try {
String fetchUrl = "http://192.168.8.6:5000/fetch_comments?product_id=" + product_id;
@@ -1734,7 +1732,7 @@ public class JDUtil {
logger.info("fetchUrl: {}", fetchUrl);
// code = 200 表示成功,-200 表示失败
if (response.getStatus() == 200) {
wxUtil.sendTextMessage(fromWxid, "已获取新的评论,请稍等", 1, fromWxid, false);
wxUtil.sendTextMessage(fromWxid, "已获取新的评论,请稍等", 1, fromWxid, true);
// ✅ 关键修改:重新从数据库中查询,而不是使用内存中的 fetchedComments
availableComments = commentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(product_id, 1);
if (!availableComments.isEmpty()) {
@@ -1756,7 +1754,7 @@ public class JDUtil {
wxUtil.sendTextMessage(fromWxid, "没有找到可用的评论数据", 1, fromWxid, false);
return;
}
wxUtil.sendTextMessage(fromWxid, "原评论:\n" + commentToUse.getCommentText(), 1, fromWxid, false);
wxUtil.sendTextMessage(fromWxid, "原评论:\n" + commentToUse.getCommentText(), 1, fromWxid, true);
// 发送图片(如果有)
String pictureUrls = commentToUse.getPictureUrls();
if (pictureUrls != null && !pictureUrls.isEmpty()) {
@@ -1777,7 +1775,7 @@ public class JDUtil {
wxUtil.sendTextMessage(fromWxid, "DS评论生成失败", 1, fromWxid, false);
}
// 发送生成的评论文本
wxUtil.sendTextMessage(fromWxid, "DS回复\n" + deepSeekResponse, 1, fromWxid, false);
wxUtil.sendTextMessage(fromWxid, "DS回复\n" + deepSeekResponse, 1, fromWxid, true);
// 更新评论状态为已使用
commentToUse.setIsUse(1);