1
This commit is contained in:
@@ -1887,7 +1887,7 @@ public class JDUtil {
|
||||
public void sendOrderToWxByOrderP(String order, String fromWxid) {
|
||||
logger.info("sendOrderToWxByOrderP.order {}", order);
|
||||
getProductTypeMap();
|
||||
// 检查是否命中“评”指令
|
||||
// 检查是否命中"评"指令
|
||||
if (!productTypeMap.containsKey(order.trim())) {
|
||||
if (order.startsWith("添加型号")) {
|
||||
String replace = order.replace("添加型号-", "");
|
||||
@@ -2377,11 +2377,11 @@ public class JDUtil {
|
||||
userDate = localDates;
|
||||
logger.info("用户输入的日期 {}", userDate);
|
||||
} else {
|
||||
// 2️⃣ 获取有效“今天”
|
||||
// 2️⃣ 获取有效今天
|
||||
LocalDateTime today = getEffectiveToday();
|
||||
userDate.add(today.toLocalDate());
|
||||
userDate.add(today.toLocalDate());
|
||||
logger.info("有效“今天” {}", today);
|
||||
logger.info("有效今天 {}", today);
|
||||
}
|
||||
// 3️⃣ 构造查询时间范围 - 修正后的代码
|
||||
LocalDateTime startOfDay = userDate.get(0).atStartOfDay();
|
||||
@@ -2655,7 +2655,7 @@ public class JDUtil {
|
||||
.replace(modelNumber, "") // 去除型号
|
||||
.replaceAll("\\s+", " ").trim();
|
||||
|
||||
// 拼接“安装派送联系”字段
|
||||
// 拼接"安装派送联系"字段
|
||||
String deliveryInfo = " 安装派送联系" + phone + "转" + suffix;
|
||||
|
||||
// 最终地址
|
||||
@@ -2724,7 +2724,7 @@ public class JDUtil {
|
||||
extractField(input, fields, "物流链接:", "订单号:");
|
||||
extractField(input, fields, "订单号:", "下单人:");
|
||||
|
||||
// 手动提取“下单人”
|
||||
// 手动提取"下单人"
|
||||
Pattern buyerPattern = Pattern.compile("下单人:\\s*(.*?)\\s*(?=单:|\\Z)", Pattern.DOTALL);
|
||||
Matcher buyerMatcher = buyerPattern.matcher(input);
|
||||
if (buyerMatcher.find()) {
|
||||
@@ -2796,8 +2796,9 @@ public class JDUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 使用能够匹配🔥或◉字符的正则表达式
|
||||
Pattern pattern = Pattern.compile("(\\uD83D\\uDECD|\\u25C9)[\\s\\S]*?([\\d.]+)\\s*\\uD83D\\uDCB0?");
|
||||
// 优化后的正则表达式,更精确地匹配价格格式
|
||||
// 匹配格式:🔥折扣◉价格💰 或 🔥折扣◉价格
|
||||
Pattern pattern = Pattern.compile("(\\uD83D\\uDECD|\\u25C9)[^\\d]*([\\d.]+)\\s*\\uD83D\\uDCB0?");
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
|
||||
if (matcher.find()) {
|
||||
@@ -2812,8 +2813,8 @@ public class JDUtil {
|
||||
}
|
||||
}
|
||||
|
||||
// fallback处理 - 使用相同的模式但不依赖💰符号
|
||||
Pattern fallbackPattern = Pattern.compile("(\\uD83D\\uDECD|\\u25C9)[\\s\\S]*?([\\d.]+)");
|
||||
// fallback处理 - 更宽松的匹配,不依赖💰符号
|
||||
Pattern fallbackPattern = Pattern.compile("(\\uD83D\\uDECD|\\u25C9)[^\\d]*([\\d.]+)");
|
||||
Matcher fallbackMatcher = fallbackPattern.matcher(input);
|
||||
if (fallbackMatcher.find()) {
|
||||
logger.info("parsePrice第二次正则匹配到的价格{}", fallbackMatcher.group(2));
|
||||
@@ -2827,8 +2828,22 @@ public class JDUtil {
|
||||
}
|
||||
}
|
||||
|
||||
// 第三次尝试 - 直接匹配数字价格,不依赖特殊符号
|
||||
Pattern simplePattern = Pattern.compile("([\\d.]+)\\s*\\uD83D\\uDCB0");
|
||||
Matcher simpleMatcher = simplePattern.matcher(input);
|
||||
if (simpleMatcher.find()) {
|
||||
logger.info("parsePrice第三次正则匹配到的价格{}", simpleMatcher.group(1));
|
||||
try {
|
||||
String priceStr = simpleMatcher.group(1).trim();
|
||||
if (priceStr.matches("\\d+\\.?\\d*|\\d*\\.\\d+")) {
|
||||
return Double.parseDouble(priceStr);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user