瀏覽代碼

经营报表导致的排课bug

zouxuan 2 年之前
父節點
當前提交
5f8686108d

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/OperatingReportCloudService.java

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.biz.dal.entity.OperatingReportCloud;
 import com.ym.mec.common.service.BaseService;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -33,5 +34,7 @@ public interface OperatingReportCloudService extends BaseService<Integer, Operat
     */
     void updateSet(Long calenderId, List<Long> scheduleIdList);
 
+    public void updateSet(MusicGroupPaymentCalender calender,List<Long> scheduleIdList);
+
     void save(MusicGroupPaymentCalender musicGroupPaymentCalender);
 }

+ 7 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -391,8 +391,6 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	public void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds) {
 		Map<Integer, List<CourseSchedule>> memberCourseMap = courseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getMemberFlag));
-		List<Long> operatingCourse = new ArrayList<>();
-		Long calenderId = null;
 		for (Integer memberFlag : memberCourseMap.keySet()) {
 			List<CourseSchedule> courseScheduleList = memberCourseMap.get(memberFlag);
 			if(courseScheduleList != null && courseScheduleList.size() > 0){
@@ -462,10 +460,8 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 								CourseScheduleStudentPayment cssp = this.init(courseSchedule);
 								cssp.setUserId(studentId);
 								//扣除可排课时长
-								if(this.calcCourseMinutes(musicGroupPaymentStudentCourseDetails,courseDuration,cssp,musicGroupPaymentCalenders)){
-									//课程是否需要标记为云教练赠送
-									operatingCourse.add(courseSchedule.getId());
-								}
+								//处理经营报表
+								this.calcCourseMinutes(musicGroupPaymentStudentCourseDetails,courseDuration,cssp,musicGroupPaymentCalenders);
 								typeCourseStudentPayments.add(cssp);
 							}
 							courseScheduleStudentPayments.addAll(typeCourseStudentPayments);
@@ -476,9 +472,6 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				}
 			}
 		}
-		if(!CollectionUtils.isEmpty(operatingCourse)){
-			operatingReportCloudService.updateSet(calenderId,operatingCourse);
-		}
 	}
 
 	private Boolean calcCourseMinutes(List<MusicGroupPaymentStudentCourseDetail> courseDetails,
@@ -526,6 +519,11 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				if(MusicGroupPaymentCalender.PayUserType.SCHOOL.equals(calender.getPayUserType())){
 					studentPayment.setExpectPrice(BigDecimal.ZERO);
 				}
+				if(result){
+					ArrayList<Long> courseIds = new ArrayList<>();
+					courseIds.add(studentPayment.getCourseScheduleId());
+					operatingReportCloudService.updateSet(calender,courseIds);
+				}
 				if(courseMinutes == 0){
 					return result;
 				}

+ 9 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportCloudServiceImpl.java

@@ -106,17 +106,24 @@ public class OperatingReportCloudServiceImpl extends BaseServiceImpl<Integer, Op
 	public void updateSet(Long calenderId,List<Long> scheduleIdList) {
 		//如果是进行中加学员,全部算在当月云教练结转。不用摊到课程
 		MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(calenderId);
+		this.updateSet(calender,scheduleIdList);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateSet(MusicGroupPaymentCalender calender,List<Long> scheduleIdList) {
+		//如果是进行中加学员,全部算在当月云教练结转。不用摊到课程
 		if(calender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.ADD_STUDENT){
 			return;
 		}
-		OperatingReportCloud reportCloud = operatingReportCloudDao.findByCalenderId(calenderId);
+		OperatingReportCloud reportCloud = operatingReportCloudDao.findByCalenderId(calender.getId());
 		if(Objects.isNull(reportCloud)){
 			throw new BizException("操作失败,请联系管理员");
 		}
 		if(reportCloud.getSettlementFlag()){
 			return;
 		}
-		cloudTeacherFreeCourseService.batchInsert(scheduleIdList,calenderId);
+		cloudTeacherFreeCourseService.batchInsert(scheduleIdList,calender.getId());
 		//计算课程预收
 		BigDecimal costPrice = organCourseTypeOriginalCostDao.getCourseCostPrice(StringUtils.join(scheduleIdList,","));
 		if(Objects.isNull(costPrice)){