ioioio %!s(int64=4) %!d(string=hai) anos
pai
achega
3b1ff82ec2

+ 139 - 123
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/OrderServiceImpl.java

@@ -611,6 +611,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 			{
 				auditPathsLevels = iCheckClient.listLevelsByActId(4, "status");
 			}
+            if(CollectionUtils.isEmpty(auditPathsLevels))
+            {
+            	throw new SecurityException("开启审批失败:未查询到审批信息");
+			}
 
 
 			AuditProecessDTO auditProecessDTO=new AuditProecessDTO();
@@ -628,12 +632,20 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 			auditProecessDTO.setPageStatus(order.getPageStatus());
 			auditProecessDTO.setPageLabel(order.getPageLabel());
 			//增加审批类型
-			auditProecessDTO.setProcessType("付费审批");
+
+			if(checkFlag==2)
+			{
+				auditProecessDTO.setProcessType("销售审批");
+			}
+			else if(checkFlag==1)
+			{
+				auditProecessDTO.setProcessType("采购审批");
+			}
+
 
 
 
 			auditProecessDTO.setCheckType(order.getCheckType());
-			auditProecessDTO.setProcessType("付费审批");
 			auditProecessDTO.setPathsLevelsList(auditPathsLevels);
 			auditProecessDTO.setActId(1);
 			auditProecessDTO.setSrcBillId(salesOrder.getId());
@@ -670,138 +682,142 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 		baseMapper.updateById(order);
 		/**===========================end 审核通过修改销售订单信息==========================*/
 
-
-		/**===========================Start 审核通过锁定库存=============================*/
-		//获取此销售订单下,所有明细的库存
-		LambdaQueryWrapper<OrderItems> orderItemsLambdaQueryWrapper=new LambdaQueryWrapper<>();
-		orderItemsLambdaQueryWrapper
-			.eq(OrderItems::getPid,id)
-			.eq(OrderItems::getIsDeleted,0);
-		List<OrderItems> orderItems = orderItemsMapper.selectList(orderItemsLambdaQueryWrapper);
-		if(CollectionUtils.isNotEmpty(orderItems))
-		{
-			orderItems.forEach(e->{
-				StockGoods stockGoods=new StockGoods();
-				stockGoods.setCorpId(e.getCorpId());
-				stockGoods.setGoodsId(e.getItemId());
-				stockGoods.setTenantId(SecureUtil.getTenantId());
-				List<StockGoods> listStockGoods= stockGoodsClient.postListStockByCondition(stockGoods);
-				if(listStockGoods.size()>1||CollectionUtils.isEmpty(listStockGoods))
-				{
-					throw new SecurityException("锁定库存失败:未查询到库存 或者 存在多条库存记录");
-				}
-				//开始锁定库存,减少可用
-				StockGoods oneStock = stockGoodsClient.getOneStock(stockGoods);
-				if(oneStock==null)
-				{
-					throw new SecurityException("锁定库存失败:未查询到库存信息");
-				}
-				//原单据的订货数量
-				BigDecimal orderQuantity = e.getOrderQuantity();
-				//可用库存
-				BigDecimal surplusRouteQuantity = oneStock.getSurplusRouteQuantity();
-				//锁定库存
-				BigDecimal lockingQuantity = oneStock.getLockingQuantity();
-
-				//判断比较大小
-				if(orderQuantity.compareTo(surplusRouteQuantity)==1)
-				{
-					throw new SecurityException("锁定库存失败:原单据的订货数量大于可用库存,无法锁定");
-				}
-				if(surplusRouteQuantity==null)
-				{
-					throw new SecurityException("锁定库存失败:可用库存为空,禁止操作");
-				}
-				//减少可用库存
-				oneStock.setSurplusRouteQuantity(surplusRouteQuantity.subtract(orderQuantity==null?new BigDecimal("0"):orderQuantity));
-				//增加锁定库存
-				oneStock.setLockingQuantity(lockingQuantity==null?new BigDecimal("0").add(orderQuantity):lockingQuantity.add(orderQuantity));
-				//更新库存
-				R r = stockGoodsClient.updateStock(oneStock);
-				if(!r.isSuccess())
-				{
-					throw new SecurityException("锁定库存失败: 更新失败");
-				}
-			});
-		}
+		//销售的逻辑
+        if(order.getBillType().equals("XS"))
+        {
+			/**===========================Start 审核通过锁定库存=============================*/
+			//获取此销售订单下,所有明细的库存
+			LambdaQueryWrapper<OrderItems> orderItemsLambdaQueryWrapper=new LambdaQueryWrapper<>();
+			orderItemsLambdaQueryWrapper
+				.eq(OrderItems::getPid,id)
+				.eq(OrderItems::getIsDeleted,0);
+			List<OrderItems> orderItems = orderItemsMapper.selectList(orderItemsLambdaQueryWrapper);
+			if(CollectionUtils.isNotEmpty(orderItems))
+			{
+				orderItems.forEach(e->{
+					StockGoods stockGoods=new StockGoods();
+					stockGoods.setCorpId(e.getCorpId());
+					stockGoods.setGoodsId(e.getItemId());
+					stockGoods.setTenantId(SecureUtil.getTenantId());
+					List<StockGoods> listStockGoods= stockGoodsClient.postListStockByCondition(stockGoods);
+					if(listStockGoods.size()>1||CollectionUtils.isEmpty(listStockGoods))
+					{
+						throw new SecurityException("锁定库存失败:未查询到库存 或者 存在多条库存记录");
+					}
+					//开始锁定库存,减少可用
+					StockGoods oneStock = stockGoodsClient.getOneStock(stockGoods);
+					if(oneStock==null)
+					{
+						throw new SecurityException("锁定库存失败:未查询到库存信息");
+					}
+					//原单据的订货数量
+					BigDecimal orderQuantity = e.getOrderQuantity();
+					//可用库存
+					BigDecimal surplusRouteQuantity = oneStock.getSurplusRouteQuantity();
+					//锁定库存
+					BigDecimal lockingQuantity = oneStock.getLockingQuantity();
+
+					//判断比较大小
+					if(orderQuantity.compareTo(surplusRouteQuantity)==1)
+					{
+						throw new SecurityException("锁定库存失败:原单据的订货数量大于可用库存,无法锁定");
+					}
+					if(surplusRouteQuantity==null)
+					{
+						throw new SecurityException("锁定库存失败:可用库存为空,禁止操作");
+					}
+					//减少可用库存
+					oneStock.setSurplusRouteQuantity(surplusRouteQuantity.subtract(orderQuantity==null?new BigDecimal("0"):orderQuantity));
+					//增加锁定库存
+					oneStock.setLockingQuantity(lockingQuantity==null?new BigDecimal("0").add(orderQuantity):lockingQuantity.add(orderQuantity));
+					//更新库存
+					R r = stockGoodsClient.updateStock(oneStock);
+					if(!r.isSuccess())
+					{
+						throw new SecurityException("锁定库存失败: 更新失败");
+					}
+				});
+			}
 
 
-		/**===========================End 审核通过锁定库存=============================*/
+			/**===========================End 审核通过锁定库存=============================*/
 
 
 
 
-		/**===========================start 审核通过操作返利信息=============================*/
-		//不需要计算返利
-		if((order.getThisUsedProfit()==null|| order.getThisUsedProfit().compareTo(new BigDecimal("0"))==0) && (order.getCreateProfit()==null|| order.getCreateProfit().compareTo(new BigDecimal("0"))==0))
-		{
-			return;
-		}
-		//检查是否使用返利,如果使用返利
-		BasicCorpsProfitChange basicCorpsProfitChange=new BasicCorpsProfitChange();
-		basicCorpsProfitChange.setCorpId(order.getCorpId());
-		basicCorpsProfitChange.setOrderId(order.getId());
-		basicCorpsProfitChange.setOrderNo(order.getOrderNo());
-		basicCorpsProfitChange.setCreateTime(new Date());
-		basicCorpsProfitChange.setCreateUser(AuthUtil.getUserId());
-		//有返利
-		if(order.getThisUsedProfit()!=null && order.getThisUsedProfit().compareTo(BigDecimal.ZERO)==1)
-		{
-			//增加客户的总返利
-			/*basicCorpsProfitChange.setChangeProfitReturn(order.getThisUsedProfit());*/
-			//增加客户的已用返利
-			basicCorpsProfitChange.setChangeUsedProfit(order.getThisUsedProfit());
-			//减少客户的可用返利
-			basicCorpsProfitChange.setChangeSurplusProfit(order.getThisUsedProfit().negate());
-		}
-		//检查是否含有产生返利,如果有, 需要增加客户的本月待到账返利
-		 if(order.getCreateProfit()!=null && order.getCreateProfit().compareTo(BigDecimal.ZERO)==1)
-		{
+			/**===========================start 审核通过操作返利信息=============================*/
+			//不需要计算返利
+			if((order.getThisUsedProfit()==null|| order.getThisUsedProfit().compareTo(new BigDecimal("0"))==0) && (order.getCreateProfit()==null|| order.getCreateProfit().compareTo(new BigDecimal("0"))==0))
+			{
+				return;
+			}
+			//检查是否使用返利,如果使用返利
+			BasicCorpsProfitChange basicCorpsProfitChange=new BasicCorpsProfitChange();
+			basicCorpsProfitChange.setCorpId(order.getCorpId());
+			basicCorpsProfitChange.setOrderId(order.getId());
+			basicCorpsProfitChange.setOrderNo(order.getOrderNo());
+			basicCorpsProfitChange.setCreateTime(new Date());
+			basicCorpsProfitChange.setCreateUser(AuthUtil.getUserId());
+			//有返利
+			if(order.getThisUsedProfit()!=null && order.getThisUsedProfit().compareTo(BigDecimal.ZERO)==1)
+			{
+				//增加客户的总返利
+				/*basicCorpsProfitChange.setChangeProfitReturn(order.getThisUsedProfit());*/
+				//增加客户的已用返利
+				basicCorpsProfitChange.setChangeUsedProfit(order.getThisUsedProfit());
+				//减少客户的可用返利
+				basicCorpsProfitChange.setChangeSurplusProfit(order.getThisUsedProfit().negate());
+			}
+			//检查是否含有产生返利,如果有, 需要增加客户的本月待到账返利
+			if(order.getCreateProfit()!=null && order.getCreateProfit().compareTo(BigDecimal.ZERO)==1)
+			{
 				//增加客户的月返利
 				basicCorpsProfitChange.setChangeMonthProfit(order.getCreateProfit());
 
-		}
-		//新增返利变动记录
-		R save = corpsProfitChangeClient.save(basicCorpsProfitChange);
-		if(!save.isSuccess())
-		{
-			throw new SecurityException("保存返利变动记录失败");
-		}
-		//修改客户返利
-		R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(order.getCorpId());
-		if(!corpMessage.isSuccess()||corpMessage.getData()==null)
-		{
-			throw new SecurityException("未查到客户记录");
-		}
-		CorpsDesc corpsDesc = corpMessage.getData();
-		corpsDesc.setProfitReturn(basicCorpsProfitChange.getChangeProfitReturn()==null?new BigDecimal("0").add(corpsDesc.getProfitReturn()):basicCorpsProfitChange.getChangeProfitReturn().add(corpsDesc.getProfitReturn()));
-		corpsDesc.setUsedProfit(basicCorpsProfitChange.getChangeUsedProfit()==null?new BigDecimal("0").add(corpsDesc.getUsedProfit()):basicCorpsProfitChange.getChangeUsedProfit().add(corpsDesc.getUsedProfit()));
-		corpsDesc.setSurplusProfit(basicCorpsProfitChange.getChangeSurplusProfit()==null?new BigDecimal("0").add(corpsDesc.getSurplusProfit()):basicCorpsProfitChange.getChangeSurplusProfit().add(corpsDesc.getSurplusProfit()));
-		corpsDesc.setMonthProfit(basicCorpsProfitChange.getChangeMonthProfit()==null?new BigDecimal("0").add(corpsDesc.getMonthProfit()):basicCorpsProfitChange.getChangeMonthProfit().add(corpsDesc.getMonthProfit()));
+			}
+			//新增返利变动记录
+			R save = corpsProfitChangeClient.save(basicCorpsProfitChange);
+			if(!save.isSuccess())
+			{
+				throw new SecurityException("保存返利变动记录失败");
+			}
+			//修改客户返利
+			R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(order.getCorpId());
+			if(!corpMessage.isSuccess()||corpMessage.getData()==null)
+			{
+				throw new SecurityException("未查到客户记录");
+			}
+			CorpsDesc corpsDesc = corpMessage.getData();
+			corpsDesc.setProfitReturn(basicCorpsProfitChange.getChangeProfitReturn()==null?new BigDecimal("0").add(corpsDesc.getProfitReturn()):basicCorpsProfitChange.getChangeProfitReturn().add(corpsDesc.getProfitReturn()));
+			corpsDesc.setUsedProfit(basicCorpsProfitChange.getChangeUsedProfit()==null?new BigDecimal("0").add(corpsDesc.getUsedProfit()):basicCorpsProfitChange.getChangeUsedProfit().add(corpsDesc.getUsedProfit()));
+			corpsDesc.setSurplusProfit(basicCorpsProfitChange.getChangeSurplusProfit()==null?new BigDecimal("0").add(corpsDesc.getSurplusProfit()):basicCorpsProfitChange.getChangeSurplusProfit().add(corpsDesc.getSurplusProfit()));
+			corpsDesc.setMonthProfit(basicCorpsProfitChange.getChangeMonthProfit()==null?new BigDecimal("0").add(corpsDesc.getMonthProfit()):basicCorpsProfitChange.getChangeMonthProfit().add(corpsDesc.getMonthProfit()));
+
+			if(corpsDesc.getProfitReturn().compareTo(new BigDecimal("0"))==-1)
+			{
+				throw new SecurityException("修改客户返利失败:总返利不能为负数");
+			}
+			if(corpsDesc.getUsedProfit().compareTo(new BigDecimal("0"))==-1)
+			{
+				throw new SecurityException("修改客户返利失败:已用返利不能为负数");
+			}
+			if(corpsDesc.getSurplusProfit().compareTo(new BigDecimal("0"))==-1)
+			{
+				throw new SecurityException("修改客户返利失败:可用返利不能为负数");
+			}
+			if(corpsDesc.getMonthProfit().compareTo(new BigDecimal("0"))==-1)
+			{
+				throw new SecurityException("修改客户返利失败:本月待到账返利不能为负数");
+			}
+			//更新客户返利情况
+			R corpsUpdate = corpsDescClient.corpsUpdate(corpsDesc);
+			if(!corpsUpdate.isSuccess())
+			{
+				throw new SecurityException("更新客户返利信息失败");
+			}
+			/**===========================End审核通过操作返利信息=============================*/
 
-		if(corpsDesc.getProfitReturn().compareTo(new BigDecimal("0"))==-1)
-		{
-             throw new SecurityException("修改客户返利失败:总返利不能为负数");
-		}
-		if(corpsDesc.getUsedProfit().compareTo(new BigDecimal("0"))==-1)
-		{
-			throw new SecurityException("修改客户返利失败:已用返利不能为负数");
-		}
-		if(corpsDesc.getSurplusProfit().compareTo(new BigDecimal("0"))==-1)
-		{
-			throw new SecurityException("修改客户返利失败:可用返利不能为负数");
-		}
-		if(corpsDesc.getMonthProfit().compareTo(new BigDecimal("0"))==-1)
-		{
-			throw new SecurityException("修改客户返利失败:本月待到账返利不能为负数");
-		}
-		//更新客户返利情况
-		R corpsUpdate = corpsDescClient.corpsUpdate(corpsDesc);
-		if(!corpsUpdate.isSuccess())
-		{
-			throw new SecurityException("更新客户返利信息失败");
 		}
-		/**===========================End审核通过操作返利信息=============================*/