|  | @@ -594,38 +594,74 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
 | 
	
		
			
				|  |  |                  	studentPaymentOrderDetail.setPrice(BigDecimal.ZERO);
 | 
	
		
			
				|  |  |  	                studentPaymentOrderDetail.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  |  	                studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
 | 
	
		
			
				|  |  | +	              
 | 
	
		
			
				|  |  | +	                //忽略的分部
 | 
	
		
			
				|  |  | +	        		List<Integer> ignoreOrganList = Arrays.asList(4, 55, 59);
 | 
	
		
			
				|  |  | +	        		
 | 
	
		
			
				|  |  | +	        		//查询商品收款账户配置
 | 
	
		
			
				|  |  | +	                String goodsSellReceiptMerNo = sysConfigDao.findConfigValue("goodsSellReceiptMerNo");
 | 
	
		
			
				|  |  |  	                
 | 
	
		
			
				|  |  | -	                //扣减库存
 | 
	
		
			
				|  |  | -					
 | 
	
		
			
				|  |  | -					BigDecimal totalGroupPurchaseAmount = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | -					
 | 
	
		
			
				|  |  | -					BigDecimal groupPurchaseAmount = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | -					
 | 
	
		
			
				|  |  | -					minuendStockGoodsIdList = new ArrayList<Integer>();
 | 
	
		
			
				|  |  | -					
 | 
	
		
			
				|  |  | -					// 是否是组合商品
 | 
	
		
			
				|  |  | -					if(StringUtils.isNotBlank(goods.getComplementGoodsIdList())){
 | 
	
		
			
				|  |  | -						List<Goods> goodsList = goodsService.getGoodsWithLocked(goods.getComplementGoodsIdList());
 | 
	
		
			
				|  |  | -						totalGroupPurchaseAmount =  totalGroupPurchaseAmount.add(goodsList.stream().map(Goods :: getGroupPurchasePrice).reduce(BigDecimal.ZERO,BigDecimal :: add));
 | 
	
		
			
				|  |  | +	                if(!ignoreOrganList.contains(subjectChange.getOrganId()) && StringUtils.isNotBlank(goodsSellReceiptMerNo)){
 | 
	
		
			
				|  |  | +	                	//扣减库存
 | 
	
		
			
				|  |  | +						
 | 
	
		
			
				|  |  | +						BigDecimal totalGroupPurchaseAmount = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | +						
 | 
	
		
			
				|  |  | +						BigDecimal groupPurchaseAmount = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | +						
 | 
	
		
			
				|  |  | +						minuendStockGoodsIdList = new ArrayList<Integer>();
 | 
	
		
			
				|  |  |  						
 | 
	
		
			
				|  |  | -						for(Goods subGoods : goodsList){
 | 
	
		
			
				|  |  | +						// 是否是组合商品
 | 
	
		
			
				|  |  | +						if(StringUtils.isNotBlank(goods.getComplementGoodsIdList())){
 | 
	
		
			
				|  |  | +							List<Goods> goodsList = goodsService.getGoodsWithLocked(goods.getComplementGoodsIdList());
 | 
	
		
			
				|  |  | +							totalGroupPurchaseAmount =  totalGroupPurchaseAmount.add(goodsList.stream().map(Goods :: getGroupPurchasePrice).reduce(BigDecimal.ZERO,BigDecimal :: add));
 | 
	
		
			
				|  |  | +							
 | 
	
		
			
				|  |  | +							for(Goods subGoods : goodsList){
 | 
	
		
			
				|  |  | +								
 | 
	
		
			
				|  |  | +								if(batchUpdateGoodsMap.get(subGoods.getId()) != null){
 | 
	
		
			
				|  |  | +									subGoods = batchUpdateGoodsMap.get(subGoods.getId());
 | 
	
		
			
				|  |  | +								}
 | 
	
		
			
				|  |  | +								//判断是否有内部库存
 | 
	
		
			
				|  |  | +								if(subGoods.getStockCount() > 0){
 | 
	
		
			
				|  |  | +									
 | 
	
		
			
				|  |  | +									groupPurchaseAmount = groupPurchaseAmount.add(subGoods.getGroupPurchasePrice());
 | 
	
		
			
				|  |  | +									subGoods.setStockCount(new AtomicInteger(subGoods.getStockCount()).decrementAndGet());
 | 
	
		
			
				|  |  | +									subGoods.setSellCount(new AtomicInteger(subGoods.getSellCount()).incrementAndGet());
 | 
	
		
			
				|  |  | +									subGoods.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  | +									
 | 
	
		
			
				|  |  | +									batchUpdateGoodsMap.put(subGoods.getId(), subGoods);
 | 
	
		
			
				|  |  | +									
 | 
	
		
			
				|  |  | +									minuendStockGoodsIdList.add(subGoods.getId());
 | 
	
		
			
				|  |  | +									
 | 
	
		
			
				|  |  | +									goodsProcurement = goodsProcurementDao.getWithStockSurplusProcurement(subGoods.getId());
 | 
	
		
			
				|  |  | +									if(goodsProcurement != null){
 | 
	
		
			
				|  |  | +										if(goodsProcurementMap.get(goodsProcurement.getId()) != null){
 | 
	
		
			
				|  |  | +											goodsProcurement = goodsProcurementMap.get(goodsProcurement.getId());
 | 
	
		
			
				|  |  | +										}
 | 
	
		
			
				|  |  | +										goodsProcurement.setStockSoldNum(new AtomicInteger(goodsProcurement.getStockSoldNum()).incrementAndGet());
 | 
	
		
			
				|  |  | +										goodsProcurement.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  | +										goodsProcurementMap.put(goodsProcurement.getId(), goodsProcurement);
 | 
	
		
			
				|  |  | +									}
 | 
	
		
			
				|  |  | +								}
 | 
	
		
			
				|  |  | +							}
 | 
	
		
			
				|  |  | +						}else{
 | 
	
		
			
				|  |  | +							totalGroupPurchaseAmount = totalGroupPurchaseAmount.add(goods.getGroupPurchasePrice());
 | 
	
		
			
				|  |  |  							
 | 
	
		
			
				|  |  | -							if(batchUpdateGoodsMap.get(subGoods.getId()) != null){
 | 
	
		
			
				|  |  | -								subGoods = batchUpdateGoodsMap.get(subGoods.getId());
 | 
	
		
			
				|  |  | +							if(batchUpdateGoodsMap.get(goods.getId()) != null){
 | 
	
		
			
				|  |  | +								goods = batchUpdateGoodsMap.get(goods.getId());
 | 
	
		
			
				|  |  |  							}
 | 
	
		
			
				|  |  | +							
 | 
	
		
			
				|  |  |  							//判断是否有内部库存
 | 
	
		
			
				|  |  | -							if(subGoods.getStockCount() > 0){
 | 
	
		
			
				|  |  | -								
 | 
	
		
			
				|  |  | -								groupPurchaseAmount = groupPurchaseAmount.add(subGoods.getGroupPurchasePrice());
 | 
	
		
			
				|  |  | -								subGoods.setStockCount(new AtomicInteger(subGoods.getStockCount()).decrementAndGet());
 | 
	
		
			
				|  |  | -								subGoods.setSellCount(new AtomicInteger(subGoods.getSellCount()).incrementAndGet());
 | 
	
		
			
				|  |  | -								subGoods.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  | +							if(goods.getStockCount() > 0){
 | 
	
		
			
				|  |  |  								
 | 
	
		
			
				|  |  | -								batchUpdateGoodsMap.put(subGoods.getId(), subGoods);
 | 
	
		
			
				|  |  | +								groupPurchaseAmount = groupPurchaseAmount.add(goods.getGroupPurchasePrice());
 | 
	
		
			
				|  |  | +								goods.setStockCount(new AtomicInteger(goods.getStockCount()).decrementAndGet());
 | 
	
		
			
				|  |  | +								goods.setSellCount(new AtomicInteger(goods.getSellCount()).incrementAndGet());
 | 
	
		
			
				|  |  | +								goods.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  | +								batchUpdateGoodsMap.put(goods.getId(), goods);
 | 
	
		
			
				|  |  |  								
 | 
	
		
			
				|  |  | -								minuendStockGoodsIdList.add(subGoods.getId());
 | 
	
		
			
				|  |  | +								minuendStockGoodsIdList.add(goods.getId());
 | 
	
		
			
				|  |  |  								
 | 
	
		
			
				|  |  | -								goodsProcurement = goodsProcurementDao.getWithStockSurplusProcurement(subGoods.getId());
 | 
	
		
			
				|  |  | +								goodsProcurement = goodsProcurementDao.getWithStockSurplusProcurement(goods.getId());
 | 
	
		
			
				|  |  |  								if(goodsProcurement != null){
 | 
	
		
			
				|  |  |  									if(goodsProcurementMap.get(goodsProcurement.getId()) != null){
 | 
	
		
			
				|  |  |  										goodsProcurement = goodsProcurementMap.get(goodsProcurement.getId());
 | 
	
	
		
			
				|  | @@ -636,44 +672,16 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
 | 
	
		
			
				|  |  |  								}
 | 
	
		
			
				|  |  |  							}
 | 
	
		
			
				|  |  |  						}
 | 
	
		
			
				|  |  | -					}else{
 | 
	
		
			
				|  |  | -						totalGroupPurchaseAmount = totalGroupPurchaseAmount.add(goods.getGroupPurchasePrice());
 | 
	
		
			
				|  |  | -						
 | 
	
		
			
				|  |  | -						if(batchUpdateGoodsMap.get(goods.getId()) != null){
 | 
	
		
			
				|  |  | -							goods = batchUpdateGoodsMap.get(goods.getId());
 | 
	
		
			
				|  |  | -						}
 | 
	
		
			
				|  |  |  						
 | 
	
		
			
				|  |  | -						//判断是否有内部库存
 | 
	
		
			
				|  |  | -						if(goods.getStockCount() > 0){
 | 
	
		
			
				|  |  | -							
 | 
	
		
			
				|  |  | -							groupPurchaseAmount = groupPurchaseAmount.add(goods.getGroupPurchasePrice());
 | 
	
		
			
				|  |  | -							goods.setStockCount(new AtomicInteger(goods.getStockCount()).decrementAndGet());
 | 
	
		
			
				|  |  | -							goods.setSellCount(new AtomicInteger(goods.getSellCount()).incrementAndGet());
 | 
	
		
			
				|  |  | -							goods.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  | -							batchUpdateGoodsMap.put(goods.getId(), goods);
 | 
	
		
			
				|  |  | -							
 | 
	
		
			
				|  |  | -							minuendStockGoodsIdList.add(goods.getId());
 | 
	
		
			
				|  |  | -							
 | 
	
		
			
				|  |  | -							goodsProcurement = goodsProcurementDao.getWithStockSurplusProcurement(goods.getId());
 | 
	
		
			
				|  |  | -							if(goodsProcurement != null){
 | 
	
		
			
				|  |  | -								if(goodsProcurementMap.get(goodsProcurement.getId()) != null){
 | 
	
		
			
				|  |  | -									goodsProcurement = goodsProcurementMap.get(goodsProcurement.getId());
 | 
	
		
			
				|  |  | -								}
 | 
	
		
			
				|  |  | -								goodsProcurement.setStockSoldNum(new AtomicInteger(goodsProcurement.getStockSoldNum()).incrementAndGet());
 | 
	
		
			
				|  |  | -								goodsProcurement.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  | -								goodsProcurementMap.put(goodsProcurement.getId(), goodsProcurement);
 | 
	
		
			
				|  |  | +						if (minuendStockGoodsIdList.size() > 0) {
 | 
	
		
			
				|  |  | +							studentPaymentOrderDetail.setIncomeItem(OrderDetailTypeEnum.CLOUD_TEACHER.name());
 | 
	
		
			
				|  |  | +							studentPaymentOrderDetail.setIncome(BigDecimal.ZERO);
 | 
	
		
			
				|  |  | +							studentPaymentOrderDetail.setBalanceIncome(BigDecimal.ZERO);
 | 
	
		
			
				|  |  | +							if(minuendStockGoodsIdList.size() > 0){
 | 
	
		
			
				|  |  | +								studentPaymentOrderDetail.setMinuendStockGoodsIdList(minuendStockGoodsIdList.stream().map(t -> t.toString()).collect(Collectors.joining(",")));
 | 
	
		
			
				|  |  |  							}
 | 
	
		
			
				|  |  |  						}
 | 
	
		
			
				|  |  | -					}
 | 
	
		
			
				|  |  | -					
 | 
	
		
			
				|  |  | -					if (minuendStockGoodsIdList.size() > 0) {
 | 
	
		
			
				|  |  | -						studentPaymentOrderDetail.setIncomeItem(OrderDetailTypeEnum.CLOUD_TEACHER.name());
 | 
	
		
			
				|  |  | -						studentPaymentOrderDetail.setIncome(BigDecimal.ZERO);
 | 
	
		
			
				|  |  | -						studentPaymentOrderDetail.setBalanceIncome(BigDecimal.ZERO);
 | 
	
		
			
				|  |  | -						if(minuendStockGoodsIdList.size() > 0){
 | 
	
		
			
				|  |  | -							studentPaymentOrderDetail.setMinuendStockGoodsIdList(minuendStockGoodsIdList.stream().map(t -> t.toString()).collect(Collectors.joining(",")));
 | 
	
		
			
				|  |  | -						}
 | 
	
		
			
				|  |  | -					}
 | 
	
		
			
				|  |  | +	                }
 | 
	
		
			
				|  |  |  	                
 | 
	
		
			
				|  |  |  	                studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
 | 
	
		
			
				|  |  |  				}
 |