This commit is contained in:
雷欧(林平凡)
2025-08-14 18:02:31 +08:00
parent 1a762eb50a
commit 11da6257d6
5 changed files with 130 additions and 19 deletions

View File

@@ -1446,7 +1446,7 @@ public class JDUtil {
}
} else {
XbMessage xbMessage = new XbMessage();
xbMessage.setCreateDate(LocalDate.now());
xbMessage.setCreateDate(LocalDateTime.now());
xbMessage.setTipOriginalMessage(message);
xbMessage.setFromWxid(wxid);
String firstLine = message.split("\n")[0];
@@ -1475,7 +1475,7 @@ public class JDUtil {
} else {
// 商品信息
XbMessageItem xbMessageItem = new XbMessageItem();
xbMessageItem.setCreateDate(LocalDate.now());
xbMessageItem.setCreateDate(LocalDateTime.now());
xbMessageItem.setXbMessageId(String.valueOf(xbMessageId));
xbMessageItem.setJsonQueryResult(JSONObject.toJSONString(productInfo.getData()[0]));
xbMessageItem.setJsonCouponList(JSONObject.toJSONString(productInfo.getData()[0].getCouponInfo().getCouponList()));
@@ -2021,6 +2021,9 @@ public class JDUtil {
int usedCommentCount = 0;
int canUseComentCount = 0;
int addCommentCount = 0;
int allTbCommentCount = 0;
int usedTbCommentCount = 0;
int canUseTbCommentCount = 0;
boolean isTb = false;
getProductTypeMap();
@@ -2037,6 +2040,15 @@ public class JDUtil {
canUseComentCount = availableComments.size();
usedCommentCount = usedComments.size();
allCommentCount = canUseComentCount + usedCommentCount;
// 获取淘宝评论统计信息
getProductTypeMapForTB();
String taobaoProductId = productTypeMapTB.getOrDefault(product_id, product_id);
List<TaobaoComment> availableTbComments = taobaoCommentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(taobaoProductId, 1);
List<TaobaoComment> usedTbComments = taobaoCommentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(taobaoProductId, 0);
canUseTbCommentCount = availableTbComments.size();
usedTbCommentCount = usedTbComments.size();
allTbCommentCount = canUseTbCommentCount + usedTbCommentCount;
Comment commentToUse = null;
@@ -2050,9 +2062,9 @@ public class JDUtil {
* ✅ 新增逻辑:先尝试从淘宝获取评论,但前提是 productTypeMapTB 存在对应映射
*/
getProductTypeMapForTB(); // 加载淘宝映射表
String taobaoProductId = productTypeMapTB.getOrDefault(product_id, null);
String taobaoProductIdMap = productTypeMapTB.getOrDefault(product_id, null);
if (taobaoProductId != null && !taobaoProductId.isEmpty()) {
if (taobaoProductIdMap != null && !taobaoProductIdMap.isEmpty()) {
logger.info("发现淘宝映射ID尝试从淘宝获取评论");
wxUtil.sendTextMessage(fromWxid, "本地无可用京东评论已发现淘宝映射ID从淘宝获取评论", 1, null, true);
Comment taobaoComment = generateTaobaoComment(productType);
@@ -2143,7 +2155,17 @@ public class JDUtil {
"已使用:" + usedCommentCount + "\n" +
"可用:" + canUseComentCount + "\n" +
"总数:" + allCommentCount, 1, fromWxid, true);
} else {
wxUtil.sendTextMessage(fromWxid,
"淘宝评论统计:\n" +
"型号 " + productType + "\n" +
"已使用:" + usedTbCommentCount + "\n" +
"可用:" + canUseTbCommentCount + "\n" +
"总数:" + allTbCommentCount, 1, fromWxid, true);
}
} else {
wxUtil.sendTextMessage(fromWxid, "本地和京东均无可用的评论数据请检查sku", 1, fromWxid, false);
return;
}
@@ -2802,8 +2824,8 @@ public class JDUtil {
}
// 添加调试信息,检查输入字符串的字符编码
logger.debug("输入字符串长度: {}", normalized.length());
logger.debug("输入字符串字节数组: {}", java.util.Arrays.toString(normalized.getBytes()));
//logger.debug("输入字符串长度: {}", normalized.length());
//logger.debug("输入字符串字节数组: {}", java.util.Arrays.toString(normalized.getBytes()));
// 第一次尝试 - 使用Unicode转义序列匹配支持前面可选的 \u239C再跟 \u25C9
Pattern pattern = Pattern.compile("(?:\\u239C)?(\\u25C9)[^\\d]*([\\d.]+)\\s*\\uD83D\\uDCB0?");