diff --git a/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/command/product/ProductConfigGoldQryExe.java b/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/command/product/ProductConfigGoldQryExe.java index 01173fae..a206ac49 100644 --- a/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/command/product/ProductConfigGoldQryExe.java +++ b/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/command/product/ProductConfigGoldQryExe.java @@ -11,6 +11,8 @@ import com.red.circle.order.app.dto.clientobject.ProductConfigItemCO; import com.red.circle.order.domain.gateway.InAppPurchaseProductGateway; import com.red.circle.order.domain.product.IAppPurchaseProduct; import com.red.circle.other.inner.endpoint.team.agency.AgentTeamClient; +import com.red.circle.other.inner.endpoint.user.user.UserProfileClient; +import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.num.ArithmeticUtils; import com.red.circle.other.inner.model.dto.user.WealthAndCharmExpLevelDTO; @@ -18,12 +20,14 @@ import com.red.circle.other.inner.endpoint.user.region.UserRegionClient; import com.red.circle.other.inner.endpoint.user.user.UserLevelClient; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.Arrays; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; /** * 平台产品信息获取(金币) @@ -39,6 +43,7 @@ public class ProductConfigGoldQryExe { private final AgentTeamClient agentTeamClient; private final PurchaseAppConvertor purchaseAppConvertor; private final InAppPurchaseProductGateway iAppPurchaseProductRepository; + private final UserProfileClient userProfileClient; public List execute(AppExtCommand cmd) { List items = getProductConfigItemCOS(cmd); @@ -106,6 +111,7 @@ public class ProductConfigGoldQryExe { String regionId = ResponseAssert.requiredSuccess( userRegionClient.getRegionId(cmd.requiredReqUserId())); + UserProfileDTO userProfileDTO = ResponseAssert.requiredSuccess(userProfileClient.getByUserId(cmd.requiredReqUserId())); ResponseAssert.notBlank(CommonErrorCode.REGION_NOT_SUPPORTED_ERROR, regionId); @@ -117,7 +123,20 @@ public class ProductConfigGoldQryExe { return Lists.newArrayList(); } - return iAppPurchaseProducts.stream().map(purchaseAppConvertor::toProductConfigItemV2CO) + String countryCode = userProfileDTO != null ? userProfileDTO.getCountryCode() : null; + if (StringUtils.hasText(countryCode)) { + List countryMatched = iAppPurchaseProducts.stream() + .filter(p -> StringUtils.hasText(p.getCountryCodes()) + && Arrays.asList(p.getCountryCodes().split(",")).contains(countryCode.trim())) + .collect(Collectors.toList()); + iAppPurchaseProducts = countryMatched.isEmpty() + ? iAppPurchaseProducts.stream() + .filter(p -> !StringUtils.hasText(p.getCountryCodes())) + .collect(Collectors.toList()) + : countryMatched; + } + return iAppPurchaseProducts.stream() + .map(purchaseAppConvertor::toProductConfigItemV2CO) .filter(Objects::nonNull).collect(Collectors.toList()); } diff --git a/rc-service/rc-service-order/order-domain/src/main/java/com/red/circle/order/domain/product/IAppPurchaseProduct.java b/rc-service/rc-service-order/order-domain/src/main/java/com/red/circle/order/domain/product/IAppPurchaseProduct.java index 15f8f621..35588c22 100644 --- a/rc-service/rc-service-order/order-domain/src/main/java/com/red/circle/order/domain/product/IAppPurchaseProduct.java +++ b/rc-service/rc-service-order/order-domain/src/main/java/com/red/circle/order/domain/product/IAppPurchaseProduct.java @@ -70,6 +70,11 @@ public class IAppPurchaseProduct implements Serializable { */ private String tags; + /** + * 国家codes,逗号分隔,为空则不限制. + */ + private String countryCodes; + /** * 包名. */ diff --git a/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/entity/product/ProductConfigV2.java b/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/entity/product/ProductConfigV2.java index 4aecbe49..ed7232c8 100644 --- a/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/entity/product/ProductConfigV2.java +++ b/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/entity/product/ProductConfigV2.java @@ -87,6 +87,12 @@ public class ProductConfigV2 extends TimestampBaseEntity { @TableField("is_showcase") private Boolean showcase; + /** + * 国家codes,逗号分隔,为空则不限制. + */ + @TableField("country_codes") + private String countryCodes; + /** * 显示序号. */