修复汇率同步非法国家码
This commit is contained in:
parent
c39dac772a
commit
9957dc2a27
@ -358,9 +358,13 @@ public class PayCountryClientServiceImpl implements PayCountryClientService {
|
|||||||
if (Objects.isNull(country) || StringUtils.isBlank(country.getAlphaTwo())) {
|
if (Objects.isNull(country) || StringUtils.isBlank(country.getAlphaTwo())) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
String region = country.getAlphaTwo().trim().toUpperCase(Locale.ROOT);
|
||||||
|
if (region.length() != 2 || !region.chars().allMatch(ch -> ch >= 'A' && ch <= 'Z')) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Locale locale = new Locale.Builder()
|
Locale locale = new Locale.Builder()
|
||||||
.setRegion(country.getAlphaTwo().trim().toUpperCase(Locale.ROOT))
|
.setRegion(region)
|
||||||
.build();
|
.build();
|
||||||
return Currency.getInstance(locale).getCurrencyCode();
|
return Currency.getInstance(locale).getCurrencyCode();
|
||||||
} catch (IllegalArgumentException | MissingResourceException e) {
|
} catch (IllegalArgumentException | MissingResourceException e) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user