Commit f1954200 authored by liuzeheng's avatar liuzeheng

复制价格包装数据复制

parent 3f1e4bd4
...@@ -159,7 +159,15 @@ public interface WarehouseMapper extends BaseMapperX<WarehouseDO> { ...@@ -159,7 +159,15 @@ public interface WarehouseMapper extends BaseMapperX<WarehouseDO> {
"</if>", "</if>",
"GROUP BY w.title_zh", "GROUP BY w.title_zh",
"</when>", "</when>",
"<when test = 'type == 4'>",
"GROUP BY w.shi",
"</when>",
"<when test = 'type == 5'>",
"GROUP BY w.title_zh",
"</when>",
"</script>" "</script>"
}) })
List<WarehouseTreeRegionVO> getRegionList(@Param("type") Integer type, @Param("regionId") String regionId); List<WarehouseTreeRegionVO> getRegionList(@Param("type") Integer type,@Param("regionId") String regionId,
@Param("destCountryId") String destCountryId,@Param("objectiveId") String objectiveId,
@Param("destWarehouseId") String destWarehouseId);
} }
...@@ -171,5 +171,5 @@ public interface WarehouseService { ...@@ -171,5 +171,5 @@ public interface WarehouseService {
List<WarehouseTreeRegionVO> getWarehouseTreeRegionList(Integer tradeType); List<WarehouseTreeRegionVO> getWarehouseTreeRegionList(Integer tradeType);
List<WarehouseTreeRegionVO> getRegionList(Integer type, String regionId); List<WarehouseTreeRegionVO> getRegionList(Integer type, String regionId, String destCountryId, String objectiveId, String destWarehouseId);
} }
...@@ -514,11 +514,11 @@ public class WarehouseServiceImpl implements WarehouseService { ...@@ -514,11 +514,11 @@ public class WarehouseServiceImpl implements WarehouseService {
} }
@Override @Override
public List<WarehouseTreeRegionVO> getRegionList(Integer type, String regionId) { public List<WarehouseTreeRegionVO> getRegionList(Integer type, String regionId, String destCountryId, String objectiveId, String destWarehouseId) {
if(regionId.equals("")){ if(regionId.equals("")){
return new ArrayList(); return new ArrayList();
} }
List<WarehouseTreeRegionVO> list = warehouseMapper.getRegionList(type,regionId); List<WarehouseTreeRegionVO> list = warehouseMapper.getRegionList(type,regionId,destCountryId,objectiveId,destWarehouseId);
return list; return list;
} }
} }
...@@ -101,8 +101,9 @@ public class WarehouseController { ...@@ -101,8 +101,9 @@ public class WarehouseController {
} }
@GetMapping("/getRegionList") @GetMapping("/getRegionList")
public CommonResult<List<WarehouseTreeRegionVO>> getRegionList(@RequestParam(value = "type", required = false) Integer type,String regionId){ public CommonResult<List<WarehouseTreeRegionVO>> getRegionList(@RequestParam(value = "type", required = false) Integer type,
List<WarehouseTreeRegionVO> list = warehouseService.getRegionList(type,regionId); String regionId,String destCountryId, String objectiveId ,String destWarehouseId){
List<WarehouseTreeRegionVO> list = warehouseService.getRegionList(type,regionId,destCountryId,objectiveId,destWarehouseId);
return success(list); return success(list);
} }
......
...@@ -7,6 +7,9 @@ import lombok.*; ...@@ -7,6 +7,9 @@ import lombok.*;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
/**
* 线路价格特需
*/
@TableName("ecw_product_price_special") @TableName("ecw_product_price_special")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
......
...@@ -3335,12 +3335,35 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -3335,12 +3335,35 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
freightPriceStep.setRankNum(1); freightPriceStep.setRankNum(1);
freightPriceStep.setWeightUnit(price.getTransportPriceUnit()); freightPriceStep.setWeightUnit(price.getTransportPriceUnit());
freightPriceStep.setProductPriceId(price.getId()) ; freightPriceStep.setProductPriceId(price.getId()) ;
if(CollectionUtil.isNotEmpty(respVO.getSpecialList()) ){
List<ProductPriceStepSpecialDO> specialDOList = new ArrayList<>();
respVO.getSpecialList().forEach(sp->{
ProductPriceStepSpecialDO d = new ProductPriceStepSpecialDO();
BeanUtils.copyProperties(sp,d);
specialDOList.add(d) ;
});
specialDOList.stream().distinct();
freightPriceStep.setSpecialList(specialDOList) ;
}
//
if(CollectionUtil.isNotEmpty(respVO.getFreightPricePackagingList())){
List<ProductPriceStepPackagingDO> stepPackagingDOS = new ArrayList<>();
respVO.getFreightPricePackagingList().forEach(pack->{
ProductPriceStepPackagingDO packagingDO = new ProductPriceStepPackagingDO() ;
BeanUtils.copyProperties(pack,packagingDO);
stepPackagingDOS.add(packagingDO) ;
});
stepPackagingDOS.stream().distinct();
freightPriceStep.setPackagingList(stepPackagingDOS) ;
}
freightPriceStepList.add(freightPriceStep); freightPriceStepList.add(freightPriceStep);
createReqVO.setFreightPriceStepList(freightPriceStepList); createReqVO.setFreightPriceStepList(freightPriceStepList);
}else{ }else{
createReqVO.setFreightPriceStepList(respVO.getFreightPriceStepList()) ; createReqVO.setFreightPriceStepList(respVO.getFreightPriceStepList()) ;
} }
if(CollectionUtil.isEmpty(respVO.getClearancePriceStepList()) ){ if(CollectionUtil.isEmpty(respVO.getClearancePriceStepList()) ){
BeanUtils.copyProperties(price,clear); BeanUtils.copyProperties(price,clear);
clear.setStartNum(BigDecimal.valueOf(0)); clear.setStartNum(BigDecimal.valueOf(0));
...@@ -3348,6 +3371,18 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -3348,6 +3371,18 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
clear.setRankNum(2); clear.setRankNum(2);
clear.setWeightUnit(price.getClearancePriceUnit()); clear.setWeightUnit(price.getClearancePriceUnit());
clear.setProductPriceId(price.getId()) ; clear.setProductPriceId(price.getId()) ;
if(CollectionUtil.isNotEmpty(respVO.getClearancePricePackagingList()) ){
List<ProductPriceStepPackagingDO> stepPackagingDOS = new ArrayList<>();
respVO.getClearancePricePackagingList().forEach(pack->{
ProductPriceStepPackagingDO packagingDO = new ProductPriceStepPackagingDO() ;
BeanUtils.copyProperties(pack,packagingDO);
stepPackagingDOS.add(packagingDO) ;
});
stepPackagingDOS.stream().distinct();
clear.setPackagingList(stepPackagingDOS) ;
}
clearancePriceStepList.add(clear); clearancePriceStepList.add(clear);
createReqVO.setClearancePriceStepList(clearancePriceStepList); createReqVO.setClearancePriceStepList(clearancePriceStepList);
}else{ }else{
...@@ -3488,7 +3523,7 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -3488,7 +3523,7 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
List<Long> productPriceIdList = productPriceList.stream().map(ProductPriceDO::getId).collect(Collectors.toList()); List<Long> productPriceIdList = productPriceList.stream().map(ProductPriceDO::getId).collect(Collectors.toList());
List<ProductPriceStepDO> allStepList = buildCopyAllStepList(createReqVO); List<ProductPriceStepDO> allStepList = buildCopyAllStepList(createReqVO);
clearAndSavePriceStepList(productPriceIdList, allStepList, priceTransportTypeMap, createReqVO.isBatch()); copyClearAndSavePriceStepList(productPriceIdList, allStepList, priceTransportTypeMap, createReqVO.isBatch());
long t2 = System.currentTimeMillis(); long t2 = System.currentTimeMillis();
log.info("路线处理耗时:" + (t2 - t1)); log.info("路线处理耗时:" + (t2 - t1));
...@@ -3497,6 +3532,389 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -3497,6 +3532,389 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
handleOrderException(productPriceIdList, createReqVO.isSync()); handleOrderException(productPriceIdList, createReqVO.isSync());
} }
private void copyClearAndSavePriceStepList(List<Long> productPriceIdList, List<ProductPriceStepDO> stepList, Map<Long, String> priceTransportTypeMap, 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 (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>()
.in(ProductPriceStepDO::getProductPriceId, productPriceIdList)
.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<>();
List<ProductPricePackagingDO> productPricePackagingDOS = new ArrayList<>();
for (Long productPriceId : productPriceIdList) {
String transportType = priceTransportTypeMap.get(productPriceId);
List<ProductPriceStepDO> dbPriceStepList = dbStepMap.get(productPriceId);
if(CollectionUtil.isEmpty(dbPriceStepList)) {
for (ProductPriceStepDO stepItem : stepList) {
if(stepItem.getTransportPrice() == null && stepItem.getClearancePrice() == null
&& stepItem.getAllPrice() == null) continue;
ProductPriceStepDO dbItem = ObjectUtil.clone(stepItem);
dbItem.setId(null);
dbItem.setProductPriceId(productPriceId);
initBasePrice(dbItem, transportType);
insertList1.add(dbItem);
if(CollectionUtil.isNotEmpty(stepItem.getPackagingList())){
stepItem.getPackagingList().forEach(pg->{
ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO() ;
BeanUtils.copyProperties(pg,pricePackagingDO);
pricePackagingDO.setId(null);
productPricePackagingDOS.add(pricePackagingDO);
});
}
}
} else {
//更新
for (ProductPriceStepDO stepItem : stepList) {
boolean update = false;
for (ProductPriceStepDO dbStepItem : dbPriceStepList) {
if(!stepItem.getPriceType().equals(dbStepItem.getPriceType())) continue;
if(stepItem.getStartNum().intValue() != dbStepItem.getStartNum().intValue() ||
stepItem.getEndNum().intValue() != dbStepItem.getEndNum().intValue() ||
stepItem.getWeightUnit().longValue() != dbStepItem.getWeightUnit().longValue()) {
continue;
}
//更新
update = true;
dbStepItem.setSpecialList(stepItem.getSpecialList());
dbStepItem.setPackagingList(stepItem.getPackagingList());
updateList.add(dbStepItem);
if(stepItem.getTransportPrice() == null && stepItem.getClearancePrice() == null
&& stepItem.getAllPrice() == null) continue;
if(stepItem.getTransportPrice() != null) {
dbStepItem.setTransportPrice(stepItem.getTransportPrice());
}
if(stepItem.getTransportPriceUnit() != null) {
dbStepItem.setTransportPriceUnit(stepItem.getTransportPriceUnit());
}
if(stepItem.getTransportVolumeUnit() != null) {
dbStepItem.setTransportVolumeUnit(stepItem.getTransportVolumeUnit());
}
if(stepItem.getClearancePrice() != null) {
dbStepItem.setClearancePrice(stepItem.getClearancePrice());
}
if(stepItem.getClearancePriceUnit() != null) {
dbStepItem.setClearancePriceUnit(stepItem.getClearancePriceUnit());
}
if(stepItem.getClearanceVolumeUnit() != null) {
dbStepItem.setClearanceVolumeUnit(stepItem.getClearanceVolumeUnit());
}
if(stepItem.getAllPrice() != null) {
dbStepItem.setAllPrice(stepItem.getAllPrice());
}
if(stepItem.getAllPriceUnit() != null) {
dbStepItem.setAllPriceUnit(stepItem.getAllPriceUnit());
}
if(stepItem.getAllVolumeUnit() != null) {
dbStepItem.setAllVolumeUnit(stepItem.getAllVolumeUnit());
}
if(stepItem.getPriceType() != null) {
dbStepItem.setPriceType(stepItem.getPriceType());
}
if(stepItem.getRankNum() != null) {
dbStepItem.setRankNum(stepItem.getRankNum());
}
break;
}
if(!update) {
ProductPriceStepDO dbItem = ObjectUtil.clone(stepItem);
dbItem.setId(null);
dbItem.setProductPriceId(productPriceId);
initBasePrice(dbItem, transportType);
insertList1.add(dbItem);
}
if(CollectionUtil.isNotEmpty(stepItem.getPackagingList())){
stepItem.getPackagingList().forEach(pg->{
ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO() ;
BeanUtils.copyProperties(pg,pricePackagingDO);
pricePackagingDO.setId(null);
pricePackagingDO.setProductPriceId(productPriceId) ;
pricePackagingDO.setPriceType(stepItem.getPriceType()) ;
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<>();
List<ProductPriceSpecialDO> priceSpecialInsert = new ArrayList<>();
List<ProductPriceSpecialDO> priceSpecialUpdate = new ArrayList<>();
for (ProductPriceStepDO stepDO : insertList1) {
String transportType = priceTransportTypeMap.get(stepDO.getProductPriceId());
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);
//线路价格特需
ProductPriceSpecialDO priceSpecialDO = new ProductPriceSpecialDO();
BeanUtils.copyProperties(dbItem,priceSpecialDO);
priceSpecialDO.setId(null);
priceSpecialInsert.add(priceSpecialDO) ;
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());
}
ProductPriceSpecialDO priceSpecialDO = new ProductPriceSpecialDO() ;
BeanUtils.copyProperties(dbStepSpecialDO,priceSpecialDO);
priceSpecialDO.setId(null) ;
priceSpecialUpdate.add(priceSpecialDO) ;
specialUpdateList.add(dbStepSpecialDO);
}
}
}
}
// List<ProductPriceSpecialDO> priceSpecialInsert = new ArrayList<>();
// List<ProductPriceSpecialDO> priceSpecialUpdate = new ArrayList<>();
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(priceSpecialUpdate.get(0).getProductPriceId().toString()); ;
productPriceSpecialMapper.insertBatch(priceSpecialUpdate);
}
if(CollectionUtil.isNotEmpty(productPricePackagingDOS)){
productPricePackagingMapper.physicsDelete(productPricePackagingDOS.get(0).getProductPriceId().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);
}
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));
}
}
}
/** /**
* 复制另一商品价格的 阶梯价格 * 复制另一商品价格的 阶梯价格
* @param productPriceStepBaseVO * @param productPriceStepBaseVO
......
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