|
|
@@ -753,7 +753,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
|
|
|
//查询所有该商品的库存
|
|
|
List<PjStockDesc> stockDescList = finalPjStockDescList.stream().filter(i -> goodsIds.contains(i.getGoodsId())).collect(Collectors.toList());
|
|
|
if (stockDescList.size() > 0) {
|
|
|
- balanceQuantity = stockDescList.stream().map(PjStockDesc::getBalanceQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ balanceQuantity = stockDescList.stream().map(PjStockDesc::getBalanceQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -797,6 +797,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
|
|
|
pjOrder.setStatus(OrderTypeEnum.RECEIVEDGOODS.getType());
|
|
|
pjOrder.setXcxStatus(OrderTypeEnum.RECEIVEDGOODS.getType());
|
|
|
pjOrder.setShortcutWarehousingStatus("1");
|
|
|
+ pjOrder.setCheckStatus("审核完成");
|
|
|
baseMapper.updateById(pjOrder);
|
|
|
return R.data(pjOrder);
|
|
|
}
|
|
|
@@ -882,17 +883,26 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
|
|
|
StringBuilder retrieval = new StringBuilder();
|
|
|
List<Long> goodsId = order.getOrderItemsList().stream().map(PjOrderItems::getGoodsId).collect(Collectors.toList());
|
|
|
List<PjStockDesc> pjStockDescList = stockDescService.list(new LambdaQueryWrapper<PjStockDesc>()
|
|
|
- .eq(PjStockDesc::getStorageId, order.getStorageId())
|
|
|
+ .eq(ObjectUtils.isNotNull(order.getStorageId()), PjStockDesc::getStorageId, order.getStorageId())
|
|
|
.eq(PjStockDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(PjStockDesc::getIsDeleted, 0)
|
|
|
.in(PjStockDesc::getGoodsId, goodsId));
|
|
|
+ if (ObjectUtils.isNotNull(order.getStorageId())) {
|
|
|
+ if (goodsId.size() != pjStockDescList.size()) {
|
|
|
+ List<PjStockDesc> difference = pjStockDescList.stream().filter(e -> !goodsId.contains(e.getGoodsId())).collect(Collectors.toList());
|
|
|
+ if (difference.size() > 0) {
|
|
|
+ String name = difference.stream().map(PjStockDesc::getCname).collect(Collectors.joining(","));
|
|
|
+ throw new RuntimeException(name + "未查到库存,请修改");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
for (PjOrderItems item : order.getOrderItemsList()) {
|
|
|
BigDecimal balanceQuantity = new BigDecimal("0.00");
|
|
|
BigDecimal inventoryAmount = new BigDecimal("0.00");
|
|
|
if (pjStockDescList.size() > 0) {
|
|
|
- balanceQuantity = pjStockDescList.stream().filter(e-> e.getGoodsId().equals(item.getGoodsId())).map(PjStockDesc::getBalanceQuantity).filter(Objects::nonNull)
|
|
|
+ balanceQuantity = pjStockDescList.stream().filter(e -> e.getGoodsId().equals(item.getGoodsId())).map(PjStockDesc::getBalanceQuantity).filter(Objects::nonNull)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- inventoryAmount = pjStockDescList.stream().filter(e-> e.getGoodsId().equals(item.getGoodsId())).map(PjStockDesc::getInventoryAmount).filter(Objects::nonNull)
|
|
|
+ inventoryAmount = pjStockDescList.stream().filter(e -> e.getGoodsId().equals(item.getGoodsId())).map(PjStockDesc::getInventoryAmount).filter(Objects::nonNull)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
}
|
|
|
BigDecimal inventoryCostPrice = new BigDecimal("0.00");
|
|
|
@@ -980,6 +990,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
|
|
|
order.setGrossProfit(order.getOrderItemsList().stream().filter(e -> e.getGrossProfit() != null).map(PjOrderItems::getGrossProfit).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
//成本
|
|
|
order.setCost(order.getOrderItemsList().stream().filter(e -> e.getCostprie() != null).map(PjOrderItems::getCostprie).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ } else {
|
|
|
+ order.setNumberRows(0);//行数
|
|
|
+ //总数量
|
|
|
+ order.setGoodsTotalNum(new BigDecimal("0"));
|
|
|
+ order.setSalesAmount(new BigDecimal("0.00"));
|
|
|
+ order.setTotalMoney(new BigDecimal("0.00"));
|
|
|
}
|
|
|
} else if (order.getBsType().equals(OrderTypeEnum.PURCHASE.getType())) {//采购
|
|
|
//仓库名称
|
|
|
@@ -1041,6 +1057,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
|
|
|
|
|
|
order.setSalesAmount(totalMoney);
|
|
|
order.setTotalMoney(totalMoney);
|
|
|
+ } else {
|
|
|
+ order.setNumberRows(0);//行数
|
|
|
+ //总数量
|
|
|
+ order.setGoodsTotalNum(new BigDecimal("0"));
|
|
|
+ order.setSalesAmount(new BigDecimal("0.00"));
|
|
|
+ order.setTotalMoney(new BigDecimal("0.00"));
|
|
|
}
|
|
|
}
|
|
|
baseMapper.updateById(order);
|
|
|
@@ -1073,6 +1095,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
|
|
|
if (ObjectUtils.isNotNull(pjOrder.getStorageId())) {
|
|
|
//仓库名称
|
|
|
pjShip.setStorageName(storageDescMapper.selectById(pjOrder.getStorageId()).getCname());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("请先选择仓库");
|
|
|
}
|
|
|
} else {
|
|
|
pjShip.setStorageId(null);
|