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 a03f6bb21..59bbd5c24 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 @@ -431,13 +431,16 @@ public class ShopSyncServiceImpl implements ShopSyncService { Map proMap = new HashMap<>(); List products = productService.queryChain().eq(Product::getShopId, sourceShopId).list(); if (CollectionUtil.isNotEmpty(products)) { + unitService.queryChain().eq(ShopProdUnit::getIsSystem, 1).list().forEach(tbShopUnit -> { + unitMap.put(tbShopUnit.getId(), tbShopUnit.getId()); + }); for (Product tbProduct : products) { if (CollUtil.isEmpty(pointProducts) || !pointProducts.contains(tbProduct.getId())) { Product tbProductNew = BeanUtil.copyProperties(tbProduct, Product.class); tbProductNew.setId(null); tbProductNew.setSyncId(tbProduct.getId()); tbProductNew.setShopId(pointShopId); - tbProductNew.setCategoryId(tbProduct.getCategoryId() != null ? cateGoryMap.get(tbProduct.getSpecId()) : null); + tbProductNew.setCategoryId(tbProduct.getCategoryId() != null ? cateGoryMap.get(tbProduct.getCategoryId()) : null); tbProductNew.setSpecId(tbProduct.getSpecId() != null ? specMap.get(tbProduct.getSpecId()) : null); tbProductNew.setUnitId(tbProduct.getUnitId() != null ? unitMap.get(tbProduct.getUnitId()) : null); tbProductNew.setStockNumber(0); @@ -479,12 +482,16 @@ public class ShopSyncServiceImpl implements ShopSyncService { } } Map unitMap = new HashMap<>(); + Set sysUnitMap = new HashSet<>(); if (mainEntity.getUnitId() != null) { List unitList = unitService.queryChain().eq(ShopProdUnit::getSyncId, mainEntity.getUnitId()) .in(ShopProdUnit::getShopId, shopIds).list(); if (CollUtil.isNotEmpty(unitList)) { unitMap = unitList.stream().collect(Collectors.toMap(ShopProdUnit::getShopId, ShopProdUnit::getId)); } + for (ShopProdUnit shopProdUnit : unitService.queryChain().eq(ShopProdUnit::getIsSystem, 1).list()) { + sysUnitMap.add(shopProdUnit.getId()); + } } Map categoryMap = new HashMap<>(); if (mainEntity.getCategoryId() != null) { @@ -502,7 +509,11 @@ public class ShopSyncServiceImpl implements ShopSyncService { newEntity.setShopId(shopId); newEntity.setCategoryId(newEntity.getCategoryId() != null ? categoryMap.get(shopId) : null); newEntity.setSpecId(newEntity.getSpecId() != null ? specMap.get(shopId) : null); - newEntity.setUnitId(newEntity.getUnitId() != null ? unitMap.get(shopId) : null); + if (newEntity.getUnitId() != null) { + if (!sysUnitMap.contains(newEntity.getUnitId())) { + newEntity.setUnitId(unitMap.get(shopId)); + } + } if (finalMap.containsKey(shopId)) { Product childEntity = finalMap.get(shopId); newEntity.setId(childEntity.getId());