|
@@ -203,6 +203,10 @@ public class OrderExchangeServiceImpl extends ServiceImpl<OrderExchangeMapper, O
|
|
|
|
|
|
for (OrderExchangeDetail orderExchangeDetail : orderExchangeDetailList) {
|
|
|
|
|
|
+ if (orderExchangeDetail.getQuantity().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
Long orderSkuId = orderExchangeDetail.getOrderSkuId();
|
|
|
|
|
|
// 数量为空,没找到订单sku id
|
|
@@ -232,6 +236,8 @@ public class OrderExchangeServiceImpl extends ServiceImpl<OrderExchangeMapper, O
|
|
|
orderExchangeDetail.setOrderExchangeId(orderExchangeDto.getId());
|
|
|
orderExchangeDetail.setReturnStatus(StatusConstant.NO);
|
|
|
orderExchangeDetail.setExchangeStatus(StatusConstant.NO);
|
|
|
+ orderExchangeDetail.setCheckPassesQuantity(orderExchangeDetail.getQuantity());
|
|
|
+ orderExchangeDetail.setMeshBagDamageQuantity(BigDecimal.ZERO);
|
|
|
|
|
|
BigDecimal packagingMaterialCost = orderSkuBomMap.getOrDefault(orderSkuId, Collections.emptyList()).stream()
|
|
|
.map(item -> item.getUnitPrice().multiply(item.getQuantity()))
|
|
@@ -256,55 +262,57 @@ public class OrderExchangeServiceImpl extends ServiceImpl<OrderExchangeMapper, O
|
|
|
StatementOfAccount statementOfAccount = this.getStatementOfAccount(orderInfo.getDepartmentId());
|
|
|
orderExchangeDto.setStatementOfAccountId(statementOfAccount.getId());
|
|
|
|
|
|
- // 售后商品入库
|
|
|
- if (Objects.equals(orderExchangeDto.getWarehouseId(), WarehouseConstant.PRODUCTION_DEFECTIVE)) {
|
|
|
- List<InOutStorageBom> tempInOutStorageBomList = tempOrderSkuList.stream().map(item -> {
|
|
|
- InOutStorageBom inStorageBom = new InOutStorageBom();
|
|
|
- inStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
- inStorageBom.setQuantity(item.getQuantity());
|
|
|
- return inStorageBom;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ if (!tempOrderSkuList.isEmpty()) {
|
|
|
+ // 售后商品入库
|
|
|
+ if (Objects.equals(orderExchangeDto.getWarehouseId(), WarehouseConstant.PRODUCTION_DEFECTIVE)) {
|
|
|
+ List<InOutStorageBom> tempInOutStorageBomList = tempOrderSkuList.stream().map(item -> {
|
|
|
+ InOutStorageBom inStorageBom = new InOutStorageBom();
|
|
|
+ inStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
+ inStorageBom.setQuantity(item.getQuantity());
|
|
|
+ return inStorageBom;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
|
- // 合并相同bom规格出库数量
|
|
|
- List<InOutStorageBom> inOutStorageBomList = new ArrayList<>(tempInOutStorageBomList.stream()
|
|
|
- .collect(Collectors.toMap(
|
|
|
- InOutStorageBom::getBomSpecId,
|
|
|
- Function.identity(),
|
|
|
- (v1, v2) -> {
|
|
|
- v1.setQuantity(v1.getQuantity().add(v2.getQuantity()));
|
|
|
- return v1;
|
|
|
- })).values());
|
|
|
+ // 合并相同bom规格出库数量
|
|
|
+ List<InOutStorageBom> inOutStorageBomList = new ArrayList<>(tempInOutStorageBomList.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ InOutStorageBom::getBomSpecId,
|
|
|
+ Function.identity(),
|
|
|
+ (v1, v2) -> {
|
|
|
+ v1.setQuantity(v1.getQuantity().add(v2.getQuantity()));
|
|
|
+ return v1;
|
|
|
+ })).values());
|
|
|
|
|
|
- InOutStorageDto inOutStorageDto = new InOutStorageDto();
|
|
|
- inOutStorageDto.setType(InOutTypeEnum.IN.getKey());
|
|
|
- inOutStorageDto.setDetailType(InDetailTypeEnum.ABANDON.getKey());
|
|
|
- inOutStorageDto.setWarehouseId(orderExchangeDto.getWarehouseId());
|
|
|
- inOutStorageDto.setDepartmentId(DepartmentConstant.SD_SPORTS);
|
|
|
- inOutStorageDto.setApplicant(SecurityUtils.getLoginUser().getUser().getNickName());
|
|
|
- inOutStorageDto.setRemark("订单:" + orderInfo.getCode() + "订单售后报废入库");
|
|
|
- inOutStorageDto.setInOutStorageBomList(inOutStorageBomList);
|
|
|
- inOutStorageService.add(inOutStorageDto);
|
|
|
- } else {
|
|
|
- // 成品质检通过后出库包材,重新包装
|
|
|
- Map<Long, OrderSku> finishedOrderSkuMap = tempOrderSkuList.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
- orderSkuBomList.removeAll(tempOrderSkuBomList);
|
|
|
- List<InOutStorageBom> outStorageBomList = orderSkuBomList.stream().map(item -> {
|
|
|
- InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
- inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
- inOutStorageBom.setQuantity(item.getQuantity().multiply(finishedOrderSkuMap.get(item.getOrderSkuId()).getQuantity()));
|
|
|
- return inOutStorageBom;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- InOutStorageDto inOutStorageDto = new InOutStorageDto();
|
|
|
- inOutStorageDto.setType(InOutTypeEnum.OUT.getKey());
|
|
|
- inOutStorageDto.setDetailType(OutDetailTypeEnum.PRODUCTION.getKey());
|
|
|
- inOutStorageDto.setWarehouseId(WarehouseConstant.PACKAGING_MATERIAL);
|
|
|
- inOutStorageDto.setDepartmentId(DepartmentConstant.SD_SPORTS);
|
|
|
- inOutStorageDto.setApplicant(SecurityUtils.getLoginUser().getUser().getNickName());
|
|
|
- inOutStorageDto.setInOutStorageBomList(outStorageBomList);
|
|
|
- inOutStorageDto.setLockStorage(StatusConstant.NO);
|
|
|
- inOutStorageService.add(inOutStorageDto);
|
|
|
- // 入成品库
|
|
|
- inventoryFinishedService.noSourceInWarehousing(tempOrderSkuList);
|
|
|
+ InOutStorageDto inOutStorageDto = new InOutStorageDto();
|
|
|
+ inOutStorageDto.setType(InOutTypeEnum.IN.getKey());
|
|
|
+ inOutStorageDto.setDetailType(InDetailTypeEnum.ABANDON.getKey());
|
|
|
+ inOutStorageDto.setWarehouseId(orderExchangeDto.getWarehouseId());
|
|
|
+ inOutStorageDto.setDepartmentId(DepartmentConstant.SD_SPORTS);
|
|
|
+ inOutStorageDto.setApplicant(SecurityUtils.getLoginUser().getUser().getNickName());
|
|
|
+ inOutStorageDto.setRemark("订单:" + orderInfo.getCode() + "订单售后报废入库");
|
|
|
+ inOutStorageDto.setInOutStorageBomList(inOutStorageBomList);
|
|
|
+ inOutStorageService.add(inOutStorageDto);
|
|
|
+ } else {
|
|
|
+ // 成品质检通过后出库包材,重新包装
|
|
|
+ Map<Long, OrderSku> finishedOrderSkuMap = tempOrderSkuList.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
+ orderSkuBomList.removeAll(tempOrderSkuBomList);
|
|
|
+ List<InOutStorageBom> outStorageBomList = orderSkuBomList.stream().map(item -> {
|
|
|
+ InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
+ inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
+ inOutStorageBom.setQuantity(item.getQuantity().multiply(finishedOrderSkuMap.get(item.getOrderSkuId()).getQuantity()));
|
|
|
+ return inOutStorageBom;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ InOutStorageDto inOutStorageDto = new InOutStorageDto();
|
|
|
+ inOutStorageDto.setType(InOutTypeEnum.OUT.getKey());
|
|
|
+ inOutStorageDto.setDetailType(OutDetailTypeEnum.PRODUCTION.getKey());
|
|
|
+ inOutStorageDto.setWarehouseId(WarehouseConstant.PACKAGING_MATERIAL);
|
|
|
+ inOutStorageDto.setDepartmentId(DepartmentConstant.SD_SPORTS);
|
|
|
+ inOutStorageDto.setApplicant(SecurityUtils.getLoginUser().getUser().getNickName());
|
|
|
+ inOutStorageDto.setInOutStorageBomList(outStorageBomList);
|
|
|
+ inOutStorageDto.setLockStorage(StatusConstant.NO);
|
|
|
+ inOutStorageService.add(inOutStorageDto);
|
|
|
+ // 入成品库
|
|
|
+ inventoryFinishedService.noSourceInWarehousing(tempOrderSkuList);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 保存数据
|