Commit 416d4f6d authored by zhangfeng's avatar zhangfeng

Merge remote-tracking branch 'origin/dev' into dev

parents 70dfec54 4b0575aa
...@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
@Data @Data
public class BasePrice extends BaseDO { public class BasePrice extends BaseDO {
...@@ -92,4 +93,21 @@ public class BasePrice extends BaseDO { ...@@ -92,4 +93,21 @@ public class BasePrice extends BaseDO {
@JsonIgnore @JsonIgnore
private int productPriceEmptyType = 0; private int productPriceEmptyType = 0;
@ApiModelProperty(value = "特殊需求列表")
@TableField(exist = false)
private List<ProductPriceSpecialDO> specialDOList;
@ApiModelProperty(value = "运费包装价格列表")
@TableField(exist = false)
private List<ProductPricePackagingDO> freightPricePackagingList;
@ApiModelProperty(value = "清关费包装价格列表")
@TableField(exist = false)
private List<ProductPricePackagingDO> clearancePricePackagingList;
@ApiModelProperty(value = "全包价包装价格列表")
@TableField(exist = false)
private List<ProductPricePackagingDO> fullPricePackagingList;
} }
...@@ -193,7 +193,7 @@ public class ProductPriceExcelExportListener { ...@@ -193,7 +193,7 @@ public class ProductPriceExcelExportListener {
StringBuilder ytqgfSb = new StringBuilder(); StringBuilder ytqgfSb = new StringBuilder();
StringBuilder ddyfSb = new StringBuilder(); StringBuilder ddyfSb = new StringBuilder();
StringBuilder ddqgfSb = new StringBuilder(); StringBuilder ddqgfSb = new StringBuilder();
if (item.getPriceType() == 0) {
if (CollectionUtil.isNotEmpty(yfStepList)) { if (CollectionUtil.isNotEmpty(yfStepList)) {
yfStepList.sort(Comparator.comparing(ProductPriceStepDO::getRankNum)); yfStepList.sort(Comparator.comparing(ProductPriceStepDO::getRankNum));
for (int j = 1; j <= yfStepList.size(); j++) { for (int j = 1; j <= yfStepList.size(); j++) {
...@@ -232,7 +232,7 @@ public class ProductPriceExcelExportListener { ...@@ -232,7 +232,7 @@ public class ProductPriceExcelExportListener {
String unit = ""; String unit = "";
if (weightUnit != null) { if (weightUnit != null) {
UnitDO unitDO = unitMap.get(weightUnit.intValue()); UnitDO unitDO = unitMap.get(weightUnit.intValue());
unit = Objects.nonNull(unitDO)?unitDO.getTitleZh():"空"; unit = Objects.nonNull(unitDO) ? unitDO.getTitleZh() : "空";
} }
BigDecimal startNum = stepDO.getStartNum(); BigDecimal startNum = stepDO.getStartNum();
BigDecimal endNum = stepDO.getEndNum(); BigDecimal endNum = stepDO.getEndNum();
...@@ -282,7 +282,7 @@ public class ProductPriceExcelExportListener { ...@@ -282,7 +282,7 @@ public class ProductPriceExcelExportListener {
String unit = ""; String unit = "";
if (weightUnit != null) { if (weightUnit != null) {
UnitDO unitDO = unitMap.get(weightUnit.intValue()); UnitDO unitDO = unitMap.get(weightUnit.intValue());
unit = unitDO.getTitleZh(); unit = Objects.nonNull(unitDO) ? unitDO.getTitleZh() : "空";
} }
BigDecimal startNum = stepDO.getStartNum(); BigDecimal startNum = stepDO.getStartNum();
BigDecimal endNum = stepDO.getEndNum(); BigDecimal endNum = stepDO.getEndNum();
...@@ -293,7 +293,8 @@ public class ProductPriceExcelExportListener { ...@@ -293,7 +293,8 @@ public class ProductPriceExcelExportListener {
} }
} }
} }
}
if (item.getPriceType() == 1) {
if (CollectionUtil.isNotEmpty(qbjStepList) && item.getPriceType() == 1) { if (CollectionUtil.isNotEmpty(qbjStepList) && item.getPriceType() == 1) {
qbjStepList.sort(Comparator.comparing(ProductPriceStepDO::getRankNum)); qbjStepList.sort(Comparator.comparing(ProductPriceStepDO::getRankNum));
for (int j = 1; j <= qbjStepList.size(); j++) { for (int j = 1; j <= qbjStepList.size(); j++) {
...@@ -343,7 +344,7 @@ public class ProductPriceExcelExportListener { ...@@ -343,7 +344,7 @@ public class ProductPriceExcelExportListener {
} }
} }
} }
}
transportPrice = transportPriceSb.toString(); transportPrice = transportPriceSb.toString();
clearancePrice = clearancePriceSb.toString(); clearancePrice = clearancePriceSb.toString();
......
...@@ -1618,7 +1618,12 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -1618,7 +1618,12 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
//设置特殊需求列表 //设置特殊需求列表
productPriceRespVO.setSpecialList(productPriceSpecialService.getProductPriceSpecialList(id)); productPriceRespVO.setSpecialList(productPriceSpecialService.getProductPriceSpecialList(id));
List<ProductPricePackagingDO> packagingDOList = productPricePackagingMapper.selectList(new LambdaQueryWrapperX<ProductPricePackagingDO>().eq(ProductPricePackagingDO::getProductPriceId, id));
if (CollectionUtil.isNotEmpty(packagingDOList)) {
productPriceRespVO.setFreightPricePackagingList(packagingDOList.stream().filter(p -> p.getPriceType() == PriceTypeEnum.FREIGHT.getPriceType()).collect(toList()));
productPriceRespVO.setClearancePricePackagingList(packagingDOList.stream().filter(p -> p.getPriceType() == PriceTypeEnum.CLEARANCE.getPriceType()).collect(toList()));
productPriceRespVO.setFullPricePackagingList(packagingDOList.stream().filter(p -> p.getPriceType() == PriceTypeEnum.FULL_PRICE.getPriceType()).collect(toList()));
}
List<ProductPriceStepDO> priceStepDOList = productPriceStepService.getProductPriceStepList(id); List<ProductPriceStepDO> priceStepDOList = productPriceStepService.getProductPriceStepList(id);
List<Long> stepIdList = priceStepDOList.stream() List<Long> stepIdList = priceStepDOList.stream()
...@@ -3458,6 +3463,7 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -3458,6 +3463,7 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
lineChannelList.add(vo); lineChannelList.add(vo);
createReqVO.setLineChannelList(lineChannelList); createReqVO.setLineChannelList(lineChannelList);
ProductPriceRespVO respVO = this.getProductPriceDetail(price.getId()); ProductPriceRespVO respVO = this.getProductPriceDetail(price.getId());
price.setSpecialDOList(respVO.getSpecialList());
//阶梯运费价格列表 //阶梯运费价格列表
List<ProductPriceStepDO> freightPriceStepList = new ArrayList<>(); List<ProductPriceStepDO> freightPriceStepList = new ArrayList<>();
//阶梯清关费价格列表 //阶梯清关费价格列表
...@@ -3467,134 +3473,22 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -3467,134 +3473,22 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
ProductPriceStepDO freightPriceStep = new ProductPriceStepDO(); ProductPriceStepDO freightPriceStep = new ProductPriceStepDO();
ProductPriceStepDO clear = new ProductPriceStepDO(); ProductPriceStepDO clear = new ProductPriceStepDO();
if (createReqVO.getPriceType() == 1) { if (createReqVO.getPriceType() == 1) {
price.setFullPricePackagingList(respVO.getFullPricePackagingList());
if (CollectionUtil.isNotEmpty(respVO.getFullPriceStepList())) { if (CollectionUtil.isNotEmpty(respVO.getFullPriceStepList())) {
// respVO.getFullPriceStepList().forEach(pack -> {
// ProductPriceStepDO priceStepDO = new ProductPriceStepDO();
// BeanUtils.copyProperties(pack, priceStepDO);
// priceStepDO.setId(null);
// priceStepDO.setStartNum(BigDecimal.valueOf(0));
// priceStepDO.setEndNum(BigDecimal.valueOf(0));
// priceStepDO.setWeightUnit(price.getTransportPriceUnit());
// priceStepDO.setAllPrice(respVO.getAllPrice());
// priceStepDO.setAllPriceUnit(respVO.getAllPriceUnit());
// priceStepDO.setAllVolumeUnit(respVO.getAllVolumeUnit());
// if (CollectionUtil.isNotEmpty(respVO.getSpecialList())) {
// List<ProductPriceStepSpecialDO> specialList = new ArrayList<>();
// respVO.getSpecialList().forEach(sp -> {
// ProductPriceStepSpecialDO specialDO = new ProductPriceStepSpecialDO();
// BeanUtils.copyProperties(sp, specialDO);
// specialDO.setId(null);
// specialList.add(specialDO);
// });
// priceStepDO.setSpecialList(specialList);
// }
// fullPriceStepList.add(priceStepDO);
// });
createReqVO.setFullPriceStepList(respVO.getFullPriceStepList()); createReqVO.setFullPriceStepList(respVO.getFullPriceStepList());
} }
} else { } else {
// if (CollectionUtil.isEmpty(respVO.getFreightPriceStepList())) { price.setFreightPricePackagingList(respVO.getFullPricePackagingList());
// BeanUtils.copyProperties(price, freightPriceStep); price.setClearancePricePackagingList(respVO.getFullPricePackagingList());
// freightPriceStep.setStartNum(BigDecimal.valueOf(0));
// freightPriceStep.setEndNum(BigDecimal.valueOf(0));
// freightPriceStep.setRankNum(1);
// freightPriceStep.setWeightUnit(price.getTransportPriceUnit());
// 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);
// }
// if (respVO.getPriceType() == 1) {
// if (CollectionUtil.isNotEmpty(respVO.getFullPricePackagingList())) {
// List<ProductPriceStepPackagingDO> specialDOList = new ArrayList<>();
// respVO.getFullPricePackagingList().forEach(pack -> {
// ProductPriceStepPackagingDO packagingDO = new ProductPriceStepPackagingDO();
// BeanUtils.copyProperties(pack, packagingDO);
// packagingDO.setId(null);
//
// specialDOList.add(packagingDO);
// });
//
// freightPriceStep.setPackagingList(specialDOList);
//
// }
// } else {
//
// }
// freightPriceStepList.add(freightPriceStep);
//
// createReqVO.setFreightPriceStepList(freightPriceStepList);
// } else {
// createReqVO.setFreightPriceStepList(respVO.getFreightPriceStepList());
// }
if (CollectionUtil.isNotEmpty(respVO.getFreightPriceStepList())) { if (CollectionUtil.isNotEmpty(respVO.getFreightPriceStepList())) {
createReqVO.setFreightPriceStepList(respVO.getFreightPriceStepList()); createReqVO.setFreightPriceStepList(respVO.getFreightPriceStepList());
} }
// if (CollectionUtil.isEmpty(respVO.getClearancePriceStepList())) {
// BeanUtils.copyProperties(price, clear);
// clear.setStartNum(BigDecimal.valueOf(0));
// clear.setEndNum(BigDecimal.valueOf(0));
// clear.setRankNum(2);
// clear.setWeightUnit(price.getClearancePriceUnit());
// 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);
// createReqVO.setClearancePriceStepList(clearancePriceStepList);
// } else {
// createReqVO.setClearancePriceStepList(respVO.getClearancePriceStepList());
// }
if (CollectionUtil.isNotEmpty(respVO.getClearancePriceStepList())) { if (CollectionUtil.isNotEmpty(respVO.getClearancePriceStepList())) {
createReqVO.setClearancePriceStepList(respVO.getClearancePriceStepList()); createReqVO.setClearancePriceStepList(respVO.getClearancePriceStepList());
} }
} }
// if(CollectionUtil.isNotEmpty(respVO.getFullPricePackagingList())){
//
// respVO.getFullPricePackagingList().forEach(pack->{
// ProductPriceStepDO packagingDO = new ProductPriceStepDO() ;
// BeanUtils.copyProperties(pack,packagingDO);
// packagingDO.setId(null);
//
// packagingDO.setTransportPrice(pack.getPackagingPrice());
// packagingDO.setTransportPriceUnit(pack.getPackagingPriceUnit());
//
// fullPriceStepList.add(packagingDO) ;
// });
//
// createReqVO.setFullPriceStepList(fullPriceStepList);
// }
//ProductDO productDO = checkUpdateStatus(lineChannelList, createReqVO.getProductId()); //ProductDO productDO = checkUpdateStatus(lineChannelList, createReqVO.getProductId());
ProductDO productDO = productService.getProduct(createReqVO.getProductId()); ProductDO productDO = productService.getProduct(createReqVO.getProductId());
WarehouseLineSearchVO searchVO = new WarehouseLineSearchVO(); WarehouseLineSearchVO searchVO = new WarehouseLineSearchVO();
...@@ -3608,8 +3502,9 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -3608,8 +3502,9 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
createReqVO.setSync(true); createReqVO.setSync(true);
createReqVO.setBatch(false); createReqVO.setBatch(false);
copyPriceUpdateAir(createReqVO, copyPriceUpdateAir(createReqVO,
vo,
warehouseLineList, warehouseLineList,
productList, productDO,
price); price);
} }
} }
...@@ -3622,47 +3517,34 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -3622,47 +3517,34 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
* *
* @param createReqVO * @param createReqVO
* @param warehouseLineList * @param warehouseLineList
* @param productList * @param productDO
* @param productPrice * @param productPrice
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void copyPriceUpdateAir(ProductPriceAirCreateReqVO createReqVO, List<WarehouseLineDO> warehouseLineList, List<ProductDO> productList, ProductPriceDO productPrice) { public void copyPriceUpdateAir(ProductPriceAirCreateReqVO createReqVO, LineChannelVo vo, List<WarehouseLineDO> warehouseLineList, ProductDO productDO, ProductPriceDO productPrice) {
long t1 = System.currentTimeMillis(); long t1 = System.currentTimeMillis();
Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
checkAndUpdateStepToMainPrice(productPrice, createReqVO); checkAndUpdateStepToMainPrice(productPrice, createReqVO);
List<LineChannelVo> lineChannelList = createReqVO.getLineChannelList();
Set<Long> lineIdList = lineChannelList.stream()
.map(LineChannelVo::getLineId)
.collect(Collectors.toSet());
Map<Long, String> lineTransportTypeMap = warehouseLineList.stream() Map<Long, String> lineTransportTypeMap = warehouseLineList.stream()
.collect(Collectors.toMap(WarehouseLineDO::getId, WarehouseLineDO::getTransportType)); .collect(Collectors.toMap(WarehouseLineDO::getId, WarehouseLineDO::getTransportType));
List<Long> idList = productList.stream()
.map(ProductDO::getId)
.collect(toList());
//这个产品这么多线路已有的价格 //这个产品这么多线路已有的价格
List<ProductPriceDO> dbPriceList = productPriceMapper.selectList(new LambdaQueryWrapperX<ProductPriceDO>() List<ProductPriceDO> dbPriceList = productPriceMapper.selectList(new LambdaQueryWrapperX<ProductPriceDO>()
.in(ProductPriceDO::getWarehouseLineId, lineIdList) .eq(ProductPriceDO::getWarehouseLineId, vo.getLineId())
.in(ProductPriceDO::getProductId, idList)); .eq(ProductPriceDO::getProductId, productDO.getId()));
Map<String, ProductPriceDO> productLineChannelMap = dbPriceList.stream() Map<String, ProductPriceDO> productLineChannelMap = dbPriceList.stream()
.collect(Collectors.toMap(t -> t.getProductId() + "-" + t.getWarehouseLineId() + "-" + t.getShippingChannelId(), v -> v, (v1, v2) -> v2)); .collect(Collectors.toMap(t -> t.getProductId() + "-" + t.getWarehouseLineId() + "-" + t.getShippingChannelId(), v -> v, (v1, v2) -> v2));
List<ProductPriceDO> insertList = new ArrayList<>();
List<ProductPriceDO> updateList = new ArrayList<>();
List<ProductPriceDO> snapshotList = new ArrayList<>(); List<ProductPriceDO> snapshotList = new ArrayList<>();
Date current = new Date(); Date current = new Date();
for (Long productId : idList) { Long lineId = vo.getLineId();
for (LineChannelVo lineChannel : lineChannelList) { Long shippingChannelId = vo.getShippingChannelId();
Long lineId = lineChannel.getLineId(); String key = productDO.getId() + "-" + lineId + "-" + shippingChannelId;
Long shippingChannelId = lineChannel.getShippingChannelId();
String key = productId + "-" + lineId + "-" + shippingChannelId;
ProductPriceDO dbItem; ProductPriceDO dbItem;
if (productLineChannelMap.containsKey(key)) { if (productLineChannelMap.containsKey(key)) {
...@@ -3673,10 +3555,10 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -3673,10 +3555,10 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
snapshotList.add(snapshot); snapshotList.add(snapshot);
dbItem.setUpdater(String.valueOf(loginUserId)); dbItem.setUpdater(String.valueOf(loginUserId));
updateColumn(dbItem, productPrice); updateColumn(dbItem, productPrice);
updateList.add(dbItem); productPriceMapper.updateById(dbItem);
} else { } else {
dbItem = ObjectUtil.clone(productPrice); dbItem = ObjectUtil.clone(productPrice);
dbItem.setProductId(productId); dbItem.setProductId(productDO.getId());
dbItem.setWarehouseLineId(lineId); dbItem.setWarehouseLineId(lineId);
dbItem.setShippingChannelId(shippingChannelId); dbItem.setShippingChannelId(shippingChannelId);
...@@ -3707,42 +3589,35 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -3707,42 +3589,35 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
dbItem.setBlacklist(0); dbItem.setBlacklist(0);
dbItem.setStatus(0); dbItem.setStatus(0);
dbItem.setCreateTime(current); dbItem.setCreateTime(current);
insertList.add(dbItem); productPriceMapper.insert(dbItem);
} }
dbItem.setUpdateTime(current); dbItem.setUpdateTime(current);
String transportType = lineTransportTypeMap.get(lineId); String transportType = lineTransportTypeMap.get(lineId);
initBasePrice(dbItem, transportType); initBasePrice(dbItem, transportType);
}
}
if (CollectionUtil.isNotEmpty(insertList)) {
productPriceMapper.insertBatchSomeColumn(insertList);
}
if (CollectionUtil.isNotEmpty(updateList)) {
productPriceMapper.updateBatch(updateList);
}
List<ProductPriceDO> productPriceList = new ArrayList<>();
productPriceList.addAll(insertList);
productPriceList.addAll(updateList);
Map<Long, String> priceTransportTypeMap = new HashMap<>();
productPriceList.forEach(t -> priceTransportTypeMap.put(t.getId(), lineTransportTypeMap.get(t.getWarehouseLineId())));
//添加修改日志,需要查询特需和阶梯,所以需要在修改之前执行 //添加修改日志,需要查询特需和阶梯,所以需要在修改之前执行
batchAddSnapshot(snapshotList); batchAddSnapshot(snapshotList);
List<Long> productPriceIdList = productPriceList.stream().map(ProductPriceDO::getId).collect(Collectors.toList()); dbItem.setSpecialDOList(productPrice.getSpecialDOList());
if (productPrice.getPriceType() == 1) {
dbItem.setFullPricePackagingList(productPrice.getFullPricePackagingList());
} else {
dbItem.setFreightPricePackagingList(productPrice.getFullPricePackagingList());
dbItem.setClearancePricePackagingList(productPrice.getFullPricePackagingList());
}
List<ProductPriceStepDO> allStepList = buildCopyAllStepList(createReqVO); List<ProductPriceStepDO> allStepList = buildCopyAllStepList(createReqVO);
copyClearAndSavePriceStepList(productPriceIdList, allStepList, priceTransportTypeMap, createReqVO.isBatch()); copyClearAndSavePriceStepList(dbItem, allStepList, lineTransportTypeMap.get(dbItem.getWarehouseLineId()), createReqVO.isBatch());
long t2 = System.currentTimeMillis(); long t2 = System.currentTimeMillis();
log.info("路线处理耗时:" + (t2 - t1)); log.info("路线处理耗时:" + (t2 - t1));
deleteKey(idList, lineChannelList); deleteKey(Collections.singletonList(productDO.getId()), Collections.singletonList(vo));
handleOrderException(productPriceIdList, handleOrderException(Collections.singletonList(dbItem.getId()),
createReqVO.isSync()); createReqVO.isSync());
} }
private void copyClearAndSavePriceStepList(List<Long> productPriceIdList, List<ProductPriceStepDO> stepList, Map<Long, String> priceTransportTypeMap, boolean batchUpdate) { private void copyClearAndSavePriceStepList(ProductPriceDO productPriceDO, List<ProductPriceStepDO> stepList, String transportType, boolean batchUpdate) {
if (productPriceDO.getStepPrice() == 1) {
if (stepList == null) stepList = new ArrayList<>(); if (stepList == null) stepList = new ArrayList<>();
stepList = stepList.stream() stepList = stepList.stream()
...@@ -3750,146 +3625,28 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -3750,146 +3625,28 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
t.getWeightUnit() != null && t.getWeightUnit() != null &&
t.getEndNum() != null) t.getEndNum() != null)
.collect(Collectors.toList()); .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() Collection<Integer> priceTypes = stepList.stream()
.map(ProductPriceStepDO::getPriceType) .map(ProductPriceStepDO::getPriceType)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
priceTypes.add(PriceTypeEnum.FULL_PRICE.getPriceType()); priceTypes.add(PriceTypeEnum.FULL_PRICE.getPriceType());
List<ProductPriceStepDO> dbStepList = productPriceStepMapper.selectList(new LambdaQueryWrapper<ProductPriceStepDO>() List<ProductPriceStepDO> dbStepList = productPriceStepMapper.selectList(new LambdaQueryWrapper<ProductPriceStepDO>()
.in(ProductPriceStepDO::getProductPriceId, productPriceIdList) .eq(ProductPriceStepDO::getProductPriceId, productPriceDO.getId())
.in(ProductPriceStepDO::getPriceType, priceTypes) .in(ProductPriceStepDO::getPriceType, priceTypes)
); );
Map<Long, List<ProductPriceStepDO>> dbStepMap = dbStepList.stream() Map<Long, List<ProductPriceStepDO>> dbStepMap = dbStepList.stream()
.collect(Collectors.groupingBy(ProductPriceStepDO::getProductPriceId)); .collect(Collectors.groupingBy(ProductPriceStepDO::getProductPriceId));
copyStepPrice(stepList, transportType, productPriceDO, dbStepMap, insertList1, productPricePackagingDOS, updateList);
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(stepItem.getPriceType()==1){
//
// ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO() ;
// BeanUtils.copyProperties(stepItem,pricePackagingDO);
// pricePackagingDO.setId(null);
// pricePackagingDO.setProductPriceId(productPriceId) ;
// productPricePackagingDOS.add(pricePackagingDO);
//
// }else {
// 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(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)) { if (CollectionUtil.isNotEmpty(insertList1)) {
productPriceStepMapper.insertBatchSomeColumn(insertList1); productPriceStepMapper.insertBatchSomeColumn(insertList1);
} }
...@@ -3937,11 +3694,8 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -3937,11 +3694,8 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
List<ProductPriceStepSpecialDO> specialInsertList = new ArrayList<>(); List<ProductPriceStepSpecialDO> specialInsertList = new ArrayList<>();
List<ProductPriceStepSpecialDO> specialUpdateList = new ArrayList<>(); List<ProductPriceStepSpecialDO> specialUpdateList = new ArrayList<>();
List<ProductPriceSpecialDO> priceSpecialInsert = new ArrayList<>();
List<ProductPriceSpecialDO> priceSpecialUpdate = new ArrayList<>();
for (ProductPriceStepDO stepDO : insertList1) { for (ProductPriceStepDO stepDO : insertList1) {
String transportType = priceTransportTypeMap.get(stepDO.getProductPriceId());
List<ProductPriceStepSpecialDO> productPriceStepSpecialDOS = stepDO.getSpecialList(); List<ProductPriceStepSpecialDO> productPriceStepSpecialDOS = stepDO.getSpecialList();
//过滤掉价格为空的数据 //过滤掉价格为空的数据
if (CollectionUtil.isNotEmpty(productPriceStepSpecialDOS)) { if (CollectionUtil.isNotEmpty(productPriceStepSpecialDOS)) {
...@@ -3966,12 +3720,6 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -3966,12 +3720,6 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
dbItem.setProductPriceId(stepDO.getProductPriceId()); dbItem.setProductPriceId(stepDO.getProductPriceId());
dbItem.setProductPriceStepId(stepDO.getId()); dbItem.setProductPriceStepId(stepDO.getId());
initBasePrice(dbItem, transportType); initBasePrice(dbItem, transportType);
//线路价格特需
ProductPriceSpecialDO priceSpecialDO = new ProductPriceSpecialDO();
BeanUtils.copyProperties(dbItem, priceSpecialDO);
priceSpecialDO.setId(null);
priceSpecialInsert.add(priceSpecialDO);
specialInsertList.add(dbItem); specialInsertList.add(dbItem);
} else { } else {
if (stepSpecialDO.getTransportPrice() != null) { if (stepSpecialDO.getTransportPrice() != null) {
...@@ -4001,44 +3749,20 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -4001,44 +3749,20 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
if (stepSpecialDO.getAllVolumeUnit() != null) { if (stepSpecialDO.getAllVolumeUnit() != null) {
dbStepSpecialDO.setAllVolumeUnit(stepSpecialDO.getAllVolumeUnit()); dbStepSpecialDO.setAllVolumeUnit(stepSpecialDO.getAllVolumeUnit());
} }
ProductPriceSpecialDO priceSpecialDO = new ProductPriceSpecialDO();
BeanUtils.copyProperties(dbStepSpecialDO, priceSpecialDO);
priceSpecialDO.setId(null);
priceSpecialUpdate.add(priceSpecialDO);
specialUpdateList.add(dbStepSpecialDO); specialUpdateList.add(dbStepSpecialDO);
} }
} }
} }
} }
// List<ProductPriceSpecialDO> priceSpecialInsert = new ArrayList<>();
// List<ProductPriceSpecialDO> priceSpecialUpdate = new ArrayList<>();
if (CollectionUtil.isNotEmpty(specialInsertList)) { if (CollectionUtil.isNotEmpty(specialInsertList)) {
productPriceStepSpecialMapper.insertBatchSomeColumn(specialInsertList); productPriceStepSpecialMapper.insertBatchSomeColumn(specialInsertList);
} }
if (CollectionUtil.isNotEmpty(specialUpdateList)) { if (CollectionUtil.isNotEmpty(specialUpdateList)) {
productPriceStepSpecialMapper.updateBatch(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() List<ProductPriceStepPackagingDO> stepPackagingList = insertList1.stream()
.map(ProductPriceStepDO::getPackagingList) .map(ProductPriceStepDO::getPackagingList)
.filter(CollectionUtil::isNotEmpty) .filter(CollectionUtil::isNotEmpty)
...@@ -4146,6 +3870,174 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper, ...@@ -4146,6 +3870,174 @@ public class ProductPriceServiceImpl extends AbstractService<ProductPriceMapper,
productPriceStepPackagingMapper.physicsDeleteById(Joiner.on(",").join(dbPackingIdList)); 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) {
List<ProductPriceStepDO> dbPriceStepList = dbStepMap.get(productPriceDO.getId());
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(productPriceDO.getId());
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(productPriceDO.getId());
initBasePrice(dbItem, transportType);
insertList1.add(dbItem);
}
// if(stepItem.getPriceType()==1){
//
// ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO() ;
// BeanUtils.copyProperties(stepItem,pricePackagingDO);
// pricePackagingDO.setId(null);
// pricePackagingDO.setProductPriceId(productPriceId) ;
// productPricePackagingDOS.add(pricePackagingDO);
//
// }else {
// 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(stepItem.getPackagingList())) {
stepItem.getPackagingList().forEach(pg -> {
ProductPricePackagingDO pricePackagingDO = new ProductPricePackagingDO();
BeanUtils.copyProperties(pg, pricePackagingDO);
pricePackagingDO.setId(null);
pricePackagingDO.setProductPriceId(productPriceDO.getId());
pricePackagingDO.setPriceType(stepItem.getPriceType());
productPricePackagingDOS.add(pricePackagingDO);
});
}
}
}
} }
/** /**
......
package cn.iocoder.yudao.module.product.vo.productPrice; package cn.iocoder.yudao.module.product.vo.productPrice;
import cn.iocoder.yudao.module.product.dal.dataobject.product.ProductPricePackagingDO;
import cn.iocoder.yudao.module.product.dal.dataobject.product.ProductPriceSpecialDO;
import cn.iocoder.yudao.module.product.dal.dataobject.product.ProductPriceStepDO; import cn.iocoder.yudao.module.product.dal.dataobject.product.ProductPriceStepDO;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
......
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