| 
					
				 | 
			
			
				@@ -1,29 +1,33 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.ym.mec.biz.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.NO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dao.MusicGroupDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.entity.MusicGroup; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.enums.MessageTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.enums.PaymentStatusEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.service.SysMessageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.dal.BaseDAO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.exception.BizException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.service.impl.BaseServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.thirdparty.message.MessageSenderPluginContext; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.NO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalender> implements MusicGroupPaymentCalenderService { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -36,6 +40,10 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	private MusicGroupStudentFeeDao musicGroupStudentFeeDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private MusicGroupDao musicGroupDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private SysMessageService sysMessageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public BaseDAO<Long, MusicGroupPaymentCalender> getDAO() { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -79,7 +87,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if (musicGroupPaymentCalender.getPaymentStatus() == PaymentStatusEnum.OPEN) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if (musicGroupStudentFeeList != null && musicGroupStudentFeeList.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				Set<Integer> studentIds = musicGroupStudentFeeList.stream().map(e -> e.getUserId()).collect(Collectors.toSet()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				// 创建缴费明细 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				for (MusicGroupStudentFee mgsf : musicGroupStudentFeeList) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -109,6 +117,16 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					mgsf.setUpdateTime(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					updateMusicGroupStudentFeeList.add(mgsf); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if (studentIds.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					Map<Integer, String> push = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					for (Integer userId : studentIds) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						push.put(userId, userId + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					MusicGroup musicGroup = musicGroupDao.get(musicGroupPaymentCalender.getMusicGroupId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					String memo = "4?http://mstudev.dayaedu.com/#/renew?musicGroupId=" + musicGroup.getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					// 发送续费通知 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE, push, null, 0, memo,"STUDENT",musicGroup.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -140,7 +158,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		for (MusicGroupPaymentCalender mgpc : musicGroupPaymentCalenderList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (date.after(mgpc.getDeadlinePaymentDate())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (mgpc.getDeadlinePaymentDate() != null && date.after(mgpc.getDeadlinePaymentDate())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				// “进行中”更新至“已结束” 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				mgpc.setUpdateTime(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				mgpc.setPaymentStatus(PaymentStatusEnum.YES); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -148,7 +166,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				// 学生状态更新已结束 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} else if (date.after(mgpc.getStartPaymentDate())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} else if (mgpc.getStartPaymentDate() != null && date.after(mgpc.getStartPaymentDate())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				// “未开始”更新至“进行中” 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				mgpc.setUpdateTime(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				mgpc.setPaymentStatus(PaymentStatusEnum.OPEN); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -156,7 +174,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				// 学生状态更新进行中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				List<MusicGroupStudentFee> musicGroupStudentFeeList = musicGroupStudentFeeDao.queryByMusicGroupId(mgpc.getMusicGroupId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				Set<Integer> studentIds = musicGroupStudentFeeList.stream().map(e -> e.getUserId()).collect(Collectors.toSet()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				// 创建缴费明细 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				for (MusicGroupStudentFee mgsf : musicGroupStudentFeeList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -185,6 +203,16 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					mgsf.setUpdateTime(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					updateMusicGroupStudentFeeList.add(mgsf); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if (studentIds.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					Map<Integer, String> push = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					for (Integer userId : studentIds) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						push.put(userId, userId + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					MusicGroup musicGroup = musicGroupDao.get(mgpc.getMusicGroupId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					String memo = "4?http://mstudev.dayaedu.com/#/renew?musicGroupId=" + musicGroup.getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					// 发送续费通知 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_WAIT_RENEW_MESSAGE, push, null, 0, memo,"STUDENT",musicGroup.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |