Browse Source

Merge remote-tracking branch 'origin/master'

Joburgess 4 years ago
parent
commit
832e292fda
20 changed files with 758 additions and 112 deletions
  1. 1 1
      codegen/src/main/resources/generateConfigration.xml
  2. 12 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java
  3. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupStudentClassAdjustDao.java
  4. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MergeClassSplitClassAffirmDto.java
  5. 162 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupStudentClassAdjust.java
  6. 10 1
      mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java
  7. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupStudentClassAdjustService.java
  8. 114 15
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java
  9. 47 23
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  10. 23 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupStudentClassAdjustServiceImpl.java
  11. 177 51
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  12. 17 3
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  13. 1 6
      mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml
  14. 2 1
      mec-biz/src/main/resources/config/mybatis/MusicGroupQuitMapper.xml
  15. 97 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupStudentClassAdjustMapper.xml
  16. 19 4
      mec-biz/src/main/resources/config/mybatis/SysExamSongMapper.xml
  17. 1 0
      mec-im/src/main/java/com/ym/mec/im/message/MemberChangedMessage.java
  18. 32 4
      mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java
  19. 5 0
      mec-teacher/src/main/java/com/ym/mec/teacher/controller/SysExamSongController.java
  20. 9 1
      mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupController.java

+ 1 - 1
codegen/src/main/resources/generateConfigration.xml

@@ -8,7 +8,7 @@
 		<catalog>mec_dev</catalog>
 		<schema>mec_dev</schema>
 	</dbConfiguration>
-	<srcBase>d:/javabean</srcBase>
+	<srcBase>/Users/zouxuan/Documents/javabean</srcBase>
 	<pojoPackageName>com.ym.mec.biz.dal.entity</pojoPackageName>
 	<daoPackageName>com.ym.mec.biz.dal.dao</daoPackageName>
 	<servicePackageName>com.ym.mec.biz.service</servicePackageName>

+ 12 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -1402,13 +1402,13 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
                               @Param("isLock") Integer isLock);
 
     /**
-     * @param classGroupIds:
+     * @param courseId:
      * @param isLock:    冻结状态:1、冻结,0、正常
      * @return int
      * @describe 通过班级编号更改课程的冻结状态
      * @author zouxuan
      */
-    int batchUpdateLockByClassGroupIds(@Param("classGroupIds") List<Integer> classGroupIds,
+    int batchUpdateLockByClassGroupIds(@Param("courseId") List<Long> courseId,
                               @Param("isLock") Integer isLock);
 
 
@@ -1642,4 +1642,14 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @return
      */
     List<Map<String, Integer>> findClassMaxCourseNumMap(@Param("classGroupIds") List<Integer> classGroupIds);
+
+    /**
+     * 根据学员和班级列表获取未开始的课程列表
+     * @author zouxuan
+     * @param classGroupIds
+     * @param studentIds
+     * @return
+     */
+    List<Long> queryStudentNotStartByClassIdsAndStudentIds(@Param("classGroupIds") List<Integer> classGroupIds,
+                                                           @Param("studentIds") List<Integer> studentIds);
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupStudentClassAdjustDao.java

@@ -0,0 +1,10 @@
+package com.ym.mec.biz.dal.dao;
+
+
+import com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface MusicGroupStudentClassAdjustDao extends BaseDAO<Integer, MusicGroupStudentClassAdjust> {
+
+	
+}

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

@@ -10,6 +10,16 @@ public class MergeClassSplitClassAffirmDto {
 
     private List<Integer> classGroupIds;
 
+    private List<Integer> studentIds;
+
+    public List<Integer> getStudentIds() {
+        return studentIds;
+    }
+
+    public void setStudentIds(List<Integer> studentIds) {
+        this.studentIds = studentIds;
+    }
+
     public List<Integer> getClassGroupIds() {
         return classGroupIds;
     }

+ 162 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupStudentClassAdjust.java

@@ -0,0 +1,162 @@
+package com.ym.mec.biz.dal.entity;
+
+import com.ym.mec.biz.dal.dto.ClassGroup4MixDto;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 乐团学员班级调整表
+ * 对应数据库表(music_group_student_class_adjust):
+ */
+public class MusicGroupStudentClassAdjust {
+
+	private Integer id;
+
+	private String musicGroupId;
+
+	@ApiModelProperty(value = "缴费项目批次号", required = false)
+	private String batchNo;
+
+	@ApiModelProperty(value = "班级明细", required = false)
+	private String newClassGroupJson;
+
+	@ApiModelProperty(value = "所选班级列表", required = false)
+	private String classGroupIds;
+
+	@ApiModelProperty(value = "所选学员列表", required = false)
+	private String studentIds;
+
+	@ApiModelProperty(value = "班级可排课时长", required = false)
+	private String classCourseMinute;
+
+	@ApiModelProperty(value = "所有冻结的课程列表", required = false)
+	private String allLockCourseIds;
+
+	@ApiModelProperty(value = "所选学员冻结的课程列表", required = false)
+	private String subLockCourseIds;
+
+	@ApiModelProperty(value = "是否排课", required = false)
+	private boolean courseFlag;
+
+	@ApiModelProperty(value = "缴费项目审核状态", required = false)
+	private MusicGroupPaymentCalender.PaymentCalenderStatusEnum calenderStatus;
+
+	private Integer operatorId;
+
+	private Date createTime;
+
+	private Date updateTime;
+
+	public Integer getId() {
+		return id;
+	}
+
+	public void setId(Integer id) {
+		this.id = id;
+	}
+
+	public String getMusicGroupId() {
+		return musicGroupId;
+	}
+
+	public void setMusicGroupId(String musicGroupId) {
+		this.musicGroupId = musicGroupId;
+	}
+
+	public String getBatchNo() {
+		return batchNo;
+	}
+
+	public void setBatchNo(String batchNo) {
+		this.batchNo = batchNo;
+	}
+
+	public String getClassGroupIds() {
+		return classGroupIds;
+	}
+
+	public void setClassGroupIds(String classGroupIds) {
+		this.classGroupIds = classGroupIds;
+	}
+
+	public String getStudentIds() {
+		return studentIds;
+	}
+
+	public void setStudentIds(String studentIds) {
+		this.studentIds = studentIds;
+	}
+
+	public String getClassCourseMinute() {
+		return classCourseMinute;
+	}
+
+	public void setClassCourseMinute(String classCourseMinute) {
+		this.classCourseMinute = classCourseMinute;
+	}
+
+	public String getAllLockCourseIds() {
+		return allLockCourseIds;
+	}
+
+	public void setAllLockCourseIds(String allLockCourseIds) {
+		this.allLockCourseIds = allLockCourseIds;
+	}
+
+	public String getSubLockCourseIds() {
+		return subLockCourseIds;
+	}
+
+	public void setSubLockCourseIds(String subLockCourseIds) {
+		this.subLockCourseIds = subLockCourseIds;
+	}
+
+	public boolean isCourseFlag() {
+		return courseFlag;
+	}
+
+	public void setCourseFlag(boolean courseFlag) {
+		this.courseFlag = courseFlag;
+	}
+
+	public String getNewClassGroupJson() {
+		return newClassGroupJson;
+	}
+
+	public void setNewClassGroupJson(String newClassGroupJson) {
+		this.newClassGroupJson = newClassGroupJson;
+	}
+
+	public MusicGroupPaymentCalender.PaymentCalenderStatusEnum getCalenderStatus() {
+		return calenderStatus;
+	}
+
+	public void setCalenderStatus(MusicGroupPaymentCalender.PaymentCalenderStatusEnum calenderStatus) {
+		this.calenderStatus = calenderStatus;
+	}
+
+	public Integer getOperatorId() {
+		return operatorId;
+	}
+
+	public void setOperatorId(Integer operatorId) {
+		this.operatorId = operatorId;
+	}
+
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+}

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

@@ -475,9 +475,18 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
 
     /**
      * 进行中乐团-修改-班级详情-学员班级调整-合并结果确认
+     * 保存新增班级的基本信息,冻结所选班级的课程,生成同一批次的缴费项目,保存调整详情
      * @author zouxuan
      * @param mergeClassSplitClassAffirmDto
      * @return
      */
-    Object mergeClassSplitClassAffirm(MergeClassSplitClassAffirmDto mergeClassSplitClassAffirmDto);
+    void mergeClassSplitClassAffirm(MergeClassSplitClassAffirmDto mergeClassSplitClassAffirmDto);
+
+    /**
+     * 进行中乐团-修改-班级详情-学员班级调整-合并结果确认-获取新班级的可排课时长
+     * @author zouxuan
+     * @param classGroupIds
+     * @return
+     */
+    Map<String,Long> findClassCourseMinuteMap(List<Integer> classGroupIds);
 }

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupStudentClassAdjustService.java

@@ -0,0 +1,9 @@
+package com.ym.mec.biz.service;
+
+
+import com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust;
+import com.ym.mec.common.service.BaseService;
+
+public interface MusicGroupStudentClassAdjustService extends BaseService<Integer, MusicGroupStudentClassAdjust> {
+
+}

+ 114 - 15
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -26,11 +26,11 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
 
-import com.alibaba.fastjson.JSONArray;
 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.service.*;
+import com.ym.mec.common.service.IdGeneratorService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -162,6 +162,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
     @Autowired
     private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
+    @Autowired
+    private IdGeneratorService idGeneratorService;
+    @Autowired
+    private MusicGroupStudentClassAdjustDao musicGroupStudentClassAdjustDao;
 
     @Override
     public BaseDAO<Integer, ClassGroup> getDAO() {
@@ -3277,17 +3281,30 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public Object mergeClassSplitClassAffirm(MergeClassSplitClassAffirmDto mergeClassSplitClassAffirmDto) {
+    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
+    public void mergeClassSplitClassAffirm(MergeClassSplitClassAffirmDto mergeClassSplitClassAffirmDto) {
         List<Integer> classGroupIds = mergeClassSplitClassAffirmDto.getClassGroupIds();
         if(classGroupIds == null || classGroupIds.size() == 0){
             throw new BizException("参数校验失败");
         }
+        //班级信息
+        List<ClassGroup4MixDto> classGroup4MixDtos = mergeClassSplitClassAffirmDto.getClassGroup4MixDtos();
+        if(CollectionUtils.isEmpty(classGroup4MixDtos)){
+            throw new BizException("请填写班级信息");
+        }
+        List<Integer> studentIds = mergeClassSplitClassAffirmDto.getStudentIds();
+        if(CollectionUtils.isEmpty(studentIds)){
+            throw new BizException("学员列表不可为空");
+        }
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+
         MusicGroup musicGroup = musicGroupDao.findByClassGroupId(classGroupIds.get(0));
-        //生成缴费记录
-        List<MusicGroupPaymentCalenderDto> paymentCalenderDtos = mergeClassSplitClassAffirmDto.getMusicGroupPaymentCalenderDtos();
+        //生成缴费记录,同一个批次
+        MusicGroupPaymentCalender.PaymentCalenderStatusEnum status = null;
+        String batchNo = null;
+                List<MusicGroupPaymentCalenderDto> paymentCalenderDtos = mergeClassSplitClassAffirmDto.getMusicGroupPaymentCalenderDtos();
         if(paymentCalenderDtos != null && paymentCalenderDtos.size() > 0){
-            MusicGroupPaymentCalender.PaymentCalenderStatusEnum status = null;
+            batchNo = idGeneratorService.generatorId() + "";
             for (MusicGroupPaymentCalenderDto calenderDto : paymentCalenderDtos) {
                 if(status != null && status != AUDITING){
                     List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = calenderDto.getMusicGroupPaymentCalenderCourseSettingsList();
@@ -3306,22 +3323,104 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                     }
                 }
             }
+            //创建缴费项目
             for (MusicGroupPaymentCalenderDto calenderDto : paymentCalenderDtos) {
                 if(status != null && status == AUDITING){
                     calenderDto.setStatus(AUDITING);
                 }
+                //指定批次
+                calenderDto.setBatchNo(batchNo);
                 musicGroupPaymentCalenderService.create(calenderDto);
             }
         }
-        //新增班级
-        List<ClassGroup4MixDto> classGroup4MixDtos = mergeClassSplitClassAffirmDto.getClassGroup4MixDtos();
-        if(CollectionUtils.isEmpty(classGroup4MixDtos)){
-            throw new BizException("请填写班级信息");
-        }
-        classGroupService.classGroupAdjust(classGroup4MixDtos);
         //冻结所选班级的课程
-        courseScheduleDao.batchUpdateLockByClassGroupIds(classGroupIds,1);
-        //保存学员应该增加的课程时长
-        return null;
+        List<Long> allLockCourseIds = courseScheduleDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds,null);
+        courseScheduleDao.batchUpdateLockByClassGroupIds(allLockCourseIds,1);
+
+        //记录申请信息
+        MusicGroupStudentClassAdjust musicGroupStudentClassAdjust = new MusicGroupStudentClassAdjust();
+        musicGroupStudentClassAdjust.setBatchNo(batchNo);
+        musicGroupStudentClassAdjust.setBatchNo(batchNo);
+        musicGroupStudentClassAdjust.setCalenderStatus(status);
+        musicGroupStudentClassAdjust.setCourseFlag(false);
+        musicGroupStudentClassAdjust.setMusicGroupId(musicGroup.getId());
+        musicGroupStudentClassAdjust.setOperatorId(sysUser.getId());
+        musicGroupStudentClassAdjust.setNewClassGroupJson(JSON.toJSONString(classGroup4MixDtos));
+        musicGroupStudentClassAdjust.setClassGroupIds(JSON.toJSONString(classGroupIds));
+        musicGroupStudentClassAdjust.setStudentIds(JSON.toJSONString(studentIds));
+        musicGroupStudentClassAdjust.setAllLockCourseIds(JSON.toJSONString(allLockCourseIds));
+        List<Long> courseIds = courseScheduleDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds,studentIds);
+        musicGroupStudentClassAdjust.setSubLockCourseIds(JSON.toJSONString(courseIds));
+        //计算新增班级的可排课时长,总课次*默认时长  (用学员剩余的课程时长加上购买的时长,可能导致同一班级学员时长不一致)
+        musicGroupStudentClassAdjust.setClassCourseMinute(JSON.toJSONString(findClassCourseMinuteMap(classGroupIds)));
+        musicGroupStudentClassAdjustDao.insert(musicGroupStudentClassAdjust);
+
+        //如果缴费项目不需要审核,那么生成班级以及课表
+        if(status != null && status != AUDITING){
+//            classGroupService.classGroupAdjust(classGroup4MixDtos);
+        }
+        //如果需要审核,校验参数配置
+        checkMergeClassSplitClassAffirmParam(classGroup4MixDtos);
+    }
+
+    private void checkMergeClassSplitClassAffirmParam(List<ClassGroup4MixDto> classGroup4MixDtos){
+        if (classGroup4MixDtos.get(0).getCourseTimes().compareTo(0) <= 0) {
+            throw new BizException("排课次数必须大于0");
+        }
+        List<ClassGroupTeacherMapper> classGroupTeacherMapperList = classGroup4MixDtos.get(0).getClassGroupTeacherMapperList();
+        if(classGroupTeacherMapperList == null || classGroupTeacherMapperList.size() == 0){
+            throw new BizException("请设置上课老师");
+        }
+        Set<Integer> noRepeatTeacherIds = classGroupTeacherMapperList.stream().map(ClassGroupTeacherMapper::getUserId).collect(Collectors.toSet());
+        if(noRepeatTeacherIds.size()!=classGroupTeacherMapperList.size()){
+            throw new BizException("主教与助教存在冲突");
+        }
+        List<Integer> allTeacherIds = classGroupTeacherMapperList.stream()
+                .map(ClassGroupTeacherMapper::getUserId)
+                .collect(Collectors.toList());
+
+        //所有教师列表
+        List<Teacher> teachers = teacherDao.findByTeacherIds(allTeacherIds);
+        Map<Integer, Teacher> teacherMap = teachers.stream()
+                .collect(Collectors.toMap(Teacher::getId, teacher -> teacher));
+        for (ClassGroup4MixDto classGroup4MixDto : classGroup4MixDtos) {
+            for (ClassGroupTeacherMapper classGroupTeacherMapper : classGroupTeacherMapperList) {
+                List<TeacherDefaultMusicGroupSalary> teacherSalaryList = teacherDefaultMusicGroupSalaryService.getTeacherSalaryByUserIdAndType(classGroupTeacherMapper.getUserId(), null, null);
+
+                Map<CourseSchedule.CourseScheduleType, TeacherDefaultMusicGroupSalary> collect = teacherSalaryList.stream().collect(Collectors.toMap(TeacherDefaultMusicGroupSalary::getCourseScheduleType, teacherDefaultMusicGroupSalary -> teacherDefaultMusicGroupSalary));
+
+                TeacherDefaultMusicGroupSalary teacherDefaultMusicGroupSalary = collect.get(classGroup4MixDto.getCourseType());
+                Teacher teacher = teacherMap.get(classGroupTeacherMapper.getUserId());
+                if (teacherDefaultMusicGroupSalary == null) {
+                    throw new BizException("请设置" + teacher.getRealName() + "老师的" + classGroup4MixDto.getCourseType().getMsg() + "课酬");
+                }
+                if ((classGroup4MixDto.getCourseType().equals(CourseSchedule.CourseScheduleType.HIGH_ONLINE) ||
+                        classGroup4MixDto.getCourseType().equals(CourseSchedule.CourseScheduleType.MUSIC_NETWORK)) &&
+                        StringUtils.isBlank(teacherDefaultMusicGroupSalary.getSalaryRuleJson())) {
+                    throw new BizException("请设置" + teacher.getRealName() + "老师的" + classGroup4MixDto.getCourseType().getMsg() + "课酬");
+                } else if (teacherDefaultMusicGroupSalary.getAssistantTeacher30MinSalary() == null
+                        || teacherDefaultMusicGroupSalary.getAssistantTeacher90MinSalary() == null
+                        || teacherDefaultMusicGroupSalary.getMainTeacher30MinSalary() == null
+                        || teacherDefaultMusicGroupSalary.getMainTeacher90MinSalary() == null) {
+                    throw new BizException("请设置" + teacher.getRealName() + "老师的" + classGroup4MixDto.getCourseType().getMsg() + "课酬");
+                }
+            }
+        }
+    }
+
+    @Override
+    public Map<String,Long> findClassCourseMinuteMap(List<Integer> classGroupIds){
+        Map<String,Long> resultMap = new HashMap<>();
+        //获取默认的排课时长
+        String courseDefaultMinutes = sysConfigDao.findConfigValue("music_course_default_minutes");
+        JSONObject jsonObject = JSON.parseObject(courseDefaultMinutes);
+        //获取所选班级最大剩余课时
+        Map<String,Long> map = MapUtil.convertIntegerMap(courseScheduleDao.findClassMaxCourseNumMap(classGroupIds));
+        Set<String> courseTypes = map.keySet();
+        for (String courseType : courseTypes) {
+            //剩余时长*默认排课时长
+            resultMap.put(courseType,Integer.parseInt(jsonObject.get(courseType).toString()) * map.get(courseType));
+        }
+        return resultMap;
     }
 }

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

@@ -164,7 +164,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		// 所有缴费项目已完成排课才能创建下一个缴费项目
 		String orignBatchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, null, null);
 		if (StringUtils.isNoneBlank(orignBatchNo)) {
-			throw new BizException("当前乐团存在未排课的缴费项目,请先完成排课再操作");
+			if(StringUtils.isEmpty(musicGroupPaymentCalenderDto.getBatchNo()) || !musicGroupPaymentCalenderDto.getBatchNo().equals(orignBatchNo)){
+				throw new BizException("当前乐团存在未排课的缴费项目,请先完成排课再操作");
+			}
 		}
 
 		// 不是进行中,只能创建一次缴费
@@ -178,7 +180,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		PaymentCalenderStatusEnum status = PaymentCalenderStatusEnum.NO;
 
 		Date date = new Date();
-		String batchNo = idGeneratorService.generatorId() + "";
+		String batchNo;
+		if(StringUtils.isEmpty(musicGroupPaymentCalenderDto.getBatchNo())){
+			batchNo = idGeneratorService.generatorId() + "";
+		}else {
+			batchNo = musicGroupPaymentCalenderDto.getBatchNo();
+		}
 
 		// 获取设置的课程
 		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderDto
@@ -264,7 +271,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 			BigDecimal totalPaymentAmount = new BigDecimal(0);
 			for (MusicGroupPaymentCalenderCourseSettings pccs : musicGroupPaymentCalenderCourseSettingsList) {
-
+				
 				MusicGroupPaymentCalenderCourseSettings tempPccs = new MusicGroupPaymentCalenderCourseSettings();
 				try {
 					BeanUtils.copyProperties(tempPccs, pccs);
@@ -272,21 +279,30 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 					throw new BizException("克隆对象出错", e);
 				}
 				if (i == 0) {
-					tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().subtract(
-							pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
-									.setScale(2, BigDecimal.ROUND_DOWN)));
-					tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().subtract(
-							pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
-									.setScale(2, BigDecimal.ROUND_DOWN)));
-					tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() - pccs.getCourseTotalMinuties() / times * (times - 1));
+					if (pccs.getIsStudentOptional()) {
+						tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice());
+						tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice());
+						tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties());
+					} else {
+						tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().subtract(
+								pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
+										.setScale(2, BigDecimal.ROUND_DOWN)));
+						tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().subtract(
+								pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
+										.setScale(2, BigDecimal.ROUND_DOWN)));
+						tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() - pccs.getCourseTotalMinuties() / times * (times - 1));
+					}
 				} else {
-					tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN));
-					tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN));
-					tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() / times);
+					if (!pccs.getIsStudentOptional()) {
+						tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN));
+						tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN));
+						tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() / times);
+					}
 				}
 				totalPaymentAmount = totalPaymentAmount.add(tempPccs.getCourseCurrentPrice());
 				newCSList.add(tempPccs);
 			}
+			
 			musicGroupPaymentCalender.setMusicGroupPaymentCalenderCourseSettingsList(newCSList);
 			musicGroupPaymentCalender.setPaymentAmount(totalPaymentAmount);
 
@@ -554,17 +570,25 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 					throw new BizException("克隆对象出错", e);
 				}
 				if (i == 0) {
-					tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().subtract(
-							pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
-									.setScale(2, BigDecimal.ROUND_DOWN)));
-					tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().subtract(
-							pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
-									.setScale(2, BigDecimal.ROUND_DOWN)));
-					tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() - pccs.getCourseTotalMinuties() / times * (times - 1));
+					if (pccs.getIsStudentOptional()) {
+						tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice());
+						tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice());
+						tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties());
+					} else {
+						tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().subtract(
+								pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
+										.setScale(2, BigDecimal.ROUND_DOWN)));
+						tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().subtract(
+								pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
+										.setScale(2, BigDecimal.ROUND_DOWN)));
+						tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() - pccs.getCourseTotalMinuties() / times * (times - 1));
+					}
 				} else {
-					tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN));
-					tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN));
-					tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() / times);
+					if (!pccs.getIsStudentOptional()) {
+						tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN));
+						tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 2, BigDecimal.ROUND_DOWN));
+						tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() / times);
+					}
 				}
 				totalPaymentAmount = totalPaymentAmount.add(tempPccs.getCourseCurrentPrice());
 				newCSList.add(tempPccs);

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupStudentClassAdjustServiceImpl.java

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.service.impl;
+
+
+import com.ym.mec.biz.dal.dao.MusicGroupStudentClassAdjustDao;
+import com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust;
+import com.ym.mec.biz.service.MusicGroupStudentClassAdjustService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class MusicGroupStudentClassAdjustServiceImpl extends BaseServiceImpl<Integer, MusicGroupStudentClassAdjust> implements MusicGroupStudentClassAdjustService {
+	
+	@Autowired
+	private MusicGroupStudentClassAdjustDao musicGroupStudentClassAdjustDao;
+
+	@Override
+	public BaseDAO<Integer, MusicGroupStudentClassAdjust> getDAO() {
+		return musicGroupStudentClassAdjustDao;
+	}
+	
+}

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

@@ -2,7 +2,16 @@ package com.ym.mec.biz.service.impl;
 
 import java.io.IOException;
 import java.math.BigDecimal;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 import javax.annotation.Resource;
@@ -12,18 +21,88 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 
 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.enums.*;
+import com.ym.mec.biz.dal.dao.GoodsDao;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
+import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
+import com.ym.mec.biz.dal.dao.MusicGroupSubjectPlanDao;
+import com.ym.mec.biz.dal.dao.StudentCourseFeeDetailDao;
+import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
+import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
+import com.ym.mec.biz.dal.dao.SubjectChangeDao;
+import com.ym.mec.biz.dal.dao.SubjectDao;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
+import com.ym.mec.biz.dal.dao.TeacherDao;
+import com.ym.mec.biz.dal.dto.CourseFormDto;
+import com.ym.mec.biz.dal.dto.StudentAddDto;
+import com.ym.mec.biz.dal.dto.StudentApplyDetailDto;
+import com.ym.mec.biz.dal.dto.StudentFeeDetailDto;
+import com.ym.mec.biz.dal.dto.StudentInfo;
+import com.ym.mec.biz.dal.dto.StudentMusicDetailDto;
+import com.ym.mec.biz.dal.entity.ClassGroup;
+import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
+import com.ym.mec.biz.dal.entity.CooperationOrgan;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
+import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
+import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
+import com.ym.mec.biz.dal.entity.Student;
+import com.ym.mec.biz.dal.entity.StudentCourseFeeDetail;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
+import com.ym.mec.biz.dal.entity.StudentRegistration;
+import com.ym.mec.biz.dal.entity.Subject;
+import com.ym.mec.biz.dal.entity.SubjectChange;
+import com.ym.mec.biz.dal.entity.SysUserCashAccount;
+import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
+import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.GoodsType;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
+import com.ym.mec.biz.dal.enums.MessageTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
+import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
 import com.ym.mec.biz.dal.page.StudentRegistrationQueryInfo;
-import com.ym.mec.biz.service.*;
+import com.ym.mec.biz.service.ClassGroupService;
+import com.ym.mec.biz.service.ClassGroupStudentMapperService;
+import com.ym.mec.biz.service.ContractService;
+import com.ym.mec.biz.service.CourseScheduleService;
+import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
+import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
+import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
+import com.ym.mec.biz.service.SellOrderService;
+import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
+import com.ym.mec.biz.service.StudentPaymentOrderService;
+import com.ym.mec.biz.service.StudentRegistrationService;
+import com.ym.mec.biz.service.SubjectService;
+import com.ym.mec.biz.service.SysConfigService;
+import com.ym.mec.biz.service.SysMessageService;
+import com.ym.mec.biz.service.SysUserCashAccountDetailService;
+import com.ym.mec.biz.service.SysUserCashAccountService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.ImGroupMember;
 import com.ym.mec.common.entity.ImGroupModel;
@@ -31,15 +110,11 @@ import com.ym.mec.common.entity.ImResult;
 import com.ym.mec.common.entity.ImUserModel;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
-import com.ym.mec.common.redis.service.RedisCache;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.im.ImFeignService;
-import com.ym.mec.thirdparty.eseal.ESealPlugin;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
-import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.http.HttpUtil;
-import org.springframework.transaction.annotation.Isolation;
 
 @Service
 public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, StudentRegistration> implements StudentRegistrationService {
@@ -863,15 +938,26 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
 
         if (studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)) {
-            MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
+            MusicGroup musicGroup = musicGroupDao.getLocked(studentRegistration.getMusicGroupId());
 
             if (studentRegistration.getTemporaryCourseFee() != null) {
                 studentRegistration.setTemporaryCourseFee(new BigDecimal(0));
             }
             studentRegistration.setPaymentStatus(PaymentStatusEnum.YES);
             studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
+            //累加充值金额
+            studentRegistration.setSurplusCourseFee(studentRegistration.getSurplusCourseFee().add(studentPaymentOrder.getExpectAmount()));
             studentRegistrationDao.update(studentRegistration);
 
+            //添加日志
+            StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
+            studentCourseFeeDetail.setStudentRegistrationId(studentRegistration.getId());
+            studentCourseFeeDetail.setAmount(studentPaymentOrder.getExpectAmount());
+            studentCourseFeeDetail.setSurplusCourseFee(studentRegistration.getSurplusCourseFee());
+            studentCourseFeeDetail.setMemo("充值");
+            studentCourseFeeDetail.setOperator(studentPaymentOrder.getUserId());
+            studentCourseFeeDetailDao.insert(studentCourseFeeDetail);
+
             //当前乐团报名是否赠送乐团网管课
 
             MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(studentRegistration.getUserId(), studentRegistration.getMusicGroupId());
@@ -1003,59 +1089,99 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         musicGroupStudentFee.setIsLock(0);
         musicGroupStudentFee.setMusicGroupId(studentRegistration.getMusicGroupId());
         musicGroupStudentFee.setUserId(studentRegistration.getUserId());
+        
+        String currentMusicGroupId = studentRegistration.getMusicGroupId();
 
         //缴费详情 calender detail
-        MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderService.findByMusicGroupRegCalender(studentRegistration.getMusicGroupId());
+        MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderService.findByMusicGroupRegCalender(currentMusicGroupId);
+        
+        String batchNo = musicGroupRegCalender.getBatchNo();
+        Long currentPaymentCalenderId = musicGroupRegCalender.getId();
+
+        List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.findByBatchNo(batchNo);
+        
         if (musicGroupRegCalender.getIsGiveMusicNetwork() != null && musicGroupRegCalender.getIsGiveMusicNetwork()) {
             //赠送网管课
-            musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + 1);
+            musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + musicGroupPaymentCalenderList.size());
         }
         musicGroupStudentFeeDao.insert(musicGroupStudentFee);
-        //更新实际缴费人数
-        int actualNum = musicGroupRegCalender.getActualNum() == null ? 0 : musicGroupRegCalender.getActualNum();
-        musicGroupRegCalender.setExpectNum(actualNum + 1);
-        musicGroupRegCalender.setActualNum(actualNum + 1);
-        musicGroupRegCalender.setUpdateTime(nowDate);
-        musicGroupPaymentCalenderDao.update(musicGroupRegCalender);
+        
+		for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenderList) {
+			if (currentPaymentCalenderId.longValue() == musicGroupPaymentCalender.getId()) {
+				// 更新实际缴费人数
+				if (musicGroupPaymentCalender.getActualNum() == null) {
+					musicGroupPaymentCalender.setActualNum(1);
+				} else {
+					musicGroupPaymentCalender.setActualNum(musicGroupPaymentCalender.getActualNum() + 1);
+				}
+			}
+			if (musicGroupPaymentCalender.getExpectNum() == null) {
+				musicGroupPaymentCalender.setExpectNum(1);
+			} else {
+				musicGroupPaymentCalender.setExpectNum(musicGroupPaymentCalender.getExpectNum() + 1);
+			}
+			musicGroupPaymentCalender.setUpdateTime(nowDate);
+		}
+        if(musicGroupPaymentCalenderList.size() > 0){
+        	musicGroupPaymentCalenderDao.batchUpdate(musicGroupPaymentCalenderList);
+        }
 
         List<String> orderDetailTypes = studentPaymentOrderDetailDao.getOrderDetailType(studentPaymentOrder.getId());
         List<MusicGroupPaymentCalenderCourseSettings> courseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupRegCalender.getId());
         BigDecimal courseTotalPrice = courseSettings.stream().filter(e -> orderDetailTypes.contains(e.getCourseType().getCode())).map(MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
 
-        MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
-        musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupRegCalender.getId());
-        musicGroupPaymentCalenderDetail.setUserId(studentPaymentOrder.getUserId());
-        musicGroupPaymentCalenderDetail.setExpectAmount(courseTotalPrice);
-        musicGroupPaymentCalenderDetail.setActualAmount(courseTotalPrice);
-        musicGroupPaymentCalenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
-        musicGroupPaymentCalenderDetail.setUserStatus(null);
-        musicGroupPaymentCalenderDetail.setPayTime(nowDate);
-        musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupRegCalender.getDeadlinePaymentDate());
-        musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupRegCalender.getStartPaymentDate());
-        musicGroupPaymentCalenderDetail.setOpen(1);
-        musicGroupPaymentCalenderDetail.setCreateTime(nowDate);
-        musicGroupPaymentCalenderDetail.setUpdateTime(nowDate);
-        musicGroupPaymentCalenderDetail.setPaymentOrderId(studentPaymentOrder.getId());
-        musicGroupPaymentCalenderDetail.setUseInCourse(0);
-        musicGroupPaymentCalenderDetailDao.insert(musicGroupPaymentCalenderDetail);
-
+        List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
         List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = new ArrayList<>();
-
-        for (MusicGroupPaymentCalenderCourseSettings courseSetting : courseSettings) {
-            if (musicGroupRegCalender.getPayUserType().equals(MusicGroupPaymentCalender.PayUserType.STUDENT) && !orderDetailTypes.contains(courseSetting.getCourseType().getCode()))
-                continue;
-            MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
-            musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupRegCalender.getId());
-            musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
-            musicGroupPaymentStudentCourseDetail.setUserId(studentPaymentOrder.getUserId());
-            musicGroupPaymentStudentCourseDetail.setCourseType(courseSetting.getCourseType());
-            musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSetting.getCourseTotalMinuties());
-            musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
-            musicGroupPaymentStudentCourseDetail.setCreateTime(nowDate);
-            musicGroupPaymentStudentCourseDetail.setUpdateTime(nowDate);
-            musicGroupPaymentStudentCourseDetails.add(musicGroupPaymentStudentCourseDetail);
+        
+		for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenderList) {
+			MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
+			musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+			musicGroupPaymentCalenderDetail.setUserId(studentPaymentOrder.getUserId());
+
+			if (currentPaymentCalenderId.longValue() == musicGroupPaymentCalender.getId()) {
+				musicGroupPaymentCalenderDetail.setExpectAmount(courseTotalPrice);
+				musicGroupPaymentCalenderDetail.setActualAmount(courseTotalPrice);
+				musicGroupPaymentCalenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
+				musicGroupPaymentCalenderDetail.setPayTime(nowDate);
+				musicGroupPaymentCalenderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+				musicGroupPaymentCalenderDetail.setUseInCourse(0);
+				musicGroupPaymentCalenderDetail.setOpen(1);
+			} else {
+				musicGroupPaymentCalenderDetail.setExpectAmount(musicGroupPaymentCalender.getPaymentAmount());
+				musicGroupPaymentCalenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.NON_PAYMENT);
+			}
+			musicGroupPaymentCalenderDetail.setUserStatus(null);
+			musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
+			musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupPaymentCalender.getStartPaymentDate());
+			musicGroupPaymentCalenderDetail.setCreateTime(nowDate);
+			musicGroupPaymentCalenderDetail.setUpdateTime(nowDate);
+
+			musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
+
+			List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao
+					.getWithPaymentCalender(musicGroupPaymentCalender.getId());
+			for (MusicGroupPaymentCalenderCourseSettings courseSetting : courseSettingsList) {
+				if (musicGroupRegCalender.getPayUserType().equals(MusicGroupPaymentCalender.PayUserType.STUDENT)
+						&& !orderDetailTypes.contains(courseSetting.getCourseType().getCode()))
+					continue;
+				MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupRegCalender.getId());
+				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
+				musicGroupPaymentStudentCourseDetail.setUserId(studentPaymentOrder.getUserId());
+				musicGroupPaymentStudentCourseDetail.setCourseType(courseSetting.getCourseType());
+				musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSetting.getCourseTotalMinuties());
+				musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
+				musicGroupPaymentStudentCourseDetail.setCreateTime(nowDate);
+				musicGroupPaymentStudentCourseDetail.setUpdateTime(nowDate);
+
+				musicGroupPaymentStudentCourseDetails.add(musicGroupPaymentStudentCourseDetail);
+			}
+		}
+        
+
+        if(musicGroupPaymentCalenderDetailList.size()> 0){
+        	musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
         }
-
         if (musicGroupPaymentStudentCourseDetails.size() > 0) {
             musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetails);
         }

+ 17 - 3
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -1313,11 +1313,10 @@
     <update id="batchUpdateLockByClassGroupIds">
         UPDATE course_schedule
         SET is_lock_ = #{isLock}, update_time_ = NOW()
-        WHERE class_group_id_ IN
-        <foreach collection="classGroupIds" open="(" close=")" item="item" separator=",">
+        WHERE id_ IN
+        <foreach collection="courseId" open="(" close=")" item="item" separator=",">
             #{item}
         </foreach>
-        AND NOW() &lt; CONCAT(class_date_, " ", start_class_time_)
     </update>
 
     <select id="queryNoSignInListByBeforeMinutes" resultMap="CourseSchedule">
@@ -3376,6 +3375,21 @@
         GROUP BY cs.class_group_id_,cs.type_)c
         GROUP BY c.type_
     </select>
+    <select id="queryStudentNotStartByClassIdsAndStudentIds" resultType="Long">
+        SELECT course_schedule_id_ FROM course_schedule_student_payment cssp
+        WHERE cssp.class_group_id_ IN
+        <foreach collection="classGroupIds" open="(" close=")" separator="," item="item">
+            #{item}
+        </foreach>
+        <if test="studentIds != null">
+            AND cssp.user_id_ IN
+            <foreach collection="studentIds" open="(" close=")" separator="," item="item">
+                #{item}
+            </foreach>
+        </if>
+        AND CONCAT(cs.class_date_," ",cs.start_class_time_) > NOW()
+        GROUP BY cssp.course_schedule_id_
+    </select>
     <select id="getLock" resultMap="CourseSchedule">
         SELECT * FROM course_schedule WHERE id_ = #{courseId} FOR UPDATE
     </select>

+ 1 - 6
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -166,12 +166,7 @@
 		</where>
 	</update>
 	<update id="adjustExamSong">
-		UPDATE course_schedule_student_payment
-		<set>
-			<if test="examSongJson != null">
-				exam_song_download_json_ = #{examSongJson}
-			</if>
-		</set>
+		UPDATE course_schedule_student_payment SET exam_song_download_json_ = #{examSongJson}
 		WHERE course_schedule_id_ = #{roomId}
 		<if test="userId != null">
 			AND user_id_ = #{userId}

+ 2 - 1
mec-biz/src/main/resources/config/mybatis/MusicGroupQuitMapper.xml

@@ -37,7 +37,8 @@
             AS ID FROM DUAL </selectKey> -->
         INSERT INTO music_group_quit
         (id_,user_id_,music_group_id_,join_date_,quit_date_,create_time_,reason_,status_)
-        VALUES(#{id},#{userId},#{musicGroupId},#{joinDate},#{quitDate},#{createTime},#{reason},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
+        VALUES(#{id},#{userId},#{musicGroupId},#{joinDate},#{quitDate},#{createTime},#{reason},
+        #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
     </insert>
 
     <!-- 根据主键查询一条记录 -->

+ 97 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupStudentClassAdjustMapper.xml

@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--
+这个文件是自动生成的。
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
+-->
+<mapper namespace="com.ym.mec.biz.dal.dao.MusicGroupStudentClassAdjustDao">
+	
+	<resultMap type="com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust" id="MusicGroupStudentClassAdjust">
+		<result column="id_" property="id" />
+		<result column="music_group_id_" property="musicGroupId" />
+		<result column="batch_no_" property="batchNo" />
+		<result column="new_class_group_json_" property="newClassGroupJson" />
+		<result column="class_group_ids_" property="classGroupIds" />
+		<result column="student_ids_" property="studentIds" />
+		<result column="class_course_minute_" property="classCourseMinute" />
+		<result column="all_lock_course_ids_" property="allLockCourseIds" />
+		<result column="sub_lock_course_ids_" property="subLockCourseIds" />
+		<result column="course_flag_" property="courseFlag" />
+		<result column="calender_status_" property="calenderStatus" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+		<result column="operator_id_" property="operatorId" />
+		<result column="create_time_" property="createTime" />
+		<result column="update_time_" property="updateTime" />
+	</resultMap>
+	
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="MusicGroupStudentClassAdjust" >
+		SELECT * FROM music_group_student_class_adjust WHERE id_ = #{id} 
+	</select>
+	
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="MusicGroupStudentClassAdjust">
+		SELECT * FROM music_group_student_class_adjust ORDER BY id_
+	</select>
+	
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		INSERT INTO music_group_student_class_adjust (id_,music_group_id_,batch_no_,new_class_group_json_,
+		class_group_ids_,student_ids_,class_course_minute_,all_lock_course_ids_,sub_lock_course_ids_,
+		course_flag_,calender_status_,operator_id_,create_time_,update_time_)
+		VALUES(#{id},#{musicGroupId},#{batchNo},#{newClassGroupJson},#{classGroupIds},#{studentIds},
+		#{classCourseMinute},#{allLockCourseIds},#{subLockCourseIds},#{courseFlag},
+		#{calenderStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{operatorId},NOW(),NOW())
+	</insert>
+	
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust">
+		UPDATE music_group_student_class_adjust <set>
+		<if test="courseFlag != null">
+		course_flag_ = #{courseFlag},
+		</if>
+		<if test="calenderStatus != null">
+		calender_status_ = #{calenderStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+		</if>
+		<if test="allLockCourseIds != null">
+		all_lock_course_ids_ = #{allLockCourseIds},
+		</if>
+		<if test="subLockCourseIds != null">
+		sub_lock_course_ids_ = #{subLockCourseIds},
+		</if>
+		<if test="classCourseMinute != null">
+		class_course_minute_ = #{classCourseMinute},
+		</if>
+		<if test="newClassGroupJson != null">
+		new_class_group_json_ = #{newClassGroupJson},
+		</if>
+		<if test="batchNo != null">
+		batch_no_ = #{batchNo},
+		</if>
+		<if test="studentIds != null">
+		student_ids_ = #{studentIds},
+		</if>
+		<if test="classGroupIds != null">
+		class_group_ids_ = #{classGroupIds},
+		</if>
+		<if test="musicGroupId != null">
+		music_group_id_ = #{musicGroupId},
+		</if>
+		update_time_ = NOW()
+		</set> WHERE id_ = #{id}
+	</update>
+	
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete" >
+		DELETE FROM music_group_student_class_adjust WHERE id_ = #{id} 
+	</delete>
+	
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="MusicGroupStudentClassAdjust" parameterType="map">
+		SELECT * FROM music_group_student_class_adjust ORDER BY id_ <include refid="global.limit"/>
+	</select>
+	
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM music_group_student_class_adjust
+	</select>
+</mapper>

+ 19 - 4
mec-biz/src/main/resources/config/mybatis/SysExamSongMapper.xml

@@ -77,12 +77,27 @@
 			<if test="search != null and search != ''">
 				AND (ses.id_ = #{search} OR ses.name_ LIKE CONCAT('%',#{search},'%'))
 			</if>
-			<if test="createUserId != null">
-				AND ses.create_user_id_ = #{createUserId}
-			</if>
-			<if test="type != null and type != ''">
+			<if test="type != null and type == 'COMMON'">
 				AND ses.type_ = #{type}
 			</if>
+			<if test="type != null and type == 'ALL'">
+				<if test="createUserId != null">
+					AND (ses.type_ = 'COMMON' OR (ses.create_user_id_ = #{createUserId} AND ses.type_ = 'PERSON'))
+				</if>
+			</if>
+			<if test="type != null and type == 'PERSON'">
+				<if test="createUserId != null">
+					AND ses.type_ = #{type} AND ses.create_user_id_ = #{createUserId}
+				</if>
+				<if test="createUserId == null">
+					AND ses.type_ = #{type}
+				</if>
+			</if>
+			<if test="type == null or type == ''">
+				<if test="createUserId != null">
+					AND ses.create_user_id_ = #{createUserId}
+				</if>
+			</if>
 			<if test="subjectId != null">
 				AND FIND_IN_SET(#{subjectId},ses.subject_ids_)
 			</if>

+ 1 - 0
mec-im/src/main/java/com/ym/mec/im/message/MemberChangedMessage.java

@@ -21,6 +21,7 @@ public class MemberChangedMessage extends BaseMessage {
     @Getter @Setter private boolean camera;
     @Getter @Setter private boolean microphone;
     @Getter @Setter private boolean metronomeSwitch;
+    @Getter @Setter private boolean examSongSwitch;
     @Getter @Setter private boolean handUpOn;
 
     private @Getter @Setter int role;

+ 32 - 4
mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java

@@ -273,6 +273,7 @@ public class RoomServiceImpl implements RoomService {
             redisTemplate.delete(joinSuccessKey);
             return;
         }
+
         String leaveSuccessKey = "leaveRoomSuccess"+ roomId + userId;
         if(redisTemplate.hasKey(leaveSuccessKey)){
             redisTemplate.delete(leaveSuccessKey);
@@ -320,6 +321,7 @@ public class RoomServiceImpl implements RoomService {
         msg.setUserName(roomMember.getName());
         msg.setCamera(true);
         Boolean playMidi = false;
+        Boolean examSong = false;
         if(roleEnum == RoleStudent){
             String midiByCourseIdAndUserId = courseScheduleStudentPaymentDao.getMidiByCourseIdAndUserId(schedule.getId().toString(), userId);
             //获取节拍器信息
@@ -329,9 +331,15 @@ public class RoomServiceImpl implements RoomService {
                     playMidi = Boolean.parseBoolean(jsonObject.get("enable").toString());
                 }
             }
+            String examJson = courseScheduleStudentPaymentDao.getExamJsonByCourseIdAndUserId(schedule.getId(), Integer.parseInt(userId));
+            if(StringUtils.isNotEmpty(examJson)){
+                ExamSongDownloadData examSongDownloadData = JSON.parseObject(examJson, ExamSongDownloadData.class);
+                examSong = examSongDownloadData.getEnable();
+            }
         }
         msg.setHandUpOn(roomMember.isHand());
         msg.setMetronomeSwitch(playMidi);
+        msg.setExamSongSwitch(examSong);
         imHelper.publishMessage(userId, roomId, msg);
         log.info("join room success: roomId = {}, userId = {}, role = {}", roomId, userId, roleEnum);
         signInSuccess(roomMember);
@@ -340,19 +348,27 @@ public class RoomServiceImpl implements RoomService {
     public void signInSuccess(RoomMember roomMember) {
         String roomId = roomMember.getRid();
         String userId = roomMember.getUid();
+        String currentRoomIdKey = roomId + userId;
+
+        Long firstCourseId = Long.parseLong(roomId.substring(1));
+        Long currentRoomId;
+        if(redisTemplate.hasKey(currentRoomIdKey)){
+            currentRoomId = Long.parseLong(redisTemplate.opsForValue().get(currentRoomIdKey));
+        }else {
+            log.error("signInFailure: roomId={}, userId={}", roomId, userId);
+            currentRoomId = firstCourseId;
+        }
+        log.info("signInSuccess: currentRoomId={}", currentRoomId);
         log.info("signInSuccess: roomId={}, userId={}", roomId, userId);
         Integer userIdInt = Integer.parseInt(userId);
-        Long firstCourseId = Long.parseLong(roomId.substring(1));
 
-        Long currentRoomId = Long.parseLong(redisTemplate.opsForValue().get(roomId + userId));
-        log.info("signInSuccess: currentRoomId={}", currentRoomId);
-        redisTemplate.delete(roomId + userId);
         RoleEnum roleEnum = RoleEnum.getEnumByValue(roomMember.getRole());
         if(roleEnum == RoleTeacher){
             teacherAttendanceService.addTeacherAttendanceSignIn(firstCourseId,userIdInt,currentRoomId);
         }else {
             studentAttendanceService.addStudentAttendanceSignIn(firstCourseId,userIdInt,currentRoomId);
         }
+        redisTemplate.delete(roomId + userId);
     }
 
     public void saveRoom(String roomId, String roomName, Date createTime, String display) {
@@ -403,6 +419,7 @@ public class RoomServiceImpl implements RoomService {
 
         if(roleEnum == RoleTeacher){
             courseScheduleStudentPaymentDao.adjustPlayMidi(firstCourseId,null,null);
+            courseScheduleStudentPaymentDao.adjustExamSong(firstCourseId.longValue(),null,null);
             teacherAttendanceService.addTeacherAttendanceSignOut(firstCourseId.longValue(),Integer.parseInt(userId));
         }else {
             studentAttendanceService.addStudentAttendanceSignOut(firstCourseId.longValue(),Integer.parseInt(userId));
@@ -845,6 +862,17 @@ public class RoomServiceImpl implements RoomService {
         ControlDeviceTaskInfo taskInfo = (ControlDeviceTaskInfo) scheduleManager.executeTask(ticket);
         if (taskInfo.getTypeEnum().equals(DeviceTypeEnum.Camera)) {
             roomMemberDao.updateCameraByRidAndUid(roomId, userId, taskInfo.isOnOff());
+        }if (taskInfo.getTypeEnum().equals(DeviceTypeEnum.ExamSong)) {
+            long scheduleId = Long.parseLong(roomId.substring(1));
+            ExamSongDownloadData msg;
+            String examJson = courseScheduleStudentPaymentDao.getExamJsonByCourseIdAndUserId(scheduleId, authUser.getId());
+            if(StringUtils.isEmpty(examJson)){
+                throw new BizException("学员伴奏信息异常");
+            }else {
+                msg = JSON.parseObject(examJson, ExamSongDownloadData.class);
+                msg.setEnable(true);
+            }
+            courseScheduleStudentPaymentDao.adjustExamSong(scheduleId,authUser.getId(),JSON.toJSONString(msg));
         } else {
             roomMemberDao.updateMicByRidAndUid(roomId, userId, taskInfo.isOnOff());
         }

+ 5 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/SysExamSongController.java

@@ -10,6 +10,7 @@ import com.ym.mec.common.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -53,6 +54,10 @@ public class SysExamSongController extends BaseController {
     @ApiOperation(value = "分页查询")
     @GetMapping("/queryPage")
     public Object queryPage(SysExamSongQueryInfo queryInfo) {
+        String type = queryInfo.getType();
+        if(StringUtils.isEmpty(type)){
+            queryInfo.setType("ALL");
+        }
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if(sysUser == null){
             throw new BizException("请登录");

+ 9 - 1
mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupController.java

@@ -353,6 +353,14 @@ public class ClassGroupController extends BaseController {
     @PostMapping("/mergeClassSplitClassAffirm")
     @PreAuthorize("@pcs.hasPermissions('classGroup/mergeClassSplitClassAffirm')")
     public HttpResponseResult mergeClassSplitClassAffirm(@RequestBody MergeClassSplitClassAffirmDto mergeClassSplitClassAffirmDto){
-        return succeed(classGroupService.mergeClassSplitClassAffirm(mergeClassSplitClassAffirmDto));
+        classGroupService.mergeClassSplitClassAffirm(mergeClassSplitClassAffirmDto);
+        return succeed();
+    }
+
+    @ApiOperation(value = "进行中乐团-修改-班级详情-学员班级调整-合并结果确认-获取新班级可排课时长")
+    @PostMapping("/findClassCourseMinute")
+    @PreAuthorize("@pcs.hasPermissions('classGroup/findClassCourseMinute')")
+    public HttpResponseResult findClassCourseMinuteMap(@RequestBody List<Integer> classGroupIds){
+        return succeed(classGroupService.findClassCourseMinuteMap(classGroupIds));
     }
 }