|
@@ -1,59 +1,21 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
-import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum.AUDITING;
|
|
|
-import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum.NO;
|
|
|
-import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.SPAN_GROUP_CLASS_ADJUST;
|
|
|
-import static com.ym.mec.biz.dal.enums.ClassGroupTypeEnum.HIGH;
|
|
|
-import static com.ym.mec.biz.dal.enums.ClassGroupTypeEnum.HIGH_ONLINE;
|
|
|
-import static com.ym.mec.biz.dal.enums.GroupType.COMM;
|
|
|
-import static com.ym.mec.biz.dal.enums.GroupType.MUSIC;
|
|
|
-import static com.ym.mec.biz.dal.enums.GroupType.PRACTICE;
|
|
|
-import static com.ym.mec.biz.dal.enums.GroupType.VIP;
|
|
|
-import static com.ym.mec.biz.dal.enums.MusicGroupStatusEnum.PROGRESS;
|
|
|
-
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.time.Duration;
|
|
|
-import java.time.Instant;
|
|
|
-import java.time.LocalDate;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.ZoneId;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
+import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.auth.api.entity.SysUserRole;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.dto.*;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
|
|
|
import com.ym.mec.biz.dal.enums.*;
|
|
|
+import com.ym.mec.biz.dal.page.*;
|
|
|
import com.ym.mec.biz.service.*;
|
|
|
-import com.ym.mec.common.controller.BaseController;
|
|
|
-import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
-import com.ym.mec.util.collection.ListUtil;
|
|
|
-
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Propagation;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
-import com.ym.mec.auth.api.entity.SysUser;
|
|
|
-import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
|
|
|
-import com.ym.mec.biz.dal.page.ClassGroupQueryInfo;
|
|
|
-import com.ym.mec.biz.dal.page.CourseScheduleQueryInfo;
|
|
|
-import com.ym.mec.biz.dal.page.EndCourseScheduleQueryInfo;
|
|
|
-import com.ym.mec.biz.dal.page.StudentPayLogQueryInfo;
|
|
|
-import com.ym.mec.biz.dal.page.TeacherMusicClassQueryInfo;
|
|
|
-import com.ym.mec.biz.dal.page.VipClassQueryInfo;
|
|
|
-import com.ym.mec.biz.dal.page.queryMusicGroupCourseScheduleQueryInfo;
|
|
|
import com.ym.mec.common.constant.CommonConstants;
|
|
|
+import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
+import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.entity.ImGroupMember;
|
|
|
import com.ym.mec.common.entity.ImGroupModel;
|
|
|
import com.ym.mec.common.entity.ImUserModel;
|
|
@@ -65,6 +27,32 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateConvertor;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.*;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import static com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType.*;
|
|
|
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum.AUDITING;
|
|
|
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum.NO;
|
|
|
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.SPAN_GROUP_CLASS_ADJUST;
|
|
|
+import static com.ym.mec.biz.dal.enums.ClassGroupTypeEnum.HIGH;
|
|
|
+import static com.ym.mec.biz.dal.enums.ClassGroupTypeEnum.HIGH_ONLINE;
|
|
|
+import static com.ym.mec.biz.dal.enums.GroupType.COMM;
|
|
|
+import static com.ym.mec.biz.dal.enums.GroupType.PRACTICE;
|
|
|
+import static com.ym.mec.biz.dal.enums.GroupType.VIP;
|
|
|
+import static com.ym.mec.biz.dal.enums.GroupType.*;
|
|
|
+import static com.ym.mec.biz.dal.enums.MusicGroupStatusEnum.PROGRESS;
|
|
|
|
|
|
@Service
|
|
|
public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup> implements ClassGroupService {
|
|
@@ -148,7 +136,9 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
@Autowired
|
|
|
private SysConfigService sysConfigService;
|
|
|
@Autowired
|
|
|
- private StudentDao studentDao;
|
|
|
+// private StudentDao studentDao;
|
|
|
+// @Autowired
|
|
|
+ private StudentService studentService;
|
|
|
@Autowired
|
|
|
private MusicGroupPaymentCalenderCourseSettingsService musicGroupPaymentCalenderCourseSettingsService;
|
|
|
@Autowired
|
|
@@ -163,6 +153,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
|
|
|
@Autowired
|
|
|
private EmployeeDao employeeDao;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupSchoolTermStudentCourseDetailDao musicGroupSchoolTermStudentCourseDetailDao;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupSchoolTermCourseDetailDao musicGroupSchoolTermCourseDetailDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, ClassGroup> getDAO() {
|
|
@@ -1179,7 +1173,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean addStudentToClassGroupAndCourseArranging(Integer studentId, String classGroupIdListStr,
|
|
|
String batchNo,
|
|
|
- List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList) {
|
|
|
+ List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList,
|
|
|
+ MusicGroup musicGroup) {
|
|
|
|
|
|
//如果学员已经在某些班级,
|
|
|
Boolean isExistClassGroup = classGroupStudentMapperDao.existByClassGroupIds(classGroupIdListStr, studentId);
|
|
@@ -1193,25 +1188,28 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
|
|
|
Date date = new Date();
|
|
|
List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<CourseScheduleStudentPayment>();
|
|
|
+ List<CourseScheduleStudentPayment> totalCourseScheduleStudentPayments = new ArrayList<CourseScheduleStudentPayment>();
|
|
|
|
|
|
// 计算单价
|
|
|
Map<CourseScheduleType, BigDecimal> unitPriceMap = new HashMap<CourseSchedule.CourseScheduleType, BigDecimal>();
|
|
|
Map<CourseScheduleType, BigDecimal> originUnitPriceMap = new HashMap<CourseSchedule.CourseScheduleType, BigDecimal>();
|
|
|
Map<CourseScheduleType, BigDecimal> totalCurrentPriceMap = new HashMap<CourseSchedule.CourseScheduleType, BigDecimal>();
|
|
|
Map<CourseScheduleType, BigDecimal> totalOriginPriceMap = new HashMap<CourseSchedule.CourseScheduleType, BigDecimal>();
|
|
|
- for (MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList) {
|
|
|
- unitPriceMap.put(
|
|
|
- musicGroupPaymentCalenderCourseSettings.getCourseType(),
|
|
|
- musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice().divide(
|
|
|
- new BigDecimal(musicGroupPaymentCalenderCourseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
|
|
|
-
|
|
|
- originUnitPriceMap.put(
|
|
|
- musicGroupPaymentCalenderCourseSettings.getCourseType(),
|
|
|
- musicGroupPaymentCalenderCourseSettings.getCourseOriginalPrice().divide(
|
|
|
- new BigDecimal(musicGroupPaymentCalenderCourseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
|
|
|
-
|
|
|
- totalCurrentPriceMap.put(musicGroupPaymentCalenderCourseSettings.getCourseType(), musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice());
|
|
|
- totalOriginPriceMap.put(musicGroupPaymentCalenderCourseSettings.getCourseType(), musicGroupPaymentCalenderCourseSettings.getCourseOriginalPrice());
|
|
|
+ if(musicGroupPaymentCalenderCourseSettingsList != null){
|
|
|
+ for (MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList) {
|
|
|
+ unitPriceMap.put(
|
|
|
+ musicGroupPaymentCalenderCourseSettings.getCourseType(),
|
|
|
+ musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice().divide(
|
|
|
+ new BigDecimal(musicGroupPaymentCalenderCourseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
|
|
|
+
|
|
|
+ originUnitPriceMap.put(
|
|
|
+ musicGroupPaymentCalenderCourseSettings.getCourseType(),
|
|
|
+ musicGroupPaymentCalenderCourseSettings.getCourseOriginalPrice().divide(
|
|
|
+ new BigDecimal(musicGroupPaymentCalenderCourseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
|
|
|
+
|
|
|
+ totalCurrentPriceMap.put(musicGroupPaymentCalenderCourseSettings.getCourseType(), musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice());
|
|
|
+ totalOriginPriceMap.put(musicGroupPaymentCalenderCourseSettings.getCourseType(), musicGroupPaymentCalenderCourseSettings.getCourseOriginalPrice());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
List<Integer> classGroupIds = classGroupList.stream().map(ClassGroup::getId).collect(Collectors.toList());
|
|
@@ -1259,51 +1257,103 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
classGroupStudentMapperDao.insert(classGroupStudentMapper);
|
|
|
}
|
|
|
|
|
|
- // 3、学生加入级未开始课程
|
|
|
+ // 3、学生加入班级未开始课程
|
|
|
List<CourseSchedule> courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroup.getId());
|
|
|
- for (CourseSchedule courseSchedule : courseScheduleList) {
|
|
|
- if (existCourseIds.contains(courseSchedule.getId())) {
|
|
|
- throw new BizException("该学员已在此班级{}课程中", courseSchedule.getId());
|
|
|
- }
|
|
|
-
|
|
|
- CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
- courseScheduleStudentPayment.setCourseSchedule(courseSchedule);
|
|
|
- courseScheduleStudentPayment.setGroupType(classGroup.getGroupType());
|
|
|
- courseScheduleStudentPayment.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
- courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
|
- courseScheduleStudentPayment.setUserId(studentId);
|
|
|
- courseScheduleStudentPayment.setBatchNo(batchNo);
|
|
|
- courseScheduleStudentPayment.setBeMerged(false);
|
|
|
-
|
|
|
- unitPrice = unitPriceMap.get(courseSchedule.getType());
|
|
|
- if (unitPrice != null) {
|
|
|
- courseType = courseSchedule.getType();
|
|
|
- BigDecimal duration = new BigDecimal(DateUtil.minutesBetween(courseSchedule.getStartClassTime(), courseSchedule.getEndClassTime()));
|
|
|
- courseScheduleStudentPayment.setExpectPrice(unitPrice.multiply(duration).setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
-
|
|
|
- if (totalPriceMap.containsKey(courseType)) {
|
|
|
- totalPriceMap.put(courseType, totalPriceMap.get(courseType).add(courseScheduleStudentPayment.getExpectPrice()));
|
|
|
- } else {
|
|
|
- totalPriceMap.put(courseType, courseScheduleStudentPayment.getExpectPrice());
|
|
|
- }
|
|
|
- }
|
|
|
+ Map<Integer, List<CourseSchedule>> memberCourseSchedule = courseScheduleList.stream().collect(Collectors.groupingBy(CourseSchedule::getMemberFlag));
|
|
|
+ for (Integer integer : memberCourseSchedule.keySet()) {
|
|
|
+ List<CourseSchedule> courseSchedules = memberCourseSchedule.get(integer);
|
|
|
+ if(courseSchedules != null && courseSchedules.size() > 0){
|
|
|
+ if(integer == 0){
|
|
|
+ for (CourseSchedule courseSchedule : courseSchedules) {
|
|
|
+ if (existCourseIds.contains(courseSchedule.getId())) {
|
|
|
+ throw new BizException("该学员已在此班级{}课程中", courseSchedule.getId());
|
|
|
+ }
|
|
|
+ CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
+ courseScheduleStudentPayment.setCourseSchedule(courseSchedule);
|
|
|
+ courseScheduleStudentPayment.setGroupType(classGroup.getGroupType());
|
|
|
+ courseScheduleStudentPayment.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
+ courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ courseScheduleStudentPayment.setUserId(studentId);
|
|
|
+ courseScheduleStudentPayment.setBatchNo(batchNo);
|
|
|
+ courseScheduleStudentPayment.setBeMerged(false);
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(BigDecimal.ZERO);
|
|
|
+ courseScheduleStudentPayment.setOriginalPrice(BigDecimal.ZERO);
|
|
|
+ //如果当前课程不是会员收费排课,那么计算课程价值
|
|
|
+ unitPrice = unitPriceMap.get(courseSchedule.getType());
|
|
|
+ if (unitPrice != null) {
|
|
|
+ courseType = courseSchedule.getType();
|
|
|
+ BigDecimal duration = new BigDecimal(DateUtil.minutesBetween(courseSchedule.getStartClassTime(), courseSchedule.getEndClassTime()));
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(unitPrice.multiply(duration).setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
+
|
|
|
+ if (totalPriceMap.containsKey(courseType)) {
|
|
|
+ totalPriceMap.put(courseType, totalPriceMap.get(courseType).add(courseScheduleStudentPayment.getExpectPrice()));
|
|
|
+ } else {
|
|
|
+ totalPriceMap.put(courseType, courseScheduleStudentPayment.getExpectPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- originUnitPrice = originUnitPriceMap.get(courseSchedule.getType());
|
|
|
- if (originUnitPrice != null) {
|
|
|
- courseType = courseSchedule.getType();
|
|
|
- BigDecimal duration = new BigDecimal(DateUtil.minutesBetween(courseSchedule.getStartClassTime(), courseSchedule.getEndClassTime()));
|
|
|
- courseScheduleStudentPayment.setOriginalPrice(originUnitPrice.multiply(duration).setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
+ originUnitPrice = originUnitPriceMap.get(courseSchedule.getType());
|
|
|
+ if (originUnitPrice != null) {
|
|
|
+ courseType = courseSchedule.getType();
|
|
|
+ BigDecimal duration = new BigDecimal(DateUtil.minutesBetween(courseSchedule.getStartClassTime(), courseSchedule.getEndClassTime()));
|
|
|
+ courseScheduleStudentPayment.setOriginalPrice(originUnitPrice.multiply(duration).setScale(2, BigDecimal.ROUND_DOWN));
|
|
|
|
|
|
- if (totalOrignPriceMap.containsKey(courseType)) {
|
|
|
- totalOrignPriceMap.put(courseType, totalOrignPriceMap.get(courseType).add(courseScheduleStudentPayment.getOriginalPrice()));
|
|
|
- } else {
|
|
|
- totalOrignPriceMap.put(courseType, courseScheduleStudentPayment.getOriginalPrice());
|
|
|
+ if (totalOrignPriceMap.containsKey(courseType)) {
|
|
|
+ totalOrignPriceMap.put(courseType, totalOrignPriceMap.get(courseType).add(courseScheduleStudentPayment.getOriginalPrice()));
|
|
|
+ } else {
|
|
|
+ totalOrignPriceMap.put(courseType, courseScheduleStudentPayment.getOriginalPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
|
|
|
+ courseScheduleStudentPayment.setCreateTime(date);
|
|
|
+ courseScheduleStudentPayment.setUpdateTime(date);
|
|
|
+ courseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
|
+ }
|
|
|
+ if (courseScheduleStudentPayments.size() > 0) {
|
|
|
+ // 排序
|
|
|
+ Collections.sort(courseScheduleStudentPayments);
|
|
|
+ List<CourseScheduleType> list = new ArrayList<CourseSchedule.CourseScheduleType>();
|
|
|
+ for (CourseScheduleStudentPayment courseScheduleStudentPayment : courseScheduleStudentPayments) {
|
|
|
+ courseType = courseScheduleStudentPayment.getCourseSchedule().getType();
|
|
|
+ if (!list.contains(courseType)) {
|
|
|
+ list.add(courseType);
|
|
|
+
|
|
|
+ // 修改第一节课的金额
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(courseScheduleStudentPayment.getExpectPrice().add(
|
|
|
+ totalCurrentPriceMap.get(courseType).subtract(totalPriceMap.get(courseType))));
|
|
|
+
|
|
|
+ courseScheduleStudentPayment.setOriginalPrice(courseScheduleStudentPayment.getOriginalPrice().add(
|
|
|
+ totalOriginPriceMap.get(courseType).subtract(totalOrignPriceMap.get(courseType))));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ totalCourseScheduleStudentPayments.addAll(courseScheduleStudentPayments);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ for (CourseSchedule courseSchedule : courseSchedules) {
|
|
|
+ if (existCourseIds.contains(courseSchedule.getId())) {
|
|
|
+ throw new BizException("该学员已在此班级{}课程中", courseSchedule.getId());
|
|
|
+ }
|
|
|
+ CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
+ courseScheduleStudentPayment.setCourseSchedule(courseSchedule);
|
|
|
+ courseScheduleStudentPayment.setGroupType(classGroup.getGroupType());
|
|
|
+ courseScheduleStudentPayment.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
+ courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ courseScheduleStudentPayment.setUserId(studentId);
|
|
|
+ courseScheduleStudentPayment.setBatchNo(batchNo);
|
|
|
+ courseScheduleStudentPayment.setBeMerged(false);
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(BigDecimal.ZERO);
|
|
|
+ courseScheduleStudentPayment.setOriginalPrice(BigDecimal.ZERO);
|
|
|
+ courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
|
|
|
+ courseScheduleStudentPayment.setCreateTime(date);
|
|
|
+ courseScheduleStudentPayment.setUpdateTime(date);
|
|
|
+ totalCourseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
|
|
|
- courseScheduleStudentPayment.setCreateTime(date);
|
|
|
- courseScheduleStudentPayment.setUpdateTime(date);
|
|
|
- courseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
|
+ }
|
|
|
+ if(totalCourseScheduleStudentPayments.size() > 0){
|
|
|
+ courseScheduleStudentPaymentService.batchInsert(totalCourseScheduleStudentPayments);
|
|
|
+ studentService.updateStudentServiceTag(studentId, null, YesOrNoEnum.YES.getCode());
|
|
|
}
|
|
|
|
|
|
if(!CollectionUtils.isEmpty(courseScheduleList)){
|
|
@@ -1320,27 +1370,6 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
|
|
|
}
|
|
|
|
|
|
- if (courseScheduleStudentPayments.size() > 0) {
|
|
|
- // 排序
|
|
|
- Collections.sort(courseScheduleStudentPayments);
|
|
|
- List<CourseScheduleType> list = new ArrayList<CourseSchedule.CourseScheduleType>();
|
|
|
- for (CourseScheduleStudentPayment courseScheduleStudentPayment : courseScheduleStudentPayments) {
|
|
|
- courseType = courseScheduleStudentPayment.getCourseSchedule().getType();
|
|
|
- if (!list.contains(courseType)) {
|
|
|
- list.add(courseType);
|
|
|
-
|
|
|
- // 修改第一节课的金额
|
|
|
- courseScheduleStudentPayment.setExpectPrice(courseScheduleStudentPayment.getExpectPrice().add(
|
|
|
- totalCurrentPriceMap.get(courseType).subtract(totalPriceMap.get(courseType))));
|
|
|
-
|
|
|
- courseScheduleStudentPayment.setOriginalPrice(courseScheduleStudentPayment.getOriginalPrice().add(
|
|
|
- totalOriginPriceMap.get(courseType).subtract(totalOrignPriceMap.get(courseType))));
|
|
|
- }
|
|
|
- }
|
|
|
- courseScheduleStudentPaymentService.batchInsert(courseScheduleStudentPayments);
|
|
|
- studentDao.updateStudentServiceTag(studentId, null, YesOrNoEnum.YES.getCode());
|
|
|
- }
|
|
|
-
|
|
|
//4、调整未上课课酬
|
|
|
if (allNotStartCourses.size() > 0) {
|
|
|
List<Long> courseScheduleIds = allNotStartCourses.stream().map(CourseSchedule::getId).collect(Collectors.toList());
|
|
@@ -1830,7 +1859,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
|
|
|
if (classGroup4MixDtos.get(0).getType().equals(ClassGroupTypeEnum.MUSIC_NETWORK)) {
|
|
|
teachMode = TeachModeEnum.ONLINE;
|
|
|
- List<String> studentNames = studentDao.getStudentNames(studentIdList);
|
|
|
+ List<String> studentNames = studentService.getStudentNames(studentIdList);
|
|
|
classGroup4MixDtos.get(0).setClassGroupName(subjectNames + "•" + StringUtils.join(studentNames, ","));
|
|
|
}
|
|
|
|
|
@@ -1988,7 +2017,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
courseSchedule.setType(classGroup4MixDto.getCourseType());
|
|
|
courseSchedule.setGroupType(MUSIC);
|
|
|
courseSchedule.setOrganId(musicGroup.getOrganId());
|
|
|
- if (classGroup4MixDto.getCourseType().equals(CourseSchedule.CourseScheduleType.MIX)) {
|
|
|
+ if (classGroup4MixDto.getCourseType().equals(MIX)) {
|
|
|
courseSchedule.setName(classGroup4MixDto.getCourseType().getMsg());
|
|
|
} else if (classGroup4MixDto.getCourseType().equals(CourseScheduleType.MUSIC_NETWORK)) {
|
|
|
courseSchedule.setName(classGroup.getName());
|
|
@@ -2032,7 +2061,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
//学生结算表
|
|
|
if (courseScheduleList.size() > 0) {
|
|
|
courseScheduleStudentPaymentService.createForMusicGroup(musicGroupId, courseScheduleList, studentIdList);
|
|
|
- studentDao.updateStudentServiceTag(null, studentIdList, YesOrNoEnum.YES.getCode());
|
|
|
+ studentService.updateStudentServiceTag(null, studentIdList, YesOrNoEnum.YES.getCode());
|
|
|
}
|
|
|
//创建IM群组
|
|
|
addImGroup(classGroup, userIds, teacherIds);
|
|
@@ -2128,7 +2157,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
courseSchedule.setTeacherId(teacherId);
|
|
|
courseSchedule.setActualTeacherId(teacherId);
|
|
|
courseSchedule.setClassGroupId(classGroup.getId());
|
|
|
- if (classGroup4MixDto.getCourseType().equals(CourseSchedule.CourseScheduleType.MIX)) {
|
|
|
+ if (classGroup4MixDto.getCourseType().equals(MIX)) {
|
|
|
courseSchedule.setName(classGroup4MixDto.getCourseType().getMsg());
|
|
|
} else if (classGroup4MixDto.getCourseType().equals(CourseScheduleType.MUSIC_NETWORK)) {
|
|
|
courseSchedule.setName(classGroup.getName());
|
|
@@ -2509,7 +2538,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
courseSchedule.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
courseSchedule.setType(classGroup4MixDto.getCourseType());
|
|
|
|
|
|
- if (classGroup4MixDto.getCourseType().equals(CourseSchedule.CourseScheduleType.MIX)) {
|
|
|
+ if (classGroup4MixDto.getCourseType().equals(MIX)) {
|
|
|
courseSchedule.setName(classGroup4MixDto.getCourseType().getMsg());
|
|
|
} else if (classGroup4MixDto.getCourseType().equals(CourseScheduleType.MUSIC_NETWORK)) {
|
|
|
courseSchedule.setName(classGroup.getName());
|
|
@@ -2578,7 +2607,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
}
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(studentList)) {
|
|
|
- studentDao.updateStudentServiceTag(null, studentIds, YesOrNoEnum.YES.getCode());
|
|
|
+ studentService.updateStudentServiceTag(null, studentIds, YesOrNoEnum.YES.getCode());
|
|
|
|
|
|
//学生结算表
|
|
|
courseScheduleStudentPaymentService.createForMusicGroup(musicGroupId, courseScheduleList, studentIds);
|
|
@@ -2591,6 +2620,399 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
+ public void confirmPreCourseSchedule(Integer musicGroupSchoolTermCourseDetailId) {
|
|
|
+ MusicGroupSchoolTermCourseDetail termCourseDetail = musicGroupSchoolTermCourseDetailDao.get(musicGroupSchoolTermCourseDetailId);
|
|
|
+ //校验所有学员的课时都有消耗
|
|
|
+ if(musicGroupSchoolTermStudentCourseDetailDao.checkNoCourse(musicGroupSchoolTermCourseDetailId)){
|
|
|
+ throw new BizException("操作失败:请确保所有学员都已排课");
|
|
|
+ }
|
|
|
+ //获取所有预排课课程列表
|
|
|
+ List<CourseSchedule> courseSchedules = courseScheduleDao.queryPreCourseListByMusicGroupId(termCourseDetail.getMusicGroupId());
|
|
|
+ if(courseSchedules.size() == 0){
|
|
|
+ throw new BizException("操作失败:请先预排课");
|
|
|
+ }
|
|
|
+ //是否有进行中或者已结束的课程
|
|
|
+ int overCourseScheduleNum = courseScheduleDao.queryOverPreCourseListByMusicGroupId(termCourseDetail.getMusicGroupId());
|
|
|
+ if(overCourseScheduleNum > 0){
|
|
|
+ throw new BizException("操作失败:有进行中或已结束的课程,请重新排课");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<Integer, List<CourseSchedule>> courseMap = courseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getClassGroupId));
|
|
|
+ courseMap.keySet().forEach(e->{
|
|
|
+ //更新班级课程数
|
|
|
+ classGroupService.updateTotalClassTimes(e, courseMap.get(e).size());
|
|
|
+ });
|
|
|
+ List<Long> courseScheduleIds = courseSchedules.stream().map(e -> e.getId()).collect(Collectors.toList());
|
|
|
+ //取消预排课标记
|
|
|
+ courseScheduleDao.batchUpdateLockByCourseIds(courseScheduleIds,0,0);
|
|
|
+ //标记已排课
|
|
|
+ termCourseDetail.setCourseFlag(true);
|
|
|
+ musicGroupSchoolTermCourseDetailDao.update(termCourseDetail);
|
|
|
+ //更新学员服务指标
|
|
|
+ List<CourseScheduleStudentPayment> studentPayments = courseScheduleStudentPaymentDao.findByCourseScheduleIds(courseScheduleIds);
|
|
|
+ List<Integer> studentIds = studentPayments.stream().map(e -> e.getUserId()).collect(Collectors.toList());
|
|
|
+ studentService.updateStudentServiceTag(null, studentIds, YesOrNoEnum.YES.getCode());
|
|
|
+ //初始化老师考勤表
|
|
|
+ List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaries = courseScheduleTeacherSalaryDao.findByCourseSchedules(courseScheduleIds);
|
|
|
+ List<TeacherAttendance> teacherIdByCourseSchedule = teacherAttendanceDao.findTeacherIdByCourseSchedule(courseScheduleIds);
|
|
|
+ Map<Long, List<TeacherAttendance>> courseScheduleTeacherAttendanceMap = teacherIdByCourseSchedule.stream()
|
|
|
+ .collect(Collectors.groupingBy(TeacherAttendance::getCourseScheduleId));
|
|
|
+ List<TeacherAttendance> teacherAttendances = new ArrayList<>();
|
|
|
+ courseScheduleTeacherSalaries.forEach(courseScheduleTeacherSalary -> {
|
|
|
+ List<TeacherAttendance> teacherAttendancesTemp = courseScheduleTeacherAttendanceMap.get(courseScheduleTeacherSalary.getCourseScheduleId());
|
|
|
+ List<Integer> collect = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(teacherAttendancesTemp)) {
|
|
|
+ collect = teacherAttendancesTemp.stream().map(TeacherAttendance::getTeacherId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ TeacherAttendance teacherAttendance = new TeacherAttendance();
|
|
|
+ teacherAttendance.setGroupType(courseScheduleTeacherSalary.getGroupType());
|
|
|
+ teacherAttendance.setClassGroupId(courseScheduleTeacherSalary.getClassGroupId());
|
|
|
+ teacherAttendance.setMusicGroupId(courseScheduleTeacherSalary.getMusicGroupId());
|
|
|
+ if (CollectionUtils.isEmpty(collect) || !collect.contains(courseScheduleTeacherSalary.getUserId())) {
|
|
|
+ teacherAttendance.setTeacherId(courseScheduleTeacherSalary.getUserId());
|
|
|
+ teacherAttendance.setCourseScheduleId(courseScheduleTeacherSalary.getCourseScheduleId());
|
|
|
+ teacherAttendances.add(teacherAttendance);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!CollectionUtils.isEmpty(teacherAttendances)) {
|
|
|
+ teacherAttendanceDao.batchInsert(teacherAttendances);
|
|
|
+ }
|
|
|
+ imUserFriendService.refreshGroupImUserFriend(termCourseDetail.getMusicGroupId(),MUSIC);
|
|
|
+ //是否是该乐团第一次会员排课
|
|
|
+ List<MusicGroupSchoolTermCourseDetail> termCourseDetails = musicGroupSchoolTermCourseDetailDao.findByMusicGroupId(termCourseDetail.getMusicGroupId());
|
|
|
+ if(termCourseDetails.size() == 1){
|
|
|
+ MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.findByMusicGroupRegCalender(termCourseDetail.getMusicGroupId());
|
|
|
+ studentService.batchUpdateMemberRank(studentIds,calender.getMemberRankSettingId(),PeriodEnum.MONTH,calender.getMemberValidDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void cancelPreCourseSchedule(Integer musicGroupSchoolTermCourseDetailId, Integer classGroupId) {
|
|
|
+ MusicGroupSchoolTermCourseDetail termCourseDetail = musicGroupSchoolTermCourseDetailDao.get(musicGroupSchoolTermCourseDetailId);
|
|
|
+ if(classGroupId == null){
|
|
|
+ List<CourseSchedule> courseSchedules = courseScheduleDao.queryPreCourseListByMusicGroupId(termCourseDetail.getMusicGroupId());
|
|
|
+ if(courseSchedules.size() == 0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Long> courseScheduleIds = courseSchedules.stream().map(e -> e.getId()).collect(Collectors.toList());
|
|
|
+ //取消所有预排课
|
|
|
+ musicGroupSchoolTermStudentCourseDetailDao.cleanMinutes(musicGroupSchoolTermCourseDetailId);
|
|
|
+ //删除课程以及关联的学员老师
|
|
|
+ courseScheduleStudentPaymentDao.deleteByCourseSchedule(courseScheduleIds);
|
|
|
+ courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(courseScheduleIds);
|
|
|
+ courseScheduleDao.deleteCourseSchedulesByClassGroupIds(courseScheduleIds);
|
|
|
+ }else {
|
|
|
+ List<CourseSchedule> courseSchedules = courseScheduleDao.queryPreCourseListByClassGroupId(classGroupId);
|
|
|
+ if(courseSchedules.size() == 0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Long> courseScheduleIds = courseSchedules.stream().map(c -> c.getId()).collect(Collectors.toList());
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByCourseScheduleIds(courseScheduleIds);
|
|
|
+ Map<Integer, List<CourseScheduleStudentPayment>> studentCourseMap = courseScheduleStudentPayments.stream().collect(Collectors.groupingBy(CourseScheduleStudentPayment::getUserId));
|
|
|
+
|
|
|
+ for (Integer studentId : studentCourseMap.keySet()) {
|
|
|
+ int preMemberCourseMinutes = 0;
|
|
|
+ int mixCourseMinutes = 0;
|
|
|
+ int singleCourseMinutes = 0;
|
|
|
+
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPaymentList = studentCourseMap.get(studentId);
|
|
|
+ List<Long> courseIds = courseScheduleStudentPaymentList.stream().map(c -> c.getCourseScheduleId()).collect(Collectors.toList());
|
|
|
+ List<CourseSchedule> schedules = courseScheduleDao.findByCourseScheduleIds(courseIds);
|
|
|
+ Map<CourseScheduleType, List<CourseSchedule>> courseTypeMap = schedules.stream().collect(Collectors.groupingBy(CourseSchedule::getType));
|
|
|
+ for (CourseScheduleType scheduleType : courseTypeMap.keySet()) {
|
|
|
+ List<CourseSchedule> courseScheduleList = courseTypeMap.get(scheduleType);
|
|
|
+ List<Long> courseScheduleIdList = courseScheduleList.stream().map(c -> c.getId()).collect(Collectors.toList());
|
|
|
+ //根据课程编号获取总时长
|
|
|
+ int courseMinutes = courseScheduleDao.sumCourseMinutes(courseScheduleIdList);
|
|
|
+ preMemberCourseMinutes += courseMinutes;
|
|
|
+ if(scheduleType == SINGLE || scheduleType == TRAINING_SINGLE){
|
|
|
+ singleCourseMinutes += courseMinutes;
|
|
|
+ }
|
|
|
+ if(scheduleType == MIX || scheduleType == TRAINING_MIX){
|
|
|
+ mixCourseMinutes += courseMinutes;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ musicGroupSchoolTermStudentCourseDetailDao.cutMinutes(musicGroupSchoolTermCourseDetailId,preMemberCourseMinutes,mixCourseMinutes,singleCourseMinutes,studentId);
|
|
|
+ }
|
|
|
+ //删除课程以及关联的学员老师
|
|
|
+ courseScheduleStudentPaymentDao.deleteByCourseSchedule(courseScheduleIds);
|
|
|
+ courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(courseScheduleIds);
|
|
|
+ courseScheduleDao.deleteCourseSchedulesByClassGroupIds(courseScheduleIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpResponseResult preCourseSchedule(List<ClassGroup4MixDto> classGroup4MixDtos) {
|
|
|
+ Date date = new Date();
|
|
|
+ Integer classGroupId = classGroup4MixDtos.get(0).getClassGroupId();
|
|
|
+ String musicGroupId = classGroup4MixDtos.get(0).getMusicGroupId();
|
|
|
+ Integer musicGroupSchoolTermCourseDetailId = classGroup4MixDtos.get(0).getMusicGroupSchoolTermCourseDetailId();
|
|
|
+ MusicGroupSchoolTermCourseDetail schoolTermCourseDetail = musicGroupSchoolTermCourseDetailDao.get(musicGroupSchoolTermCourseDetailId);
|
|
|
+ if (schoolTermCourseDetail.isCourseFlag()) {
|
|
|
+ throw new BizException("本学期已经排课,请勿重复操作");
|
|
|
+ }
|
|
|
+ ClassGroup classGroup = classGroupDao.get(classGroupId);
|
|
|
+ if (classGroup == null) {
|
|
|
+ throw new BizException("班级不存在");
|
|
|
+ }
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(classGroup.getMusicGroupId());
|
|
|
+
|
|
|
+ Boolean confirmGenerate = false;
|
|
|
+ if (Objects.nonNull(classGroup4MixDtos.get(0).getConfirmGenerate())) {
|
|
|
+ confirmGenerate = classGroup4MixDtos.get(0).getConfirmGenerate();
|
|
|
+ }
|
|
|
+
|
|
|
+ TeachModeEnum teachMode = TeachModeEnum.OFFLINE;
|
|
|
+ if (classGroup.getType().equals(HIGH_ONLINE) || classGroup.getType().equals(ClassGroupTypeEnum.MUSIC_NETWORK)) {
|
|
|
+ teachMode = TeachModeEnum.ONLINE;
|
|
|
+ }
|
|
|
+ if (classGroup4MixDtos.get(0).getCourseTimes().compareTo(0) <= 0) {
|
|
|
+ throw new BizException("排课次数必须大于0");
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer schoolId = teachMode.equals(TeachModeEnum.ONLINE) ? null : musicGroup.getSchoolId();
|
|
|
+
|
|
|
+ List<Subject> subjectList = subjectService.findBySubjectByIdList(classGroup.getSubjectIdList());
|
|
|
+
|
|
|
+ String subjectNames = subjectList.stream().map(Subject::getName).collect(Collectors.joining("/"));
|
|
|
+
|
|
|
+ //2、获取班级学生
|
|
|
+ List<StudentRegistration> studentList = classGroupStudentMapperDao.findClassStudentList(classGroup.getId(), ClassGroupStudentStatusEnum.NORMAL);
|
|
|
+
|
|
|
+ List<Integer> studentIds = studentList.stream().map(StudentRegistration::getUserId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //计算每节课的课酬
|
|
|
+ List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaryList = new ArrayList<>();
|
|
|
+ List<CourseSchedule> courseScheduleList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (ClassGroup4MixDto classGroup4MixDto : classGroup4MixDtos) {
|
|
|
+ //3、插入班级排课信息
|
|
|
+ LocalDateTime now = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
+ //计算总时长
|
|
|
+ int totalCourseMinutes = 0;
|
|
|
+ for (CourseTimeDto courseTimeDto : classGroup4MixDto.getCourseTimeDtoList()) {
|
|
|
+ totalCourseMinutes += courseTimeDto.getExpectCourseNum() * courseTimeDto.getExpectCourseMinutes();
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer totalMixCourseMinutes = 0;
|
|
|
+ Integer singleCourseMinutes = 0;
|
|
|
+ if(classGroup4MixDto.getCourseType() == SINGLE || classGroup4MixDto.getCourseType() == MIX ||
|
|
|
+ classGroup4MixDto.getCourseType() == TRAINING_SINGLE || classGroup4MixDto.getCourseType() == TRAINING_MIX){
|
|
|
+ //单技课和合奏课最大的排课时长不能超过44 * 45 分钟
|
|
|
+ if(totalCourseMinutes > 44 * 45){
|
|
|
+ throw new BizException("操作失败:单技课和合奏课最大的排课时长不能超过{}分钟",44*45);
|
|
|
+ }
|
|
|
+ if(classGroup4MixDto.getCourseType() == SINGLE || classGroup4MixDto.getCourseType() == TRAINING_SINGLE){
|
|
|
+ singleCourseMinutes = totalCourseMinutes;
|
|
|
+ //获取所选学员最大的已消耗的单技课时长
|
|
|
+ int maxSingleCourseMinutes = musicGroupSchoolTermStudentCourseDetailDao.getMaxSingleCourseMinutes(musicGroupSchoolTermCourseDetailId,studentIds);
|
|
|
+ if(44 * 45 - maxSingleCourseMinutes < totalCourseMinutes){
|
|
|
+ throw new BizException("操作失败:所选学员可排单技课时长已不足{}分钟",totalCourseMinutes);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ totalMixCourseMinutes = totalCourseMinutes;
|
|
|
+ int maxMixCourseMinutes = musicGroupSchoolTermStudentCourseDetailDao.getMaxMixCourseMinutes(musicGroupSchoolTermCourseDetailId,studentIds);
|
|
|
+ if(44 * 45 - maxMixCourseMinutes < totalCourseMinutes){
|
|
|
+ throw new BizException("操作失败:所选学员可排合奏课时长已不足{}分钟",totalCourseMinutes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取班级学员最少可排课时长
|
|
|
+ int mixCourseMinutes = musicGroupSchoolTermStudentCourseDetailDao.getMixCourseMinutes(musicGroupSchoolTermCourseDetailId,studentIds);
|
|
|
+ if(totalCourseMinutes > mixCourseMinutes){
|
|
|
+ throw new BizException("操作失败:所选部分学员可排课时间不足");
|
|
|
+ }
|
|
|
+
|
|
|
+ int totalCourseTimes = 0;
|
|
|
+ int generateCourseTimes = 0;
|
|
|
+ if (!CollectionUtils.isEmpty(classGroup4MixDto.getCourseTimeDtoList())) {
|
|
|
+ totalCourseTimes = classGroup4MixDto.getCourseTimeDtoList().stream().mapToInt(CourseTimeDto::getExpectCourseNum).reduce(0, Integer::sum);
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<String> holidayDays = new HashSet<>();
|
|
|
+ SysConfig holidaySetting = sysConfigService.findByParamName(SysConfigService.HOLIDAY_SETTING);
|
|
|
+ if (Objects.nonNull(holidaySetting) && StringUtils.isNotBlank(holidaySetting.getParanValue())) {
|
|
|
+ holidayDays = new HashSet<>(JSON.parseArray(holidaySetting.getParanValue(), String.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Integer> allTeacherIds = new HashSet<>();
|
|
|
+ List<SimpleUserDto> allTeacherInfo = new ArrayList<>();
|
|
|
+ if(!confirmGenerate){
|
|
|
+ for (CourseTimeDto courseTimeDto : classGroup4MixDto.getCourseTimeDtoList()) {
|
|
|
+ List<ClassGroupTeacherMapper> newClassGroupTeacherMapperList = courseTimeDto.getClassGroupTeacherMapperList();
|
|
|
+ Set<Integer> teacherIds = newClassGroupTeacherMapperList.stream().map(t -> t.getUserId()).collect(Collectors.toSet());
|
|
|
+ if(!CollectionUtils.isEmpty(teacherIds)){
|
|
|
+ allTeacherIds.addAll(teacherIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!CollectionUtils.isEmpty(allTeacherIds)){
|
|
|
+ allTeacherInfo = teacherDao.getUsersSimpleInfo(new ArrayList<>(allTeacherIds));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ WhileNode:
|
|
|
+ while (true) {
|
|
|
+ int dayOfWeek = now.getDayOfWeek().getValue();
|
|
|
+ for (CourseTimeDto courseTimeDto : classGroup4MixDto.getCourseTimeDtoList()) {
|
|
|
+ List<ClassGroupTeacherMapper> newClassGroupTeacherMapperList = courseTimeDto.getClassGroupTeacherMapperList();
|
|
|
+
|
|
|
+ Set<Integer> noRepeatTeacherIds = newClassGroupTeacherMapperList.stream().map(ClassGroupTeacherMapper::getUserId).collect(Collectors.toSet());
|
|
|
+ if (noRepeatTeacherIds.size() != newClassGroupTeacherMapperList.size()) {
|
|
|
+ throw new BizException("主教与助教存在冲突");
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer teacherId = newClassGroupTeacherMapperList.stream().filter(ct->TeachTypeEnum.BISHOP.equals(ct.getTeacherRole())).findAny().get().getUserId();
|
|
|
+ if(Objects.isNull(teacherId)){
|
|
|
+ throw new BizException("请设置主教");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (courseTimeDto.getDayOfWeek() < 1 || courseTimeDto.getDayOfWeek() > 7) {
|
|
|
+ throw new BizException("排课循环周期错误,请核查");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(courseTimeDto.getStartDate()) || Objects.isNull(courseTimeDto.getEndDate())) {
|
|
|
+ throw new BizException("排课循环周期错误,请核查");
|
|
|
+ }
|
|
|
+ //排课截止时间不可超过学期截止日期
|
|
|
+ if(courseTimeDto.getEndDate().compareTo(schoolTermCourseDetail.getEndSchoolTerm()) > 0){
|
|
|
+ throw new BizException("操作失败:不可跨学期排课,请调整课程截止日期");
|
|
|
+ }
|
|
|
+ //排课开始时间不可小于预排课时间
|
|
|
+ if(courseTimeDto.getStartDate().compareTo(schoolTermCourseDetail.getStartSchoolTerm()) < 0){
|
|
|
+ throw new BizException("操作失败:排课开始时间不可小于预排课时间");
|
|
|
+ }
|
|
|
+
|
|
|
+ //跳过节假日
|
|
|
+ if (courseTimeDto.getHoliday() && holidayDays.contains(now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!courseTimeDto.getDayOfWeek().equals(dayOfWeek)) continue;
|
|
|
+
|
|
|
+ Date classDate = DateConvertor.toDate(now);
|
|
|
+
|
|
|
+ if (courseTimeDto.getStartDate().compareTo(classDate) > 0
|
|
|
+ || courseTimeDto.getEndDate().compareTo(classDate) < 0
|
|
|
+ || courseTimeDto.getExpectCourseNum() <= courseTimeDto.getCourseNum()) {
|
|
|
+ if (courseTimeDto.getEndDate().compareTo(classDate) < 0 && courseTimeDto.getExpectCourseNum() > courseTimeDto.getCourseNum()) {
|
|
|
+ throw new BizException("在指定的排课时间段内({}-{})无法完成预计课时数的排课", DateUtil.dateToString(courseTimeDto.getStartDate(), "yyyy.MM.dd"), DateUtil.dateToString(courseTimeDto.getEndDate(), "yyyy.MM.dd"));
|
|
|
+ }
|
|
|
+ if (totalCourseTimes <= generateCourseTimes) {
|
|
|
+ break WhileNode;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ courseTimeDto.setCourseNum(courseTimeDto.getCourseNum() + 1);
|
|
|
+ generateCourseTimes += 1;
|
|
|
+
|
|
|
+ if (totalCourseTimes < generateCourseTimes) {
|
|
|
+ break WhileNode;
|
|
|
+ }
|
|
|
+
|
|
|
+ String startClassTime = DateUtil.getDate(classDate) + " " + courseTimeDto.getStartClassTime() + ":00";
|
|
|
+ String endClassTime = DateUtil.getDate(classDate) + " " + courseTimeDto.getEndClassTime() + ":00";
|
|
|
+
|
|
|
+ CourseSchedule courseSchedule = new CourseSchedule();
|
|
|
+ courseSchedule.setSchoolId(schoolId);
|
|
|
+ courseSchedule.setClassGroupId(classGroup.getId());
|
|
|
+ courseSchedule.setStatus(CourseStatusEnum.NOT_START);
|
|
|
+ courseSchedule.setClassDate(classDate);
|
|
|
+ courseSchedule.setStartClassTime(DateUtil.stringToDate(startClassTime));
|
|
|
+ if (date.compareTo(courseSchedule.getStartClassTime()) > 0) {
|
|
|
+ throw new BizException("课程开始时间不得早于当前时间");
|
|
|
+ }
|
|
|
+ courseSchedule.setEndClassTime(DateUtil.stringToDate(endClassTime));
|
|
|
+ courseSchedule.setCreateTime(date);
|
|
|
+ courseSchedule.setUpdateTime(date);
|
|
|
+ courseSchedule.setTeachMode(teachMode);
|
|
|
+ courseSchedule.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
+ courseSchedule.setType(classGroup4MixDto.getCourseType());
|
|
|
+
|
|
|
+ if (classGroup4MixDto.getCourseType().equals(MIX)) {
|
|
|
+ courseSchedule.setName(classGroup4MixDto.getCourseType().getMsg());
|
|
|
+ } else if (classGroup4MixDto.getCourseType().equals(CourseScheduleType.MUSIC_NETWORK)) {
|
|
|
+ courseSchedule.setName(classGroup.getName());
|
|
|
+ } else {
|
|
|
+ courseSchedule.setName(subjectNames + "-" + classGroup4MixDto.getCourseType().getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ courseSchedule.setGroupType(MUSIC);
|
|
|
+ courseSchedule.setTeacherId(teacherId);
|
|
|
+ courseSchedule.setActualTeacherId(teacherId);
|
|
|
+ courseSchedule.setOrganId(musicGroup.getOrganId());
|
|
|
+ courseSchedule.setClassGroupType(classGroup.getType().getCode());
|
|
|
+ courseSchedule.setIsLock(1);
|
|
|
+ courseSchedule.setPreCourseFlag(1);
|
|
|
+ courseSchedule.setMemberFlag(1);
|
|
|
+ courseSchedule.setValidEndTime(schoolTermCourseDetail.getEndSchoolTerm());
|
|
|
+ courseScheduleDao.insert(courseSchedule);
|
|
|
+ courseScheduleList.add(courseSchedule);
|
|
|
+
|
|
|
+ if(!confirmGenerate){
|
|
|
+ Set<Integer> teacherIds = newClassGroupTeacherMapperList.stream().filter(ct->TeachTypeEnum.TEACHING.equals(ct.getTeacherRole())).map(ClassGroupTeacherMapper::getUserId).collect(Collectors.toSet());
|
|
|
+ SimpleUserDto mainTeacher = allTeacherInfo.stream().filter(t -> teacherId.equals(t.getUserId())).findAny().get();
|
|
|
+ if(Objects.nonNull(mainTeacher)){
|
|
|
+ courseSchedule.setActualTeacherName(mainTeacher.getUserName());
|
|
|
+ }
|
|
|
+ List<SimpleUserDto> teachingTeachers = allTeacherInfo.stream().filter(t -> teacherIds.contains(t.getUserId())).collect(Collectors.toList());
|
|
|
+ if(!CollectionUtils.isEmpty(teachingTeachers)){
|
|
|
+ courseSchedule.setTeachingTeacherNames(StringUtils.join(teachingTeachers.stream().map(SimpleUserDto::getUserName).collect(Collectors.toList()), ","));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (ClassGroupTeacherMapper classGroupTeacherMapper : newClassGroupTeacherMapperList) {
|
|
|
+ CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();
|
|
|
+ courseScheduleTeacherSalary.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ courseScheduleTeacherSalary.setGroupType(courseSchedule.getGroupType());
|
|
|
+ courseScheduleTeacherSalary.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
|
+ courseScheduleTeacherSalary.setTeacherRole(classGroupTeacherMapper.getTeacherRole());
|
|
|
+ courseScheduleTeacherSalary.setUserId(classGroupTeacherMapper.getUserId());
|
|
|
+ courseScheduleTeacherSalary.setClassGroupId(classGroup.getId());
|
|
|
+ courseScheduleTeacherSalary.setCreateTime(date);
|
|
|
+ courseScheduleTeacherSalary.setUpdateTime(date);
|
|
|
+ courseScheduleTeacherSalaryService.createMusicGroupCourseTeacherSalary(musicGroup, courseSchedule, courseScheduleTeacherSalary);
|
|
|
+ courseScheduleTeacherSalaryList.add(courseScheduleTeacherSalary);
|
|
|
+ if (confirmGenerate && !classGroup4MixDto.getAllowZeroSalary() && BigDecimal.ZERO.compareTo(courseScheduleTeacherSalary.getExpectSalary()) == 0) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return BaseController.failed(HttpStatus.MULTI_STATUS, "当前课程课酬预计为0,是否继续");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ now = now.plusDays(1);
|
|
|
+ }
|
|
|
+ //更新学员的排课时长
|
|
|
+ musicGroupSchoolTermStudentCourseDetailDao.updateMinutes(musicGroupSchoolTermCourseDetailId,
|
|
|
+ totalCourseMinutes,
|
|
|
+ totalMixCourseMinutes,
|
|
|
+ singleCourseMinutes,
|
|
|
+ studentIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ courseScheduleService.checkNewCourseSchedules(courseScheduleList, false, false);
|
|
|
+
|
|
|
+// if (!confirmGenerate) {
|
|
|
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+// courseScheduleList.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
|
+// return BaseController.failed(HttpStatus.PARTIAL_CONTENT, courseScheduleList, "");
|
|
|
+// }
|
|
|
+
|
|
|
+ //老师结算表
|
|
|
+ if (courseScheduleTeacherSalaryList.size() > 0) {
|
|
|
+ courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaryList);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(studentList)) {
|
|
|
+ //学生结算表
|
|
|
+ courseScheduleStudentPaymentService.createForMemberMusicGroup(musicGroupId, courseScheduleList, studentIds);
|
|
|
+ }
|
|
|
+ return BaseController.succeed(classGroup);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public ClassGroup classGroupSnap(List<ClassGroup4MixDto> classGroup4MixDtos) throws Exception {
|
|
|
Date date = new Date();
|
|
|
String musicGroupId = classGroup4MixDtos.get(0).getMusicGroupId();
|
|
@@ -2763,7 +3185,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
courseSchedule.setType(classGroup4MixDto.getCourseType());
|
|
|
courseSchedule.setGroupType(MUSIC);
|
|
|
courseSchedule.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
- if (classGroup4MixDto.getCourseType().equals(CourseSchedule.CourseScheduleType.MIX)) {
|
|
|
+ if (classGroup4MixDto.getCourseType().equals(MIX)) {
|
|
|
courseSchedule.setName(classGroup4MixDto.getCourseType().getMsg());
|
|
|
} else {
|
|
|
courseSchedule.setName(subjectNames + "-" + classGroup4MixDto.getCourseType().getMsg());
|
|
@@ -2807,7 +3229,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
//学生结算表
|
|
|
if (!CollectionUtils.isEmpty(studentIdList)) {
|
|
|
courseScheduleStudentPaymentService.createForMusicGroup(musicGroupId, courseScheduleList, studentIdList);
|
|
|
- studentDao.updateStudentServiceTag(null, studentIdList, YesOrNoEnum.YES.getCode());
|
|
|
+ studentService.updateStudentServiceTag(null, studentIdList, YesOrNoEnum.YES.getCode());
|
|
|
}
|
|
|
return classGroup;
|
|
|
}
|
|
@@ -3065,6 +3487,13 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
Map<Integer, Integer> studyNums = JSONObject.parseObject(JSONObject.toJSONString(MapUtil.convertIntegerMap(classGroupDao.countStudyNum(classGroupIds))), HashMap.class);
|
|
|
|
|
|
Map<Integer, Long> totalNumMap = MapUtil.convertIntegerMap(courseScheduleDao.countTotalNumByClassGroupId(classGroupSet, null));
|
|
|
+ MusicGroupSchoolTermCourseDetail termCourseDetail = musicGroupSchoolTermCourseDetailDao.findByCourseDateAndMusicGroupId(musicGroupId, null,0);
|
|
|
+ Map<Integer, Long> preTotalNumMap = null;
|
|
|
+ Map<Integer, Long> preSubMinutesMap = null;
|
|
|
+ if(termCourseDetail != null){
|
|
|
+ preTotalNumMap = MapUtil.convertIntegerMap(courseScheduleDao.countPreTotalNumByClassGroupId(classGroupSet));
|
|
|
+ preSubMinutesMap = MapUtil.convertIntegerMap(courseScheduleDao.countPreSubMinutesByClassGroupId(classGroupSet,termCourseDetail.getId()));
|
|
|
+ }
|
|
|
Map<Integer, Long> currentNumMap = MapUtil.convertIntegerMap(courseScheduleDao.countExpendNumByClassGroupId(classGroupSet));
|
|
|
|
|
|
for (ClassGroupTeachersDto classGroup : classGroups) {
|
|
@@ -3077,12 +3506,26 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
classGroup.setStudentNum(studyNums.get(classGroup.getId()));
|
|
|
int totalClassTimes = 0;
|
|
|
int currentClassTimes = 0;
|
|
|
+ if(preSubMinutesMap != null){
|
|
|
+ if (preSubMinutesMap.containsKey(classGroup.getId())) {
|
|
|
+ Long aLong = preSubMinutesMap.get(classGroup.getId());
|
|
|
+ classGroup.setPreSubMinutes(aLong==null?0:aLong.intValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(preTotalNumMap != null){
|
|
|
+ if (preTotalNumMap.containsKey(classGroup.getId())) {
|
|
|
+ Long aLong = preTotalNumMap.get(classGroup.getId());
|
|
|
+ classGroup.setPreTotalClassTimes(aLong==null?0:aLong.intValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (totalNumMap.containsKey(classGroup.getId())) {
|
|
|
totalClassTimes = totalNumMap.get(classGroup.getId()).intValue();
|
|
|
}
|
|
|
if (currentNumMap.containsKey(classGroup.getId())) {
|
|
|
currentClassTimes = currentNumMap.get(classGroup.getId()).intValue();
|
|
|
}
|
|
|
+
|
|
|
classGroup.setTotalClassTimes(totalClassTimes);
|
|
|
classGroup.setCurrentClassTimes(currentClassTimes);
|
|
|
}
|
|
@@ -3501,8 +3944,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<RemainCourseTypeDurationDto> queryRemainCourseTypeDuration(String classGroupIdList) {
|
|
|
- return courseScheduleDao.queryRemainCourseTypeDuration(classGroupIdList);
|
|
|
+ public List<RemainCourseTypeDurationDto> queryRemainCourseTypeDuration(String classGroupIdList,Integer memberFlag) {
|
|
|
+ return courseScheduleDao.queryRemainCourseTypeDuration(classGroupIdList,memberFlag);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -3702,7 +4145,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
//冻结班级
|
|
|
classGroupDao.batchUpdateLockByClassGroupIds(classGroupIds, 1);
|
|
|
//冻结所选班级的课程
|
|
|
- courseScheduleDao.batchUpdateLockByCourseIds(allLockCourseIds, 1);
|
|
|
+ courseScheduleDao.batchUpdateLockByCourseIds(allLockCourseIds, 1,null);
|
|
|
httpResponseResult.setMsg("学员班级调整申请已提交,缴费项目审核中");
|
|
|
}
|
|
|
return httpResponseResult;
|
|
@@ -3900,6 +4343,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
}
|
|
|
//获取分布默认的课程类型单价
|
|
|
MusicGroup musicGroup = musicGroupDao.findByClassGroupId(masterClassGroupId);
|
|
|
+ //主班乐团不能是系统收费团
|
|
|
+ if(musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
|
|
|
+ throw new BizException("操作失败:主班乐团不能是系统收费团");
|
|
|
+ }
|
|
|
Map<String, BigDecimal> unitPriceMap = MapUtil.convertIntegerMap(organizationCourseUnitPriceSettingsDao.queryMapByOrganIdAndChargeTypeId(musicGroup.getChargeTypeId(), musicGroup.getOrganId()));
|
|
|
Set<String> masterKeySet = masterMap.keySet();
|
|
|
//计算主班课程类型剩余价值
|
|
@@ -4133,7 +4580,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
// 冻结班级
|
|
|
classGroupDao.batchUpdateLockByClassGroupIds(classGroupIds, 1);
|
|
|
// 冻结所选班级的课程
|
|
|
- courseScheduleDao.batchUpdateLockByCourseIds(allLockCourseIds, 1);
|
|
|
+ courseScheduleDao.batchUpdateLockByCourseIds(allLockCourseIds, 1,null);
|
|
|
httpResponseResult.setMsg("操作成功:学员班级调整申请已提交,缴费项目审核中");
|
|
|
}
|
|
|
return httpResponseResult;
|
|
@@ -4169,7 +4616,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudents(courseIds, studentIds);
|
|
|
}
|
|
|
//解冻课程
|
|
|
- courseScheduleDao.batchUpdateLockByCourseIds(allLockCourseIds, 0);
|
|
|
+ courseScheduleDao.batchUpdateLockByCourseIds(allLockCourseIds, 0,null);
|
|
|
//解冻班级
|
|
|
classGroupIds.add(masterClassGroupId);
|
|
|
classGroupDao.batchUpdateLockByClassGroupIds(classGroupIds, 0);
|
|
@@ -4188,4 +4635,19 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
//如果是基础技能班,重新计算老师课酬
|
|
|
batchUpdateTeacherSalary(classGroupIds);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<CourseSchedule> queryPreCourseList(Integer classGroupId) {
|
|
|
+ List<CourseSchedule> courseSchedules = courseScheduleDao.queryPreCourseListByClassGroupId(classGroupId);
|
|
|
+ if(courseSchedules.size() > 0){
|
|
|
+ List<Long> courseIdList = courseSchedules.stream().map(e -> e.getId()).collect(Collectors.toList());
|
|
|
+ Map<Long, String> bishopTeacherMap = MapUtil.convertMybatisMap(courseScheduleTeacherSalaryDao.queryTeacherNameMap(courseIdList,"BISHOP"));
|
|
|
+ Map<Long, String> teachingTeacherMap = MapUtil.convertMybatisMap(courseScheduleTeacherSalaryDao.queryTeacherNameMap(courseIdList,"TEACHING"));
|
|
|
+ for (CourseSchedule courseSchedule : courseSchedules) {
|
|
|
+ courseSchedule.setActualTeacherName(bishopTeacherMap.get(courseSchedule.getId()));
|
|
|
+ courseSchedule.setTeachingTeacherNames(teachingTeacherMap.get(courseSchedule.getId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return courseSchedules;
|
|
|
+ }
|
|
|
}
|