diff --git a/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopSyncServiceImpl.java b/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopSyncServiceImpl.java index 8abca37d..381117af 100644 --- a/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopSyncServiceImpl.java +++ b/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ShopSyncServiceImpl.java @@ -1139,25 +1139,14 @@ public class ShopSyncServiceImpl implements ShopSyncService { for (Long shopId : shopIds) { Product product = productService.queryChain().eq(Product::getSyncId, sourceProdId).eq(Product::getShopId, shopId).one(); if (product != null) { - List newCons = new ArrayList<>(); - if (CollUtil.isEmpty(list)) { - newCons = consInfoService.queryChain() - .isNotNull(ConsInfo::getSyncId).eq(ConsInfo::getShopId, shopId).list(); - if (CollUtil.isNotEmpty(newCons)) { - prodConsRelationService.remove(QueryWrapper.create() - .eq(ProdConsRelation::getShopId, shopId) - .eq(ProdConsRelation::getProductId, product.getId()) - .in(ProdConsRelation::getConsInfoId, newCons.stream().map(ConsInfo::getId).collect(Collectors.toList()))); - } - } else { + prodConsRelationService.remove(QueryWrapper.create() + .eq(ProdConsRelation::getShopId, shopId) + .eq(ProdConsRelation::getProductId, product.getId())); + if(CollUtil.isNotEmpty(list)){ Map map = list.stream().collect(Collectors.toMap(ProdConsRelation::getConsInfoId, ProdConsRelation::getSurplusStock)); - newCons = consInfoService.queryChain() + List newCons = consInfoService.queryChain() .in(ConsInfo::getSyncId, map.keySet()).eq(ConsInfo::getShopId, shopId).list(); if (CollUtil.isNotEmpty(newCons)) { - prodConsRelationService.remove(QueryWrapper.create() - .eq(ProdConsRelation::getShopId, shopId) - .eq(ProdConsRelation::getProductId, product.getId()) - .in(ProdConsRelation::getConsInfoId, newCons.stream().map(ConsInfo::getId).collect(Collectors.toList()))); for (ConsInfo newCon : newCons) { ProdConsRelation prodConsRelation = new ProdConsRelation(); prodConsRelation.setShopId(shopId);