google商店新增国家过滤
This commit is contained in:
parent
be52af65af
commit
e95318c471
@ -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.gateway.InAppPurchaseProductGateway;
|
||||||
import com.red.circle.order.domain.product.IAppPurchaseProduct;
|
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.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.collection.CollectionUtils;
|
||||||
import com.red.circle.tool.core.num.ArithmeticUtils;
|
import com.red.circle.tool.core.num.ArithmeticUtils;
|
||||||
import com.red.circle.other.inner.model.dto.user.WealthAndCharmExpLevelDTO;
|
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 com.red.circle.other.inner.endpoint.user.user.UserLevelClient;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平台产品信息获取(金币)
|
* 平台产品信息获取(金币)
|
||||||
@ -39,6 +43,7 @@ public class ProductConfigGoldQryExe {
|
|||||||
private final AgentTeamClient agentTeamClient;
|
private final AgentTeamClient agentTeamClient;
|
||||||
private final PurchaseAppConvertor purchaseAppConvertor;
|
private final PurchaseAppConvertor purchaseAppConvertor;
|
||||||
private final InAppPurchaseProductGateway iAppPurchaseProductRepository;
|
private final InAppPurchaseProductGateway iAppPurchaseProductRepository;
|
||||||
|
private final UserProfileClient userProfileClient;
|
||||||
|
|
||||||
public List<ProductConfigItemCO> execute(AppExtCommand cmd) {
|
public List<ProductConfigItemCO> execute(AppExtCommand cmd) {
|
||||||
List<ProductConfigItemCO> items = getProductConfigItemCOS(cmd);
|
List<ProductConfigItemCO> items = getProductConfigItemCOS(cmd);
|
||||||
@ -106,6 +111,7 @@ public class ProductConfigGoldQryExe {
|
|||||||
|
|
||||||
String regionId = ResponseAssert.requiredSuccess(
|
String regionId = ResponseAssert.requiredSuccess(
|
||||||
userRegionClient.getRegionId(cmd.requiredReqUserId()));
|
userRegionClient.getRegionId(cmd.requiredReqUserId()));
|
||||||
|
UserProfileDTO userProfileDTO = ResponseAssert.requiredSuccess(userProfileClient.getByUserId(cmd.requiredReqUserId()));
|
||||||
|
|
||||||
ResponseAssert.notBlank(CommonErrorCode.REGION_NOT_SUPPORTED_ERROR, regionId);
|
ResponseAssert.notBlank(CommonErrorCode.REGION_NOT_SUPPORTED_ERROR, regionId);
|
||||||
|
|
||||||
@ -117,7 +123,20 @@ public class ProductConfigGoldQryExe {
|
|||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return iAppPurchaseProducts.stream().map(purchaseAppConvertor::toProductConfigItemV2CO)
|
String countryCode = userProfileDTO != null ? userProfileDTO.getCountryCode() : null;
|
||||||
|
if (StringUtils.hasText(countryCode)) {
|
||||||
|
List<IAppPurchaseProduct> 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());
|
.filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,6 +70,11 @@ public class IAppPurchaseProduct implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String tags;
|
private String tags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国家codes,逗号分隔,为空则不限制.
|
||||||
|
*/
|
||||||
|
private String countryCodes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 包名.
|
* 包名.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -87,6 +87,12 @@ public class ProductConfigV2 extends TimestampBaseEntity {
|
|||||||
@TableField("is_showcase")
|
@TableField("is_showcase")
|
||||||
private Boolean showcase;
|
private Boolean showcase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国家codes,逗号分隔,为空则不限制.
|
||||||
|
*/
|
||||||
|
@TableField("country_codes")
|
||||||
|
private String countryCodes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示序号.
|
* 显示序号.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user