fix: 阻断规格重量数字误当货号 (#273)
This commit is contained in:
@@ -436,12 +436,12 @@ func innerCodeStallMatches(stall string, item syb.DetailItem) bool {
|
||||
}
|
||||
return innerCodeTextHasNumericArticle(sku, article) ||
|
||||
innerCodeTextHasNumericArticle(variation, article) ||
|
||||
innerCodeTextHasNumericArticle(item.ProductSpec, article)
|
||||
innerCodeProductSpecStartsWithArticle(item.ProductSpec, article, true)
|
||||
}
|
||||
|
||||
return innerCodeTextHasExactArticle(sku, article) ||
|
||||
innerCodeTextHasExactArticle(variation, article) ||
|
||||
innerCodeTextHasExactArticle(item.ProductSpec, article)
|
||||
innerCodeProductSpecStartsWithArticle(item.ProductSpec, article, false)
|
||||
}
|
||||
|
||||
// splitInnerCodeStall 从“档口名称#货号”取最后一个 #,避免档口名称本身含 # 时截错。
|
||||
@@ -493,6 +493,20 @@ func innerCodeTextHasExactArticle(text, article string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func innerCodeProductSpecStartsWithArticle(productSpec, article string, numeric bool) bool {
|
||||
productSpec = strings.TrimSpace(productSpec)
|
||||
separator := strings.IndexAny(productSpec, " ,,")
|
||||
if separator <= 0 {
|
||||
return false
|
||||
}
|
||||
prefix := strings.TrimSpace(productSpec[:separator])
|
||||
if numeric {
|
||||
return isInnerCodeNumericArticle(prefix) &&
|
||||
normalizeInnerCodeNumericArticle(prefix) == normalizeInnerCodeNumericArticle(article)
|
||||
}
|
||||
return prefix == article
|
||||
}
|
||||
|
||||
// innerCodeArticleTokens 只把连续字母或数字视为货号候选。
|
||||
// `【】`、`#`、横线、空格等标点自然成为边界,因此能识别 `067【档口】`,
|
||||
// 又不会把 `PDD256437` 中间的数字误认为独立货号。
|
||||
|
||||
Reference in New Issue
Block a user