yonge 4 anni fa
parent
commit
9132d1bc90

+ 15 - 23
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -123,6 +123,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	private StudentRegistrationDao studentRegistrationDao;
 	@Autowired
 	private GroupEventSource groupEventSource;
+	
+	@Autowired
+	private StudentPaymentOrderDao studentPaymentOrderDao;
 
 	@Override
 	public BaseDAO<Long, MusicGroupPaymentCalender> getDAO() {
@@ -1350,33 +1353,22 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		if (calender == null) {
 			throw new BizException("缴费信息不存在");
 		}
-		if (calender.getStatus() != PaymentCalenderStatusEnum.AUDITING && calender.getStatus() != PaymentCalenderStatusEnum.NO
-				&& calender.getStatus() != PaymentCalenderStatusEnum.REJECT) {
-			throw new BizException("删除失败,只有[审核中]、[拒绝]或[未开启缴费]状态才能删除");
-		}
-		MusicGroupStudentClassAdjust byBatchNo = musicGroupStudentClassAdjustDao.findByBatchNo(calender.getBatchNo());
-		if(byBatchNo != null){
-			throw new BizException("删除失败,班级调整的缴费项目不允许删除");
+		
+		//缴费项目中没有学生即可删除缴费项目
+		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = musicGroupPaymentCalenderDetailDao.queryByCalenderId(id, null);
+		if (musicGroupPaymentCalenderDetailList != null && musicGroupPaymentCalenderDetailList.size() > 0) {
+			throw new BizException("缴费项目中已存在学员,不能删除");
 		}
 
-		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = musicGroupPaymentCalenderDetailDao.queryByCalenderId(id,null);
-		if (musicGroupPaymentCalenderDetailList != null && musicGroupPaymentCalenderDetailList.size() > 0) {
-			List<MusicGroupPaymentCalenderDetail> paidList = musicGroupPaymentCalenderDetailList.stream()
-					.filter(MusicGroupPaymentCalenderDetail -> MusicGroupPaymentCalenderDetail.getPaymentStatus() != PaymentStatus.NON_PAYMENT)
-					.collect(Collectors.toList());
-			if (paidList.size() > 0) {
-				throw new BizException("存在已缴费的学生不能删除");
-			}
-			
-			List<Long> calenderDetailIdList = musicGroupPaymentCalenderDetailList.stream().map(cd -> cd.getId()).collect(Collectors.toList());
-			//是否已排课
-			List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = musicGroupPaymentStudentCourseDetailDao.queryByMusicGroupPaymentStudentCourseDetailId(calenderDetailIdList);
-			long count = musicGroupPaymentStudentCourseDetailList.stream().filter(e -> e.getUsedCourseMinutes() > 0).count();
-			if(count > 0){
-				throw new BizException("存在已排课的学员");
+		if (calender.getPaymentType() == PaymentType.MUSIC_APPLY) {
+			// 是否存在缴费中的
+			List<StudentPaymentOrder> studentPaymentOrderList = studentPaymentOrderDao.queryByDealStatus(calender.getMusicGroupId(), OrderTypeEnum.APPLY,
+					DealStatusEnum.ING);
+			if (studentPaymentOrderList != null && studentPaymentOrderList.size() > 0) {
+				throw new BizException("存在缴费中的学生,不能删除");
 			}
 		}
-
+		
 		musicGroupPaymentCalenderDao.delete(id);
 		musicGroupPaymentCalenderDetailDao.deleteByCalenderId(id);
 		musicGroupPaymentStudentCourseDetailDao.deleteByMusicGroupPaymentCalenderId(id);