Commit 7d446b75 authored by 332784038@qq.com's avatar 332784038@qq.com

复制价格业务再次重构调整

parent 61755259
......@@ -3611,27 +3611,18 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
}
private void copyClearAndSavePriceStepList(ProductPriceDO productPriceDO, List<ProductPriceStepDO> stepList, String transportType, boolean batchUpdate) {
if (stepList == null) stepList = new ArrayList<>();
stepList = stepList.stream()
.filter(t -> t.getStartNum() != null &&
t.getWeightUnit() != null &&
t.getEndNum() != null)
.collect(Collectors.toList());
if (productPriceDO.getStepPrice() == 1) {
if (stepList == null) stepList = new ArrayList<>();
if (CollectionUtil.isEmpty(stepList)) return;
stepList = stepList.stream()
.filter(t -> t.getStartNum() != null &&
t.getWeightUnit() != null &&
t.getEndNum() != null)
.collect(Collectors.toList());
}
if (productPriceDO.getStepPrice() == 1 && CollectionUtil.isEmpty(stepList)) return;
Collection<Integer> priceTypes = stepList.stream()
.map(ProductPriceStepDO::getPriceType)
.collect(Collectors.toSet());
priceTypes.add(PriceTypeEnum.FULL_PRICE.getPriceType());
List<ProductPriceStepDO> dbStepList = productPriceStepMapper.selectList(new LambdaQueryWrapper<ProductPriceStepDO>()
.eq(ProductPriceStepDO::getProductPriceId, productPriceDO.getId())
.in(ProductPriceStepDO::getPriceType, priceTypes)
);
Map<Long, List<ProductPriceStepDO>> dbStepMap = dbStepList.stream()
.collect(Collectors.groupingBy(ProductPriceStepDO::getProductPriceId));
List<ProductPriceStepDO> insertList1 = new ArrayList<>();
List<ProductPriceStepDO> updateList = new ArrayList<>();
......@@ -3639,7 +3630,240 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
List<ProductPriceSpecialDO> priceSpecialUpdate = new ArrayList<>();
if (productPriceDO.getStepPrice() == 1) {
Collection<Integer> priceTypes = stepList.stream()
.map(ProductPriceStepDO::getPriceType)
.collect(Collectors.toSet());
priceTypes.add(PriceTypeEnum.FULL_PRICE.getPriceType());
List<ProductPriceStepDO> dbStepList = productPriceStepMapper.selectList(new LambdaQueryWrapper<ProductPriceStepDO>()
.eq(ProductPriceStepDO::getProductPriceId, productPriceDO.getId())
.in(ProductPriceStepDO::getPriceType, priceTypes)
);
Map<Long, List<ProductPriceStepDO>> dbStepMap = dbStepList.stream()
.collect(Collectors.groupingBy(ProductPriceStepDO::getProductPriceId));
copyStepPrice(stepList, transportType, productPriceDO, dbStepMap, insertList1, productPricePackagingDOS, updateList);
if (CollectionUtil.isNotEmpty(insertList1)) {
productPriceStepMapper.insertBatchSomeColumn(insertList1);
}
if (CollectionUtil.isNotEmpty(updateList)) {
productPriceStepMapper.updateBatch(updateList);
}
List<Long> dbStepIdList = dbStepList.stream()
.map(ProductPriceStepDO::getId)
.collect(toList());
if (!batchUpdate) {
List<Long> updateIdList = updateList.stream()
.map(ProductPriceStepDO::getId)
.collect(toList());
List<Long> dbIdList = new ArrayList<>(dbStepIdList);
dbIdList.removeAll(updateIdList);
if (CollectionUtil.isNotEmpty(dbIdList)) {
productPriceStepMapper.physicsDeleteById(Joiner.on(",").join(dbIdList));
}
}
insertList1.addAll(updateList);
List<ProductPriceStepSpecialDO> allUpdateStepSpecialList = insertList1.stream()
.filter(step -> CollectionUtil.isNotEmpty(step.getSpecialList()))
.flatMap(step -> step.getSpecialList().stream())
.filter(stepSpecialDO -> stepSpecialDO.getTransportPrice() != null
|| stepSpecialDO.getClearancePrice() != null
|| stepSpecialDO.getAllPrice() != null)
.collect(Collectors.toList());
Map<Long, List<ProductPriceStepSpecialDO>> stepSpecialGroupMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(allUpdateStepSpecialList)) {
//数据库查找所有阶梯特需数据
List<List<Long>> stepIdPartList = Lists.partition(dbStepIdList, 1000);
List<ProductPriceStepSpecialDO> allStepSpecialList = new ArrayList<>();
for (List<Long> stepIdLis : stepIdPartList) {
List<ProductPriceStepSpecialDO> itemStepSpecialList = productPriceStepSpecialMapper.selectList(new LambdaQueryWrapper<ProductPriceStepSpecialDO>()
.in(ProductPriceStepSpecialDO::getProductPriceStepId, stepIdLis)
);
allStepSpecialList.addAll(itemStepSpecialList);
}
stepSpecialGroupMap = allStepSpecialList.stream()
.collect(Collectors.groupingBy(ProductPriceStepSpecialDO::getProductPriceStepId));
}
List<ProductPriceStepSpecialDO> specialInsertList = new ArrayList<>();
List<ProductPriceStepSpecialDO> specialUpdateList = new ArrayList<>();
for (ProductPriceStepDO stepDO : insertList1) {
List<ProductPriceStepSpecialDO> productPriceStepSpecialDOS = stepDO.getSpecialList();
//过滤掉价格为空的数据
if (CollectionUtil.isNotEmpty(productPriceStepSpecialDOS)) {
productPriceStepSpecialDOS = productPriceStepSpecialDOS.stream()
.filter(stepSpecialDO -> stepSpecialDO.getTransportPrice() != null
|| stepSpecialDO.getClearancePrice() != null
|| stepSpecialDO.getAllPrice() != null)
.collect(toList());
List<ProductPriceStepSpecialDO> dbStepSpecialList = stepSpecialGroupMap.get(stepDO.getId());
Map<String, ProductPriceStepSpecialDO> stepSpecialMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(dbStepSpecialList)) {
stepSpecialMap = dbStepSpecialList.stream()
.collect(Collectors.toMap(ProductPriceStepSpecialDO::getSpecialDictType, v -> v));
}
for (ProductPriceStepSpecialDO stepSpecialDO : productPriceStepSpecialDOS) {
ProductPriceStepSpecialDO dbStepSpecialDO = stepSpecialMap.get(stepSpecialDO.getSpecialDictType());
if (dbStepSpecialDO == null) {
ProductPriceStepSpecialDO dbItem = ObjectUtil.clone(stepSpecialDO);
dbItem.setId(null);
dbItem.setProductPriceId(stepDO.getProductPriceId());
dbItem.setProductPriceStepId(stepDO.getId());
initBasePrice(dbItem, transportType);
specialInsertList.add(dbItem);
} else {
if (stepSpecialDO.getTransportPrice() != null) {
dbStepSpecialDO.setTransportPrice(stepSpecialDO.getTransportPrice());
}
if (stepSpecialDO.getTransportPriceUnit() != null) {
dbStepSpecialDO.setTransportPriceUnit(stepSpecialDO.getTransportPriceUnit());
}
if (stepSpecialDO.getTransportVolumeUnit() != null) {
dbStepSpecialDO.setTransportVolumeUnit(stepSpecialDO.getTransportVolumeUnit());
}
if (stepSpecialDO.getClearancePrice() != null) {
dbStepSpecialDO.setClearancePrice(stepSpecialDO.getClearancePrice());
}
if (stepSpecialDO.getClearancePriceUnit() != null) {
dbStepSpecialDO.setClearancePriceUnit(stepSpecialDO.getClearancePriceUnit());
}
if (stepSpecialDO.getClearanceVolumeUnit() != null) {
dbStepSpecialDO.setClearanceVolumeUnit(stepSpecialDO.getClearanceVolumeUnit());
}
if (stepSpecialDO.getAllPrice() != null) {
dbStepSpecialDO.setAllPrice(stepSpecialDO.getAllPrice());
}
if (stepSpecialDO.getAllPriceUnit() != null) {
dbStepSpecialDO.setAllPriceUnit(stepSpecialDO.getAllPriceUnit());
}
if (stepSpecialDO.getAllVolumeUnit() != null) {
dbStepSpecialDO.setAllVolumeUnit(stepSpecialDO.getAllVolumeUnit());
}
specialUpdateList.add(dbStepSpecialDO);
}
}
}
}
if (CollectionUtil.isNotEmpty(specialInsertList)) {
productPriceStepSpecialMapper.insertBatchSomeColumn(specialInsertList);
}
if (CollectionUtil.isNotEmpty(specialUpdateList)) {
productPriceStepSpecialMapper.updateBatch(specialUpdateList);
}
List<ProductPriceStepPackagingDO> stepPackagingList = insertList1.stream()
.map(ProductPriceStepDO::getPackagingList)
.filter(CollectionUtil::isNotEmpty)
.flatMap(List::stream)
.collect(Collectors.toList());
Map<Long, List<ProductPriceStepPackagingDO>> stepPackagingGroupMap = new HashMap<>();
List<Long> dbPackingIdList = new ArrayList<>();
if (CollectionUtil.isNotEmpty(stepPackagingList)) {
//数据库查找所有阶梯包装数据
List<List<Long>> stepIdPartList = Lists.partition(dbStepIdList, 1000);
List<ProductPriceStepPackagingDO> allStepPackagingList = new ArrayList<>();
for (List<Long> stepIdLis : stepIdPartList) {
List<ProductPriceStepPackagingDO> itemStepPackagingList = productPriceStepPackagingMapper.selectList(new LambdaQueryWrapper<ProductPriceStepPackagingDO>()
.in(ProductPriceStepPackagingDO::getProductPriceStepId, stepIdLis)
);
allStepPackagingList.addAll(itemStepPackagingList);
}
dbPackingIdList = allStepPackagingList.stream()
.map(BasePackagingPrice::getId)
.collect(toList());
stepPackagingGroupMap = allStepPackagingList.stream()
.collect(Collectors.groupingBy(ProductPriceStepPackagingDO::getProductPriceStepId));
}
List<ProductPriceStepPackagingDO> packagingInsertList = new ArrayList<>();
List<ProductPriceStepPackagingDO> packagingUpdateList = new ArrayList<>();
List<ProductPriceStepPackagingDO> packagingDeleteListList = new ArrayList<>();
for (ProductPriceStepDO priceStepDO : insertList1) {
List<ProductPriceStepPackagingDO> productPriceStepPackagingDOS = priceStepDO.getPackagingList();
if (CollectionUtil.isNotEmpty(productPriceStepPackagingDOS)) {
productPriceStepPackagingDOS = productPriceStepPackagingDOS.stream()
.filter(t -> t.getPackagingPrice() != null)
.collect(toList());
}
if (CollectionUtil.isNotEmpty(productPriceStepPackagingDOS)) {
List<ProductPriceStepPackagingDO> dbStepPackagingList = stepPackagingGroupMap.get(priceStepDO.getId());
if (CollectionUtil.isEmpty(dbStepPackagingList)) {
for (int i = 0; i < productPriceStepPackagingDOS.size(); i++) {
ProductPriceStepPackagingDO m = productPriceStepPackagingDOS.get(i);
ProductPriceStepPackagingDO dbItem = ObjectUtil.clone(m);
dbItem.setId(null);
dbItem.setProductPriceId(priceStepDO.getProductPriceId());
dbItem.setProductPriceStepId(priceStepDO.getId());
dbItem.setRankNum(i + 1);
dbItem.setDeleted(false);
packagingInsertList.add(dbItem);
}
} else {
for (int i = 0; i < productPriceStepPackagingDOS.size(); i++) {
ProductPriceStepPackagingDO item = productPriceStepPackagingDOS.get(i);
String addPricePackagingTypes = item.getPackagingTypes();
if (StringUtils.isBlank(addPricePackagingTypes)) continue;
Long addPricePackagingPriceUnit = item.getPackagingPriceUnit();
if (addPricePackagingPriceUnit == null) continue;
Long addPricePackagingVolumeUnit = item.getPackagingVolumeUnit();
if (addPricePackagingVolumeUnit == null) continue;
Set<String> addPriceTypeSets = new HashSet<>(Arrays.asList(addPricePackagingTypes.split(",")));
//新增BC
ProductPriceStepPackagingDO dbItem = ObjectUtil.clone(item);
dbItem.setId(null);
dbItem.setProductPriceId(priceStepDO.getProductPriceId());
dbItem.setProductPriceStepId(priceStepDO.getId());
dbItem.setRankNum(i + 1);
dbItem.setDeleted(false);
packagingInsertList.add(dbItem);
if (!batchUpdate) continue;
for (ProductPriceStepPackagingDO dbStepPacking : dbStepPackagingList) {
Set<String> dbPriceTypeSets = new HashSet<>(Arrays.asList(dbStepPacking.getPackagingTypes().split(",")));
dbPriceTypeSets.removeAll(addPriceTypeSets);
if (dbPriceTypeSets.isEmpty()) {
packagingDeleteListList.add(dbStepPacking);
} else {
dbStepPacking.setPackagingTypes(Joiner.on(",").join(dbPriceTypeSets));
dbStepPacking.setPackagingPriceUnit(item.getPackagingPriceUnit());
dbStepPacking.setPackagingVolumeUnit(item.getPackagingVolumeUnit());
packagingUpdateList.add(dbStepPacking);
}
}
}
}
}
}
if (CollectionUtil.isNotEmpty(packagingInsertList)) {
productPriceStepPackagingMapper.insertBatchSomeColumn(packagingInsertList);
}
if (CollectionUtil.isNotEmpty(packagingUpdateList)) {
productPriceStepPackagingMapper.updateBatch(packagingUpdateList);
}
if (CollectionUtil.isNotEmpty(packagingDeleteListList)) {
List<Long> dIdList = packagingDeleteListList.stream()
.map(BasePackagingPrice::getId)
.collect(toList());
productPriceStepPackagingMapper.deleteBatchIds(dIdList);
}
if (!batchUpdate) {
List<Long> updateIdList = packagingUpdateList.stream()
.map(ProductPriceStepPackagingDO::getId)
.collect(toList());
dbPackingIdList.removeAll(updateIdList);
if (CollectionUtil.isNotEmpty(dbPackingIdList)) {
productPriceStepPackagingMapper.physicsDeleteById(Joiner.on(",").join(dbPackingIdList));
}
}
} else {
if (CollectionUtil.isNotEmpty(productPriceDO.getSpecialDOList())) {
for (ProductPriceSpecialDO specialDO : productPriceDO.getSpecialDOList()) {
......@@ -3677,244 +3901,18 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
productPricePackagingDOS.add(pricePackagingDO);
}
}
}
if (CollectionUtil.isNotEmpty(insertList1)) {
productPriceStepMapper.insertBatchSomeColumn(insertList1);
}
if (CollectionUtil.isNotEmpty(updateList)) {
productPriceStepMapper.updateBatch(updateList);
}
List<Long> dbStepIdList = dbStepList.stream()
.map(ProductPriceStepDO::getId)
.collect(toList());
if (!batchUpdate) {
List<Long> updateIdList = updateList.stream()
.map(ProductPriceStepDO::getId)
.collect(toList());
List<Long> dbIdList = new ArrayList<>(dbStepIdList);
dbIdList.removeAll(updateIdList);
if (CollectionUtil.isNotEmpty(dbIdList)) {
productPriceStepMapper.physicsDeleteById(Joiner.on(",").join(dbIdList));
}
}
insertList1.addAll(updateList);
List<ProductPriceStepSpecialDO> allUpdateStepSpecialList = insertList1.stream()
.filter(step -> CollectionUtil.isNotEmpty(step.getSpecialList()))
.flatMap(step -> step.getSpecialList().stream())
.filter(stepSpecialDO -> stepSpecialDO.getTransportPrice() != null
|| stepSpecialDO.getClearancePrice() != null
|| stepSpecialDO.getAllPrice() != null)
.collect(Collectors.toList());
Map<Long, List<ProductPriceStepSpecialDO>> stepSpecialGroupMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(allUpdateStepSpecialList)) {
//数据库查找所有阶梯特需数据
List<List<Long>> stepIdPartList = Lists.partition(dbStepIdList, 1000);
List<ProductPriceStepSpecialDO> allStepSpecialList = new ArrayList<>();
for (List<Long> stepIdLis : stepIdPartList) {
List<ProductPriceStepSpecialDO> itemStepSpecialList = productPriceStepSpecialMapper.selectList(new LambdaQueryWrapper<ProductPriceStepSpecialDO>()
.in(ProductPriceStepSpecialDO::getProductPriceStepId, stepIdLis)
);
allStepSpecialList.addAll(itemStepSpecialList);
}
stepSpecialGroupMap = allStepSpecialList.stream()
.collect(Collectors.groupingBy(ProductPriceStepSpecialDO::getProductPriceStepId));
}
List<ProductPriceStepSpecialDO> specialInsertList = new ArrayList<>();
List<ProductPriceStepSpecialDO> specialUpdateList = new ArrayList<>();
for (ProductPriceStepDO stepDO : insertList1) {
List<ProductPriceStepSpecialDO> productPriceStepSpecialDOS = stepDO.getSpecialList();
//过滤掉价格为空的数据
if (CollectionUtil.isNotEmpty(productPriceStepSpecialDOS)) {
productPriceStepSpecialDOS = productPriceStepSpecialDOS.stream()
.filter(stepSpecialDO -> stepSpecialDO.getTransportPrice() != null
|| stepSpecialDO.getClearancePrice() != null
|| stepSpecialDO.getAllPrice() != null)
.collect(toList());
List<ProductPriceStepSpecialDO> dbStepSpecialList = stepSpecialGroupMap.get(stepDO.getId());
Map<String, ProductPriceStepSpecialDO> stepSpecialMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(dbStepSpecialList)) {
stepSpecialMap = dbStepSpecialList.stream()
.collect(Collectors.toMap(ProductPriceStepSpecialDO::getSpecialDictType, v -> v));
}
for (ProductPriceStepSpecialDO stepSpecialDO : productPriceStepSpecialDOS) {
ProductPriceStepSpecialDO dbStepSpecialDO = stepSpecialMap.get(stepSpecialDO.getSpecialDictType());
if (dbStepSpecialDO == null) {
ProductPriceStepSpecialDO dbItem = ObjectUtil.clone(stepSpecialDO);
dbItem.setId(null);
dbItem.setProductPriceId(stepDO.getProductPriceId());
dbItem.setProductPriceStepId(stepDO.getId());
initBasePrice(dbItem, transportType);
specialInsertList.add(dbItem);
} else {
if (stepSpecialDO.getTransportPrice() != null) {
dbStepSpecialDO.setTransportPrice(stepSpecialDO.getTransportPrice());
}
if (stepSpecialDO.getTransportPriceUnit() != null) {
dbStepSpecialDO.setTransportPriceUnit(stepSpecialDO.getTransportPriceUnit());
}
if (stepSpecialDO.getTransportVolumeUnit() != null) {
dbStepSpecialDO.setTransportVolumeUnit(stepSpecialDO.getTransportVolumeUnit());
}
if (stepSpecialDO.getClearancePrice() != null) {
dbStepSpecialDO.setClearancePrice(stepSpecialDO.getClearancePrice());
}
if (stepSpecialDO.getClearancePriceUnit() != null) {
dbStepSpecialDO.setClearancePriceUnit(stepSpecialDO.getClearancePriceUnit());
}
if (stepSpecialDO.getClearanceVolumeUnit() != null) {
dbStepSpecialDO.setClearanceVolumeUnit(stepSpecialDO.getClearanceVolumeUnit());
}
if (stepSpecialDO.getAllPrice() != null) {
dbStepSpecialDO.setAllPrice(stepSpecialDO.getAllPrice());
}
if (stepSpecialDO.getAllPriceUnit() != null) {
dbStepSpecialDO.setAllPriceUnit(stepSpecialDO.getAllPriceUnit());
}
if (stepSpecialDO.getAllVolumeUnit() != null) {
dbStepSpecialDO.setAllVolumeUnit(stepSpecialDO.getAllVolumeUnit());
}
specialUpdateList.add(dbStepSpecialDO);
}
}
}
}
if (CollectionUtil.isNotEmpty(specialInsertList)) {
productPriceStepSpecialMapper.insertBatchSomeColumn(specialInsertList);
}
if (CollectionUtil.isNotEmpty(specialUpdateList)) {
productPriceStepSpecialMapper.updateBatch(specialUpdateList);
}
// if (CollectionUtil.isNotEmpty(priceSpecialInsert)) {
// productPriceSpecialMapper.insertBatch(priceSpecialInsert);
// }
if (CollectionUtil.isNotEmpty(priceSpecialUpdate)) {
productPriceSpecialMapper.physicsDelete(productPriceDO.getId().toString());
productPriceSpecialMapper.insertBatch(priceSpecialUpdate);
}
if (CollectionUtil.isNotEmpty(productPricePackagingDOS)) {
productPricePackagingMapper.physicsDelete(productPriceDO.getId().toString());
productPricePackagingMapper.insertBatch(productPricePackagingDOS);
}
List<ProductPriceStepPackagingDO> stepPackagingList = insertList1.stream()
.map(ProductPriceStepDO::getPackagingList)
.filter(CollectionUtil::isNotEmpty)
.flatMap(List::stream)
.collect(Collectors.toList());
Map<Long, List<ProductPriceStepPackagingDO>> stepPackagingGroupMap = new HashMap<>();
List<Long> dbPackingIdList = new ArrayList<>();
if (CollectionUtil.isNotEmpty(stepPackagingList)) {
//数据库查找所有阶梯包装数据
List<List<Long>> stepIdPartList = Lists.partition(dbStepIdList, 1000);
List<ProductPriceStepPackagingDO> allStepPackagingList = new ArrayList<>();
for (List<Long> stepIdLis : stepIdPartList) {
List<ProductPriceStepPackagingDO> itemStepPackagingList = productPriceStepPackagingMapper.selectList(new LambdaQueryWrapper<ProductPriceStepPackagingDO>()
.in(ProductPriceStepPackagingDO::getProductPriceStepId, stepIdLis)
);
allStepPackagingList.addAll(itemStepPackagingList);
if (CollectionUtil.isNotEmpty(priceSpecialUpdate)) {
productPriceSpecialMapper.physicsDelete(productPriceDO.getId().toString());
productPriceSpecialMapper.insertBatch(priceSpecialUpdate);
}
dbPackingIdList = allStepPackagingList.stream()
.map(BasePackagingPrice::getId)
.collect(toList());
stepPackagingGroupMap = allStepPackagingList.stream()
.collect(Collectors.groupingBy(ProductPriceStepPackagingDO::getProductPriceStepId));
}
List<ProductPriceStepPackagingDO> packagingInsertList = new ArrayList<>();
List<ProductPriceStepPackagingDO> packagingUpdateList = new ArrayList<>();
List<ProductPriceStepPackagingDO> packagingDeleteListList = new ArrayList<>();
for (ProductPriceStepDO priceStepDO : insertList1) {
List<ProductPriceStepPackagingDO> productPriceStepPackagingDOS = priceStepDO.getPackagingList();
if (CollectionUtil.isNotEmpty(productPriceStepPackagingDOS)) {
productPriceStepPackagingDOS = productPriceStepPackagingDOS.stream()
.filter(t -> t.getPackagingPrice() != null)
.collect(toList());
if (CollectionUtil.isNotEmpty(productPricePackagingDOS)) {
productPricePackagingMapper.physicsDelete(productPriceDO.getId().toString());
productPricePackagingMapper.insertBatch(productPricePackagingDOS);
}
if (CollectionUtil.isNotEmpty(productPriceStepPackagingDOS)) {
List<ProductPriceStepPackagingDO> dbStepPackagingList = stepPackagingGroupMap.get(priceStepDO.getId());
if (CollectionUtil.isEmpty(dbStepPackagingList)) {
for (int i = 0; i < productPriceStepPackagingDOS.size(); i++) {
ProductPriceStepPackagingDO m = productPriceStepPackagingDOS.get(i);
ProductPriceStepPackagingDO dbItem = ObjectUtil.clone(m);
dbItem.setId(null);
dbItem.setProductPriceId(priceStepDO.getProductPriceId());
dbItem.setProductPriceStepId(priceStepDO.getId());
dbItem.setRankNum(i + 1);
dbItem.setDeleted(false);
packagingInsertList.add(dbItem);
}
} else {
for (int i = 0; i < productPriceStepPackagingDOS.size(); i++) {
ProductPriceStepPackagingDO item = productPriceStepPackagingDOS.get(i);
String addPricePackagingTypes = item.getPackagingTypes();
if (StringUtils.isBlank(addPricePackagingTypes)) continue;
Long addPricePackagingPriceUnit = item.getPackagingPriceUnit();
if (addPricePackagingPriceUnit == null) continue;
Long addPricePackagingVolumeUnit = item.getPackagingVolumeUnit();
if (addPricePackagingVolumeUnit == null) continue;
Set<String> addPriceTypeSets = new HashSet<>(Arrays.asList(addPricePackagingTypes.split(",")));
//新增BC
ProductPriceStepPackagingDO dbItem = ObjectUtil.clone(item);
dbItem.setId(null);
dbItem.setProductPriceId(priceStepDO.getProductPriceId());
dbItem.setProductPriceStepId(priceStepDO.getId());
dbItem.setRankNum(i + 1);
dbItem.setDeleted(false);
packagingInsertList.add(dbItem);
if (!batchUpdate) continue;
for (ProductPriceStepPackagingDO dbStepPacking : dbStepPackagingList) {
Set<String> dbPriceTypeSets = new HashSet<>(Arrays.asList(dbStepPacking.getPackagingTypes().split(",")));
dbPriceTypeSets.removeAll(addPriceTypeSets);
if (dbPriceTypeSets.isEmpty()) {
packagingDeleteListList.add(dbStepPacking);
} else {
dbStepPacking.setPackagingTypes(Joiner.on(",").join(dbPriceTypeSets));
dbStepPacking.setPackagingPriceUnit(item.getPackagingPriceUnit());
dbStepPacking.setPackagingVolumeUnit(item.getPackagingVolumeUnit());
packagingUpdateList.add(dbStepPacking);
}
}
}
}
}
}
if (CollectionUtil.isNotEmpty(packagingInsertList)) {
productPriceStepPackagingMapper.insertBatchSomeColumn(packagingInsertList);
}
if (CollectionUtil.isNotEmpty(packagingUpdateList)) {
productPriceStepPackagingMapper.updateBatch(packagingUpdateList);
}
if (CollectionUtil.isNotEmpty(packagingDeleteListList)) {
List<Long> dIdList = packagingDeleteListList.stream()
.map(BasePackagingPrice::getId)
.collect(toList());
productPriceStepPackagingMapper.deleteBatchIds(dIdList);
}
if (!batchUpdate) {
List<Long> updateIdList = packagingUpdateList.stream()
.map(ProductPriceStepPackagingDO::getId)
.collect(toList());
dbPackingIdList.removeAll(updateIdList);
if (CollectionUtil.isNotEmpty(dbPackingIdList)) {
productPriceStepPackagingMapper.physicsDeleteById(Joiner.on(",").join(dbPackingIdList));
}
}
}
private void copyStepPrice(List<ProductPriceStepDO> stepList, String transportType, ProductPriceDO productPriceDO, Map<Long, List<ProductPriceStepDO>> dbStepMap, List<ProductPriceStepDO> insertList1, List<ProductPricePackagingDO> productPricePackagingDOS, List<ProductPriceStepDO> updateList) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment