|  | @@ -1,21 +1,19 @@
 | 
											
												
													
														|  |  package com.ym.mec.biz.service.impl;
 |  |  package com.ym.mec.biz.service.impl;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +import java.util.Date;
 | 
											
												
													
														|  | 
 |  | +import java.util.List;
 | 
											
												
													
														|  | 
 |  | +import java.util.stream.Collectors;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +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.MusicGroupPaymentCalenderDao;
 |  |  import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
 | 
											
												
													
														|  |  import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 |  |  import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 | 
											
												
													
														|  |  import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 |  |  import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 | 
											
												
													
														|  |  import com.ym.mec.common.dal.BaseDAO;
 |  |  import com.ym.mec.common.dal.BaseDAO;
 | 
											
												
													
														|  |  import com.ym.mec.common.service.impl.BaseServiceImpl;
 |  |  import com.ym.mec.common.service.impl.BaseServiceImpl;
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |  import com.ym.mec.util.date.DateUtil;
 |  |  import com.ym.mec.util.date.DateUtil;
 | 
											
												
													
														|  | -import org.springframework.beans.factory.annotation.Autowired;
 |  | 
 | 
											
												
													
														|  | -import org.springframework.stereotype.Service;
 |  | 
 | 
											
												
													
														|  | -import org.springframework.transaction.annotation.Transactional;
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -import java.util.Calendar;
 |  | 
 | 
											
												
													
														|  | -import java.util.Collections;
 |  | 
 | 
											
												
													
														|  | -import java.util.Date;
 |  | 
 | 
											
												
													
														|  | -import java.util.List;
 |  | 
 | 
											
												
													
														|  | -import java.util.stream.Collectors;
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  @Service
 |  |  @Service
 | 
											
												
													
														|  |  public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalender> implements MusicGroupPaymentCalenderService {
 |  |  public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalender> implements MusicGroupPaymentCalenderService {
 | 
											
										
											
												
													
														|  | @@ -44,29 +42,29 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 | 
											
												
													
														|  |  		List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
 |  |  		List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
 | 
											
												
													
														|  |  		if (musicGroupPaymentCalenderList != null && musicGroupPaymentCalenderList.size() > 0) {
 |  |  		if (musicGroupPaymentCalenderList != null && musicGroupPaymentCalenderList.size() > 0) {
 | 
											
												
													
														|  |  			Date date = new Date();
 |  |  			Date date = new Date();
 | 
											
												
													
														|  | -			List<Integer> months = musicGroupPaymentCalenderList.stream().map(e -> e.getPaymentMonth()).collect(Collectors.toList());
 |  | 
 | 
											
												
													
														|  | -			//获取当前月份
 |  | 
 | 
											
												
													
														|  | -			int currentMonth = Integer.parseInt(DateUtil.getMonth(date));
 |  | 
 | 
											
												
													
														|  | -			int nextMonth = currentMonth;
 |  | 
 | 
											
												
													
														|  | -			for (int i = 0;i < months.size();i++){
 |  | 
 | 
											
												
													
														|  | -				if(i == months.size()-1 && months.get(i) <= currentMonth){
 |  | 
 | 
											
												
													
														|  | -					nextMonth = months.get(0);
 |  | 
 | 
											
												
													
														|  | -					break;
 |  | 
 | 
											
												
													
														|  | -				}else if(months.get(i) > currentMonth){
 |  | 
 | 
											
												
													
														|  | -					nextMonth = months.get(i);
 |  | 
 | 
											
												
													
														|  | -					break;
 |  | 
 | 
											
												
													
														|  | 
 |  | +			List<Integer> months = musicGroupPaymentCalenderList.stream().map(e -> e.getPaymentMonth()).sorted().collect(Collectors.toList());
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			if (months.size() > 0) {
 | 
											
												
													
														|  | 
 |  | +				// 获取当前月份
 | 
											
												
													
														|  | 
 |  | +				int currentMonth = Integer.parseInt(DateUtil.getMonth(date));
 | 
											
												
													
														|  | 
 |  | +				int nextMonth = months.get(0);
 | 
											
												
													
														|  | 
 |  | +				for (int i = 0; i < months.size(); i++) {
 | 
											
												
													
														|  | 
 |  | +					if (currentMonth < months.get(i)) {
 | 
											
												
													
														|  | 
 |  | +						nextMonth = months.get(i);
 | 
											
												
													
														|  | 
 |  | +						break;
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  |  				}
 |  |  				}
 | 
											
												
													
														|  | 
 |  | +				// 修改学员付费周期
 | 
											
												
													
														|  | 
 |  | +				Date nextPaymentDate = null;
 | 
											
												
													
														|  | 
 |  | +				if (nextMonth > currentMonth) {
 | 
											
												
													
														|  | 
 |  | +					nextPaymentDate = DateUtil.addMonths(date, nextMonth - currentMonth);
 | 
											
												
													
														|  | 
 |  | +				} else if (nextMonth < currentMonth) {
 | 
											
												
													
														|  | 
 |  | +					nextPaymentDate = DateUtil.addMonths(date, 12 - currentMonth + nextMonth);
 | 
											
												
													
														|  | 
 |  | +				} else {
 | 
											
												
													
														|  | 
 |  | +					nextPaymentDate = DateUtil.addMonths(date, 12);
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				return DateUtil.getFirstDayOfMonth(nextPaymentDate);
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  | -			// 修改学员付费周期
 |  | 
 | 
											
												
													
														|  | -			Date nextPaymentDate = null;
 |  | 
 | 
											
												
													
														|  | -			if(nextMonth > currentMonth){
 |  | 
 | 
											
												
													
														|  | -				nextPaymentDate = DateUtil.addMonths(date, nextMonth - currentMonth);
 |  | 
 | 
											
												
													
														|  | -			}else if(nextMonth < currentMonth) {
 |  | 
 | 
											
												
													
														|  | -				nextPaymentDate = DateUtil.addMonths(date, 12 - currentMonth + nextMonth);
 |  | 
 | 
											
												
													
														|  | -			}else {
 |  | 
 | 
											
												
													
														|  | -				nextPaymentDate = DateUtil.addMonths(date, 12);
 |  | 
 | 
											
												
													
														|  | -			}
 |  | 
 | 
											
												
													
														|  | -			return DateUtil.getFirstDayOfMonth(nextPaymentDate);
 |  | 
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  		return null;
 |  |  		return null;
 | 
											
												
													
														|  |  	}
 |  |  	}
 |