活动礼物列表 分区处理
This commit is contained in:
parent
ed73193d46
commit
065611a20f
@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.other.app.dto.clientobject.gift.ActivityGiftCO;
|
||||
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.service.other.BannerCacheService;
|
||||
import com.red.circle.other.infra.database.mongo.entity.sys.ActivityConfig;
|
||||
import com.red.circle.other.infra.database.mongo.service.sys.ActivityConfigService;
|
||||
@ -15,6 +18,8 @@ import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.red.circle.tool.core.text.StringUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -32,6 +37,8 @@ public class ActivityGiftListQryExe {
|
||||
private final ActivityConfigService activityConfigService;
|
||||
private final GiftConfigService giftConfigService;
|
||||
private final BannerConfigService bannerConfigService;
|
||||
private final UserProfileGateway userProfileGateway;
|
||||
private final UserRegionGateway userRegionGateway;
|
||||
|
||||
public List<ActivityGiftCO> execute(AppExtCommand cmd) {
|
||||
// 获取进行中的活动
|
||||
@ -61,6 +68,10 @@ public class ActivityGiftListQryExe {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
String regionId = userRegionGateway.getRegionId(cmd.requiredReqUserId());
|
||||
UserProfile userProfile = userProfileGateway.getByUserId(cmd.requiredReqUserId());
|
||||
String countryCode = userProfile.getCountryCode();
|
||||
|
||||
// 收集所有需要查询的 bannerId(去重)
|
||||
List<Long> bannerIds = giftIdToBannerIdMap.values().stream()
|
||||
.filter(Objects::nonNull).map(ActivityConfig::getBannerId).distinct().collect(Collectors.toList());
|
||||
@ -70,12 +81,15 @@ public class ActivityGiftListQryExe {
|
||||
LambdaQueryWrapper<BannerConfig> query = Wrappers.<BannerConfig>lambdaQuery()
|
||||
.in(BannerConfig::getId, bannerIds);
|
||||
bannerUrlMap = bannerConfigService.list(query).stream()
|
||||
.filter(bannerCache -> StringUtils.isBlank(bannerCache.getRegions()) || bannerCache.getRegions().contains(regionId))
|
||||
.filter(bannerCache -> StringUtils.isBlank(bannerCache.getCountryCode()) || bannerCache.getCountryCode().contains(countryCode))
|
||||
.collect(Collectors.toMap(BannerConfig::getId, e -> e, (u1, u2) -> u1));
|
||||
} else {
|
||||
bannerUrlMap = new HashMap<>();
|
||||
}
|
||||
// 查询礼物配置
|
||||
List<GiftConfig> giftConfigs = giftConfigService.listByIds(giftIds);
|
||||
giftConfigs = giftConfigs.stream().filter(gift -> StringUtils.isBlank(gift.getRegions()) || gift.getRegions().contains(regionId != null ? regionId : "null")).toList();
|
||||
if (CollectionUtils.isEmpty(giftConfigs)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user