|  | @@ -149,7 +149,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 | 
											
												
													
														|  |  		List<MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList = musicGroupPaymentCalenderDto.getMusicGroupPaymentDateRangeList();
 |  |  		List<MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList = musicGroupPaymentCalenderDto.getMusicGroupPaymentDateRangeList();
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		if ((paymentType == PaymentType.ADD_COURSE || payUserType == PayUserType.SCHOOL) && musicGroupPaymentDateRangeList.size() > 1) {
 |  |  		if ((paymentType == PaymentType.ADD_COURSE || payUserType == PayUserType.SCHOOL) && musicGroupPaymentDateRangeList.size() > 1) {
 | 
											
												
													
														|  | -			throw new BizException("临时加课和学校缴费不支持多周期缴费");
 |  | 
 | 
											
												
													
														|  | 
 |  | +			throw new BizException("[临时加课]和[学校缴费]不支持多周期缴费");
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
 |  |  		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
 | 
											
										
											
												
													
														|  | @@ -162,9 +162,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 | 
											
												
													
														|  |  			throw new BizException("请登录");
 |  |  			throw new BizException("请登录");
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  		// 所有缴费项目已完成排课才能创建下一个缴费项目
 |  |  		// 所有缴费项目已完成排课才能创建下一个缴费项目
 | 
											
												
													
														|  | -		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = musicGroupPaymentCalenderDetailDao
 |  | 
 | 
											
												
													
														|  | -				.getUnusedPaymentCalenderWithMusicGroup(musicGroupId);
 |  | 
 | 
											
												
													
														|  | -		if (musicGroupPaymentCalenderDetailList != null && musicGroupPaymentCalenderDetailList.size() > 0) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +		String orignBatchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, null, null);
 | 
											
												
													
														|  | 
 |  | +		if (StringUtils.isNoneBlank(orignBatchNo)) {
 | 
											
												
													
														|  |  			throw new BizException("当前乐团存在未排课的缴费项目,请先完成排课再操作");
 |  |  			throw new BizException("当前乐团存在未排课的缴费项目,请先完成排课再操作");
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -404,67 +403,70 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  	@Override
 |  |  	@Override
 | 
											
												
													
														|  |  	@Transactional(rollbackFor = Exception.class)
 |  |  	@Transactional(rollbackFor = Exception.class)
 | 
											
												
													
														|  | -	public Long merge(MusicGroupPaymentCalender musicGroupPaymentCalender) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +	public String merge(MusicGroupPaymentCalenderDto musicGroupPaymentCalenderDto) {
 | 
											
												
													
														|  |  		
 |  |  		
 | 
											
												
													
														|  | -		MusicGroupPaymentCalender originMusicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(musicGroupPaymentCalender.getId());
 |  | 
 | 
											
												
													
														|  | -		if(originMusicGroupPaymentCalender == null){
 |  | 
 | 
											
												
													
														|  | -			throw new BizException("查询不到缴费记录");
 |  | 
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  | -		SysUser sysUser = sysUserFeignService.queryUserInfo();
 |  | 
 | 
											
												
													
														|  | -		if (sysUser == null) {
 |  | 
 | 
											
												
													
														|  | -			throw new BizException("请登录");
 |  | 
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  | -		//只有“拒绝”才能修改
 |  | 
 | 
											
												
													
														|  | -		if(originMusicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.REJECT){
 |  | 
 | 
											
												
													
														|  | -			throw new BizException("缴费记录只有被“审核拒绝”才能修改");
 |  | 
 | 
											
												
													
														|  | 
 |  | +		String batchNo = musicGroupPaymentCalenderDto.getBatchNo();
 | 
											
												
													
														|  | 
 |  | +		
 | 
											
												
													
														|  | 
 |  | +		List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.findByBatchNo(batchNo);
 | 
											
												
													
														|  | 
 |  | +		if(musicGroupPaymentCalenderList == null || musicGroupPaymentCalenderList.size() == 0){
 | 
											
												
													
														|  | 
 |  | +			throw new BizException("[批次号]参数错误");
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  		
 |  |  		
 | 
											
												
													
														|  | -		String musicGroupId = musicGroupPaymentCalender.getMusicGroupId();
 |  | 
 | 
											
												
													
														|  | 
 |  | +		PaymentCalenderStatusEnum status = musicGroupPaymentCalenderList.get(0).getStatus();
 | 
											
												
													
														|  | 
 |  | +		
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		String musicGroupId = musicGroupPaymentCalenderDto.getMusicGroupId();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		PaymentType paymentType = musicGroupPaymentCalenderDto.getPaymentType();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		PayUserType payUserType = musicGroupPaymentCalenderDto.getPayUserType();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		List<MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList = musicGroupPaymentCalenderDto.getMusicGroupPaymentDateRangeList();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		if ((paymentType == PaymentType.ADD_COURSE || payUserType == PayUserType.SCHOOL) && musicGroupPaymentDateRangeList.size() > 1) {
 | 
											
												
													
														|  | 
 |  | +			throw new BizException("[临时加课]和[学校缴费]不支持多周期缴费");
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
 |  |  		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
 | 
											
												
													
														|  | -		
 |  | 
 | 
											
												
													
														|  | -		if(musicGroup == null){
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		if (musicGroup == null) {
 | 
											
												
													
														|  |  			throw new BizException("乐团查询失败,请检查参数");
 |  |  			throw new BizException("乐团查询失败,请检查参数");
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  | -		//如果是进行中加学生,查看学员是否在团
 |  | 
 | 
											
												
													
														|  | -		if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
 |  | 
 | 
											
												
													
														|  | -			musicGroupPaymentCalender.setStudentIds(originMusicGroupPaymentCalender.getStudentIds());
 |  | 
 | 
											
												
													
														|  | -			StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(Integer.parseInt(musicGroupPaymentCalender.getStudentIds()),musicGroupId);
 |  | 
 | 
											
												
													
														|  | -			if(studentRegistration == null){
 |  | 
 | 
											
												
													
														|  | -				throw new BizException("修改失败:学员不存在或已退团");
 |  | 
 | 
											
												
													
														|  | -			}
 |  | 
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  | -		
 |  | 
 | 
											
												
													
														|  | -		Date date = new Date();
 |  | 
 | 
											
												
													
														|  | -		
 |  | 
 | 
											
												
													
														|  | -		musicGroupPaymentCalender.setUpdateTime(date);
 |  | 
 | 
											
												
													
														|  | -		if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null && musicGroupPaymentCalender.getPayUserType() == PayUserType.STUDENT) {
 |  | 
 | 
											
												
													
														|  | -			musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
 |  | 
 | 
											
												
													
														|  | 
 |  | +		SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
											
												
													
														|  | 
 |  | +		if (sysUser == null) {
 | 
											
												
													
														|  | 
 |  | +			throw new BizException("请登录");
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  | -		if(musicGroupPaymentCalender.getPaymentType() != ADD_STUDENT){
 |  | 
 | 
											
												
													
														|  | -			int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(), musicGroupPaymentCalender.getPaymentValidStartDate(),
 |  | 
 | 
											
												
													
														|  | -					musicGroupPaymentCalender.getPaymentValidEndDate(), musicGroupPaymentCalender.getId());
 |  | 
 | 
											
												
													
														|  | -			if (count > 0) {
 |  | 
 | 
											
												
													
														|  | -				throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		// 不是进行中,只能创建一次缴费
 | 
											
												
													
														|  | 
 |  | +		if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS) {
 | 
											
												
													
														|  | 
 |  | +			List<MusicGroupPaymentCalender> list = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
 | 
											
												
													
														|  | 
 |  | +			if (list.size() > 0) {
 | 
											
												
													
														|  | 
 |  | +				throw new BizException("创建失败,已经存在缴费信息");
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  | -		
 |  | 
 | 
											
												
													
														|  | -		//获取设置的课程
 |  | 
 | 
											
												
													
														|  | -		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalender.getMusicGroupPaymentCalenderCourseSettingsList();
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		status = PaymentCalenderStatusEnum.NO;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		Date date = new Date();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		// 获取设置的课程
 | 
											
												
													
														|  | 
 |  | +		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderDto
 | 
											
												
													
														|  | 
 |  | +				.getMusicGroupPaymentCalenderCourseSettingsList();
 | 
											
												
													
														|  |  		if (musicGroupPaymentCalenderCourseSettingsList == null) {
 |  |  		if (musicGroupPaymentCalenderCourseSettingsList == null) {
 | 
											
												
													
														|  |  			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
 |  |  			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  | -		if (musicGroupPaymentCalender.getPayUserType() == SCHOOL) {
 |  | 
 | 
											
												
													
														|  | -			musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		if (payUserType == SCHOOL) {
 | 
											
												
													
														|  | 
 |  | +			status = PaymentCalenderStatusEnum.AUDITING;
 | 
											
												
													
														|  |  		} else {
 |  |  		} else {
 | 
											
												
													
														|  | -			if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY || musicGroupPaymentCalender.getPaymentType() == MUSIC_RENEW) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +			if (paymentType == MUSIC_APPLY || paymentType == MUSIC_RENEW) {
 | 
											
												
													
														|  |  				// 当前缴费的课程费用
 |  |  				// 当前缴费的课程费用
 | 
											
												
													
														|  |  				Map<CourseScheduleType, BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(
 |  |  				Map<CourseScheduleType, BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(
 | 
											
												
													
														|  |  						Collectors
 |  |  						Collectors
 | 
											
												
													
														|  |  								.toMap(MusicGroupPaymentCalenderCourseSettings::getCourseType, MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice));
 |  |  								.toMap(MusicGroupPaymentCalenderCourseSettings::getCourseType, MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice));
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  				// 查询默认课程费用
 |  |  				// 查询默认课程费用
 | 
											
												
													
														|  | -				Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
 |  | 
 | 
											
												
													
														|  | 
 |  | +				Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId();
 | 
											
												
													
														|  |  				Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao
 |  |  				Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao
 | 
											
												
													
														|  |  						.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId)
 |  |  						.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId)
 | 
											
												
													
														|  |  						.stream()
 |  |  						.stream()
 | 
											
										
											
												
													
														|  | @@ -475,11 +477,11 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 | 
											
												
													
														|  |  				// 相同类型的课程如果修改了课程费用,需要走审批
 |  |  				// 相同类型的课程如果修改了课程费用,需要走审批
 | 
											
												
													
														|  |  				for (Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()) {
 |  |  				for (Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()) {
 | 
											
												
													
														|  |  					if (defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0) {
 |  |  					if (defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0) {
 | 
											
												
													
														|  | -						musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
 |  | 
 | 
											
												
													
														|  | 
 |  | +						status = PaymentCalenderStatusEnum.AUDITING;
 | 
											
												
													
														|  |  						break;
 |  |  						break;
 | 
											
												
													
														|  |  					}
 |  |  					}
 | 
											
												
													
														|  |  				}
 |  |  				}
 | 
											
												
													
														|  | -			} else if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_COURSE || musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +			} else if (paymentType == PaymentType.ADD_COURSE || paymentType == PaymentType.ADD_STUDENT) {
 | 
											
												
													
														|  |  				// 如果是临时加课,是否审核是根据单价判断
 |  |  				// 如果是临时加课,是否审核是根据单价判断
 | 
											
												
													
														|  |  				for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
 |  |  				for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
 | 
											
												
													
														|  |  					OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
 |  |  					OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
 | 
											
										
											
												
													
														|  | @@ -487,54 +489,147 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 | 
											
												
													
														|  |  					if (defaultUnitPrice == null) {
 |  |  					if (defaultUnitPrice == null) {
 | 
											
												
													
														|  |  						throw new BizException("请先设置分部课程类型单价");
 |  |  						throw new BizException("请先设置分部课程类型单价");
 | 
											
												
													
														|  |  					}
 |  |  					}
 | 
											
												
													
														|  | -					if (courseSettings.getCourseCurrentPrice().divide(new BigDecimal(courseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN)
 |  | 
 | 
											
												
													
														|  | 
 |  | +					if (courseSettings.getCourseCurrentPrice()
 | 
											
												
													
														|  | 
 |  | +							.divide(new BigDecimal(courseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN)
 | 
											
												
													
														|  |  							.compareTo(defaultUnitPrice.getUnitPrice()) != 0) {
 |  |  							.compareTo(defaultUnitPrice.getUnitPrice()) != 0) {
 | 
											
												
													
														|  | -						musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
 |  | 
 | 
											
												
													
														|  | 
 |  | +						status = PaymentCalenderStatusEnum.AUDITING;
 | 
											
												
													
														|  |  						break;
 |  |  						break;
 | 
											
												
													
														|  |  					}
 |  |  					}
 | 
											
												
													
														|  |  				}
 |  |  				}
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
 |  | 
 | 
											
												
													
														|  | -			if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
 |  | 
 | 
											
												
													
														|  | -				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
 |  | 
 | 
											
												
													
														|  | -			}else if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
 |  | 
 | 
											
												
													
														|  | -				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
 |  | 
 | 
											
												
													
														|  | -			}else {
 |  | 
 | 
											
												
													
														|  | -				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
 |  | 
 | 
											
												
													
														|  | 
 |  | +		int times = musicGroupPaymentDateRangeList.size();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		// 排序
 | 
											
												
													
														|  | 
 |  | +		Collections.sort(musicGroupPaymentDateRangeList, new Comparator<MusicGroupPaymentDateRange>() {
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			@Override
 | 
											
												
													
														|  | 
 |  | +			public int compare(MusicGroupPaymentDateRange o1, MusicGroupPaymentDateRange o2) {
 | 
											
												
													
														|  | 
 |  | +				return o1.getPaymentValidStartDate().compareTo(o2.getPaymentValidStartDate());
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  | -			
 |  | 
 | 
											
												
													
														|  | -			//如果是进行中加学生
 |  | 
 | 
											
												
													
														|  | -			if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
 |  | 
 | 
											
												
													
														|  | -				addStudent(musicGroupPaymentCalender,musicGroupPaymentCalenderCourseSettingsList);
 |  | 
 | 
											
												
													
														|  | 
 |  | +		});
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		for (int i = 0; i < musicGroupPaymentDateRangeList.size(); i++) {
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			MusicGroupPaymentDateRange musicGroupPaymentDateRange = musicGroupPaymentDateRangeList.get(i);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			MusicGroupPaymentCalender musicGroupPaymentCalender = new MusicGroupPaymentCalender();
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setAttribute1(musicGroupPaymentCalenderDto.getAttribute1());
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setAttribute2(musicGroupPaymentCalenderDto.getAttribute2());
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setDeadlinePaymentDate(musicGroupPaymentDateRange.getDeadlinePaymentDate());
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setIsGiveMusicNetwork(musicGroupPaymentCalenderDto.getIsGiveMusicNetwork());
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setMemo(musicGroupPaymentCalenderDto.getMemo());
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setMusicGroupId(musicGroupId);
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setMusicGroupOrganizationCourseSettingId(musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId());
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			List<MusicGroupPaymentCalenderCourseSettings> newCSList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>(
 | 
											
												
													
														|  | 
 |  | +					musicGroupPaymentCalenderCourseSettingsList.size());
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			for (MusicGroupPaymentCalenderCourseSettings pccs : musicGroupPaymentCalenderCourseSettingsList) {
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +				MusicGroupPaymentCalenderCourseSettings tempPccs = new MusicGroupPaymentCalenderCourseSettings();
 | 
											
												
													
														|  | 
 |  | +				try {
 | 
											
												
													
														|  | 
 |  | +					BeanUtils.copyProperties(tempPccs, pccs);
 | 
											
												
													
														|  | 
 |  | +				} catch (Exception e) {
 | 
											
												
													
														|  | 
 |  | +					throw new BizException("克隆对象出错", e);
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				if (i == 0) {
 | 
											
												
													
														|  | 
 |  | +					tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().subtract(
 | 
											
												
													
														|  | 
 |  | +							pccs.getCourseCurrentPrice().divide(new BigDecimal(times)).setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))));
 | 
											
												
													
														|  | 
 |  | +					tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().subtract(
 | 
											
												
													
														|  | 
 |  | +							pccs.getCourseOriginalPrice().divide(new BigDecimal(times)).setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))));
 | 
											
												
													
														|  | 
 |  | +					tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() - pccs.getCourseTotalMinuties() / times * (times - 1));
 | 
											
												
													
														|  | 
 |  | +				} else {
 | 
											
												
													
														|  | 
 |  | +					tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().divide(new BigDecimal(times)).setScale(2, BigDecimal.ROUND_DOWN));
 | 
											
												
													
														|  | 
 |  | +					tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().divide(new BigDecimal(times)).setScale(2, BigDecimal.ROUND_DOWN));
 | 
											
												
													
														|  | 
 |  | +					tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() / times);
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				newCSList.add(tempPccs);
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setMusicGroupPaymentCalenderCourseSettingsList(newCSList);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		}else {
 |  | 
 | 
											
												
													
														|  | -			if(musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT){
 |  | 
 | 
											
												
													
														|  | -				musicGroupPaymentCalender.setExpectNum(1);
 |  | 
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setPaymentPattern(musicGroupPaymentCalenderDto.getPaymentPattern());
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setPaymentValidEndDate(musicGroupPaymentDateRange.getPaymentValidEndDate());
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setPaymentValidStartDate(musicGroupPaymentDateRange.getPaymentValidStartDate());
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setPaymentType(musicGroupPaymentCalenderDto.getPaymentType());
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setPayUserType(musicGroupPaymentCalenderDto.getPayUserType());
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setStartPaymentDate(musicGroupPaymentDateRange.getStartPaymentDate());
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setStudentIds(musicGroupPaymentCalenderDto.getStudentIds());
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setOperator(sysUser.getId());
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setCreateTime(date);
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setUpdateTime(date);
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setStatus(status);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null && payUserType == PayUserType.STUDENT) {
 | 
											
												
													
														|  | 
 |  | +				musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if (paymentType != ADD_STUDENT) {
 | 
											
												
													
														|  | 
 |  | +				int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(),
 | 
											
												
													
														|  | 
 |  | +						musicGroupPaymentCalender.getPaymentValidStartDate(), musicGroupPaymentCalender.getPaymentValidEndDate(), null);
 | 
											
												
													
														|  | 
 |  | +				if (count > 0) {
 | 
											
												
													
														|  | 
 |  | +					throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  | -            Set<Integer> roleIds = new HashSet<>(1);
 |  | 
 | 
											
												
													
														|  | -            roleIds.add(SysUserRole.ADMINISTRATOR);
 |  | 
 | 
											
												
													
														|  | -            Organization organization = organizationDao.get(musicGroup.getOrganId());
 |  | 
 | 
											
												
													
														|  | -            sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_PAYMENT_CALENDER_AUDIT, "", organization.getName(),musicGroup.getName());
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			if (paymentType == PaymentType.ADD_STUDENT) {
 | 
											
												
													
														|  | 
 |  | +				musicGroupPaymentCalender.setPayUserType(STUDENT);
 | 
											
												
													
														|  | 
 |  | +				musicGroupPaymentCalender.setIsGiveMusicNetwork(false);
 | 
											
												
													
														|  | 
 |  | +				if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
 | 
											
												
													
														|  | 
 |  | +					musicGroupPaymentCalender.setExpectNum(1);
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
 | 
											
												
													
														|  | 
 |  | +				if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
 | 
											
												
													
														|  | 
 |  | +					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
 | 
											
												
													
														|  | 
 |  | +				} else if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
 | 
											
												
													
														|  | 
 |  | +					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OVER);
 | 
											
												
													
														|  | 
 |  | +				} else {
 | 
											
												
													
														|  | 
 |  | +					musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			status = musicGroupPaymentCalender.getStatus();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			// 设置批次号
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalender.setBatchNo(batchNo);
 | 
											
												
													
														|  | 
 |  | +			musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			List<MusicGroupPaymentCalenderCourseSettings> currentMusicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalender
 | 
											
												
													
														|  | 
 |  | +					.getMusicGroupPaymentCalenderCourseSettingsList();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
 | 
											
												
													
														|  | 
 |  | +				// 如果是进行中加学生
 | 
											
												
													
														|  | 
 |  | +				if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
 | 
											
												
													
														|  | 
 |  | +					addStudent(musicGroupPaymentCalender, currentMusicGroupPaymentCalenderCourseSettings);
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			if (currentMusicGroupPaymentCalenderCourseSettings.size() > 0) {
 | 
											
												
													
														|  | 
 |  | +				MusicGroupOrganizationCourseSettings courseSettings = musicGroupOrganizationCourseSettingsDao.get(musicGroupPaymentCalender
 | 
											
												
													
														|  | 
 |  | +						.getMusicGroupOrganizationCourseSettingId());
 | 
											
												
													
														|  | 
 |  | +				for (MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : currentMusicGroupPaymentCalenderCourseSettings) {
 | 
											
												
													
														|  | 
 |  | +					musicGroupPaymentCalenderCourseSettings.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
 | 
											
												
													
														|  | 
 |  | +					if (courseSettings != null) {
 | 
											
												
													
														|  | 
 |  | +						musicGroupPaymentCalenderCourseSettings.setName(courseSettings.getName());
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				musicGroupPaymentCalenderCourseSettingsDao.batchInsert(currentMusicGroupPaymentCalenderCourseSettings);
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		// 如果是报名,需要修改乐团状态
 |  |  		// 如果是报名,需要修改乐团状态
 | 
											
												
													
														|  | -		if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
 |  | 
 | 
											
												
													
														|  | -			int countAuditReject = musicGroupPaymentCalenderDao.countAuditReject(musicGroupPaymentCalender.getMusicGroupId(),musicGroupPaymentCalender.getId());
 |  | 
 | 
											
												
													
														|  | -			if(countAuditReject == 0){
 |  | 
 | 
											
												
													
														|  | -				if (musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT && musicGroup.getStatus() != MusicGroupStatusEnum.AUDIT_FAILED) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +		if (paymentType == MUSIC_APPLY) {
 | 
											
												
													
														|  | 
 |  | +			int countAuditReject = musicGroupPaymentCalenderDao.countAuditReject(musicGroupId, null);
 | 
											
												
													
														|  | 
 |  | +			if (countAuditReject == 0) {
 | 
											
												
													
														|  | 
 |  | +				if (musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT) {
 | 
											
												
													
														|  |  					throw new BizException("创建失败:缴费项目类型不匹配");
 |  |  					throw new BizException("创建失败:缴费项目类型不匹配");
 | 
											
												
													
														|  |  				}
 |  |  				}
 | 
											
												
													
														|  | -				if(musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING){
 |  | 
 | 
											
												
													
														|  | 
 |  | +				if (status != PaymentCalenderStatusEnum.AUDITING) {
 | 
											
												
													
														|  |  					musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
 |  |  					musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
 | 
											
												
													
														|  |  					// 记录操作日志
 |  |  					// 记录操作日志
 | 
											
												
													
														|  |  					musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(草稿 -> 基础信息审核中)", sysUser.getId(), ""));
 |  |  					musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(草稿 -> 基础信息审核中)", sysUser.getId(), ""));
 | 
											
												
													
														|  | -					Set<Integer> roleIds = new HashSet<>(1);
 |  | 
 | 
											
												
													
														|  | -					roleIds.add(SysUserRole.SECTION_MANAGER);
 |  | 
 | 
											
												
													
														|  | -					sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getUsername());
 |  | 
 | 
											
												
													
														|  | -				}else{
 |  | 
 | 
											
												
													
														|  | 
 |  | +				} else {
 | 
											
												
													
														|  |  					musicGroup.setStatus(MusicGroupStatusEnum.FEE_AUDIT);
 |  |  					musicGroup.setStatus(MusicGroupStatusEnum.FEE_AUDIT);
 | 
											
												
													
														|  |  					// 记录操作日志
 |  |  					// 记录操作日志
 | 
											
												
													
														|  |  					musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(草稿 -> 费用审核中)", sysUser.getId(), ""));
 |  |  					musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(草稿 -> 费用审核中)", sysUser.getId(), ""));
 | 
											
										
											
												
													
														|  | @@ -543,24 +638,17 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 | 
											
												
													
														|  |  				musicGroupDao.update(musicGroup);
 |  |  				musicGroupDao.update(musicGroup);
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  | -		
 |  | 
 | 
											
												
													
														|  | -		musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		musicGroupPaymentCalenderCourseSettingsDao.deleteByMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
 |  | 
 | 
											
												
													
														|  | -		
 |  | 
 | 
											
												
													
														|  | -		if(musicGroupPaymentCalenderCourseSettingsList.size() > 0){
 |  | 
 | 
											
												
													
														|  | -			MusicGroupOrganizationCourseSettings courseSettings = musicGroupOrganizationCourseSettingsDao.get(musicGroupPaymentCalender
 |  | 
 | 
											
												
													
														|  | -					.getMusicGroupOrganizationCourseSettingId());
 |  | 
 | 
											
												
													
														|  | -			for (MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList) {
 |  | 
 | 
											
												
													
														|  | -				musicGroupPaymentCalenderCourseSettings.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
 |  | 
 | 
											
												
													
														|  | -				if (courseSettings != null) {
 |  | 
 | 
											
												
													
														|  | -					musicGroupPaymentCalenderCourseSettings.setName(courseSettings.getName());
 |  | 
 | 
											
												
													
														|  | -				}
 |  | 
 | 
											
												
													
														|  | -			}
 |  | 
 | 
											
												
													
														|  | -			musicGroupPaymentCalenderCourseSettingsDao.batchInsert(musicGroupPaymentCalenderCourseSettingsList);
 |  | 
 | 
											
												
													
														|  | 
 |  | +		if (status == PaymentCalenderStatusEnum.AUDITING) {
 | 
											
												
													
														|  | 
 |  | +			// 如果是审核中
 | 
											
												
													
														|  | 
 |  | +			Set<Integer> roleIds = new HashSet<>(1);
 | 
											
												
													
														|  | 
 |  | +			roleIds.add(SysUserRole.ADMINISTRATOR);
 | 
											
												
													
														|  | 
 |  | +			Organization organization = organizationDao.get(musicGroup.getOrganId());
 | 
											
												
													
														|  | 
 |  | +			sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()),
 | 
											
												
													
														|  | 
 |  | +					MessageTypeEnum.BACKSTAGE_PAYMENT_CALENDER_AUDIT, "", organization.getName(), musicGroup.getName());
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  | -		
 |  | 
 | 
											
												
													
														|  | -		return musicGroupPaymentCalender.getId();
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		return batchNo;
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  	@Override
 |  |  	@Override
 |