fix: map Pakistan aliases for MifaPay web payments

This commit is contained in:
z 2026-05-03 00:19:54 +08:00
parent c7a650ce7f
commit 399da096b0
7 changed files with 275 additions and 199 deletions

View File

@ -6,8 +6,10 @@ import com.red.circle.tool.core.text.StringUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
@ -17,6 +19,16 @@ public final class CountryCodeAliasUtils {
private static final String SA = "SA";
private static final String KSA = "KSA";
private static final String PK = "PK";
private static final String PAK = "PAK";
private static final Map<String, Set<String>> COUNTRY_CODE_ALIAS_GROUPS;
static {
Map<String, Set<String>> aliasGroups = new LinkedHashMap<>();
aliasGroups.put(SA, Set.of(SA, KSA));
aliasGroups.put(PK, Set.of(PK, PAK, "P2", "P3"));
COUNTRY_CODE_ALIAS_GROUPS = Collections.unmodifiableMap(aliasGroups);
}
private CountryCodeAliasUtils() {
}
@ -36,6 +48,22 @@ public final class CountryCodeAliasUtils {
return isSaudiCode(normalized) ? SA : normalized;
}
/**
* 支付国家码归一化三方不识别的业务别名会转换为真实国家码.
*/
public static String normalizePaymentCountryCode(String code) {
String normalized = normalize(code);
if (StringUtils.isBlank(normalized)) {
return null;
}
return COUNTRY_CODE_ALIAS_GROUPS.entrySet().stream()
.filter(entry -> entry.getValue().contains(normalized))
.map(Map.Entry::getKey)
.findFirst()
.orElse(normalized);
}
/**
* 是否是沙特国家码.
*/
@ -90,9 +118,9 @@ public final class CountryCodeAliasUtils {
aliasCodes.forEach(code -> appendCode(result, code));
}
if (result.stream().anyMatch(CountryCodeAliasUtils::isSaudiCode)) {
result.add(SA);
result.add(KSA);
LinkedHashSet<String> originalCodes = new LinkedHashSet<>(result);
for (String code : originalCodes) {
result.addAll(aliasGroupCodes(code));
}
return result;
}
@ -116,4 +144,12 @@ public final class CountryCodeAliasUtils {
result.add(normalized);
}
}
private static Set<String> aliasGroupCodes(String code) {
String normalized = normalizePaymentCountryCode(code);
if (StringUtils.isBlank(normalized)) {
return Collections.emptySet();
}
return COUNTRY_CODE_ALIAS_GROUPS.getOrDefault(normalized, Set.of(normalized));
}
}

View File

@ -0,0 +1,123 @@
package com.red.circle.order.app.command.pay.web;
import com.red.circle.common.business.core.util.CountryCodeAliasUtils;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.order.infra.database.rds.entity.pay.PayCountry;
import com.red.circle.order.infra.database.rds.service.pay.PayCountryChannelDetailsService;
import com.red.circle.order.infra.database.rds.service.pay.PayCountryService;
import com.red.circle.other.inner.endpoint.sys.SysCountryCodeClient;
import com.red.circle.other.inner.model.dto.sys.SysCountryCodeDTO;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.text.StringUtils;
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
/**
* 支付国家兼容映射.
*/
@Component
@RequiredArgsConstructor
public class PayCountryAliasResolver {
private final PayCountryService payCountryService;
private final SysCountryCodeClient sysCountryCodeClient;
private final PayCountryChannelDetailsService payCountryChannelDetailsService;
public PayCountry resolveUsablePayCountry(Long payCountryOrCountryId) {
if (Objects.isNull(payCountryOrCountryId)) {
return payCountryService.getShelfSortMax();
}
PayCountry payCountry = payCountryService.getById(payCountryOrCountryId);
if (isUsablePayCountry(payCountry)) {
return payCountry;
}
Long countryId = Objects.nonNull(payCountry) ? payCountry.getCountryId() : payCountryOrCountryId;
PayCountry compatiblePayCountry = resolveUsablePayCountryByCountryId(countryId);
return Objects.nonNull(compatiblePayCountry) ? compatiblePayCountry : payCountry;
}
public PayCountry resolveUsablePayCountryByCountryId(Long countryId) {
PayCountry payCountry = getUsablePayCountryByCountryId(countryId);
if (Objects.nonNull(payCountry)) {
return payCountry;
}
return getMappedUsablePayCountryByCountryId(countryId);
}
private PayCountry getMappedUsablePayCountryByCountryId(Long countryId) {
SysCountryCodeDTO countryCode = getCountryCodeById(countryId);
if (Objects.isNull(countryCode)) {
return null;
}
for (String candidateCode : getMappedCountryCodes(countryCode)) {
SysCountryCodeDTO mappedCountry = ResponseAssert.requiredSuccess(
sysCountryCodeClient.getByCode(candidateCode));
if (Objects.isNull(mappedCountry)
|| Objects.equals(mappedCountry.getId(), countryCode.getId())) {
continue;
}
PayCountry mappedPayCountry = getUsablePayCountryByCountryId(mappedCountry.getId());
if (Objects.nonNull(mappedPayCountry)) {
return mappedPayCountry;
}
}
return null;
}
private Set<String> getMappedCountryCodes(SysCountryCodeDTO countryCode) {
LinkedHashSet<String> result = new LinkedHashSet<>();
// 后续新增同国别名时可在别名国家的 countryCodeAliases 配置真实国家码.
if (CollectionUtils.isNotEmpty(countryCode.getCountryCodeAliases())) {
countryCode.getCountryCodeAliases().stream()
.map(CountryCodeAliasUtils::normalizePaymentCountryCode)
.filter(StringUtils::isNotBlank)
.forEach(result::add);
}
String defaultCode = CountryCodeAliasUtils.normalizePaymentCountryCode(
StringUtils.isNotBlank(countryCode.getAlphaTwo())
? countryCode.getAlphaTwo()
: countryCode.getAlphaThree());
if (StringUtils.isNotBlank(defaultCode)) {
result.add(defaultCode);
}
return result;
}
private SysCountryCodeDTO getCountryCodeById(Long countryId) {
if (Objects.isNull(countryId)) {
return null;
}
return ResponseAssert.requiredSuccess(sysCountryCodeClient.getById(countryId));
}
private PayCountry getUsablePayCountryByCountryId(Long countryId) {
if (Objects.isNull(countryId)) {
return null;
}
return payCountryService.query()
.eq(PayCountry::getShelf, Boolean.TRUE)
.eq(PayCountry::getCountryId, countryId)
.orderByDesc(PayCountry::getSort)
.list()
.stream()
.filter(this::isUsablePayCountry)
.findFirst()
.orElse(null);
}
private boolean isUsablePayCountry(PayCountry payCountry) {
return Objects.nonNull(payCountry)
&& StringUtils.isNotBlank(payCountry.getCurrency())
&& CollectionUtils.isNotEmpty(
payCountryChannelDetailsService.listChannelCode(payCountry.getId()));
}
}

View File

@ -19,23 +19,22 @@ import com.red.circle.order.infra.database.rds.entity.pay.PayApplicationCommodit
import com.red.circle.order.infra.database.rds.entity.pay.PayChannel;
import com.red.circle.order.infra.database.rds.entity.pay.PayCountry;
import com.red.circle.order.infra.database.rds.entity.pay.PayCountryChannelDetails;
import com.red.circle.order.infra.database.rds.service.pay.PayApplicationCommodityService;
import com.red.circle.order.infra.database.rds.service.pay.PayApplicationService;
import com.red.circle.order.infra.database.rds.service.pay.PayChannelService;
import com.red.circle.order.infra.database.rds.service.pay.PayCountryChannelDetailsService;
import com.red.circle.order.infra.database.rds.service.pay.PayCountryService;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.num.ArithmeticUtils;
import com.red.circle.tool.core.text.StringUtils;
import com.red.circle.order.infra.database.rds.service.pay.PayApplicationCommodityService;
import com.red.circle.order.infra.database.rds.service.pay.PayApplicationService;
import com.red.circle.order.infra.database.rds.service.pay.PayChannelService;
import com.red.circle.order.infra.database.rds.service.pay.PayCountryChannelDetailsService;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.num.ArithmeticUtils;
import com.red.circle.tool.core.text.StringUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.springframework.stereotype.Component;
@ -49,12 +48,12 @@ import org.springframework.stereotype.Component;
@RequiredArgsConstructor
public class PayWebApplicationCommodityV2QueryExe {
private final PayAppConvertor payAppConvertor;
private final PayCountryService payCountryService;
private final PayChannelService payChannelService;
private final PayApplicationService payApplicationService;
private final PayApplicationCommodityService payApplicationCommodityService;
private final PayCountryChannelDetailsService payCountryChannelDetailsService;
private final PayAppConvertor payAppConvertor;
private final PayChannelService payChannelService;
private final PayApplicationService payApplicationService;
private final PayCountryAliasResolver payCountryAliasResolver;
private final PayApplicationCommodityService payApplicationCommodityService;
private final PayCountryChannelDetailsService payCountryChannelDetailsService;
public ApplicationCommodityCardV2CO execute(PayWebApplicationCommodityCmd cmd) {
@ -165,44 +164,9 @@ public class PayWebApplicationCommodityV2QueryExe {
.orElseGet(Lists::newArrayList);
}
private PayCountry getPayCountry(PayWebApplicationCommodityCmd cmd) {
if (Objects.isNull(cmd.getPayCountryId())) {
return payCountryService.getShelfSortMax();
}
PayCountry payCountry = payCountryService.getById(cmd.getPayCountryId());
if (Objects.isNull(payCountry)) {
return getUsablePayCountryByCountryId(cmd.getPayCountryId());
}
if (isUsablePayCountry(payCountry)) {
return payCountry;
}
return Optional.ofNullable(getUsablePayCountryByCountryId(payCountry.getCountryId()))
.orElse(payCountry);
}
private PayCountry getUsablePayCountryByCountryId(Long countryId) {
if (Objects.isNull(countryId)) {
return null;
}
return payCountryService.query()
.eq(PayCountry::getShelf, Boolean.TRUE)
.eq(PayCountry::getCountryId, countryId)
.orderByDesc(PayCountry::getSort)
.list()
.stream()
.filter(this::isUsablePayCountry)
.findFirst()
.orElse(null);
}
private boolean isUsablePayCountry(PayCountry payCountry) {
return Objects.nonNull(payCountry)
&& StringUtils.isNotBlank(payCountry.getCurrency())
&& CollectionUtils.isNotEmpty(
payCountryChannelDetailsService.listChannelCode(payCountry.getId()));
}
private PayCountry getPayCountry(PayWebApplicationCommodityCmd cmd) {
return payCountryAliasResolver.resolveUsablePayCountry(cmd.getPayCountryId());
}
private List<PayChannelDetailsCO> getPayChannels(List<PayChannel> payChannels,
List<PayCountryChannelDetails> details) {

View File

@ -23,8 +23,9 @@ import org.springframework.stereotype.Component;
@RequiredArgsConstructor
public class PayWebOpenPayCountryQueryExe {
private final PayCountryService payCountryService;
private final SysCountryCodeClient sysCountryCodeClient;
private final PayCountryService payCountryService;
private final SysCountryCodeClient sysCountryCodeClient;
private final PayCountryAliasResolver payCountryAliasResolver;
public List<PayCountryCO> execute() {
List<PayCountry> payCountries = payCountryService.listAllShelf();
@ -36,12 +37,18 @@ public class PayWebOpenPayCountryQueryExe {
.mapByIdes(
payCountries.stream().map(PayCountry::getCountryId).collect(Collectors.toSet()))
);
return payCountries.stream().map(payCountry -> new PayCountryCO()
.setId(payCountry.getId())
.setPayCountryId(payCountry.getId())
.setCountryId(payCountry.getCountryId())
.setCurrency(payCountry.getCurrency())
.setCountry(countryCodeMap.get(payCountry.getCountryId()))
).collect(Collectors.toList());
}
}
return payCountries.stream().map(payCountry -> {
PayCountry compatiblePayCountry = payCountryAliasResolver
.resolveUsablePayCountryByCountryId(payCountry.getCountryId());
if (compatiblePayCountry == null) {
compatiblePayCountry = payCountry;
}
return new PayCountryCO()
.setId(payCountry.getId())
.setPayCountryId(compatiblePayCountry.getId())
.setCountryId(payCountry.getCountryId())
.setCurrency(compatiblePayCountry.getCurrency())
.setCountry(countryCodeMap.get(payCountry.getCountryId()));
}).collect(Collectors.toList());
}
}

View File

@ -10,35 +10,29 @@ import com.red.circle.order.app.dto.clientobject.pay.PlaceAnOrderResponseCO;
import com.red.circle.order.app.dto.cmd.PayPlaceAnOrderCmd;
import com.red.circle.order.domain.gateway.UserFreightRechargeRecordGateway;
import com.red.circle.order.infra.database.mongo.order.entity.assist.InAppPurchaseProduct;
import com.red.circle.order.infra.database.rds.entity.pay.PayApplication;
import com.red.circle.order.infra.database.rds.entity.pay.PayApplicationCommodity;
import com.red.circle.order.infra.database.rds.entity.pay.PayCountry;
import com.red.circle.order.infra.database.rds.entity.pay.PayCountryChannelDetails;
import com.red.circle.order.infra.database.rds.service.pay.PayApplicationCommodityService;
import com.red.circle.order.infra.database.rds.service.pay.PayApplicationService;
import com.red.circle.order.infra.database.rds.service.pay.PayCountryChannelDetailsService;
import com.red.circle.order.infra.database.rds.service.pay.PayCountryService;
import com.red.circle.order.infra.util.IpUtils;
import com.red.circle.order.inner.asserts.PayErrorCode;
import com.red.circle.order.inner.model.enums.inapp.InAppPurchaseReceiptType;
import com.red.circle.other.inner.endpoint.sys.SysCountryCodeClient;
import com.red.circle.other.inner.model.dto.sys.SysCountryCodeDTO;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.num.ArithmeticUtils;
import com.red.circle.tool.core.sequence.IdWorkerUtils;
import com.red.circle.tool.core.text.StringUtils;
import com.red.circle.other.inner.endpoint.user.region.UserRegionClient;
import com.red.circle.order.app.common.PayerMaxProperties;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import static com.red.circle.tool.core.text.StringPool.SYMBOL_COMMA;
import com.red.circle.order.infra.database.rds.entity.pay.PayApplication;
import com.red.circle.order.infra.database.rds.entity.pay.PayApplicationCommodity;
import com.red.circle.order.infra.database.rds.entity.pay.PayCountry;
import com.red.circle.order.infra.database.rds.entity.pay.PayCountryChannelDetails;
import com.red.circle.order.infra.database.rds.service.pay.PayApplicationCommodityService;
import com.red.circle.order.infra.database.rds.service.pay.PayApplicationService;
import com.red.circle.order.infra.database.rds.service.pay.PayCountryChannelDetailsService;
import com.red.circle.order.infra.util.IpUtils;
import com.red.circle.order.inner.asserts.PayErrorCode;
import com.red.circle.order.inner.model.enums.inapp.InAppPurchaseReceiptType;
import com.red.circle.other.inner.endpoint.sys.SysCountryCodeClient;
import com.red.circle.other.inner.model.dto.sys.SysCountryCodeDTO;
import com.red.circle.tool.core.num.ArithmeticUtils;
import com.red.circle.tool.core.sequence.IdWorkerUtils;
import com.red.circle.tool.core.text.StringUtils;
import com.red.circle.order.app.common.PayerMaxProperties;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* web 下单处理.
@ -50,14 +44,14 @@ import static com.red.circle.tool.core.text.StringPool.SYMBOL_COMMA;
@RequiredArgsConstructor
public class PayWebPlaceAnOrderCmdExe {
private final PayProperties payProperties;
private final PayerMaxProperties payerMaxProperties;
private final PayCountryService payCountryService;
private final SysCountryCodeClient sysCountryCodeClient;
private final PayApplicationService payApplicationService;
private final PayPlaceAnOrderService payPlaceAnOrderService;
private final PayApplicationCommodityService payApplicationCommodityService;
private final PayCountryChannelDetailsService payCountryChannelDetailsService;
private final PayProperties payProperties;
private final PayerMaxProperties payerMaxProperties;
private final SysCountryCodeClient sysCountryCodeClient;
private final PayApplicationService payApplicationService;
private final PayCountryAliasResolver payCountryAliasResolver;
private final PayPlaceAnOrderService payPlaceAnOrderService;
private final PayApplicationCommodityService payApplicationCommodityService;
private final PayCountryChannelDetailsService payCountryChannelDetailsService;
private final UserFreightRechargeRecordGateway userFreightRechargeRecordGateway;
public PlaceAnOrderResponseCO execute(PayPlaceAnOrderCmd cmd) {
@ -71,7 +65,7 @@ public class PayWebPlaceAnOrderCmdExe {
ResponseAssert.notNull(PayErrorCode.UNKNOWN_APPLICATION, application);
PayApplicationCommodity commodity = getAppCommodity(cmd);
PayCountry payCountry = getPayCountry(cmd.getPayCountryId());
PayCountry payCountry = payCountryAliasResolver.resolveUsablePayCountry(cmd.getPayCountryId());
// 不支持地区
ResponseAssert.notNull(PayErrorCode.REGION_NOT_SUPPORTED, payCountry);
cmd.setPayCountryId(payCountry.getId());
@ -134,41 +128,6 @@ public class PayWebPlaceAnOrderCmdExe {
return details;
}
private PayCountry getPayCountry(Long payCountryId) {
PayCountry payCountry = payCountryService.getById(payCountryId);
if (Objects.isNull(payCountry)) {
return getUsablePayCountryByCountryId(payCountryId);
}
if (isUsablePayCountry(payCountry)) {
return payCountry;
}
PayCountry compatiblePayCountry = getUsablePayCountryByCountryId(payCountry.getCountryId());
return Objects.nonNull(compatiblePayCountry) ? compatiblePayCountry : payCountry;
}
private PayCountry getUsablePayCountryByCountryId(Long countryId) {
if (Objects.isNull(countryId)) {
return null;
}
return payCountryService.query()
.eq(PayCountry::getShelf, Boolean.TRUE)
.eq(PayCountry::getCountryId, countryId)
.orderByDesc(PayCountry::getSort)
.list()
.stream()
.filter(this::isUsablePayCountry)
.findFirst()
.orElse(null);
}
private boolean isUsablePayCountry(PayCountry payCountry) {
return Objects.nonNull(payCountry)
&& StringUtils.isNotBlank(payCountry.getCurrency())
&& CollectionUtils.isNotEmpty(
payCountryChannelDetailsService.listChannelCode(payCountry.getId()));
}
/**
* 获取实时汇率失败时返回配置的汇率
* @param payCountry 支付国家配置

View File

@ -6,14 +6,13 @@ import com.red.circle.framework.core.response.CommonErrorCode;
import com.red.circle.order.app.dto.clientobject.pay.PayCountryCO;
import com.red.circle.order.app.dto.clientobject.pay.UserProfileAndCountryCO;
import com.red.circle.order.app.dto.clientobject.pay.WebSiteUseProfileCO;
import com.red.circle.order.app.dto.cmd.PayWebUserCmd;
import com.red.circle.order.infra.database.rds.entity.pay.PayCountry;
import com.red.circle.order.infra.database.rds.service.pay.PayCountryChannelDetailsService;
import com.red.circle.order.infra.database.rds.service.pay.PayCountryService;
import com.red.circle.order.inner.model.enums.PayApplicationCommodityType;
import com.red.circle.other.inner.endpoint.sys.SysCountryCodeClient;
import com.red.circle.other.inner.model.dto.sys.SysCountryCodeDTO;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.order.app.dto.cmd.PayWebUserCmd;
import com.red.circle.order.infra.database.rds.entity.pay.PayCountry;
import com.red.circle.order.infra.database.rds.service.pay.PayCountryService;
import com.red.circle.order.inner.model.enums.PayApplicationCommodityType;
import com.red.circle.other.inner.endpoint.sys.SysCountryCodeClient;
import com.red.circle.other.inner.model.dto.sys.SysCountryCodeDTO;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.parse.DataTypeUtils;
import com.red.circle.tool.core.regex.RegexConstant;
import com.red.circle.tool.core.text.StringUtils;
@ -24,11 +23,12 @@ import com.red.circle.other.inner.enums.user.RegionRelationGroupEnum;
import com.red.circle.other.inner.endpoint.user.region.RegionRelationClient;
import com.red.circle.other.inner.endpoint.user.region.UserRegionClient;
import com.red.circle.other.inner.endpoint.user.user.UserProfileClient;
import com.red.circle.wallet.inner.endpoint.freight.FreightGoldClient;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import com.red.circle.wallet.inner.endpoint.freight.FreightGoldClient;
import java.util.AbstractMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@ -41,13 +41,13 @@ import org.springframework.stereotype.Component;
@RequiredArgsConstructor
public class UserProfileAndCountryQueryExe {
private final UserRegionClient userRegionClient;
private final FreightGoldClient freightGoldClient;
private final PayCountryService payCountryService;
private final PayCountryChannelDetailsService payCountryChannelDetailsService;
private final UserProfileClient userProfileClient;
private final SysCountryCodeClient sysCountryCodeClient;
private final RegionRelationClient regionRelationClient;
private final UserRegionClient userRegionClient;
private final FreightGoldClient freightGoldClient;
private final PayCountryService payCountryService;
private final PayCountryAliasResolver payCountryAliasResolver;
private final UserProfileClient userProfileClient;
private final SysCountryCodeClient sysCountryCodeClient;
private final RegionRelationClient regionRelationClient;
public UserProfileAndCountryCO execute(PayWebUserCmd cmd) {
@ -133,28 +133,18 @@ public class UserProfileAndCountryQueryExe {
);
}
private Map<Long, PayCountry> getCompatiblePayCountryMap(List<PayCountry> payCountryList) {
if (CollectionUtils.isEmpty(payCountryList)) {
return java.util.Collections.emptyMap();
}
List<PayCountry> candidates = payCountryService.query()
.eq(PayCountry::getShelf, Boolean.TRUE)
.in(PayCountry::getCountryId, payCountryList.stream().map(PayCountry::getCountryId)
.collect(Collectors.toSet()))
.orderByDesc(PayCountry::getSort)
.list();
if (CollectionUtils.isEmpty(candidates)) {
return java.util.Collections.emptyMap();
}
return candidates.stream()
.filter(country -> StringUtils.isNotBlank(country.getCurrency()))
.filter(country -> CollectionUtils.isNotEmpty(
payCountryChannelDetailsService.listChannelCode(country.getId())))
.collect(Collectors.toMap(PayCountry::getCountryId, country -> country,
(left, right) -> left));
}
private Map<Long, PayCountry> getCompatiblePayCountryMap(List<PayCountry> payCountryList) {
if (CollectionUtils.isEmpty(payCountryList)) {
return java.util.Collections.emptyMap();
}
return payCountryList.stream()
.map(country -> new AbstractMap.SimpleEntry<>(country.getCountryId(),
payCountryAliasResolver.resolveUsablePayCountryByCountryId(country.getCountryId())))
.filter(entry -> Objects.nonNull(entry.getValue()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
(left, right) -> left));
}
private List<RegionRelationDTO> getRegionRelationList(UserProfileDTO userProfile,
String regionId) {

View File

@ -11,19 +11,16 @@ import com.red.circle.order.app.service.MiFaPayService;
import com.red.circle.order.domain.payer.PlaceAnOrderPaymentDetail;
import com.red.circle.order.infra.util.MemberInfoGenerator;
import com.red.circle.order.inner.asserts.OrderErrorCode;
import com.red.circle.tool.core.json.JacksonUtils;
import com.red.circle.tool.core.text.StringUtils;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import com.red.circle.tool.core.json.JacksonUtils;
import com.red.circle.tool.core.text.StringUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import static com.red.circle.tool.core.text.StringPool.SYMBOL_COMMA;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* MiFaPay web 支付策略
@ -126,9 +123,9 @@ public class MiFaPayWebPayPlaceAnOrderStrategy implements PayWebPlaceAnOrderStra
return underscoreIndex > 0 ? channelCode.substring(0, underscoreIndex) : channelCode;
}
private static String replaceCountryCode(String countryCode) {
return CountryCodeAliasUtils.normalizeSaudiCode(countryCode);
}
private static String replaceCountryCode(String countryCode) {
return CountryCodeAliasUtils.normalizePaymentCountryCode(countryCode);
}
private String getPlaceAnOrderPaymentDetailParam(PayPlaceAnOrderDetailsV2 details) {