新增邮编相关字段及优化附加费计算逻辑

This commit is contained in:
wuweihua
2026-11-18 15:39:52 +08:00
parent b4569e5c15
commit b3ef85b0bb
9 changed files with 381 additions and 50 deletions
@@ -170,7 +170,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/**
* 规范化目的地邮编,用于分区匹配/持久化。
* 移除所有 Unicode 空白字符(包括 NBSP / U+2005)和 ASCII 空格;
* 仅去掉两端 Unicode 空白(含 NBSP / U+2005),保留中间空格;
* 去除纯数字末尾 Excel 风格的 ".0"。
*/
public static String normalizePostcode(String postcode)
@@ -179,17 +179,27 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
{
return postcode;
}
StringBuilder sb = new StringBuilder(postcode.length());
for (int i = 0; i < postcode.length(); )
int startIdx = 0;
int endIdx = postcode.length();
while (startIdx < endIdx)
{
int cp = postcode.codePointAt(i);
int cp = postcode.codePointAt(startIdx);
if (!Character.isWhitespace(cp))
{
sb.appendCodePoint(cp);
break;
}
i += Character.charCount(cp);
startIdx += Character.charCount(cp);
}
String n = sb.toString();
while (endIdx > startIdx)
{
int cp = postcode.codePointBefore(endIdx);
if (!Character.isWhitespace(cp))
{
break;
}
endIdx -= Character.charCount(cp);
}
String n = postcode.substring(startIdx, endIdx);
if (n.endsWith(".0") && n.matches("\\d+\\.0"))
{
return n.substring(0, n.length() - 2);