From f3be903a9ff1f3816cd432a07bf332b869d6026b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=92?= Date: Thu, 30 Oct 2025 20:59:48 +0800 Subject: [PATCH] 1 --- .../ruoyi/jarvis/util/LineReportParser.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ruoyi-system/src/main/java/com/ruoyi/jarvis/util/LineReportParser.java b/ruoyi-system/src/main/java/com/ruoyi/jarvis/util/LineReportParser.java index e0a0aef..ab40afe 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/jarvis/util/LineReportParser.java +++ b/ruoyi-system/src/main/java/com/ruoyi/jarvis/util/LineReportParser.java @@ -144,6 +144,33 @@ public class LineReportParser { result.put(url, price); } } + if (!result.containsKey(url)) { + // 前向查找:向下最多2行寻找价格 + Double fprice = null; + for (int k = 1; k <= 2 && i + k < lines.length; k++) { + String next = lines[i + k]; + if (next == null || next.isEmpty()) break; // 空行视为分段 + // 优先匹配包含💰或¥的价格 + Matcher richN = Pattern.compile("[¥💰]\\s*([0-9]{1,6}(?:\\.[0-9]{1,2})?)").matcher(next); + if (richN.find()) { + fprice = parsePrice(richN.group(1)); + break; + } + // 其次匹配“不高于 xxxx” + Matcher nhN = NOT_HIGHER_PATTERN.matcher(next); + if (nhN.find()) { + fprice = parsePrice(nhN.group(1)); + break; + } + Matcher anyN = PRICE_NEAR_PATTERN.matcher(next); + if (anyN.find()) { + fprice = parsePrice(anyN.group(1)); + } + } + if (fprice != null) { + result.put(url, fprice); + } + } } return result;