diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopConfigServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopConfigServiceImpl.java index 69850a7ed..85ae30782 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopConfigServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopConfigServiceImpl.java @@ -2,6 +2,7 @@ package com.czg.service.account.service.impl; import com.czg.account.dto.ShopConfigDTO; import com.czg.account.entity.ShopConfig; +import com.czg.account.entity.ShopInfo; import com.czg.account.service.ShopConfigService; import com.czg.sa.StpKit; import com.czg.service.RedisService; @@ -20,6 +21,8 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; /** * 店铺配置扩展 @@ -59,19 +62,17 @@ public class ShopConfigServiceImpl extends ServiceImpl(); } // 防止报错 - shopIdList.add(-9999L); - List extistList; - if (!shopIdList.isEmpty()) { - extistList = list(new QueryWrapper().in(ShopConfig::getId, shopIdList).select(ShopConfig::getId)).stream().map(ShopConfig::getId).toList(); - List finalShopIdList2 = shopIdList; - extistList.stream().filter(id -> !finalShopIdList2.contains(id)).forEach(id -> { - save(new ShopConfig().setId(id).setMainId(mainShopId).setIsEnableDiscount(0).setIsProductSuggest(0)); - }); - } else { - extistList = new ArrayList<>(); - } + Set childShopIdList = shopInfoMapper.selectListByQuery(new QueryWrapper().eq(ShopInfo::getMainId, mainShopId) + .select(ShopInfo::getId)).stream().map(ShopInfo::getId).collect(Collectors.toSet()); + childShopIdList.add(mainShopId); + List extistList = new ArrayList<>(list(new QueryWrapper().in(ShopConfig::getId, childShopIdList)).stream().map(ShopConfig::getId).toList()); + extistList.add(mainShopId); + childShopIdList.stream().filter(id -> !extistList.contains(id)).forEach(id -> { + save(new ShopConfig().setId(id).setMainId(id.equals(mainShopId) ? null : mainShopId).setIsEnableDiscount(0).setIsProductSuggest(0)); + }); if (isEnable == 0 && !onyUpValid) { + List finalShopIdList = shopIdList; updateChain().or(or -> { or.eq(ShopConfig::getId, mainShopId);