| 
					
				 | 
			
			
				@@ -52,7 +52,7 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (OrganFullJobResourceNumDto organFullJobResource : organFullJobResources) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             OperatingReport operatingReport = new OperatingReport(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             operatingReport.setOrganId(organFullJobResource.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            operatingReport.setDistributionAmount(new BigDecimal(organFullJobResource.getNum()).multiply(fullJobFee)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            operatingReport.setDistributionAmount(new BigDecimal(organFullJobResource.getNum()).multiply(fullJobFee).divide(new BigDecimal(12),2,BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             organOperating.put(organFullJobResource.getOrganId(), operatingReport); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -70,6 +70,8 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             organOperatingReport.setOrganId(cooperationExpenditure.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cooperationOperatingReport.setOrganId(cooperationExpenditure.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cooperationOperatingReport.setCooperationOrganId(cooperationExpenditure.getCooperationOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (cooperationExpenditure.getType().equals(ExpenditureTypeEnum.FIXED)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 organOperatingReport.setExpensesAmount(organOperatingReport.getExpensesAmount().add(cooperationExpenditure.getAmount())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 cooperationOperatingReport.setExpensesAmount(cooperationExpenditure.getAmount()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -99,6 +101,9 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (cooperationOperating.containsKey(musicReport.getCooperationOrganId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 cooperationOperatingReport = cooperationOperating.get(musicReport.getCooperationOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            organOperatingReport.setOrganId(musicReport.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cooperationOperatingReport.setOrganId(musicReport.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cooperationOperatingReport.setCooperationOrganId(musicReport.getCooperationOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (musicReport.getSellAmount() == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 musicReport.setSellAmount(BigDecimal.ZERO); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -128,6 +133,10 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (vpReport.getCooperationOrganId() != null && cooperationOperating.containsKey(vpReport.getCooperationOrganId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 cooperationOperatingReport = cooperationOperating.get(vpReport.getCooperationOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            organOperatingReport.setOrganId(vpReport.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cooperationOperatingReport.setOrganId(vpReport.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cooperationOperatingReport.setCooperationOrganId(vpReport.getCooperationOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             organOperatingReport.setServiceAmount(organOperatingReport.getServiceAmount().add(vpReport.getIncomeTotal())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             cooperationOperatingReport.setServiceAmount(cooperationOperatingReport.getServiceAmount().add(vpReport.getIncomeTotal())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -152,6 +161,10 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 cooperationOperatingReport = cooperationOperating.get(outOrderReport.getCooperationOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            organOperatingReport.setOrganId(outOrderReport.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cooperationOperatingReport.setOrganId(outOrderReport.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cooperationOperatingReport.setCooperationOrganId(outOrderReport.getCooperationOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (outOrderReport.getSellAmount() == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 outOrderReport.setSellAmount(BigDecimal.ZERO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 outOrderReport.setSellCost(BigDecimal.ZERO); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -184,6 +197,10 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (rechargeReport.getCooperationOrganId() != null && cooperationOperating.containsKey(rechargeReport.getCooperationOrganId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 cooperationOperatingReport = cooperationOperating.get(rechargeReport.getCooperationOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            organOperatingReport.setOrganId(rechargeReport.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cooperationOperatingReport.setOrganId(rechargeReport.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cooperationOperatingReport.setCooperationOrganId(rechargeReport.getCooperationOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             organOperatingReport.setOtherIncome(organOperatingReport.getOtherIncome().add(rechargeReport.getIncomeTotal())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             cooperationOperatingReport.setOtherIncome(cooperationOperatingReport.getIncomeTotal().add(rechargeReport.getIncomeTotal())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -206,6 +223,10 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (sporadicReport.getCooperationOrganId() != null && cooperationOperating.containsKey(sporadicReport.getCooperationOrganId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 cooperationOperatingReport = cooperationOperating.get(sporadicReport.getCooperationOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            organOperatingReport.setOrganId(sporadicReport.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cooperationOperatingReport.setOrganId(sporadicReport.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cooperationOperatingReport.setCooperationOrganId(sporadicReport.getCooperationOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             organOperatingReport.setServiceAmount(organOperatingReport.getServiceAmount().add(sporadicReport.getIncomeTotal())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             cooperationOperatingReport.setServiceAmount(cooperationOperatingReport.getServiceAmount().add(sporadicReport.getIncomeTotal())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -217,29 +238,38 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        organOperating.putAll(cooperationOperating); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Map<String, Object> params = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         params.put("startTime", startTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         params.put("endTime", endTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         organOperating.forEach((organId, operatingReport) -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             operatingReport.setMonth(startTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             operatingReport.setCreateTime(nowDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //收入合计:销售收入+服务收入-业务退费 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal incomeTotal = operatingReport.getSellAmount().add(operatingReport.getServiceAmount()).subtract(operatingReport.getRefundAmount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            operatingReport.setIncomeTotal(incomeTotal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //成本费用合计:销售成本+固定支出+变动支出+分摊费用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal costAmount = operatingReport.getSellCost().add(operatingReport.getExpensesAmount()).add(operatingReport.getVariableCost()).add(operatingReport.getDistributionAmount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            operatingReport.setCostAmount(costAmount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //利润:收入合计-成本费用合计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            operatingReport.setProfit(incomeTotal.subtract(costAmount)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            params.put("organId", operatingReport.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            params.put("cooperationOrganId", operatingReport.getCooperationOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (operatingReportDao.getReport(params) == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                operatingReportDao.insert(operatingReport); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                operatingReportDao.update(operatingReport); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            updateReport(operatingReport, params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cooperationOperating.forEach((organId, operatingReport) -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            operatingReport.setDistributionAmount(fullJobFee.divide(new BigDecimal(12),2,BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            operatingReport.setMonth(startTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            operatingReport.setCreateTime(nowDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            updateReport(operatingReport, params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void updateReport(OperatingReport operatingReport, Map<String, Object> params) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //收入合计:销售收入+服务收入-业务退费 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal incomeTotal = operatingReport.getSellAmount().add(operatingReport.getServiceAmount()).subtract(operatingReport.getRefundAmount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        operatingReport.setIncomeTotal(incomeTotal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //成本费用合计:销售成本+固定支出+变动支出+分摊费用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal costAmount = operatingReport.getSellCost().add(operatingReport.getExpensesAmount()).add(operatingReport.getVariableCost()).add(operatingReport.getDistributionAmount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        operatingReport.setCostAmount(costAmount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //利润:收入合计-成本费用合计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        operatingReport.setProfit(incomeTotal.subtract(costAmount)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        params.put("organId", operatingReport.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        params.put("cooperationOrganId", operatingReport.getCooperationOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (operatingReportDao.getReport(params) == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            operatingReportDao.insert(operatingReport); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            operatingReportDao.update(operatingReport); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |