|
@@ -538,10 +538,10 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
baseMapper.updateById(ship);
|
|
baseMapper.updateById(ship);
|
|
|
}
|
|
}
|
|
|
// 保存订单明细
|
|
// 保存订单明细
|
|
|
|
|
+ List<PjShipItems> shipItemsList = new ArrayList<>();
|
|
|
|
|
+ List<PjOrderItems> pjOrderItemsList = new ArrayList<>();
|
|
|
|
|
+ List<PjStockDesc> pjStockDescArrayList = new ArrayList<>();
|
|
|
if (CollectionUtils.isNotEmpty(ship.getShipItemsList())) {
|
|
if (CollectionUtils.isNotEmpty(ship.getShipItemsList())) {
|
|
|
- List<PjShipItems> shipItemsList = new ArrayList<>();
|
|
|
|
|
- List<PjOrderItems> pjOrderItemsList = new ArrayList<>();
|
|
|
|
|
- List<PjStockDesc> pjStockDescArrayList = new ArrayList<>();
|
|
|
|
|
List<Long> goodIds = ship.getShipItemsList().stream().map(PjShipItems::getGoodsId).distinct().collect(Collectors.toList());
|
|
List<Long> goodIds = ship.getShipItemsList().stream().map(PjShipItems::getGoodsId).distinct().collect(Collectors.toList());
|
|
|
List<PjGoodsDesc> pjGoodsDescList = goodsDescMapper.selectList(new LambdaQueryWrapper<PjGoodsDesc>()
|
|
List<PjGoodsDesc> pjGoodsDescList = goodsDescMapper.selectList(new LambdaQueryWrapper<PjGoodsDesc>()
|
|
|
.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
|
|
.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
|
|
@@ -689,6 +689,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
if ("已收货".equals(order.getStatus()) || "退款请核".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
|
|
if ("已收货".equals(order.getStatus()) || "退款请核".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
|
|
|
throw new RuntimeException("单据已收货或申请售后中,操作失败");
|
|
throw new RuntimeException("单据已收货或申请售后中,操作失败");
|
|
|
}
|
|
}
|
|
|
|
|
+ order.setGrossProfit(pjOrderItemsList.stream().map(PjOrderItems::getProfit).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
|
|
+ order.setCost(pjOrderItemsList.stream().map(PjOrderItems::getCostprie).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
order.setShipType(ship.getShipType());
|
|
order.setShipType(ship.getShipType());
|
|
|
order.setLogisticsCorpId(ship.getLogisticsCorpId());
|
|
order.setLogisticsCorpId(ship.getLogisticsCorpId());
|
|
|
order.setLogisticsCorpName(ship.getLogisticsCorpName());
|
|
order.setLogisticsCorpName(ship.getLogisticsCorpName());
|
|
@@ -718,30 +720,11 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
ship.setUpdateTime(new Date());
|
|
ship.setUpdateTime(new Date());
|
|
|
baseMapper.updateById(ship);
|
|
baseMapper.updateById(ship);
|
|
|
PjOrder order = orderMapper.selectById(ship.getOrdId());
|
|
PjOrder order = orderMapper.selectById(ship.getOrdId());
|
|
|
- if (ObjectUtil.isNotEmpty(order)) {
|
|
|
|
|
- PjOrder order1 = orderMapper.selectOne(new LambdaQueryWrapper<PjOrder>()
|
|
|
|
|
- .eq(PjOrder::getTenantId, AuthUtil.getTenantId())
|
|
|
|
|
- .eq(PjOrder::getIsDeleted, 0)
|
|
|
|
|
- .eq(PjOrder::getSrcNo, order.getOrdNo()));
|
|
|
|
|
- if (order1 != null && "待入库,已完成".contains(order1.getStatus())) {
|
|
|
|
|
- throw new RuntimeException("已生成销售退货单据,撤销失败");
|
|
|
|
|
- }
|
|
|
|
|
- if ("已收货".equals(order.getStatus()) || "退款请核".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
|
|
|
|
|
- throw new RuntimeException("单据已收货或申请售后中,操作失败");
|
|
|
|
|
- }
|
|
|
|
|
- order.setStatus(OrderTypeEnum.XSDFH.getType());
|
|
|
|
|
- order.setXcxStatus(OrderTypeEnum.XSDFH.getType());
|
|
|
|
|
- order.setDeliveryBusinesDate(null);
|
|
|
|
|
- orderMapper.updateById(order);
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new RuntimeException("数据异常请联系管理员");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// 保存订单明细
|
|
// 保存订单明细
|
|
|
|
|
+ List<PjShipItems> itemsList = new ArrayList<>();
|
|
|
|
|
+ List<PjOrderItems> pjOrderItemsList = new ArrayList<>();
|
|
|
|
|
+ List<PjStockDesc> pjStockDescArrayList = new ArrayList<>();
|
|
|
if (CollectionUtils.isNotEmpty(ship.getShipItemsList())) {
|
|
if (CollectionUtils.isNotEmpty(ship.getShipItemsList())) {
|
|
|
- List<PjShipItems> itemsList = new ArrayList<>();
|
|
|
|
|
- List<PjOrderItems> pjOrderItemsList = new ArrayList<>();
|
|
|
|
|
- List<PjStockDesc> pjStockDescArrayList = new ArrayList<>();
|
|
|
|
|
List<Long> goodIds = ship.getShipItemsList().stream().map(PjShipItems::getGoodsId).distinct().collect(Collectors.toList());
|
|
List<Long> goodIds = ship.getShipItemsList().stream().map(PjShipItems::getGoodsId).distinct().collect(Collectors.toList());
|
|
|
List<PjGoodsDesc> pjGoodsDescList = goodsDescMapper.selectList(new LambdaQueryWrapper<PjGoodsDesc>()
|
|
List<PjGoodsDesc> pjGoodsDescList = goodsDescMapper.selectList(new LambdaQueryWrapper<PjGoodsDesc>()
|
|
|
.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
|
|
.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
|
|
@@ -861,6 +844,26 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
baseMapper.updateById(rwShip);
|
|
baseMapper.updateById(rwShip);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(order)) {
|
|
|
|
|
+ PjOrder order1 = orderMapper.selectOne(new LambdaQueryWrapper<PjOrder>()
|
|
|
|
|
+ .eq(PjOrder::getTenantId, AuthUtil.getTenantId())
|
|
|
|
|
+ .eq(PjOrder::getIsDeleted, 0)
|
|
|
|
|
+ .eq(PjOrder::getSrcNo, order.getOrdNo()));
|
|
|
|
|
+ if (order1 != null && "待入库,已完成".contains(order1.getStatus())) {
|
|
|
|
|
+ throw new RuntimeException("已生成销售退货单据,撤销失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ if ("已收货".equals(order.getStatus()) || "退款请核".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
|
|
|
|
|
+ throw new RuntimeException("单据已收货或申请售后中,操作失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ order.setGrossProfit(pjOrderItemsList.stream().map(PjOrderItems::getProfit).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
|
|
+ order.setCost(pjOrderItemsList.stream().map(PjOrderItems::getCostprie).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
|
|
+ order.setStatus(OrderTypeEnum.XSDFH.getType());
|
|
|
|
|
+ order.setXcxStatus(OrderTypeEnum.XSDFH.getType());
|
|
|
|
|
+ order.setDeliveryBusinesDate(null);
|
|
|
|
|
+ orderMapper.updateById(order);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new RuntimeException("数据异常请联系管理员");
|
|
|
|
|
+ }
|
|
|
//生成出库工单历史记录
|
|
//生成出库工单历史记录
|
|
|
saveHistory(ship.getId(), OrderTypeEnum.TOBESHIPPEDOUT.getType());
|
|
saveHistory(ship.getId(), OrderTypeEnum.TOBESHIPPEDOUT.getType());
|
|
|
|
|
|
|
@@ -2115,7 +2118,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
item.setNumberRows(list.size());
|
|
item.setNumberRows(list.size());
|
|
|
- item.setSendTotalNum(list.stream().map(PjOrderItems::getReturnsNumber).reduce(BigDecimal.ZERO,BigDecimal::add));
|
|
|
|
|
|
|
+ item.setSendTotalNum(list.stream().map(PjOrderItems::getReturnsNumber).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//修改出库任务状态
|
|
//修改出库任务状态
|
|
@@ -2668,7 +2671,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
shipItemsList.add(shipItems);
|
|
shipItemsList.add(shipItems);
|
|
|
}
|
|
}
|
|
|
item.setNumberRows(list.size());
|
|
item.setNumberRows(list.size());
|
|
|
- item.setSendTotalNum(list.stream().map(PjOrderItems::getReturnsNumber).reduce(BigDecimal.ZERO,BigDecimal::add));
|
|
|
|
|
|
|
+ item.setSendTotalNum(list.stream().map(PjOrderItems::getReturnsNumber).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//修改入库任务状态
|
|
//修改入库任务状态
|
|
@@ -2885,7 +2888,9 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
stockDesc.setStoreInventory(item.getSendNum());
|
|
stockDesc.setStoreInventory(item.getSendNum());
|
|
|
stockDesc.setInventoryAmount(item.getSendNum().multiply(item.getPrice()));
|
|
stockDesc.setInventoryAmount(item.getSendNum().multiply(item.getPrice()));
|
|
|
if (stockDesc.getBalanceQuantity().compareTo(new BigDecimal("0")) != 0) {
|
|
if (stockDesc.getBalanceQuantity().compareTo(new BigDecimal("0")) != 0) {
|
|
|
- stockDesc.setInventoryCostPrice(stockDesc.getInventoryAmount().divide(stockDesc.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
|
|
+ BigDecimal amount = ObjectUtils.isNotNull(orderItems.getCostprie()) ? orderItems.getCostprie() : stockDesc.getInventoryAmount();
|
|
|
|
|
+// stockDesc.setInventoryCostPrice(stockDesc.getInventoryAmount().divide(stockDesc.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
+ stockDesc.setInventoryCostPrice(amount.divide(stockDesc.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
|
|
|
} else {
|
|
} else {
|
|
|
stockDesc.setInventoryCostPrice(item.getPrice());
|
|
stockDesc.setInventoryCostPrice(item.getPrice());
|
|
|
}
|
|
}
|
|
@@ -2899,7 +2904,9 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
stockDesc.setInventoryAmount(item.getCostprie());
|
|
stockDesc.setInventoryAmount(item.getCostprie());
|
|
|
stockDesc.setInventoryAmount(stockDesc.getInventoryAmount().add(stockOne.getInventoryAmount()));
|
|
stockDesc.setInventoryAmount(stockDesc.getInventoryAmount().add(stockOne.getInventoryAmount()));
|
|
|
if (stockDesc.getBalanceQuantity().compareTo(new BigDecimal("0")) != 0) {
|
|
if (stockDesc.getBalanceQuantity().compareTo(new BigDecimal("0")) != 0) {
|
|
|
- stockDesc.setInventoryCostPrice(stockDesc.getInventoryAmount().divide(stockDesc.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
|
|
+ BigDecimal amount = ObjectUtils.isNotNull(orderItems.getCostprie()) ? orderItems.getCostprie() : stockDesc.getInventoryAmount();
|
|
|
|
|
+// stockDesc.setInventoryCostPrice(stockDesc.getInventoryAmount().divide(stockDesc.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
+ stockDesc.setInventoryCostPrice(amount.divide(stockDesc.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
|
|
|
}
|
|
}
|
|
|
stockDesc.setVersion(stockOne.getVersion());
|
|
stockDesc.setVersion(stockOne.getVersion());
|
|
|
pjStockDescArrayListUpdate.add(stockDesc);
|
|
pjStockDescArrayListUpdate.add(stockDesc);
|
|
@@ -3074,7 +3081,13 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
if (new BigDecimal("0.00").compareTo(stockOne.getInventoryAmount()) == 0 && new BigDecimal("0.00").compareTo(stockOne.getBalanceQuantity()) == 0) {
|
|
if (new BigDecimal("0.00").compareTo(stockOne.getInventoryAmount()) == 0 && new BigDecimal("0.00").compareTo(stockOne.getBalanceQuantity()) == 0) {
|
|
|
stockOne.setInventoryCostPrice(new BigDecimal("0.00"));
|
|
stockOne.setInventoryCostPrice(new BigDecimal("0.00"));
|
|
|
} else {
|
|
} else {
|
|
|
- stockOne.setInventoryCostPrice(stockOne.getInventoryAmount().divide(stockOne.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
|
|
+ PjOrderItems orderItems = pjOrderItems.stream().filter(e -> e.getId().equals(item.getSrcItemId())).findFirst().orElse(null);
|
|
|
|
|
+ if (orderItems != null) {
|
|
|
|
|
+ BigDecimal amount = ObjectUtils.isNotNull(orderItems.getCostprie()) ? orderItems.getCostprie() : stockOne.getInventoryAmount();
|
|
|
|
|
+ stockOne.setInventoryCostPrice(amount.divide(stockOne.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new RuntimeException("数据异常请联系管理员");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
stockOne.setVersion(stockOne.getVersion());
|
|
stockOne.setVersion(stockOne.getVersion());
|
|
|
/*R res = iStockDescService.updateByIdNew(stockOne);
|
|
/*R res = iStockDescService.updateByIdNew(stockOne);
|