|  | @@ -6,7 +6,9 @@ import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.SimpleUserDto;
 | 
	
		
			
				|  |  |  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.enums.MessageTypeEnum;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.MusicGroupPaymentCalenderDetailService;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.MusicGroupStudentFeeService;
 | 
	
	
		
			
				|  | @@ -131,4 +133,40 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 | 
	
		
			
				|  |  |  	public void refreshUserMusicGroupPaymentStatusTask() {
 | 
	
		
			
				|  |  |  		musicGroupPaymentCalenderDetailDao.refreshUserMusicGroupPaymentStatusTask();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Override
 | 
	
		
			
				|  |  | +	@Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +	public void add(Long musicGroupPaymentCalenderId, Integer userId) {
 | 
	
		
			
				|  |  | +		if(musicGroupPaymentCalenderId == null || userId == null){
 | 
	
		
			
				|  |  | +			throw new BizException("参数校验异常");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(musicGroupPaymentCalenderId);
 | 
	
		
			
				|  |  | +		if(calender == null){
 | 
	
		
			
				|  |  | +			throw new BizException("缴费信息不存在");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		MusicGroupPaymentCalenderDetail userLastCalenderDetail = musicGroupPaymentCalenderDetailDao.getUserLastCalenderDetail(calender.getMusicGroupId(), userId);
 | 
	
		
			
				|  |  | +		if(userLastCalenderDetail != null){
 | 
	
		
			
				|  |  | +			throw new BizException("数据已存在");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		Date date = new Date();
 | 
	
		
			
				|  |  | +		MusicGroupStudentFee studentFee = musicGroupStudentFeeDao.findByUser(userId, calender.getMusicGroupId());
 | 
	
		
			
				|  |  | +		//修改预计人数
 | 
	
		
			
				|  |  | +		calender.setExpectNum(calender.getExpectNum());
 | 
	
		
			
				|  |  | +		calender.setUpdateTime(date);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		//生成详情
 | 
	
		
			
				|  |  | +		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
 | 
	
		
			
				|  |  | +		musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(calender.getId());
 | 
	
		
			
				|  |  | +		musicGroupPaymentCalenderDetail.setCreateTime(date);
 | 
	
		
			
				|  |  | +		musicGroupPaymentCalenderDetail.setExpectAmount(studentFee.getCourseFee());
 | 
	
		
			
				|  |  | +		if (studentFee.getCourseFee().doubleValue() == 0) {
 | 
	
		
			
				|  |  | +			musicGroupPaymentCalenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
 | 
	
		
			
				|  |  | +		} else {
 | 
	
		
			
				|  |  | +			musicGroupPaymentCalenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.NON_PAYMENT);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		musicGroupPaymentCalenderDetail.setUpdateTime(date);
 | 
	
		
			
				|  |  | +		musicGroupPaymentCalenderDetail.setUserId(userId);
 | 
	
		
			
				|  |  | +		musicGroupPaymentCalenderDetailDao.insert(musicGroupPaymentCalenderDetail);
 | 
	
		
			
				|  |  | +		musicGroupPaymentCalenderDao.update(calender);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  |  }
 |