修复汇率同步非法国家码

This commit is contained in:
hy001 2026-06-25 17:10:34 +08:00
parent c39dac772a
commit 9957dc2a27

View File

@ -358,9 +358,13 @@ public class PayCountryClientServiceImpl implements PayCountryClientService {
if (Objects.isNull(country) || StringUtils.isBlank(country.getAlphaTwo())) {
return "";
}
String region = country.getAlphaTwo().trim().toUpperCase(Locale.ROOT);
if (region.length() != 2 || !region.chars().allMatch(ch -> ch >= 'A' && ch <= 'Z')) {
return "";
}
try {
Locale locale = new Locale.Builder()
.setRegion(country.getAlphaTwo().trim().toUpperCase(Locale.ROOT))
.setRegion(region)
.build();
return Currency.getInstance(locale).getCurrencyCode();
} catch (IllegalArgumentException | MissingResourceException e) {