From 5370dfae0ce0c7d14cb81c42f49eae176b83b60e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 7 Nov 2025 15:50:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E5=BA=97=E9=85=8D=E7=BD=AE=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ShopConfigServiceImpl.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) 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);