|
@@ -1,6 +1,8 @@
|
|
package com.ym.mec.biz.service.impl;
|
|
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.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.GroupType.COMM;
|
|
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.MUSIC;
|
|
import static com.ym.mec.biz.dal.enums.GroupType.PRACTICE;
|
|
import static com.ym.mec.biz.dal.enums.GroupType.PRACTICE;
|
|
@@ -30,7 +32,6 @@ import com.ym.mec.biz.dal.dao.*;
|
|
import com.ym.mec.biz.dal.dto.*;
|
|
import com.ym.mec.biz.dal.dto.*;
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
import com.ym.mec.biz.service.*;
|
|
import com.ym.mec.biz.service.*;
|
|
-import com.ym.mec.common.service.IdGeneratorService;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -100,6 +101,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
@Autowired
|
|
@Autowired
|
|
private ClassGroupStudentMapperDao classGroupStudentMapperDao;
|
|
private ClassGroupStudentMapperDao classGroupStudentMapperDao;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private ClassGroupStudentMapperService classGroupStudentMapperService;
|
|
|
|
+ @Autowired
|
|
private ClassGroupRelationDao classGroupRelationDao;
|
|
private ClassGroupRelationDao classGroupRelationDao;
|
|
@Autowired
|
|
@Autowired
|
|
private ClassGroupTeacherMapperService classGroupTeacherMapperService;
|
|
private ClassGroupTeacherMapperService classGroupTeacherMapperService;
|
|
@@ -163,8 +166,6 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
@Autowired
|
|
@Autowired
|
|
private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
|
|
private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
|
|
@Autowired
|
|
@Autowired
|
|
- private IdGeneratorService idGeneratorService;
|
|
|
|
- @Autowired
|
|
|
|
private MusicGroupStudentClassAdjustDao musicGroupStudentClassAdjustDao;
|
|
private MusicGroupStudentClassAdjustDao musicGroupStudentClassAdjustDao;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -905,7 +906,6 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
public List<ImGroupModel> queryUserGroups(Integer userId, String search) {
|
|
public List<ImGroupModel> queryUserGroups(Integer userId, String search) {
|
|
List<ImGroupModel> imGroupModels = classGroupDao.queryUserMusicGroups(userId, search);
|
|
List<ImGroupModel> imGroupModels = classGroupDao.queryUserMusicGroups(userId, search);
|
|
imGroupModels.addAll(classGroupDao.queryUserVipGroups(userId, search));
|
|
imGroupModels.addAll(classGroupDao.queryUserVipGroups(userId, search));
|
|
-// imGroupModels.addAll(classGroupDao.queryUserPracticeGroups(userId, search));
|
|
|
|
imGroupModels.addAll(classGroupDao.queryUserCommGroups(userId, search));
|
|
imGroupModels.addAll(classGroupDao.queryUserCommGroups(userId, search));
|
|
if (imGroupModels != null && imGroupModels.size() > 0) {
|
|
if (imGroupModels != null && imGroupModels.size() > 0) {
|
|
imGroupModels.forEach(e -> {
|
|
imGroupModels.forEach(e -> {
|
|
@@ -2919,6 +2919,53 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ public PageInfo<ClassGroupTeachersDto> queryClassGroupPage(ClassGroupQueryInfo queryInfo) {
|
|
|
|
+ PageInfo<ClassGroupTeachersDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
|
+
|
|
|
|
+ List<ClassGroupTeachersDto> dataList = null;
|
|
|
|
+ int count = classGroupDao.countClassGroup(params);
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ pageInfo.setTotal(count);
|
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
|
+ dataList = classGroupDao.queryClassGroupPage(params);
|
|
|
|
+ String classGroupIds = dataList.stream().map(classGroup -> classGroup.getId().toString()).collect(Collectors.joining(","));
|
|
|
|
+ List<Integer> classGroupSet = dataList.stream().map(classGroup -> classGroup.getId()).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ List<ClassGroupTeacherMapper> classGroupTeachers = classGroupTeacherMapperDao.findClassGroupTeachers(classGroupIds);
|
|
|
|
+ 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));
|
|
|
|
+ Map<Integer, Long> currentNumMap = MapUtil.convertIntegerMap(courseScheduleDao.countExpendNumByClassGroupId(classGroupSet));
|
|
|
|
+ for (ClassGroupTeachersDto classGroup : dataList) {
|
|
|
|
+ List<ClassGroupTeacherMapper> classGroupTeacherMappers = new ArrayList<>();
|
|
|
|
+ for (ClassGroupTeacherMapper classGroupTeacher : classGroupTeachers) {
|
|
|
|
+ if (!classGroup.getId().equals(classGroupTeacher.getClassGroupId())) continue;
|
|
|
|
+ classGroupTeacherMappers.add(classGroupTeacher);
|
|
|
|
+ }
|
|
|
|
+ classGroup.setClassGroupTeacherMapperList(classGroupTeacherMappers);
|
|
|
|
+ classGroup.setStudentNum(studyNums.get(classGroup.getId()));
|
|
|
|
+ int totalClassTimes = 0;
|
|
|
|
+ int currentClassTimes = 0;
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (count == 0) {
|
|
|
|
+ dataList = new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
|
+ return pageInfo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
public Boolean addImGroup(ClassGroup classGroup, List<Integer> userIds) {
|
|
public Boolean addImGroup(ClassGroup classGroup, List<Integer> userIds) {
|
|
MusicGroup musicGroup = musicGroupDao.get(classGroup.getMusicGroupId());
|
|
MusicGroup musicGroup = musicGroupDao.get(classGroup.getMusicGroupId());
|
|
List<Integer> userIdList = new ArrayList<>();
|
|
List<Integer> userIdList = new ArrayList<>();
|
|
@@ -3255,34 +3302,14 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
@Override
|
|
@Override
|
|
public Map<String, Integer> classGroupSubCourseNum(Integer classGroupId) {
|
|
public Map<String, Integer> classGroupSubCourseNum(Integer classGroupId) {
|
|
return MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseNumMap(classGroupId));
|
|
return MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseNumMap(classGroupId));
|
|
-
|
|
|
|
-// List<Map<String,Object>> result = new ArrayList<>();
|
|
|
|
-// //获取班级列表
|
|
|
|
-// List<ClassGroup> classGroups = classGroupDao.queryClassGroups(musicGroupId, null);
|
|
|
|
-// for (ClassGroup classGroup : classGroups) {
|
|
|
|
-// Map<String,Object> resultMap = new HashMap();
|
|
|
|
-// resultMap.put("classGroup",classGroup);
|
|
|
|
-// //获取班级剩余的课程类型和课程数量
|
|
|
|
-// List<Map<String,Integer>> courseTypeNumMap = courseScheduleDao.querySubCourseNumMap(classGroup.getId());
|
|
|
|
-// resultMap.put("courseTypeNumMap",courseTypeNumMap);
|
|
|
|
-// //获取班级里学员列表
|
|
|
|
-// resultMap.put("students",classGroupStudentMapperDao.findCourseStudentNameAndPhoneByClassGroupId(classGroup.getId()));
|
|
|
|
-// result.add(resultMap);
|
|
|
|
-// }
|
|
|
|
-// return result;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
public Map<String, Object> getDefaultPaymentCalender(List<Integer> classGroupIds) {
|
|
public Map<String, Object> getDefaultPaymentCalender(List<Integer> classGroupIds) {
|
|
if (classGroupIds == null || classGroupIds.size() == 0) {
|
|
if (classGroupIds == null || classGroupIds.size() == 0) {
|
|
throw new BizException("参数校验失败");
|
|
throw new BizException("参数校验失败");
|
|
}
|
|
}
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<Integer, Map<String, MusicGroupOrganizationCourseSettingsDetail>> resultMap = new HashMap<>();
|
|
Map<Integer, Map<String, MusicGroupOrganizationCourseSettingsDetail>> resultMap = new HashMap<>();
|
|
- //获取默认的排课时长
|
|
|
|
-// JSONObject jsonObject = JSON.parseObject(classAdjust.getDefaultCourseTypeMinute());
|
|
|
|
-// String courseDefaultMinutes = sysConfigDao.findConfigValue("music_course_default_minutes");
|
|
|
|
-// JSONObject jsonObject = JSON.parseObject(courseDefaultMinutes);
|
|
|
|
//获取所选班级最大剩余课时
|
|
//获取所选班级最大剩余课时
|
|
Map<String, Long> map = MapUtil.convertIntegerMap(courseScheduleDao.findClassMaxCourseNumMap(classGroupIds));
|
|
Map<String, Long> map = MapUtil.convertIntegerMap(courseScheduleDao.findClassMaxCourseNumMap(classGroupIds));
|
|
//获取分布默认的课程类型单价
|
|
//获取分布默认的课程类型单价
|
|
@@ -3545,4 +3572,236 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
highClassGroupNumDto.setMaxHighClassGroupNum(maxClassGroupNum);
|
|
highClassGroupNumDto.setMaxHighClassGroupNum(maxClassGroupNum);
|
|
return highClassGroupNumDto;
|
|
return highClassGroupNumDto;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<MusicGroupPaymentCalenderStudentDetail> queryStudentPaymentCalenders(Integer masterClassGroupId,List<Map<Integer, String>> classGroupStudents,List<Integer> studentIds) {
|
|
|
|
+ //获取主班剩余时长
|
|
|
|
+ Map<String, Long> masterMap = MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseNumMap(masterClassGroupId));
|
|
|
|
+ if(masterMap.size() <= 0){
|
|
|
|
+ throw new BizException("所选主班没有剩余课程,请重新选择");
|
|
|
|
+ }
|
|
|
|
+ //获取学员列表
|
|
|
|
+ Map<Integer, String> userNames = MapUtil.convertMybatisMap(teacherDao.queryUsernameByIds(studentIds));
|
|
|
|
+ Map<Integer, String> phoneMaps = MapUtil.convertMybatisMap(teacherDao.queryPhoneByIds(StringUtils.join(studentIds,",")));
|
|
|
|
+
|
|
|
|
+ Map<Integer, Integer> studentCLassMap = new HashMap<>();
|
|
|
|
+ List<Map<Integer, BigDecimal>> surplusCourseFeeMapList = new ArrayList<>();
|
|
|
|
+ for (Map<Integer, String> classGroupStudent : classGroupStudents) {
|
|
|
|
+ for (Integer integer : classGroupStudent.keySet()) {
|
|
|
|
+ //获取学员剩余课程费用
|
|
|
|
+ surplusCourseFeeMapList.addAll(studentRegistrationDao.querySurplusCourseFeeByClassGroupId(integer,classGroupStudent.get(integer)));
|
|
|
|
+ String[] s = classGroupStudent.get(integer).split(",");
|
|
|
|
+ for (String s1 : s) {
|
|
|
|
+ studentCLassMap.put(Integer.parseInt(s1),integer);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //学员剩余课程费用
|
|
|
|
+ Map<Integer, BigDecimal> surplusCourseFeeMap = MapUtil.convertIntegerMap(surplusCourseFeeMapList);
|
|
|
|
+ //获取分布默认的课程类型单价
|
|
|
|
+ MusicGroup musicGroup = musicGroupDao.findByClassGroupId(masterClassGroupId);
|
|
|
|
+ Map<String, BigDecimal> unitPriceMap = MapUtil.convertIntegerMap(organizationCourseUnitPriceSettingsDao.queryMapByOrganIdAndChargeTypeId(musicGroup.getChargeTypeId(), musicGroup.getOrganId()));
|
|
|
|
+ Set<String> masterKeySet = masterMap.keySet();
|
|
|
|
+ //计算主班课程类型剩余价值
|
|
|
|
+ Map<String, BigDecimal> masterTotalPriceMap = new HashMap<>(masterKeySet.size());
|
|
|
|
+ //学员缴费项目列表
|
|
|
|
+ List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails = new ArrayList<>();
|
|
|
|
+ for (String s : masterKeySet) {
|
|
|
|
+ BigDecimal unitPrice = unitPriceMap.get(s);
|
|
|
|
+ if (unitPrice == null) {
|
|
|
|
+ throw new BizException("分部默认课程类型单价不存在,请设置");
|
|
|
|
+ }
|
|
|
|
+ Long courseTime = masterMap.get(s);
|
|
|
|
+ //获取主班剩余课程价值,按分部默认单价计算
|
|
|
|
+ if(courseTime == 0l){
|
|
|
|
+ masterTotalPriceMap.put(s,BigDecimal.ZERO);
|
|
|
|
+ }
|
|
|
|
+ //总价四舍五入取整
|
|
|
|
+ BigDecimal totalPrice = unitPrice.multiply(new BigDecimal(courseTime)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ masterTotalPriceMap.put(s,totalPrice);
|
|
|
|
+ //课程余额转移
|
|
|
|
+ for (Integer studentId : studentCLassMap.keySet()) {
|
|
|
|
+ //学员剩余课程余额
|
|
|
|
+ BigDecimal bigDecimal = surplusCourseFeeMap.get(studentId);
|
|
|
|
+ //创建学员缴费项目
|
|
|
|
+ MusicGroupPaymentCalenderStudentDetail calenderDto = new MusicGroupPaymentCalenderStudentDetail();
|
|
|
|
+ calenderDto.setClassGroupId(studentCLassMap.get(studentId));
|
|
|
|
+ //如果剩余课程余额小于等于0
|
|
|
|
+ if(bigDecimal.doubleValue() <= 0d){
|
|
|
|
+ calenderDto.setCourseCurrentPrice(totalPrice);
|
|
|
|
+ calenderDto.setCourseOriginalPrice(totalPrice);
|
|
|
|
+ }else {
|
|
|
|
+ //如果剩余课程余额大于等于总价值,那么补交0元
|
|
|
|
+ if(bigDecimal.doubleValue() >= totalPrice.doubleValue()){
|
|
|
|
+ calenderDto.setCourseCurrentPrice(BigDecimal.ZERO);
|
|
|
|
+ calenderDto.setCourseOriginalPrice(BigDecimal.ZERO);
|
|
|
|
+ }else {
|
|
|
|
+ calenderDto.setCourseCurrentPrice(totalPrice.subtract(bigDecimal));
|
|
|
|
+ calenderDto.setCourseOriginalPrice(totalPrice.subtract(bigDecimal));
|
|
|
|
+ }
|
|
|
|
+ //剩余课程余额减去主班对应课程类型总的课程价值,负数就是需要补交的金额
|
|
|
|
+// bigDecimal = bigDecimal.subtract(totalPrice);
|
|
|
|
+ surplusCourseFeeMap.put(studentId,bigDecimal.subtract(totalPrice));
|
|
|
|
+ }
|
|
|
|
+ calenderDto.setCourseTime(courseTime);
|
|
|
|
+ calenderDto.setCourseType(s);
|
|
|
|
+
|
|
|
|
+ calenderDto.setPhone(phoneMaps.get(studentId));
|
|
|
|
+ calenderDto.setUserId(studentId);
|
|
|
|
+ calenderDto.setUsername(userNames.get(studentId));
|
|
|
|
+ musicGroupPaymentCalenderStudentDetails.add(calenderDto);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return musicGroupPaymentCalenderStudentDetails;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public BigDecimal getMasterTotalPrice(Integer masterClassGroupId) {
|
|
|
|
+ //获取主班剩余时长
|
|
|
|
+ Map<String, Long> masterMap = MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseNumMap(masterClassGroupId));
|
|
|
|
+ if(masterMap.size() <= 0){
|
|
|
|
+ throw new BizException("所选主班没有剩余课程,请重新选择");
|
|
|
|
+ }
|
|
|
|
+ //获取分布默认的课程类型单价
|
|
|
|
+ MusicGroup musicGroup = musicGroupDao.findByClassGroupId(masterClassGroupId);
|
|
|
|
+ Map<String, BigDecimal> unitPriceMap = MapUtil.convertIntegerMap(organizationCourseUnitPriceSettingsDao.queryMapByOrganIdAndChargeTypeId(musicGroup.getChargeTypeId(), musicGroup.getOrganId()));
|
|
|
|
+ Set<String> masterKeySet = masterMap.keySet();
|
|
|
|
+ //计算主班课程类型剩余价值
|
|
|
|
+ BigDecimal masterTotalPrice = BigDecimal.ZERO;
|
|
|
|
+ for (String s : masterKeySet) {
|
|
|
|
+ BigDecimal unitPrice = unitPriceMap.get(s);
|
|
|
|
+ if (unitPrice == null) {
|
|
|
|
+ throw new BizException("分部默认课程类型单价不存在,请设置");
|
|
|
|
+ }
|
|
|
|
+ Long courseTime = masterMap.get(s);
|
|
|
|
+ //获取主班剩余课程价值,按分部默认单价计算
|
|
|
|
+ //总价四舍五入取整
|
|
|
|
+ BigDecimal totalPrice = unitPrice.multiply(new BigDecimal(courseTime)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ masterTotalPrice = masterTotalPrice.add(totalPrice);
|
|
|
|
+ }
|
|
|
|
+ return masterTotalPrice;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Map<String, Long> querySubCourseTime(Integer classGroupId) {
|
|
|
|
+ return MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseNumMap(classGroupId));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public void spanGroupMergeClassSplitClassAffirm(MergeClassSplitClassAffirmDto mergeClassSplitClassAffirmDto) {
|
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
|
+ //缴费项目
|
|
|
|
+ List<MusicGroupPaymentCalenderDto> paymentCalenderDtos = mergeClassSplitClassAffirmDto.getMusicGroupPaymentCalenderDtos();
|
|
|
|
+ //主班
|
|
|
|
+ Integer masterClassGroupId = mergeClassSplitClassAffirmDto.getMasterClassGroupId();
|
|
|
|
+ //学员列表
|
|
|
|
+ List<Integer> studentIds = mergeClassSplitClassAffirmDto.getStudentIds();
|
|
|
|
+ //主班是否包含所选学员学员
|
|
|
|
+ Boolean hasStudent = classGroupStudentMapperDao.hasStudent(masterClassGroupId,studentIds);
|
|
|
|
+ if(hasStudent){
|
|
|
|
+ throw new BizException("操作失败: 主班包含部分已选学员");
|
|
|
|
+ }
|
|
|
|
+ //学员列表
|
|
|
|
+ List<Integer> classGroupIds = mergeClassSplitClassAffirmDto.getClassGroupIds();
|
|
|
|
+ //班级和学员关联
|
|
|
|
+ List<Map<Integer, String>> classGroupStudents = mergeClassSplitClassAffirmDto.getClassGroupStudents();
|
|
|
|
+ //获取默认的学员缴费详情
|
|
|
|
+ List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails = queryStudentPaymentCalenders(masterClassGroupId,
|
|
|
|
+ classGroupStudents,
|
|
|
|
+ studentIds);
|
|
|
|
+ //创建缴费项目
|
|
|
|
+ MusicGroup musicGroup = musicGroupDao.findByClassGroupId(masterClassGroupId);
|
|
|
|
+ MusicGroupPaymentCalender.PaymentCalenderStatusEnum status = null;
|
|
|
|
+ StringBuffer batchNos = new StringBuffer();
|
|
|
|
+ List<String> batchNoList = new ArrayList<>();
|
|
|
|
+ if (paymentCalenderDtos != null && paymentCalenderDtos.size() > 0) {
|
|
|
|
+ BigDecimal masterTotalPrice = getMasterTotalPrice(masterClassGroupId);
|
|
|
|
+ //是否有需要审核的缴费项目
|
|
|
|
+ for (MusicGroupPaymentCalenderDto calenderDto : paymentCalenderDtos) {
|
|
|
|
+ //将学员加入新乐团、扣除原乐团剩余课程余额、补充到现有乐团
|
|
|
|
+ studentRegistrationService.insertStudent(calenderDto.getStudentIds(),calenderDto.getMusicGroupId(),musicGroup.getId(),masterTotalPrice);
|
|
|
|
+ calenderDto.setMusicGroupId(musicGroup.getId());
|
|
|
|
+ List<MusicGroupPaymentCalenderStudentDetail> calenderStudentDetails = calenderDto.getMusicGroupPaymentCalenderStudentDetails();
|
|
|
|
+ boolean containsAll = musicGroupPaymentCalenderStudentDetails.containsAll(calenderStudentDetails);
|
|
|
|
+ if(!containsAll){
|
|
|
|
+ calenderDto.setStatus(AUDITING);
|
|
|
|
+ }else {
|
|
|
|
+ calenderDto.setStatus(NO);
|
|
|
|
+ }
|
|
|
|
+ calenderDto.setPaymentType(SPAN_GROUP_CLASS_ADJUST);
|
|
|
|
+ //生成缴费项目
|
|
|
|
+ calenderDto.setMasterTotalPrice(masterTotalPrice);
|
|
|
|
+ musicGroupPaymentCalenderService.create(calenderDto);
|
|
|
|
+ if (batchNos.length() > 0) {
|
|
|
|
+ batchNos.append(",");
|
|
|
|
+ }
|
|
|
|
+ batchNoList.add(calenderDto.getBatchNo());
|
|
|
|
+ batchNos.append(calenderDto.getBatchNo());
|
|
|
|
+ if (status == null || status != AUDITING) {
|
|
|
|
+ if(!containsAll){
|
|
|
|
+ status = AUDITING;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //记录申请信息
|
|
|
|
+ MusicGroupStudentClassAdjust musicGroupStudentClassAdjust = new MusicGroupStudentClassAdjust();
|
|
|
|
+ musicGroupStudentClassAdjust.setMasterClassGroupId(masterClassGroupId);
|
|
|
|
+ musicGroupStudentClassAdjust.setBatchNo(batchNos.toString());
|
|
|
|
+ musicGroupStudentClassAdjust.setMusicGroupId(musicGroup.getId());
|
|
|
|
+ musicGroupStudentClassAdjust.setOperatorId(sysUser.getId());
|
|
|
|
+ musicGroupStudentClassAdjust.setClassGroupIds(JSON.toJSONString(classGroupIds));
|
|
|
|
+ musicGroupStudentClassAdjust.setStudentIds(JSON.toJSONString(studentIds));
|
|
|
|
+ if (classGroupStudents != null && classGroupStudents.size() > 0) {
|
|
|
|
+ musicGroupStudentClassAdjust.setClassGroupStudents(JSON.toJSONString(mergeClassSplitClassAffirmDto.getClassGroupStudents()));
|
|
|
|
+ }
|
|
|
|
+ //获取需要删除的学员关联的课程
|
|
|
|
+ List<Long> courseIds = courseScheduleDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds, studentIds);
|
|
|
|
+ musicGroupStudentClassAdjust.setSubLockCourseIds(JSON.toJSONString(courseIds));
|
|
|
|
+ //获取关联的学员缴费信息
|
|
|
|
+ List<Long> studentPaymentIds = courseScheduleStudentPaymentDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds, studentIds);
|
|
|
|
+ musicGroupStudentClassAdjust.setStudentPaymentIds(JSON.toJSONString(studentPaymentIds));
|
|
|
|
+ //获取需要冻结的课程
|
|
|
|
+ classGroupIds.add(masterClassGroupId);
|
|
|
|
+ List<Long> allLockCourseIds = courseScheduleDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds, null);
|
|
|
|
+ musicGroupStudentClassAdjust.setAllLockCourseIds(JSON.toJSONString(allLockCourseIds));
|
|
|
|
+ musicGroupStudentClassAdjustDao.insert(musicGroupStudentClassAdjust);
|
|
|
|
+ //没有需要审核的缴费项目
|
|
|
|
+ if (status == null) {
|
|
|
|
+ spanGroupClassAdjustPass(masterClassGroupId,studentIds,courseIds,classGroupStudents);
|
|
|
|
+ }else {
|
|
|
|
+// 冻结班级
|
|
|
|
+ classGroupDao.batchUpdateLockByClassGroupIds(classGroupIds, 1);
|
|
|
|
+// 冻结所选班级的课程
|
|
|
|
+ courseScheduleDao.batchUpdateLockByCourseIds(allLockCourseIds, 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void spanGroupClassAdjustPass(Integer masterClassGroupId,List<Integer> studentIds,List<Long> courseIds,List<Map<Integer, String>> classGroupStudents){
|
|
|
|
+ //将学员加进班级未开始的课程,以及班级关联、加群
|
|
|
|
+ classGroupStudentMapperService.updateClassGroupStudents(masterClassGroupId.longValue(),new HashSet<>(studentIds));
|
|
|
|
+ //删除学员课程
|
|
|
|
+ courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudents(courseIds, studentIds);
|
|
|
|
+ //删除班级关联的学员
|
|
|
|
+ if (classGroupStudents != null && classGroupStudents.size() > 0) {
|
|
|
|
+ for (Map<Integer, String> classGroupStudent : classGroupStudents) {
|
|
|
|
+ Set<Integer> integers = classGroupStudent.keySet();
|
|
|
|
+ for (Integer integer : integers) {
|
|
|
|
+ classGroupStudentMapperDao.deleteByClassGroupIdAndStudents(integer, classGroupStudent.get(integer));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //获取没有学员的课程
|
|
|
|
+ List<Long> delCourseIds = courseScheduleDao.findNoStudentCourseIds(courseIds);
|
|
|
|
+ if (delCourseIds != null && delCourseIds.size() > 0) {
|
|
|
|
+ //删除课程
|
|
|
|
+ courseScheduleDao.deleteCourseSchedulesByClassGroupIds(delCourseIds);
|
|
|
|
+ //删除教师考勤
|
|
|
|
+ teacherAttendanceDao.batchDeleteByCourseSchedules(delCourseIds);
|
|
|
|
+ //删除教师课酬
|
|
|
|
+ courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(delCourseIds);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|