| 
					
				 | 
			
			
				@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.StudentRegistrationDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dto.LuckStatisDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dto.OrderStatisDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dto.OrganMaxAmountDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.Organization; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.controller.BaseController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.entity.HttpResponseResult; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -43,6 +44,8 @@ public class ActivityController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Set<Integer> orderOrganIds = orders.stream().map(OrderStatisDto::getOrganId).collect(Collectors.toSet()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //获取所有分部预计的人数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<OrderStatisDto> organNormalStudents = studentRegistrationDao.getOrganNormalStudent(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //获取分部的目标金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<OrganMaxAmountDto> maxAmount4Organs = sporadicChargeInfoDao.getActiveOrgansMaxAmount(12); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (Organization organ : organs) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (!orderOrganIds.contains(organ.getId())) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -56,7 +59,15 @@ public class ActivityController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Integer totalEstimatedNums = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Integer totalNum = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Integer totalTimes = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal totalMaxAmount = BigDecimal.ZERO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (OrderStatisDto order : orders) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (OrganMaxAmountDto maxAmount4Organ : maxAmount4Organs) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (order.getOrganId().equals(maxAmount4Organ.getId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    order.setMaxAmount(maxAmount4Organ.getMaxAmount() == null ? BigDecimal.ZERO.setScale(2) : maxAmount4Organ.getMaxAmount().setScale(2)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             for (OrderStatisDto organNormalStudent : organNormalStudents) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (order.getOrganId().equals(organNormalStudent.getOrganId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     order.setEstimatedNums(organNormalStudent.getEstimatedNums()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -67,10 +78,11 @@ public class ActivityController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             totalNum += order.getNums(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             totalTimes += order.getTimes(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             totalMoney = totalMoney.add(order.getMoney()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (order.getEstimatedNums() <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                order.setScale(new BigDecimal(order.getNums()).multiply(new BigDecimal(100)).divide(new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                order.setScale(new BigDecimal(order.getNums()).multiply(new BigDecimal(100)).divide(new BigDecimal(order.getEstimatedNums()), 2, BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            totalMaxAmount = totalMaxAmount.add(order.getMaxAmount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (order.getMaxAmount().compareTo(BigDecimal.ZERO) <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                order.setScale(new BigDecimal("100.00")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                order.setScale(order.getMoney().multiply(new BigDecimal(100)).divide(order.getMaxAmount(), 2, BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         orders.sort(Comparator.comparing(OrderStatisDto::getMoney).reversed()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -81,10 +93,11 @@ public class ActivityController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         luckStatisDto.setTotalNum(totalNum); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         luckStatisDto.setTotalTimes(totalTimes); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         luckStatisDto.setTotalMoney(totalMoney); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (luckStatisDto.getTotalEstimatedNums() <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            totalEstimatedNums = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        luckStatisDto.setTotalMaxAmount(totalMaxAmount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (luckStatisDto.getTotalMaxAmount().compareTo(BigDecimal.ZERO) <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            totalMaxAmount = BigDecimal.ONE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        luckStatisDto.setScale(new BigDecimal(totalNum).multiply(new BigDecimal(100)).divide(new BigDecimal(totalEstimatedNums), 2, BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        luckStatisDto.setScale(totalMoney.multiply(new BigDecimal(100)).divide(totalMaxAmount, 2, BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return succeed(luckStatisDto); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |