商品同步问题
This commit is contained in:
@@ -459,20 +459,28 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||||||
if (CollUtil.isNotEmpty(list)) {
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
map = list.stream().collect(Collectors.toMap(Product::getShopId, t -> t));
|
map = list.stream().collect(Collectors.toMap(Product::getShopId, t -> t));
|
||||||
}
|
}
|
||||||
List<ShopProdSpec> specList = specService.queryChain().eq(ShopProdSpec::getSyncId, productId).in(ShopProdSpec::getShopId, shopIds).list();
|
|
||||||
Map<Long, Long> specMap = new HashMap<>();
|
Map<Long, Long> specMap = new HashMap<>();
|
||||||
if (CollUtil.isNotEmpty(specList)) {
|
if (mainEntity.getSpecId() != null) {
|
||||||
specMap = specList.stream().collect(Collectors.toMap(ShopProdSpec::getShopId, ShopProdSpec::getId));
|
List<ShopProdSpec> specList = specService.queryChain().eq(ShopProdSpec::getSyncId, mainEntity.getSpecId())
|
||||||
|
.in(ShopProdSpec::getShopId, shopIds).list();
|
||||||
|
if (CollUtil.isNotEmpty(specList)) {
|
||||||
|
specMap = specList.stream().collect(Collectors.toMap(ShopProdSpec::getShopId, ShopProdSpec::getId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
List<ShopProdUnit> unitList = unitService.queryChain().eq(ShopProdUnit::getSyncId, productId).in(ShopProdUnit::getShopId, shopIds).list();
|
|
||||||
Map<Long, Long> unitMap = new HashMap<>();
|
Map<Long, Long> unitMap = new HashMap<>();
|
||||||
if (CollUtil.isNotEmpty(unitList)) {
|
if (mainEntity.getUnitId() != null) {
|
||||||
unitMap = unitList.stream().collect(Collectors.toMap(ShopProdUnit::getShopId, ShopProdUnit::getId));
|
List<ShopProdUnit> 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
List<ShopProdCategory> categoryList = categoryService.queryChain().eq(ShopProdCategory::getSyncId, productId).in(ShopProdCategory::getShopId, shopIds).list();
|
|
||||||
Map<Long, Long> categoryMap = new HashMap<>();
|
Map<Long, Long> categoryMap = new HashMap<>();
|
||||||
if (CollUtil.isNotEmpty(categoryList)) {
|
if (mainEntity.getCategoryId() != null) {
|
||||||
categoryMap = categoryList.stream().collect(Collectors.toMap(ShopProdCategory::getShopId, ShopProdCategory::getId));
|
List<ShopProdCategory> categoryList = categoryService.queryChain().eq(ShopProdCategory::getSyncId, mainEntity.getCategoryId()).in(ShopProdCategory::getShopId, shopIds).list();
|
||||||
|
if (CollUtil.isNotEmpty(categoryList)) {
|
||||||
|
categoryMap = categoryList.stream().collect(Collectors.toMap(ShopProdCategory::getShopId, ShopProdCategory::getId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Map<Long, Product> finalMap = map;
|
Map<Long, Product> finalMap = map;
|
||||||
for (Long shopId : shopIds) {
|
for (Long shopId : shopIds) {
|
||||||
@@ -481,9 +489,9 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||||||
Product newEntity = BeanUtil.copyProperties(mainEntity, Product.class);
|
Product newEntity = BeanUtil.copyProperties(mainEntity, Product.class);
|
||||||
newEntity.setSyncId(mainEntity.getSyncId());
|
newEntity.setSyncId(mainEntity.getSyncId());
|
||||||
newEntity.setShopId(shopId);
|
newEntity.setShopId(shopId);
|
||||||
newEntity.setCategoryId(newEntity.getCategoryId() != null ? categoryMap.get(newEntity.getSpecId()) : null);
|
newEntity.setCategoryId(newEntity.getCategoryId() != null ? categoryMap.get(shopId) : null);
|
||||||
newEntity.setSpecId(newEntity.getSpecId() != null ? specMap.get(newEntity.getSpecId()) : null);
|
newEntity.setSpecId(newEntity.getSpecId() != null ? specMap.get(shopId) : null);
|
||||||
newEntity.setUnitId(newEntity.getUnitId() != null ? unitMap.get(newEntity.getUnitId()) : null);
|
newEntity.setUnitId(newEntity.getUnitId() != null ? unitMap.get(shopId) : null);
|
||||||
if (finalMap.containsKey(shopId)) {
|
if (finalMap.containsKey(shopId)) {
|
||||||
Product childEntity = finalMap.get(shopId);
|
Product childEntity = finalMap.get(shopId);
|
||||||
newEntity.setId(childEntity.getId());
|
newEntity.setId(childEntity.getId());
|
||||||
|
|||||||
Reference in New Issue
Block a user