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

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

parent 61755259
......@@ -3611,6 +3611,7 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
}
private void copyClearAndSavePriceStepList(ProductPriceDO productPriceDO, List<ProductPriceStepDO> stepList, String transportType, boolean batchUpdate) {
if (productPriceDO.getStepPrice() == 1) {
if (stepList == null) stepList = new ArrayList<>();
stepList = stepList.stream()
......@@ -3618,10 +3619,17 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
t.getWeightUnit() != null &&
t.getEndNum() != null)
.collect(Collectors.toList());
}
if (productPriceDO.getStepPrice() == 1 && CollectionUtil.isEmpty(stepList)) return;
if (CollectionUtil.isEmpty(stepList)) return;
List<ProductPriceStepDO> insertList1 = new ArrayList<>();
List<ProductPriceStepDO> updateList = new ArrayList<>();
List<ProductPricePackagingDO> productPricePackagingDOS = new ArrayList<>();
List<ProductPriceSpecialDO> priceSpecialUpdate = new ArrayList<>();
if (productPriceDO.getStepPrice() == 1) {
Collection<Integer> priceTypes = stepList.stream()
.map(ProductPriceStepDO::getPriceType)
.collect(Collectors.toSet());
......@@ -3632,52 +3640,7 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
);
Map<Long, List<ProductPriceStepDO>> dbStepMap = dbStepList.stream()
.collect(Collectors.groupingBy(ProductPriceStepDO::getProductPriceId));
List<ProductPriceStepDO> insertList1 = new ArrayList<>();
List<ProductPriceStepDO> updateList = new ArrayList<>();
List<ProductPricePackagingDO> productPricePackagingDOS = new ArrayList<>();
List<ProductPriceSpecialDO> priceSpecialUpdate = new ArrayList<>();
if (productPriceDO.getStepPrice() == 1) {
copyStepPrice(stepList, transportType, productPriceDO, dbStepMap, insertList1, productPricePackagingDOS, updateList);
} else {
if (CollectionUtil.isNotEmpty(productPriceDO.getSpecialDOList())) {
for (ProductPriceSpecialDO specialDO : productPriceDO.getSpecialDOList()) {
ProductPriceSpecialDO priceSpecialDO = new ProductPriceSpecialDO();
BeanUtils.copyProperties(specialDO, priceSpecialDO);
priceSpecialDO.setId(null);
priceSpecialDO.setProductPriceId(productPriceDO.getId());
priceSpecialUpdate.add(priceSpecialDO);
}
}
if (CollectionUtil.isNotEmpty(productPriceDO.getFreightPricePackagingList())) {
for (ProductPricePackagingDO packagingDO : productPriceDO.getFreightPricePackagingList()) {
ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO();
BeanUtils.copyProperties(packagingDO, pricePackagingDO);
pricePackagingDO.setId(null);
pricePackagingDO.setProductPriceId(productPriceDO.getId());
productPricePackagingDOS.add(pricePackagingDO);
}
}
if (CollectionUtil.isNotEmpty(productPriceDO.getClearancePricePackagingList())) {
for (ProductPricePackagingDO packagingDO : productPriceDO.getClearancePricePackagingList()) {
ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO();
BeanUtils.copyProperties(packagingDO, pricePackagingDO);
pricePackagingDO.setId(null);
pricePackagingDO.setProductPriceId(productPriceDO.getId());
productPricePackagingDOS.add(pricePackagingDO);
}
}
if (CollectionUtil.isNotEmpty(productPriceDO.getFullPricePackagingList())) {
for (ProductPricePackagingDO packagingDO : productPriceDO.getFullPricePackagingList()) {
ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO();
BeanUtils.copyProperties(packagingDO, pricePackagingDO);
pricePackagingDO.setId(null);
pricePackagingDO.setProductPriceId(productPriceDO.getId());
productPricePackagingDOS.add(pricePackagingDO);
}
}
}
if (CollectionUtil.isNotEmpty(insertList1)) {
productPriceStepMapper.insertBatchSomeColumn(insertList1);
}
......@@ -3787,7 +3750,6 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
}
}
}
if (CollectionUtil.isNotEmpty(specialInsertList)) {
productPriceStepSpecialMapper.insertBatchSomeColumn(specialInsertList);
}
......@@ -3795,19 +3757,6 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
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)
......@@ -3915,6 +3864,55 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
productPriceStepPackagingMapper.physicsDeleteById(Joiner.on(",").join(dbPackingIdList));
}
}
} else {
if (CollectionUtil.isNotEmpty(productPriceDO.getSpecialDOList())) {
for (ProductPriceSpecialDO specialDO : productPriceDO.getSpecialDOList()) {
ProductPriceSpecialDO priceSpecialDO = new ProductPriceSpecialDO();
BeanUtils.copyProperties(specialDO, priceSpecialDO);
priceSpecialDO.setId(null);
priceSpecialDO.setProductPriceId(productPriceDO.getId());
priceSpecialUpdate.add(priceSpecialDO);
}
}
if (CollectionUtil.isNotEmpty(productPriceDO.getFreightPricePackagingList())) {
for (ProductPricePackagingDO packagingDO : productPriceDO.getFreightPricePackagingList()) {
ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO();
BeanUtils.copyProperties(packagingDO, pricePackagingDO);
pricePackagingDO.setId(null);
pricePackagingDO.setProductPriceId(productPriceDO.getId());
productPricePackagingDOS.add(pricePackagingDO);
}
}
if (CollectionUtil.isNotEmpty(productPriceDO.getClearancePricePackagingList())) {
for (ProductPricePackagingDO packagingDO : productPriceDO.getClearancePricePackagingList()) {
ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO();
BeanUtils.copyProperties(packagingDO, pricePackagingDO);
pricePackagingDO.setId(null);
pricePackagingDO.setProductPriceId(productPriceDO.getId());
productPricePackagingDOS.add(pricePackagingDO);
}
}
if (CollectionUtil.isNotEmpty(productPriceDO.getFullPricePackagingList())) {
for (ProductPricePackagingDO packagingDO : productPriceDO.getFullPricePackagingList()) {
ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO();
BeanUtils.copyProperties(packagingDO, pricePackagingDO);
pricePackagingDO.setId(null);
pricePackagingDO.setProductPriceId(productPriceDO.getId());
productPricePackagingDOS.add(pricePackagingDO);
}
}
if (CollectionUtil.isNotEmpty(priceSpecialUpdate)) {
productPriceSpecialMapper.physicsDelete(productPriceDO.getId().toString());
productPriceSpecialMapper.insertBatch(priceSpecialUpdate);
}
if (CollectionUtil.isNotEmpty(productPricePackagingDOS)) {
productPricePackagingMapper.physicsDelete(productPriceDO.getId().toString());
productPricePackagingMapper.insertBatch(productPricePackagingDOS);
}
}
}
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