|
|
|
|
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import cn.ysk.cashier.cons.domain.TbConsInfo;
|
|
|
|
|
import cn.ysk.cashier.cons.domain.TbConsType;
|
|
|
|
|
import cn.ysk.cashier.cons.domain.TbProskuCon;
|
|
|
|
|
import cn.ysk.cashier.cons.repository.TbConsInfoRepository;
|
|
|
|
|
import cn.ysk.cashier.cons.repository.TbConsTypeRepository;
|
|
|
|
|
import cn.ysk.cashier.cons.repository.TbProskuConRepository;
|
|
|
|
|
@@ -17,10 +18,7 @@ import cn.ysk.cashier.pojo.product.*;
|
|
|
|
|
import cn.ysk.cashier.pojo.shop.TbShopUnit;
|
|
|
|
|
import cn.ysk.cashier.repository.product.*;
|
|
|
|
|
import cn.ysk.cashier.repository.shop.TbShopUnitRepository;
|
|
|
|
|
import cn.ysk.cashier.utils.JSONUtil;
|
|
|
|
|
import cn.ysk.cashier.utils.ListUtil;
|
|
|
|
|
import cn.ysk.cashier.utils.PageUtil;
|
|
|
|
|
import cn.ysk.cashier.utils.QueryHelp;
|
|
|
|
|
import cn.ysk.cashier.utils.*;
|
|
|
|
|
import cn.ysk.cashier.vo.ProductGroupVo;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
@@ -45,6 +43,8 @@ import java.util.concurrent.ExecutionException;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
import static cn.ysk.cashier.utils.StringCodeUtil.TYPE.LETTER_CAPITAL_NUMBER;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 店铺信息同步记录表(TbShopSyncInfo)表服务实现类
|
|
|
|
|
*
|
|
|
|
|
@@ -125,7 +125,6 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
futures.add(futureUnit);
|
|
|
|
|
futures.add(futureSpec);
|
|
|
|
|
futures.add(futureCate);
|
|
|
|
|
|
|
|
|
|
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
|
|
|
|
|
|
|
|
|
|
units = futureUnit.get();
|
|
|
|
|
@@ -202,6 +201,18 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
tbShopSyncInfo.setStatus(2);
|
|
|
|
|
tbShopSyncInfomapper.updateById(tbShopSyncInfo);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
tbShopSyncInfo.setProSpec(0);
|
|
|
|
|
tbShopSyncInfo.setProGroup(0);
|
|
|
|
|
tbShopSyncInfo.setProUnit(0);
|
|
|
|
|
tbShopSyncInfo.setProCategory(0);
|
|
|
|
|
tbShopSyncInfo.setProSkuResult(0);
|
|
|
|
|
tbShopSyncInfo.setProSku(0);
|
|
|
|
|
tbShopSyncInfo.setProduct(0);
|
|
|
|
|
|
|
|
|
|
tbShopSyncInfo.setConsType(0);
|
|
|
|
|
tbShopSyncInfo.setConsInfo(0);
|
|
|
|
|
tbShopSyncInfo.setConsPro(0);
|
|
|
|
|
|
|
|
|
|
tbShopSyncInfo.setSyncTime(new Date());
|
|
|
|
|
tbShopSyncInfo.setStatus(0);
|
|
|
|
|
tbShopSyncInfomapper.updateById(tbShopSyncInfo);
|
|
|
|
|
@@ -222,6 +233,10 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
skuRepository.clearShopSku(tbShopSyncInfo.getPointShopId().toString());
|
|
|
|
|
consRepository.clearShopCons(tbShopSyncInfo.getPointShopId());
|
|
|
|
|
consTypeRepository.clearShopConType(tbShopSyncInfo.getPointShopId());
|
|
|
|
|
List<TbProskuCon> tbProskuCons = proSkuConRepository.searchConsProByShopId(tbShopSyncInfo.getPointShopId());
|
|
|
|
|
List<Integer> proCons = tbProskuCons.stream().map(TbProskuCon::getId).collect(Collectors.toList());
|
|
|
|
|
proSkuConRepository.deleteAllByIdInBatch(proCons);
|
|
|
|
|
|
|
|
|
|
proSkuConRepository.clearShopConPro(tbShopSyncInfo.getPointShopId());
|
|
|
|
|
QueryWrapper<TbShopSyncInfo> wrapper = new QueryWrapper<>();
|
|
|
|
|
wrapper.eq("point_shop_id", tbShopSyncInfo.getPointShopId());
|
|
|
|
|
@@ -235,10 +250,12 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
Map<Integer, Integer> unitMap = new HashMap<>();
|
|
|
|
|
unitRepository.searchUnitByShopId(sourceShopId.toString()).forEach(tbShopUnit -> {
|
|
|
|
|
Integer sourceUnitId = tbShopUnit.getId();
|
|
|
|
|
tbShopUnit.setId(null);
|
|
|
|
|
tbShopUnit.setShopId(pointShopId.toString());
|
|
|
|
|
unitRepository.save(tbShopUnit);
|
|
|
|
|
unitMap.put(sourceUnitId, tbShopUnit.getId());
|
|
|
|
|
TbShopUnit unitNew = new TbShopUnit();
|
|
|
|
|
unitNew.copy(tbShopUnit);
|
|
|
|
|
unitNew.setId(null);
|
|
|
|
|
unitNew.setShopId(pointShopId.toString());
|
|
|
|
|
unitRepository.save(unitNew);
|
|
|
|
|
unitMap.put(sourceUnitId, unitNew.getId());
|
|
|
|
|
});
|
|
|
|
|
future.complete(unitMap);
|
|
|
|
|
return future;
|
|
|
|
|
@@ -247,13 +264,16 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
//规格
|
|
|
|
|
@Async
|
|
|
|
|
public CompletableFuture<Map<Integer, Integer>> syncSpec(Integer sourceShopId, Integer pointShopId) {
|
|
|
|
|
log.info("规格同步 "+System.currentTimeMillis());
|
|
|
|
|
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
|
|
|
|
|
Map<Integer, Integer> specMap = new HashMap<>();
|
|
|
|
|
specRepository.searchSpecByShopId(sourceShopId.toString()).forEach(tbProductSpec -> {
|
|
|
|
|
Integer sourceSpecId = tbProductSpec.getId();
|
|
|
|
|
tbProductSpec.setId(null);
|
|
|
|
|
tbProductSpec.setShopId(pointShopId.toString());
|
|
|
|
|
specRepository.save(tbProductSpec);
|
|
|
|
|
TbProductSpec tbProductSpecNew = new TbProductSpec();
|
|
|
|
|
tbProductSpecNew.copy(tbProductSpec);
|
|
|
|
|
tbProductSpecNew.setId(null);
|
|
|
|
|
tbProductSpecNew.setShopId(pointShopId.toString());
|
|
|
|
|
specRepository.save(tbProductSpecNew);
|
|
|
|
|
specMap.put(sourceSpecId, tbProductSpec.getId());
|
|
|
|
|
});
|
|
|
|
|
future.complete(specMap);
|
|
|
|
|
@@ -263,6 +283,7 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
// 分类
|
|
|
|
|
@Async
|
|
|
|
|
public CompletableFuture<Map<Integer, Integer>> syncCategory(Integer sourceShopId, Integer pointShopId) {
|
|
|
|
|
log.info("分类同步 "+System.currentTimeMillis());
|
|
|
|
|
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
|
|
|
|
|
Map<Integer, Integer> categoryMap = new HashMap<>();
|
|
|
|
|
List<TbShopCategory> tbShopCategories = categoryRepository.searchCategoryByShopId(sourceShopId.toString());
|
|
|
|
|
@@ -271,23 +292,28 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
treeIds.add(tbShopCategory.getId());
|
|
|
|
|
|
|
|
|
|
Integer sourceCategoryId = tbShopCategory.getId();
|
|
|
|
|
tbShopCategory.setId(null);
|
|
|
|
|
tbShopCategory.setShopId(pointShopId.toString());
|
|
|
|
|
tbShopCategory.setTree(null);
|
|
|
|
|
tbShopCategory.setPid("");
|
|
|
|
|
categoryRepository.save(tbShopCategory);
|
|
|
|
|
categoryMap.put(sourceCategoryId, tbShopCategory.getId());
|
|
|
|
|
|
|
|
|
|
TbShopCategory tbShopCategoryNew = new TbShopCategory();
|
|
|
|
|
tbShopCategoryNew.copy(tbShopCategory);
|
|
|
|
|
tbShopCategoryNew.setId(null);
|
|
|
|
|
tbShopCategoryNew.setShopId(pointShopId.toString());
|
|
|
|
|
tbShopCategoryNew.setTree(null);
|
|
|
|
|
tbShopCategoryNew.setPid("");
|
|
|
|
|
categoryRepository.save(tbShopCategoryNew);
|
|
|
|
|
categoryMap.put(sourceCategoryId, tbShopCategoryNew.getId());
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtil.isNotEmpty(treeIds)) {
|
|
|
|
|
List<TbShopCategory> children = categoryRepository.findChildren(treeIds);
|
|
|
|
|
for (TbShopCategory child : children) {
|
|
|
|
|
Integer sourceCategoryId = child.getId();
|
|
|
|
|
child.setId(null);
|
|
|
|
|
child.setShopId(pointShopId.toString());
|
|
|
|
|
child.setTree(categoryMap.get(child.getTree()));
|
|
|
|
|
child.setPid(StringUtils.isNotBlank(child.getPid()) ? categoryMap.get(Integer.valueOf(child.getPid())).toString() : "");
|
|
|
|
|
categoryRepository.save(child);
|
|
|
|
|
categoryMap.put(sourceCategoryId, child.getId());
|
|
|
|
|
TbShopCategory tbShopCategoryNew = new TbShopCategory();
|
|
|
|
|
tbShopCategoryNew.copy(child);
|
|
|
|
|
tbShopCategoryNew.setId(null);
|
|
|
|
|
tbShopCategoryNew.setShopId(pointShopId.toString());
|
|
|
|
|
tbShopCategoryNew.setTree(categoryMap.get(child.getTree()));
|
|
|
|
|
tbShopCategoryNew.setPid(StringUtils.isNotBlank(child.getPid()) ? categoryMap.get(Integer.valueOf(child.getPid())).toString() : "");
|
|
|
|
|
categoryRepository.save(tbShopCategoryNew);
|
|
|
|
|
categoryMap.put(sourceCategoryId, tbShopCategoryNew.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
future.complete(categoryMap);
|
|
|
|
|
@@ -300,7 +326,7 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
|
|
|
|
|
String cateGory = "";
|
|
|
|
|
if(CollectionUtil.isNotEmpty(cateGorys)){
|
|
|
|
|
cateGory = cateGorys.get(cateGorys.keySet().stream().findFirst()).toString();
|
|
|
|
|
cateGory = cateGorys.keySet().stream().findFirst().get().toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<Integer, Integer> proMap = new HashMap<>();
|
|
|
|
|
@@ -308,20 +334,23 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
if(CollectionUtil.isNotEmpty(products)){
|
|
|
|
|
for (TbProduct tbProduct : products) {
|
|
|
|
|
Integer sourceSpecId = tbProduct.getId();
|
|
|
|
|
tbProduct.setId(null);
|
|
|
|
|
tbProduct.setShopId(pointShopId.toString());
|
|
|
|
|
if(cateGorys.containsKey(Integer.valueOf(tbProduct.getCategoryId()))){
|
|
|
|
|
tbProduct.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId()) ? cateGorys.get(Integer.valueOf(tbProduct.getCategoryId())).toString() : "");
|
|
|
|
|
TbProduct tbProductNew = new TbProduct();
|
|
|
|
|
tbProductNew.copy(tbProduct);
|
|
|
|
|
|
|
|
|
|
tbProductNew.setId(null);
|
|
|
|
|
tbProductNew.setShopId(pointShopId.toString());
|
|
|
|
|
if(StringUtils.isNotBlank(tbProduct.getCategoryId()) && cateGorys.containsKey(Integer.valueOf(tbProduct.getCategoryId()))){
|
|
|
|
|
tbProductNew.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId()) ? cateGorys.get(Integer.valueOf(tbProduct.getCategoryId())).toString() : "");
|
|
|
|
|
}else {
|
|
|
|
|
tbProduct.setCategoryId(cateGory);
|
|
|
|
|
tbProductNew.setCategoryId(cateGory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tbProduct.setSpecId(tbProduct.getSpecId() != null ? specs.get(tbProduct.getSpecId()) : null);
|
|
|
|
|
tbProduct.setUnitId(tbProduct.getUnitId() != null ? units.get(tbProduct.getUnitId()) : null);
|
|
|
|
|
tbProduct.setStockNumber(0);
|
|
|
|
|
tbProductNew.setSpecId(tbProduct.getSpecId() != null ? specs.get(tbProduct.getSpecId()) : null);
|
|
|
|
|
tbProductNew.setUnitId(tbProduct.getUnitId() != null ? units.get(tbProduct.getUnitId()) : null);
|
|
|
|
|
tbProductNew.setStockNumber(0);
|
|
|
|
|
|
|
|
|
|
productRepository.save(tbProduct);
|
|
|
|
|
proMap.put(sourceSpecId, tbProduct.getId());
|
|
|
|
|
productRepository.save(tbProductNew);
|
|
|
|
|
proMap.put(sourceSpecId, tbProductNew.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
future.complete(proMap);
|
|
|
|
|
@@ -334,12 +363,14 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
Map<Integer, Integer> groupMap = new HashMap<>();
|
|
|
|
|
groupRepository.searchGroupByShopId(sourceShopId).forEach(tbProductGroup -> {
|
|
|
|
|
Integer groupId = tbProductGroup.getId();
|
|
|
|
|
tbProductGroup.setId(null);
|
|
|
|
|
tbProductGroup.setShopId(pointShopId);
|
|
|
|
|
tbProductGroup.setUseTime(0);
|
|
|
|
|
tbProductGroup.setProductIds(replaceProIds(tbProductGroup.getProductIds(), pros));
|
|
|
|
|
groupRepository.save(tbProductGroup);
|
|
|
|
|
groupMap.put(groupId, tbProductGroup.getId());
|
|
|
|
|
TbProductGroup tbProductGroupNew = new TbProductGroup();
|
|
|
|
|
tbProductGroupNew.copy(tbProductGroup);
|
|
|
|
|
tbProductGroupNew.setId(null);
|
|
|
|
|
tbProductGroupNew.setShopId(pointShopId);
|
|
|
|
|
tbProductGroupNew.setUseTime(0);
|
|
|
|
|
tbProductGroupNew.setProductIds(replaceProIds(tbProductGroup.getProductIds(), pros));
|
|
|
|
|
groupRepository.save(tbProductGroupNew);
|
|
|
|
|
groupMap.put(groupId, tbProductGroupNew.getId());
|
|
|
|
|
});
|
|
|
|
|
future.complete(groupMap);
|
|
|
|
|
return future;
|
|
|
|
|
@@ -349,28 +380,30 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
@Async
|
|
|
|
|
public void syncGroupPackage(Integer shopId, Map<Integer, Integer> pros, Map<Integer, Integer> skus) {
|
|
|
|
|
productRepository.findPackageByShopId(shopId.toString()).forEach(tbProduct -> {
|
|
|
|
|
tbProduct.setProGroupVo(JSONUtil.parseJSONStrTList(tbProduct.getGroupSnap(), ProductGroupVo.class));
|
|
|
|
|
if (tbProduct.getProGroupVo() != null) {
|
|
|
|
|
tbProduct.getProGroupVo().forEach(proGroupVo -> {
|
|
|
|
|
proGroupVo.getGoods().forEach(goods -> {
|
|
|
|
|
if (pros.containsKey(goods.getProId())) {
|
|
|
|
|
if (goods.getSkuId() != null && skus.containsKey(goods.getSkuId())) {
|
|
|
|
|
goods.setProId(pros.get(goods.getProId()));
|
|
|
|
|
goods.setSkuId(skus.get(goods.getSkuId()));
|
|
|
|
|
} else {
|
|
|
|
|
goods.setProId(pros.get(goods.getProId()));
|
|
|
|
|
if(StringUtils.isNotBlank(tbProduct.getGroupSnap())){
|
|
|
|
|
tbProduct.setProGroupVo(JSONUtil.parseJSONStrTList(tbProduct.getGroupSnap(), ProductGroupVo.class));
|
|
|
|
|
if (tbProduct.getProGroupVo() != null) {
|
|
|
|
|
tbProduct.getProGroupVo().forEach(proGroupVo -> {
|
|
|
|
|
proGroupVo.getGoods().forEach(goods -> {
|
|
|
|
|
if (pros.containsKey(goods.getProId())) {
|
|
|
|
|
if (goods.getSkuId() != null && skus.containsKey(goods.getSkuId())) {
|
|
|
|
|
goods.setProId(pros.get(goods.getProId()));
|
|
|
|
|
goods.setSkuId(skus.get(goods.getSkuId()));
|
|
|
|
|
} else {
|
|
|
|
|
goods.setProId(pros.get(goods.getProId()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
proGroupVo.setCount(proGroupVo.getGoods().size());
|
|
|
|
|
if (proGroupVo.getNumber() != null && proGroupVo.getNumber() > 0) {
|
|
|
|
|
if (proGroupVo.getNumber() > proGroupVo.getCount()) {
|
|
|
|
|
proGroupVo.setNumber(proGroupVo.getCount());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
proGroupVo.setCount(proGroupVo.getGoods().size());
|
|
|
|
|
if (proGroupVo.getNumber() != null && proGroupVo.getNumber() > 0) {
|
|
|
|
|
if (proGroupVo.getNumber() > proGroupVo.getCount()) {
|
|
|
|
|
proGroupVo.setNumber(proGroupVo.getCount());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
tbProduct.setGroupSnap(ListUtil.listToJsonString(tbProduct.getProGroupVo()));
|
|
|
|
|
productRepository.save(tbProduct);
|
|
|
|
|
tbProduct.setGroupSnap(ListUtil.listToJsonString(tbProduct.getProGroupVo()));
|
|
|
|
|
productRepository.save(tbProduct);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
@@ -384,11 +417,13 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
Integer productId = Integer.valueOf(tbProductSku.getProductId());
|
|
|
|
|
if (pros.containsKey(productId)) {
|
|
|
|
|
Integer sourceSkuId = tbProductSku.getId();
|
|
|
|
|
tbProductSku.setId(null);
|
|
|
|
|
tbProductSku.setShopId(pointShopId.toString());
|
|
|
|
|
tbProductSku.setProductId(pros.get(productId).toString());
|
|
|
|
|
skuRepository.save(tbProductSku);
|
|
|
|
|
skuMap.put(sourceSkuId, tbProductSku.getId());
|
|
|
|
|
TbProductSku tbProductSkuNew = new TbProductSku();
|
|
|
|
|
tbProductSkuNew.copy(tbProductSku);
|
|
|
|
|
tbProductSkuNew.setId(null);
|
|
|
|
|
tbProductSkuNew.setShopId(pointShopId.toString());
|
|
|
|
|
tbProductSkuNew.setProductId(pros.get(productId).toString());
|
|
|
|
|
skuRepository.save(tbProductSkuNew);
|
|
|
|
|
skuMap.put(sourceSkuId, tbProductSkuNew.getId());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
future.complete(skuMap);
|
|
|
|
|
@@ -403,8 +438,10 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
return predicate;
|
|
|
|
|
});
|
|
|
|
|
skuResults.forEach(tbProductSkuResult -> {
|
|
|
|
|
tbProductSkuResult.setId(pros.get(tbProductSkuResult.getId()));
|
|
|
|
|
skuResultRepository.save(tbProductSkuResult);
|
|
|
|
|
TbProductSkuResult tbProductSkuResultNew = new TbProductSkuResult();
|
|
|
|
|
tbProductSkuResultNew.copy(tbProductSkuResult);
|
|
|
|
|
tbProductSkuResultNew.setId(pros.get(tbProductSkuResult.getId()));
|
|
|
|
|
skuResultRepository.save(tbProductSkuResultNew);
|
|
|
|
|
});
|
|
|
|
|
future.complete(skuResults.size());
|
|
|
|
|
return future;
|
|
|
|
|
@@ -418,10 +455,12 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
List<TbConsType> tbConsTypes = consTypeRepository.searchConsTypeByShopId(sourceShopId);
|
|
|
|
|
for (TbConsType tbConsType : tbConsTypes) {
|
|
|
|
|
Integer sourceConsTypeId = tbConsType.getId();
|
|
|
|
|
tbConsType.setId(null);
|
|
|
|
|
tbConsType.setShopId(pointShopId);
|
|
|
|
|
consTypeRepository.save(tbConsType);
|
|
|
|
|
consTypeMap.put(sourceConsTypeId, tbConsType.getId());
|
|
|
|
|
TbConsType tbConsTypeNew = new TbConsType();
|
|
|
|
|
tbConsTypeNew.copy(tbConsType);
|
|
|
|
|
tbConsTypeNew.setId(null);
|
|
|
|
|
tbConsTypeNew.setShopId(pointShopId);
|
|
|
|
|
consTypeRepository.save(tbConsTypeNew);
|
|
|
|
|
consTypeMap.put(sourceConsTypeId, tbConsTypeNew.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
future.complete(consTypeMap);
|
|
|
|
|
@@ -436,14 +475,16 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
List<TbConsInfo> tbConsInfos = consRepository.searchConsInfoByShopId(sourceShopId);
|
|
|
|
|
for (TbConsInfo tbConsInfo : tbConsInfos) {
|
|
|
|
|
Integer sourceConsId = tbConsInfo.getId();
|
|
|
|
|
|
|
|
|
|
tbConsInfo.setId(null);
|
|
|
|
|
tbConsInfo.setShopId(pointShopId);
|
|
|
|
|
tbConsInfo.setConTypeId(conTypes.get(tbConsInfo.getConTypeId()));
|
|
|
|
|
tbConsInfo.setStockNumber(BigDecimal.ZERO);
|
|
|
|
|
tbConsInfo.setStockConsume(BigDecimal.ZERO);
|
|
|
|
|
consRepository.save(tbConsInfo);
|
|
|
|
|
consMap.put(sourceConsId, tbConsInfo.getId());
|
|
|
|
|
TbConsInfo tbConsInfoNew = new TbConsInfo();
|
|
|
|
|
tbConsInfoNew.copy(tbConsInfo);
|
|
|
|
|
tbConsInfoNew.setId(null);
|
|
|
|
|
tbConsInfoNew.setShopId(pointShopId);
|
|
|
|
|
tbConsInfoNew.setConTypeId(conTypes.get(tbConsInfo.getConTypeId()));
|
|
|
|
|
tbConsInfoNew.setConCode(StringCodeUtil.getRandom(8, LETTER_CAPITAL_NUMBER));
|
|
|
|
|
tbConsInfoNew.setStockNumber(BigDecimal.ZERO);
|
|
|
|
|
tbConsInfoNew.setStockConsume(BigDecimal.ZERO);
|
|
|
|
|
consRepository.save(tbConsInfoNew);
|
|
|
|
|
consMap.put(sourceConsId, tbConsInfoNew.getId());
|
|
|
|
|
}
|
|
|
|
|
future.complete(consMap);
|
|
|
|
|
return future;
|
|
|
|
|
@@ -456,15 +497,17 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl<TbShopSyncInfoMapper,
|
|
|
|
|
proSkuConRepository.searchConsProByShopId(sourceShopId).forEach(tbConsPro -> {
|
|
|
|
|
if (consMap.containsKey(tbConsPro.getConInfoId()) && proMap.containsKey(tbConsPro.getProductId()) && skuMap.containsKey(tbConsPro.getProductSkuId())) {
|
|
|
|
|
Integer sourceConsProId = tbConsPro.getId();
|
|
|
|
|
tbConsPro.setId(null);
|
|
|
|
|
tbConsPro.setShopId(pointShopId);
|
|
|
|
|
tbConsPro.setConInfoId(consMap.get(tbConsPro.getConInfoId()));
|
|
|
|
|
tbConsPro.setProductId(proMap.get(tbConsPro.getProductId()));
|
|
|
|
|
TbProskuCon tbConsProNew = new TbProskuCon();
|
|
|
|
|
tbConsProNew.copy(tbConsPro);
|
|
|
|
|
tbConsProNew.setId(null);
|
|
|
|
|
tbConsProNew.setShopId(pointShopId);
|
|
|
|
|
tbConsProNew.setConInfoId(consMap.get(tbConsPro.getConInfoId()));
|
|
|
|
|
tbConsProNew.setProductId(proMap.get(tbConsPro.getProductId()));
|
|
|
|
|
if (tbConsPro.getProductSkuId() > 0) {
|
|
|
|
|
tbConsPro.setProductSkuId(skuMap.get(tbConsPro.getProductSkuId()));
|
|
|
|
|
tbConsProNew.setProductSkuId(skuMap.get(tbConsPro.getProductSkuId()));
|
|
|
|
|
}
|
|
|
|
|
proSkuConRepository.save(tbConsPro);
|
|
|
|
|
proSkuConMap.put(sourceConsProId, tbConsPro.getId());
|
|
|
|
|
proSkuConRepository.save(tbConsProNew);
|
|
|
|
|
proSkuConMap.put(sourceConsProId, tbConsProNew.getId());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
future.complete(proSkuConMap);
|
|
|
|
|
|