diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/sys/SysBannerConfigQryCmd.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/sys/SysBannerConfigQryCmd.java index f13f7c44..df60af31 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/sys/SysBannerConfigQryCmd.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/sys/SysBannerConfigQryCmd.java @@ -25,6 +25,10 @@ public class SysBannerConfigQryCmd extends PageCommand { */ private String sysOrigin; + private String platform; + + private String countryCode; + /** * 区域. */ diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/sys/SysBannerConfigDTO.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/sys/SysBannerConfigDTO.java index 61321b4f..e38c47a4 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/sys/SysBannerConfigDTO.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/sys/SysBannerConfigDTO.java @@ -37,6 +37,10 @@ public class SysBannerConfigDTO extends DTO { */ private String sysOrigin; + private String platform; + + private String countryCode; + /** * 封面. */ diff --git a/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/sys/SysBannerConfigCO.java b/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/sys/SysBannerConfigCO.java index d1ddac01..82549ace 100644 --- a/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/sys/SysBannerConfigCO.java +++ b/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/sys/SysBannerConfigCO.java @@ -45,6 +45,12 @@ public class SysBannerConfigCO implements Serializable { */ private String sysOrigin; + private String platform; + + private String countryId; + + private String countryCode; + /** * 小封面图. */ diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/sys/query/BannerQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/sys/query/BannerQryExe.java index 1a986705..419412e8 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/sys/query/BannerQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/sys/query/BannerQryExe.java @@ -7,7 +7,9 @@ import com.red.circle.framework.core.response.CommonErrorCode; import com.red.circle.order.inner.endpoint.OrderPurchaseHistoryClient; import com.red.circle.other.app.convertor.sys.SysConfigAppConvertor; import com.red.circle.other.app.dto.clientobject.sys.BannerCO; +import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; +import com.red.circle.other.domain.model.user.UserProfile; import com.red.circle.other.infra.database.cache.entity.sys.BannerCache; import com.red.circle.other.infra.database.cache.service.other.BannerCacheService; import com.red.circle.other.infra.database.rds.entity.sys.BannerConfig; @@ -34,27 +36,32 @@ public class BannerQryExe { private final BannerConfigService bannerConfigService; private final SysConfigAppConvertor sysConfigAppConvertor; private final OrderPurchaseHistoryClient orderPurchaseHistoryClient; + private final UserProfileGateway userProfileGateway; public List execute(AppExtCommand cmd) { - - String regionId = userRegionGateway.getRegionId(cmd.requiredReqUserId()); + UserProfile userProfile = userProfileGateway.getByUserId(cmd.requiredReqUserId()); + String regionId = userRegionGateway.getRegionId(cmd.requiredReqUserId()); ResponseAssert.notBlank(CommonErrorCode.REGION_NOT_SUPPORTED_ERROR, regionId); - List list = bannerCacheService.listBannerCacheBySysOrigin(cmd.requireReqSysOrigin(), () -> { - List configs = listEffectiveCache(cmd.requireReqSysOrigin(), cmd.getReqClient().getClientName()); + String reqClient = cmd.getReqClient().getClientName(); + String sysOrigin = cmd.requireReqSysOrigin(); + String countryCode = userProfile.getCountryCode(); + + List list = bannerCacheService.listBannerCacheBySysOrigin(sysOrigin, reqClient, countryCode, () -> { + List configs = listEffectiveCache(sysOrigin, reqClient, countryCode); if (CollectionUtils.isEmpty(configs)) { return Lists.newArrayList(); } return sysConfigAppConvertor.toListBannerCache(configs); - }).stream().filter( - bannerCache -> StringUtils.isBlank(bannerCache.getRegions()) || bannerCache.getRegions() - .contains(regionId)) + }).stream() + .filter(bannerCache -> StringUtils.isBlank(bannerCache.getRegions()) || bannerCache.getRegions().contains(regionId)) + .filter(bannerCache -> StringUtils.isBlank(bannerCache.getCountryCode()) || bannerCache.getCountryCode().contains(countryCode)) .toList(); return sysConfigAppConvertor.toListBannerCO(list); } - private List listEffectiveCache(String sysOrigin, String platform) { - return bannerConfigService.listEffective(sysOrigin, platform); + private List listEffectiveCache(String sysOrigin, String platform, String countryCode) { + return bannerConfigService.listEffective(sysOrigin, platform, countryCode); } } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/entity/sys/BannerCache.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/entity/sys/BannerCache.java index a9220a60..e3bacae9 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/entity/sys/BannerCache.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/entity/sys/BannerCache.java @@ -33,6 +33,10 @@ public class BannerCache implements Serializable { */ private String sysOrigin; + private String platform; + + private String countryCode; + /** * 封面. */ diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/BannerCacheService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/BannerCacheService.java index 4447da6a..4c9011dc 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/BannerCacheService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/BannerCacheService.java @@ -18,7 +18,8 @@ public interface BannerCacheService { * @param orElsePut 否则put * @return banner */ - List listBannerCacheBySysOrigin(String sysOrigin, VoidCallable> orElsePut); + List listBannerCacheBySysOrigin(String sysOrigin, String reqClient, String countryCode, + VoidCallable> orElsePut); /** * 移除banner. diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/BannerCacheServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/BannerCacheServiceImpl.java index be5f3261..676ed428 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/BannerCacheServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/BannerCacheServiceImpl.java @@ -27,15 +27,15 @@ public class BannerCacheServiceImpl implements BannerCacheService { private final RedisService redisService; - private String getBannerKey(String sysOrigin) { - return sysOrigin + "_" + BannerKeys.BANNER.name(); + private String getBannerKey(String sysOrigin, String reqClient, String countryCode) { + return String.join("_", BannerKeys.BANNER.name(), sysOrigin, reqClient, countryCode); } @Override - public List listBannerCacheBySysOrigin(String sysOrigin, VoidCallable> orElsePut) { + public List listBannerCacheBySysOrigin(String sysOrigin, String reqClient, String countryCode, VoidCallable> orElsePut) { return Optional - .ofNullable(redisService.hashGet(BannerKeys.BANNER.getKey(), getBannerKey(sysOrigin + "22"), + .ofNullable(redisService.hashGet(BannerKeys.BANNER.getKey(), getBannerKey(sysOrigin, reqClient, countryCode), new TypeReference>() { })) .map(bannerCaches -> bannerCaches.stream() @@ -49,7 +49,7 @@ public class BannerCacheServiceImpl implements BannerCacheService { .orElseGet(() -> { List bannerCaches = orElsePut.apply(); if (CollectionUtils.isNotEmpty(bannerCaches)) { - redisService.hashPut(BannerKeys.BANNER.getKey(), getBannerKey(sysOrigin), + redisService.hashPut(BannerKeys.BANNER.getKey(), getBannerKey(sysOrigin, reqClient, countryCode), bannerCaches); } return bannerCaches; diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/sys/BannerConfig.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/sys/BannerConfig.java index 24561980..9265e2cc 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/sys/BannerConfig.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/sys/BannerConfig.java @@ -45,6 +45,12 @@ public class BannerConfig extends TimestampBaseEntity { @TableField("platform") private String platform; + /** + * 国家编码 + */ + @TableField("country_code") + private String countryCode; + /** * 封面. */ diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/BannerConfigService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/BannerConfigService.java index 8b50f962..5d26d5be 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/BannerConfigService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/BannerConfigService.java @@ -22,7 +22,7 @@ public interface BannerConfigService extends BaseService { * @param sysOrigin 来源系统 * @return ignore */ - List listEffective(String sysOrigin, String platform); + List listEffective(String sysOrigin, String platform, String countryCode); PageResult pageBanner(SysBannerConfigQryCmd query); diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/BannerConfigServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/BannerConfigServiceImpl.java index 035ccae7..d372f148 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/BannerConfigServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/BannerConfigServiceImpl.java @@ -28,10 +28,15 @@ public class BannerConfigServiceImpl extends BaseServiceImpl implements BannerConfigService { @Override - public List listEffective(String sysOrigin, String platform) { + public List listEffective(String sysOrigin, String platform, String countryCode) { return query() .eq(BannerConfig::getSysOrigin, sysOrigin) - .in(BannerConfig::getPlatform, Arrays.asList(platform, "")) + .and(StringUtils.isNotBlank(platform), wrapper -> + wrapper.in(BannerConfig::getPlatform, "", platform) + ) + .and(StringUtils.isNotBlank(countryCode), wrapper -> + wrapper.in(BannerConfig::getCountryCode, "", countryCode) + ) .gt(BannerConfig::getExpiredTime, LocalDateTime.now()) .eq(BannerConfig::getShowcase, Boolean.TRUE) .orderByDesc(BannerConfig::getSort) @@ -42,6 +47,12 @@ public class BannerConfigServiceImpl extends public PageResult pageBanner(SysBannerConfigQryCmd query) { return query() .eq(StringUtils.isNotBlank(query.getSysOrigin()), BannerConfig::getSysOrigin, query.getSysOrigin()) + .and(StringUtils.isNotBlank(query.getPlatform()), wrapper -> + wrapper.in(BannerConfig::getPlatform, "", query.getPlatform()) + ) + .and(StringUtils.isNotBlank(query.getCountryCode()), wrapper -> + wrapper.in(BannerConfig::getCountryCode, "", query.getCountryCode()) + ) .eq(Objects.equals(query.getShowcase(), 1), BannerConfig::getShowcase, Boolean.TRUE) .gt(Objects.equals(query.getShowcase(), 1), BannerConfig::getExpiredTime, TimestampUtils.now()) .eq(Objects.equals(query.getShowcase(), 2), BannerConfig::getShowcase, Boolean.FALSE) diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/sys/impl/SysBannerConfigClientServiceImpl.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/sys/impl/SysBannerConfigClientServiceImpl.java index f2f7704f..97a92f33 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/sys/impl/SysBannerConfigClientServiceImpl.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/sys/impl/SysBannerConfigClientServiceImpl.java @@ -55,7 +55,7 @@ public class SysBannerConfigClientServiceImpl implements SysBannerConfigClientSe public void updateBanner(SysBannerConfigDTO bannerConfigDTO) { BannerConfig bannerConfig = getSysBannerConfig(bannerConfigDTO); ResponseAssert.isTrue(CommonErrorCode.UPDATE_FAILURE, - bannerConfigService.updateInfo(bannerConfig)); + bannerConfigService.updateSelectiveById(bannerConfig)); bannerCacheService.remove(bannerConfigDTO.getSysOrigin()); }