浏览代码

2023年12月2日10:19:35

纪新园 1 年之前
父节点
当前提交
91d7ce149f

+ 16 - 17
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/order/service/impl/OrderServiceImpl.java

@@ -631,8 +631,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
 				pjGoodsDescList = goodsDescMapper.selectList(new LambdaQueryWrapper<PjGoodsDesc>()
 					.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
 					.eq(PjGoodsDesc::getIsDeleted, 0)
-					.in(PjGoodsDesc::getId, goodsIds)
-					.eq(PjGoodsDesc::getEnableOrNot, 1));
+					.in(PjGoodsDesc::getId, goodsIds));
 				pjStockDescList = stockDescService.list(new LambdaQueryWrapper<PjStockDesc>()
 					.eq(PjStockDesc::getTenantId, AuthUtil.getTenantId())
 					.eq(PjStockDesc::getIsDeleted, 0)
@@ -707,16 +706,17 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
 				stockDesc.setDot(e.getDot());
 				stockDesc.setTenantId(AuthUtil.getTenantId());
 				PjStockDesc stockOne = null;
-				if (finalPjStockDescList.size() <= 0) {
-					throw new RuntimeException(goodsDesc.getCname() + "未查到库存信息");
-				}
 				if (ObjectUtil.isNotEmpty(goodsDesc.getWhether()) && "1".equals(goodsDesc.getWhether())) {//管理批次号
 					if (ObjectUtil.isEmpty(e.getDot())) {
 						throw new RuntimeException(goodsDesc.getCname() + "已开启批次号管理,请填写批次号");
 					}
-					stockOne = finalPjStockDescList.stream().filter(i -> i.getDot().equals(e.getDot())).findFirst().orElse(null);
+					if (finalPjStockDescList.size() > 0) {
+						stockOne = finalPjStockDescList.stream().filter(i -> i.getDot() != null && i.getDot().equals(e.getDot())).findFirst().orElse(null);
+					}
 				} else {
-					stockOne = finalPjStockDescList.stream().filter(i -> "".equals(i.getDot()) || i.getDot() == null).findFirst().orElse(null);
+					if (finalPjStockDescList.size() > 0) {
+						stockOne = finalPjStockDescList.stream().filter(i -> "".equals(i.getDot()) || i.getDot() == null).findFirst().orElse(null);
+					}
 				}
 				if (ObjectUtil.isEmpty(stockOne)) {
 					stockDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
@@ -748,17 +748,16 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
 					throw new RuntimeException(stockOne.getCname() + "该产品库存正在操作,请稍后刷新在进行操作!");
 				}
 				/** ----------------------修改上架库存---------------------- */
-
-				if (finalPjStockDescList.size() <= 0) {
-					throw new RuntimeException(goodsDesc.getCname() + "未查到库存信息");
-				}
-				//查询所有该商品的库存
-				List<PjStockDesc> stockDescList = finalPjStockDescList.stream().filter(i -> goodsIds.contains(i.getGoodsId())).collect(Collectors.toList());
-				if (stockDescList.size() <= 0) {
-					throw new RuntimeException(goodsDesc.getCname() + "未查到库存结余");
+				BigDecimal balanceQuantity = new BigDecimal("0.00");
+				if (finalPjStockDescList.size() > 0) {
+					//查询所有该商品的库存
+					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);
+					}
 				}
+
 				//库存总数量
-				BigDecimal balanceQuantity = stockDescList.stream().map(PjStockDesc::getBalanceQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
 				balanceQuantity = balanceQuantity.add(e.getGoodsNum());
 				//查询所有上架商品
 				List<PjProductLaunch> productLaunch = finalPjProductLaunch.stream().filter(i -> i.getGoodsId().equals(e.getGoodsId())).collect(Collectors.toList());
@@ -785,7 +784,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
 		}
 
 		//修改入库任务状态
-		pjShip.setStatusName(OrderTypeEnum.DISPATCHED.getType());
+		pjShip.setStatusName("已完成");
 		shipMapper.updateById(pjShip);
 		shipMapper.updateById(gdShip);