yonge il y a 4 ans
Parent
commit
08d4b21cec

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentCalenderDto.java

@@ -29,6 +29,8 @@ public class MusicGroupPaymentCalenderDto {
 	private String attribute2;
 
 	private String studentIds;
+	
+	private String batchNo;
 
 	private List<MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList = new ArrayList<MusicGroupPaymentDateRange>();
 
@@ -130,6 +132,14 @@ public class MusicGroupPaymentCalenderDto {
 		this.musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderCourseSettingsList;
 	}
 
+	public String getBatchNo() {
+		return batchNo;
+	}
+
+	public void setBatchNo(String batchNo) {
+		this.batchNo = batchNo;
+	}
+
 	public class MusicGroupPaymentDateRange {
 
 		private java.util.Date startPaymentDate;

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java

@@ -31,7 +31,7 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 	/**
 	 * 更新缴费信息
 	 */
-	Long merge(MusicGroupPaymentCalender musicGroupPaymentCalender);
+	String merge(MusicGroupPaymentCalenderDto musicGroupPaymentCalenderDto);
 	
 	/**
 	 * 

+ 181 - 93
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -149,7 +149,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		List<MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList = musicGroupPaymentCalenderDto.getMusicGroupPaymentDateRangeList();
 
 		if ((paymentType == PaymentType.ADD_COURSE || payUserType == PayUserType.SCHOOL) && musicGroupPaymentDateRangeList.size() > 1) {
-			throw new BizException("临时加课和学校缴费不支持多周期缴费");
+			throw new BizException("[临时加课][学校缴费]不支持多周期缴费");
 		}
 
 		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
@@ -162,9 +162,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			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("当前乐团存在未排课的缴费项目,请先完成排课再操作");
 		}
 
@@ -404,67 +403,70 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 	@Override
 	@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);
-		
-		if(musicGroup == null){
+
+		if (musicGroup == null) {
 			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) {
 			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
 		}
-		if (musicGroupPaymentCalender.getPayUserType() == SCHOOL) {
-			musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+
+		if (payUserType == SCHOOL) {
+			status = PaymentCalenderStatusEnum.AUDITING;
 		} else {
-			if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY || musicGroupPaymentCalender.getPaymentType() == MUSIC_RENEW) {
+			if (paymentType == MUSIC_APPLY || paymentType == MUSIC_RENEW) {
 				// 当前缴费的课程费用
 				Map<CourseScheduleType, BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(
 						Collectors
 								.toMap(MusicGroupPaymentCalenderCourseSettings::getCourseType, MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice));
 
 				// 查询默认课程费用
-				Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalender.getMusicGroupOrganizationCourseSettingId();
+				Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId();
 				Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao
 						.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId)
 						.stream()
@@ -475,11 +477,11 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				// 相同类型的课程如果修改了课程费用,需要走审批
 				for (Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()) {
 					if (defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0) {
-						musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+						status = PaymentCalenderStatusEnum.AUDITING;
 						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) {
 					OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
@@ -487,54 +489,147 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 					if (defaultUnitPrice == null) {
 						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) {
-						musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+						status = PaymentCalenderStatusEnum.AUDITING;
 						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("创建失败:缴费项目类型不匹配");
 				}
-				if(musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING){
+				if (status != PaymentCalenderStatusEnum.AUDITING) {
 					musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
 					// 记录操作日志
 					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);
 					// 记录操作日志
 					musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(草稿 -> 费用审核中)", sysUser.getId(), ""));
@@ -543,24 +638,17 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				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

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -1012,7 +1012,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
         //缴费详情 calender detail
         MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderService.findByMusicGroupRegCalender(studentRegistration.getMusicGroupId());
-        if (musicGroupRegCalender.getIsGiveMusicNetwork()) {
+        if (musicGroupRegCalender.getIsGiveMusicNetwork() != null && musicGroupRegCalender.getIsGiveMusicNetwork()) {
             //赠送网管课
             musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + 1);
         }

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml

@@ -153,8 +153,12 @@
             LEFT JOIN music_group_payment_student_course_detail mgpscd ON mgpscd.music_group_payment_calender_id_ = mgpc.id_
         WHERE
             mgpc.music_group_id_ = #{musicGroupId}
+            <if test="studentId != null">
             AND mgpscd.user_id_ = #{studentId}
+            </if>
+            <if test="courseType != null">
             AND mgpscd.course_type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            </if>
         GROUP BY mgpc.batch_no_ HAVING SUM(mgpscd.used_course_minutes_) &lt;=0 ORDER BY MIN(mgpc.id_) LIMIT 1;
     </select>
 

+ 3 - 4
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

@@ -28,7 +28,6 @@ import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderDto;
 import com.ym.mec.biz.dal.entity.Employee;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
@@ -89,10 +88,10 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     @ApiOperation(value = "修改乐团缴费时间")
     @PostMapping("/update")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/update')")
-    public Object update(@RequestBody MusicGroupPaymentCalender paymentCalender) {
-    	Long musicGroupPaymentCalenderId = musicGroupPaymentCalenderService.merge(paymentCalender);
+    public Object update(@RequestBody MusicGroupPaymentCalenderDto musicGroupPaymentCalenderDto) {
+    	String batchNo = musicGroupPaymentCalenderService.merge(musicGroupPaymentCalenderDto);
         ModelMap map = new ModelMap();
-        map.put("musicGroupPaymentCalenderId", musicGroupPaymentCalenderId);
+        map.put("musicGroupPaymentCalenderBatchNo", batchNo);
         return succeed();
     }