瀏覽代碼

Merge branch 'master' of http://git.dayaedu.com/yonge/mec into origin_master

yonge 4 年之前
父節點
當前提交
9bc4959b76
共有 19 個文件被更改,包括 333 次插入142 次删除
  1. 64 47
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java
  2. 14 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderStudentDetailDao.java
  3. 3 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentCourseFeeDetailDao.java
  4. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentRegistrationDao.java
  5. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentCalenderDto.java
  6. 9 9
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderStudentDetail.java
  7. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupStudentClassAdjust.java
  8. 13 2
      mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java
  9. 74 9
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java
  10. 16 14
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  11. 46 8
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  12. 28 30
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  13. 8 0
      mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml
  14. 5 5
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  15. 16 8
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderStudentDetailMapper.xml
  16. 7 2
      mec-biz/src/main/resources/config/mybatis/MusicGroupStudentClassAdjustMapper.xml
  17. 1 1
      mec-biz/src/main/resources/config/mybatis/StudentCourseFeeDetailMapper.xml
  18. 1 1
      mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml
  19. 4 1
      mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupController.java

+ 64 - 47
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java

@@ -17,6 +17,7 @@ import java.util.Map;
 public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStudentMapper> {
 
     int batchUpdate(@Param("classGroupStudentMappers") List<ClassGroupStudentMapper> classGroupStudentMappers);
+
     /**
      * 批量插入学生
      *
@@ -35,12 +36,12 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
     ClassGroupStudentMapper query(@Param("classGroupId") int classGroupId, @Param("userId") Integer userId);
 
     /**
+     * @param classGroupId: 班级编号
+     * @param userId:       学员编号
+     * @return com.ym.mec.biz.dal.entity.ClassGroupStudentMapper
      * @describe 获取班级上的学员
      * @author Joburgess
      * @date 2019/12/18
-     * @param classGroupId: 班级编号
-     * @param userId: 学员编号
-     * @return com.ym.mec.biz.dal.entity.ClassGroupStudentMapper
      */
     ClassGroupStudentMapper findClassGroupStudent(@Param("classGroupId") int classGroupId, @Param("userId") Integer userId);
 
@@ -61,26 +62,26 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
     void deleteByClassId(Integer classGroupId);
 
     /**
-     * @describe 根据团体删除班上的学生
-     * @author Joburgess
-     * @date 2020/2/17
      * @param groupId:
      * @param groupType:
      * @return int
+     * @describe 根据团体删除班上的学生
+     * @author Joburgess
+     * @date 2020/2/17
      */
     int deleteByGroup(@Param("groupId") String groupId,
                       @Param("groupType") GroupType groupType);
 
     /**
-     * @describe 根据团体删除班上的学生-退学
-     * @author Joburgess
-     * @date 2020/2/17
      * @param groupId:
      * @param groupType:
      * @return int
+     * @describe 根据团体删除班上的学生-退学
+     * @author Joburgess
+     * @date 2020/2/17
      */
     int deleteByGroupWithLogic(@Param("groupId") String groupId,
-                      @Param("groupType") GroupType groupType);
+                               @Param("groupType") GroupType groupType);
 
     /**
      * @return int
@@ -102,7 +103,7 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
 
     int deleteClassGroupStudent(@Param("classGroupId") Long classGroupId, @Param("userId") Integer userId);
 
-  /**
+    /**
      * @param classGroupId: 班级编号
      * @return java.lang.String[]
      * @describe 根据班级编号获取班级学生名称列表
@@ -112,20 +113,20 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
     String[] findStudentNumByClassGroupId(@Param("classGroupId") Integer classGroupId);
 
     /**
+     * @param courseScheduleId:
+     * @return java.lang.String[]
      * @describe 获取课程上的学员名称集合
      * @author Joburgess
      * @date 2019/12/4
-     * @param courseScheduleId:
-     * @return java.lang.String[]
      */
     String[] findCourseStudentName(@Param("courseScheduleId") Integer courseScheduleId);
 
     /**
+     * @param courseScheduleId:
+     * @return java.util.List<com.ym.mec.biz.dal.dto.StudentNameAndPhoneDto>
      * @describe 获取课程上的学员名称和电话
      * @author Joburgess
      * @date 2020/2/16
-     * @param courseScheduleId:
-     * @return java.util.List<com.ym.mec.biz.dal.dto.StudentNameAndPhoneDto>
      */
     List<StudentNameAndPhoneDto> findCourseStudentNameAndPhone(@Param("courseScheduleId") Integer courseScheduleId);
 
@@ -185,22 +186,22 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
     List<ClassGroupStudentMapper> findByClassGroups(@Param("classGroupIds") List<Integer> classGroupIds);
 
     /**
-     * @describe 获取团体学员
-     * @author Joburgess
-     * @date 2020/3/8
      * @param groupIds:
      * @param groupType:
      * @return java.util.List<com.ym.mec.biz.dal.entity.ClassGroupStudentMapper>
+     * @describe 获取团体学员
+     * @author Joburgess
+     * @date 2020/3/8
      */
     List<ClassGroupStudentMapper> findByGroups(@Param("groupIds") List<String> groupIds,
                                                @Param("groupType") GroupType groupType);
 
     /**
+     * @param classGroupId:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.ClassGroupStudentMapper>
      * @describe 获取指定班级的所有学员
      * @author Joburgess
      * @date 2020.11.04
-     * @param classGroupId:
-     * @return java.util.List<com.ym.mec.biz.dal.entity.ClassGroupStudentMapper>
      */
     List<ClassGroupStudentMapper> findAllByClassGroup(@Param("classGroupId") Long classGroupId);
 
@@ -214,17 +215,17 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
     List<ClassGroupStudentMapper> findByClassGroup(@Param("classGroupId") Integer classGroupId);
 
     /**
-     * @describe 获取团体或者班级上的学员
-     * @author Joburgess
-     * @date 2020/3/10
      * @param groupId:
      * @param groupType:
      * @param classGroupId:
      * @return java.util.List<com.ym.mec.biz.dal.dto.SimpleUserDto>
+     * @describe 获取团体或者班级上的学员
+     * @author Joburgess
+     * @date 2020/3/10
      */
     List<ClassGroupStudentInfoDto> findByGroupOrClassGroup(@Param("groupId") String groupId,
-                                               @Param("groupType") GroupType groupType,
-                                               @Param("classGroupId") Integer classGroupId);
+                                                           @Param("groupType") GroupType groupType,
+                                                           @Param("classGroupId") Integer classGroupId);
 
     /**
      * 查询班级某状态下所有的学生
@@ -266,10 +267,10 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
      * @date 2019/11/21
      */
     List<Map<Integer, Integer>> countClassGroupsStudentNum(@Param("classGroupIds") List<Integer> classGroupIds,
-                                                           @Param("status")ClassGroupStudentStatusEnum status);
+                                                           @Param("status") ClassGroupStudentStatusEnum status);
 
     List<Map<String, Integer>> countGroupAllStudentNum(@Param("groupIds") List<String> groupIds,
-                                                        @Param("groupType") GroupType groupType);
+                                                       @Param("groupType") GroupType groupType);
 
     /**
      * @param classGroupId: 班级编号
@@ -281,32 +282,32 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
     Integer countClassGroupStudentNum(@Param("classGroupId") Integer classGroupId);
 
     /**
+     * @param classGroupId:
+     * @return java.lang.Integer
      * @describe 统计班级上学生人数,
      * @author Joburgess
      * @date 2019/12/26
-     * @param classGroupId:
-     * @return java.lang.Integer
      */
     Integer countClassGroupNormalStudentNum(@Param("classGroupId") Integer classGroupId);
 
     /**
-     * @describe 统计课程组上状态正常的学员数量
-     * @author Joburgess
-     * @date 2020.08.05
      * @param groupType:
      * @param groupId:
      * @return int
+     * @describe 统计课程组上状态正常的学员数量
+     * @author Joburgess
+     * @date 2020.08.05
      */
     int countGroupNormalStudentNum(@Param("groupType") GroupType groupType,
                                    @Param("groupId") String groupId);
 
     /**
-     * @describe 统计vip课或乐团下的学生人数
-     * @author Joburgess
-     * @date 2019/12/14
      * @param groupId:
      * @param groupType:
      * @return java.lang.Integer
+     * @describe 统计vip课或乐团下的学生人数
+     * @author Joburgess
+     * @date 2019/12/14
      */
     Integer countGroupStudentNum(@Param("groupId") String groupId,
                                  @Param("groupType") String groupType);
@@ -345,6 +346,7 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
 
     /**
      * 查询乐团某种类型班级的学生
+     *
      * @param musicGroupId
      * @param classGroupType
      * @return
@@ -353,6 +355,7 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
 
     /**
      * 获取vip课所有学员列表
+     *
      * @param vipGroupId
      * @return
      */
@@ -360,50 +363,52 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
 
     /**
      * 获取vip课所有教师列表
+     *
      * @param vipGroupId
      * @return
      */
     List<Map<Integer, String>> queryTeacherIdMap(Long vipGroupId);
 
     /**
+     * @param classGroupId: 班级编号
+     * @param userIds:      学生编号列表
+     * @return java.util.List<com.ym.mec.biz.dal.entity.ClassGroupStudentMapper>
      * @describe 根据班级和学生编号获取关联记录
      * @author Joburgess
      * @date 2019/12/8
-     * @param classGroupId: 班级编号
-     * @param userIds: 学生编号列表
-     * @return java.util.List<com.ym.mec.biz.dal.entity.ClassGroupStudentMapper>
      */
     List<ClassGroupStudentMapper> findByClassGroupAndStudent(@Param("classGroupId") Integer classGroupId,
                                                              @Param("userIds") List<Integer> userIds);
 
     /**
+     * @param groupId:   编号
+     * @param groupType: 类型
+     * @param status:    状态
+     * @return int
      * @describe 批量更新指定乐团或小课下学员状态
      * @author Joburgess
      * @date 2019/12/10
-     * @param groupId: 编号
-     * @param groupType: 类型
-     * @param status: 状态
-     * @return int
      */
     int updateVipGroupStudentStatus(@Param("groupId") String groupId,
                                     @Param("groupType") String groupType,
                                     @Param("status") String status);
-    
+
     /**
      * 查询这节课的新学生
+     *
      * @param courseScheduleId
      * @return
      */
     List<ClassGroupStudentMapper> queryNewStudentListByCourseScheduleId(Long courseScheduleId);
 
     /**
-     * @describe 获取课程组上的学生
-     * @author Joburgess
-     * @date 2020/3/11
      * @param groupId:
      * @param groupType:
      * @param userId:
      * @return java.util.List<com.ym.mec.biz.dal.entity.ClassGroupStudentMapper>
+     * @describe 获取课程组上的学生
+     * @author Joburgess
+     * @date 2020/3/11
      */
     List<ClassGroupStudentMapper> findGroupStudents(@Param("groupId") String groupId,
                                                     @Param("groupType") GroupType groupType,
@@ -412,6 +417,7 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
 
     /**
      * 获取学员教务老师
+     *
      * @param studentIds
      * @return
      */
@@ -419,6 +425,7 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
 
     /**
      * 是否在指定的班级
+     *
      * @param classGroupIdListStr
      * @return
      */
@@ -426,8 +433,18 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
 
     /**
      * 获取班级里学员列表
-     * @author zouxuan
+     *
      * @param classGroupId
+     * @author zouxuan
      */
     List<StudentNameAndPhoneDto> findCourseStudentNameAndPhoneByClassGroupId(Integer classGroupId);
+
+    /**
+     * //主班是否包含所选学员学员
+     *
+     * @param masterClassGroupId
+     * @param studentIds
+     * @return
+     */
+    Boolean hasStudent(@Param("masterClassGroupId") Integer masterClassGroupId, @Param("studentIds") List<Integer> studentIds);
 }

+ 14 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderStudentDetailDao.java

@@ -8,7 +8,20 @@ import java.util.List;
 
 public interface MusicGroupPaymentCalenderStudentDetailDao extends BaseDAO<Integer, MusicGroupPaymentCalenderStudentDetail> {
 
-    void batchInsert(@Param("musicGroupPaymentCalenderStudentDetails") List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails, @Param("calenderId") Long calenderId);
+    void batchInsert(@Param("musicGroupPaymentCalenderStudentDetails") List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails, @Param("batchNo") String batchNo);
 
     void batchUpdate(@Param("musicGroupPaymentCalenderStudentDetails") List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails);
+
+    /**
+     * 根据批次号获取缴费详情
+     * @param batchNo
+     * @return
+     */
+    List<MusicGroupPaymentCalenderStudentDetail> findByBatchNo(String batchNo);
+
+    /**
+     * 根据批次号删除
+     * @param batchNo
+     */
+    void delByBatchNo(String batchNo);
 }

+ 3 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentCourseFeeDetailDao.java

@@ -2,11 +2,12 @@ package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.StudentCourseFeeDetail;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
-public interface StudentCourseFeeDetailDao extends BaseDAO<Long, StudentCourseFeeDetail>{
+public interface StudentCourseFeeDetailDao extends BaseDAO<Long, StudentCourseFeeDetail> {
 
 
-    void batchInsert(List<StudentCourseFeeDetail> studentCourseFeeDetails);
+    void batchInsert(@Param("studentCourseFeeDetails") List<StudentCourseFeeDetail> studentCourseFeeDetails);
 }

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

@@ -419,8 +419,8 @@ public interface StudentRegistrationDao extends BaseDAO<Long, StudentRegistratio
      * 根据学员编号列表和乐团编号获取学员注册列表
      *
      * @param studentIds
-     * @param oldMusicGroupId
+     * @param musicGroupId
      * @return
      */
-    List<StudentRegistration> queryByUserIdsAndMusicGroupId(@Param("studentIds") String studentIds, @Param("oldMusicGroupId") String oldMusicGroupId);
+    List<StudentRegistration> queryByUserIdsAndMusicGroupId(@Param("studentIds") String studentIds, @Param("musicGroupId") String musicGroupId);
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentCalenderDto.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.dto;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -39,9 +40,19 @@ public class MusicGroupPaymentCalenderDto {
 
 	private List<String> IgnoreBatchNoList = null;
 
+	private BigDecimal masterTotalPrice = BigDecimal.ZERO;
+
 	@ApiModelProperty(value = "跨团合并时缴费项目中学员的缴费明细")
 	private List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails;
 
+	public BigDecimal getMasterTotalPrice() {
+		return masterTotalPrice;
+	}
+
+	public void setMasterTotalPrice(BigDecimal masterTotalPrice) {
+		this.masterTotalPrice = masterTotalPrice;
+	}
+
 	public List<MusicGroupPaymentCalenderStudentDetail> getMusicGroupPaymentCalenderStudentDetails() {
 		return musicGroupPaymentCalenderStudentDetails;
 	}

+ 9 - 9
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderStudentDetail.java

@@ -33,9 +33,9 @@ public class MusicGroupPaymentCalenderStudentDetail {
 	
 	/** 班级编号 */
 	private Integer classGroupId;
-	
+
 	/** 缴费项目编号 */
-	private Long calenderId;
+	private String batchNo;
 	
 	/**  */
 	private java.util.Date createTime;
@@ -114,15 +114,15 @@ public class MusicGroupPaymentCalenderStudentDetail {
 	public Integer getClassGroupId(){
 		return this.classGroupId;
 	}
-			
-	public void setCalenderId(Long calenderId){
-		this.calenderId = calenderId;
+
+	public String getBatchNo() {
+		return batchNo;
 	}
-	
-	public Long getCalenderId(){
-		return this.calenderId;
+
+	public void setBatchNo(String batchNo) {
+		this.batchNo = batchNo;
 	}
-			
+
 	public void setCreateTime(java.util.Date createTime){
 		this.createTime = createTime;
 	}

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

@@ -48,10 +48,21 @@ public class MusicGroupStudentClassAdjust {
 
 	private Integer operatorId;
 
+	@ApiModelProperty(value = "主班编号", required = false)
+	private Integer masterClassGroupId;
+
 	private Date createTime;
 
 	private Date updateTime;
 
+	public Integer getMasterClassGroupId() {
+		return masterClassGroupId;
+	}
+
+	public void setMasterClassGroupId(Integer masterClassGroupId) {
+		this.masterClassGroupId = masterClassGroupId;
+	}
+
 	public String getStudentPaymentCalender() {
 		return studentPaymentCalender;
 	}

+ 13 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java

@@ -508,10 +508,12 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
 
     /**
      * 进行中乐团-修改-班级详情-班级合并-获取学员需要补交的费用以及需要退还的课程余额
-     * @param mergeClassSplitClassAffirmDto
+     * @param masterClassGroupId
+     * @param classGroupStudents
+     * @param studentIds
      * @return
      */
-    List<MusicGroupPaymentCalenderStudentDetail> queryStudentPaymentCalenders(MergeClassSplitClassAffirmDto mergeClassSplitClassAffirmDto);
+    List<MusicGroupPaymentCalenderStudentDetail> queryStudentPaymentCalenders(Integer masterClassGroupId,List<Map<Integer, String>> classGroupStudents,List<Integer> studentIds);
 
     /**
      * 获取主班课程类型剩余价值
@@ -533,4 +535,13 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
      * @return
      */
     void spanGroupMergeClassSplitClassAffirm(MergeClassSplitClassAffirmDto mergeClassSplitClassAffirmDto);
+
+    /**
+     * 跨团合班缴费项目审核通过后
+     * @param masterClassGroupId
+     * @param studentIds
+     * @param courseIds
+     * @param classGroupStudents
+     */
+    void spanGroupClassAdjustPass(Integer masterClassGroupId,List<Integer> studentIds,List<Long> courseIds,List<Map<Integer, String>> classGroupStudents);
 }

+ 74 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -3572,19 +3572,18 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     }
 
     @Override
-    public List<MusicGroupPaymentCalenderStudentDetail> queryStudentPaymentCalenders(MergeClassSplitClassAffirmDto mergeClassSplitClassAffirmDto) {
+    public List<MusicGroupPaymentCalenderStudentDetail> queryStudentPaymentCalenders(Integer masterClassGroupId,List<Map<Integer, String>> classGroupStudents,List<Integer> studentIds) {
         //获取主班剩余时长
-        Map<String, Long> masterMap = MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseNumMap(mergeClassSplitClassAffirmDto.getMasterClassGroupId()));
+        Map<String, Long> masterMap = MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseNumMap(masterClassGroupId));
         if(masterMap.size() <= 0){
             throw new BizException("所选主班没有剩余课程,请重新选择");
         }
         //获取学员列表
-        Map<Integer, String> userNames = MapUtil.convertMybatisMap(teacherDao.queryUsernameByIds(mergeClassSplitClassAffirmDto.getStudentIds()));
-        Map<Integer, String> phoneMaps = MapUtil.convertMybatisMap(teacherDao.queryPhoneByIds(StringUtils.join(mergeClassSplitClassAffirmDto.getStudentIds(),",")));
+        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<>();
-        List<Map<Integer, String>> classGroupStudents = mergeClassSplitClassAffirmDto.getClassGroupStudents();
         for (Map<Integer, String> classGroupStudent : classGroupStudents) {
             for (Integer integer : classGroupStudent.keySet()) {
                 //获取学员剩余课程费用
@@ -3598,7 +3597,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         //学员剩余课程费用
         Map<Integer, BigDecimal> surplusCourseFeeMap = MapUtil.convertIntegerMap(surplusCourseFeeMapList);
         //获取分布默认的课程类型单价
-        MusicGroup musicGroup = musicGroupDao.findByClassGroupId(mergeClassSplitClassAffirmDto.getMasterClassGroupId());
+        MusicGroup musicGroup = musicGroupDao.findByClassGroupId(masterClassGroupId);
         Map<String, BigDecimal> unitPriceMap = MapUtil.convertIntegerMap(organizationCourseUnitPriceSettingsDao.queryMapByOrganIdAndChargeTypeId(musicGroup.getChargeTypeId(), musicGroup.getOrganId()));
         Set<String> masterKeySet = masterMap.keySet();
         //计算主班课程类型剩余价值
@@ -3690,16 +3689,26 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     @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(mergeClassSplitClassAffirmDto);
+        List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails = queryStudentPaymentCalenders(masterClassGroupId,
+                classGroupStudents,
+                studentIds);
         //创建缴费项目
         MusicGroup musicGroup = musicGroupDao.findByClassGroupId(masterClassGroupId);
         MusicGroupPaymentCalender.PaymentCalenderStatusEnum status = null;
@@ -3721,6 +3730,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                 }
                 calenderDto.setPaymentType(SPAN_GROUP_CLASS_ADJUST);
                 //生成缴费项目
+                calenderDto.setMasterTotalPrice(masterTotalPrice);
                 musicGroupPaymentCalenderService.create(calenderDto);
                 if (batchNos.length() > 0) {
                     batchNos.append(",");
@@ -3733,8 +3743,63 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                     }
                 }
             }
-            //将学员加进班级未开始的课程,以及班级关联、加群
-            classGroupStudentMapperService.updateClassGroupStudents(masterClassGroupId.longValue(),new HashSet<>(studentIds));
+            //记录申请信息
+            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);
         }
     }
 }

+ 16 - 14
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java

@@ -378,7 +378,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 	public void batchAdd(MusicGroupPaymentCalender musicGroupPaymentCalender,List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails) {
 		Map<Integer, List<MusicGroupPaymentCalenderStudentDetail>> collect = musicGroupPaymentCalenderStudentDetails.stream().collect(Collectors.groupingBy(e -> e.getUserId()));
 		//生成music_group_payment_calender_detail
-		List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<MusicGroupPaymentStudentCourseDetail>();
+//		List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<MusicGroupPaymentStudentCourseDetail>();
 		MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
 		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
 		Long musicGroupPaymentCalenderId = musicGroupPaymentCalender.getId();
@@ -392,29 +392,31 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 			if(musicGroupPaymentCalender.getStatus() != AUDITING){
 				if (totalPrice.doubleValue() == 0d) {
 					musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
+					musicGroupPaymentCalenderDetail.setActualAmount(totalPrice);
 				}
 			}
+			musicGroupPaymentCalenderDetail.setMusicGroupId(musicGroupPaymentCalender.getMusicGroupId());
 			musicGroupPaymentCalenderDetail.setUserId(studentId);
 			musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupPaymentCalender.getStartPaymentDate());
 			musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
 			musicGroupPaymentCalenderDetail.setResponsibleUserId(musicGroupPaymentCalender.getOperator());
 			musicGroupPaymentCalenderDetailDao.insert(musicGroupPaymentCalenderDetail);
-			Long musicGroupPaymentCalenderDetailId = musicGroupPaymentCalenderDetail.getId();
-			for (MusicGroupPaymentCalenderStudentDetail calenderStudentDetail : calenderStudentDetails) {
-				//创建学生课排课分钟数
-				musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
-				musicGroupPaymentStudentCourseDetail.setCourseType(CourseSchedule.CourseScheduleType.valueOf(calenderStudentDetail.getCourseType()));
-				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalenderId);
-				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetailId);
-				musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(0);
-				musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(calenderStudentDetail.getCourseTime().intValue());
-				musicGroupPaymentStudentCourseDetail.setUserId(studentId);
-				musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
-			}
+//			Long musicGroupPaymentCalenderDetailId = musicGroupPaymentCalenderDetail.getId();
+//			for (MusicGroupPaymentCalenderStudentDetail calenderStudentDetail : calenderStudentDetails) {
+//				//创建学生课排课分钟数
+//				musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+//				musicGroupPaymentStudentCourseDetail.setCourseType(CourseSchedule.CourseScheduleType.valueOf(calenderStudentDetail.getCourseType()));
+//				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalenderId);
+//				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetailId);
+//				musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(0);
+//				musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(calenderStudentDetail.getCourseTime().intValue());
+//				musicGroupPaymentStudentCourseDetail.setUserId(studentId);
+//				musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
+//			}
 		}
 		musicGroupPaymentCalender.setExpectNum(collect.keySet().size());
 		musicGroupPaymentCalenderService.update(musicGroupPaymentCalender);
-		musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
+//		musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
 		//给学员推送缴费通知
 		if(musicGroupPaymentCalender.getStatus() == PaymentCalenderStatusEnum.OPEN){
 			musicGroupPaymentCalenderService.pushWaitRenewMessage(musicGroupPaymentCalenderId,musicGroupDao.get(musicGroupPaymentCalender.getMusicGroupId()),collect.keySet());

+ 46 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -260,7 +260,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			List<MusicGroupPaymentCalenderCourseSettings> newCSList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>(
 					musicGroupPaymentCalenderCourseSettingsList.size());
 
-			BigDecimal totalPaymentAmount = new BigDecimal(0);
+			BigDecimal totalPaymentAmount = musicGroupPaymentCalenderDto.getMasterTotalPrice();
 			for (MusicGroupPaymentCalenderCourseSettings pccs : musicGroupPaymentCalenderCourseSettingsList) {
 				
 				MusicGroupPaymentCalenderCourseSettings tempPccs = new MusicGroupPaymentCalenderCourseSettings();
@@ -368,13 +368,15 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				}
 				musicGroupPaymentCalenderCourseSettingsDao.batchInsert(currentMusicGroupPaymentCalenderCourseSettings);
 			}
+
 			//如果是跨团班级合并,保存用户缴费详情
 			List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails = null;
 			if (musicGroupPaymentCalender.getPaymentType() == SPAN_GROUP_CLASS_ADJUST){
 				musicGroupPaymentCalenderStudentDetails = musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails();
 				//记录学员缴费详情
-				musicGroupPaymentCalenderStudentDetailDao.batchInsert(musicGroupPaymentCalenderStudentDetails,musicGroupPaymentCalender.getId());
+				musicGroupPaymentCalenderStudentDetailDao.batchInsert(musicGroupPaymentCalenderStudentDetails,musicGroupPaymentCalender.getBatchNo());
 			}
+
 			if (musicGroupPaymentCalender.getStatus() != AUDITING) {
 				// 如果是进行中加学生
 				if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
@@ -547,6 +549,23 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 						break;
 					}
 				}
+			}else if(paymentType == SPAN_GROUP_CLASS_ADJUST){
+				MusicGroupStudentClassAdjust adjust = musicGroupStudentClassAdjustDao.findByBatchNo(batchNo);
+				//获取默认的学员缴费详情
+				List<Map<Integer,String>> classGroupStudents = (List<Map<Integer,String>>)JSON.parse(adjust.getClassGroupStudents());
+				List<Integer> studentIds = JSON.parseArray(adjust.getStudentIds(), Integer.class);
+				List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails = classGroupService.queryStudentPaymentCalenders(adjust.getMasterClassGroupId(),
+						classGroupStudents,studentIds);
+				List<MusicGroupPaymentCalenderStudentDetail> calenderStudentDetails = musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails();
+				boolean containsAll = musicGroupPaymentCalenderStudentDetails.containsAll(calenderStudentDetails);
+				if(!containsAll){
+					status = AUDITING;
+					//保存新的学员详情
+				}
+				//删除之前的记录
+				musicGroupPaymentCalenderStudentDetailDao.delByBatchNo(batchNo);
+				//保存现有记录
+				musicGroupPaymentCalenderStudentDetailDao.batchInsert(calenderStudentDetails,batchNo);
 			}
 		}
 
@@ -675,6 +694,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				// 如果是进行中加学生
 				if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
 					addStudent(musicGroupPaymentCalender, currentMusicGroupPaymentCalenderCourseSettings);
+				}else if(musicGroupPaymentCalender.getPaymentType() == SPAN_GROUP_CLASS_ADJUST){
+					//如果是跨团班级合并,添加学员
+					musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalender,musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails());
 				}
 			}
 
@@ -708,7 +730,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			musicGroup.setUpdateTime(date);
 			musicGroupDao.update(musicGroup);
 		} else if (paymentType == ADD_STUDENT) {
-
 			if (status != AUDITING) {
 				// 学生加到班级
 				String classGroupIdStr = musicGroupPaymentCalenderDto.getAttribute1();
@@ -727,8 +748,18 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()),
 					MessageTypeEnum.BACKSTAGE_PAYMENT_CALENDER_AUDIT, "", organization.getName(), musicGroup.getName());
 		}else {
-			//如果是合班缴费
-			autoClassGroupAdjust(batchNo);
+			if(paymentType == ADD_STUDENT){
+				//如果是合班缴费
+				autoClassGroupAdjust(batchNo);
+			}else if(paymentType == SPAN_GROUP_CLASS_ADJUST){
+				//删除和解冻班级,课程信息
+				MusicGroupStudentClassAdjust adjust = musicGroupStudentClassAdjustDao.findByBatchNo(batchNo);
+				List<Map<Integer,String>> classGroupStudents = (List<Map<Integer,String>>)JSON.parse(adjust.getClassGroupStudents());
+				List<Integer> studentIds = JSON.parseArray(adjust.getStudentIds(), Integer.class);
+				List<Long> courseIds = JSON.parseArray(adjust.getSubLockCourseIds(), Long.class);
+				classGroupService.spanGroupClassAdjustPass(adjust.getMasterClassGroupId()
+						,studentIds,courseIds,classGroupStudents);
+			}
 		}
 		return batchNo;
 	}
@@ -1024,17 +1055,24 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getUsername());
 			}
 		} else if (calender.getPaymentType() == ADD_STUDENT) {
-
 			// 学生加到班级
 			String classGroupIdStr = calender.getAttribute1();
 			if (StringUtils.isNotBlank(classGroupIdStr)) {
 				classGroupService.addStudentToClassGroupAndCourseArranging(Integer.parseInt(calender.getStudentIds()), classGroupIdStr, batchNo,
 						musicGroupPaymentCalenderCourseSettingsDao.queryCalenderCourseSettingsByBatchNo(batchNo));
 			}
+			//如果是合班缴费
+			autoClassGroupAdjust(batchNo);
+		}else if(calender.getPaymentType() == SPAN_GROUP_CLASS_ADJUST){
+			//删除和解冻班级,课程信息
+			MusicGroupStudentClassAdjust adjust = musicGroupStudentClassAdjustDao.findByBatchNo(batchNo);
+			List<Map<Integer,String>> classGroupStudents = (List<Map<Integer,String>>)JSON.parse(adjust.getClassGroupStudents());
+			List<Integer> studentIds = JSON.parseArray(adjust.getStudentIds(), Integer.class);
+			List<Long> courseIds = JSON.parseArray(adjust.getSubLockCourseIds(), Long.class);
+			classGroupService.spanGroupClassAdjustPass(adjust.getMasterClassGroupId()
+					,studentIds,courseIds,classGroupStudents);
 		}
 		musicGroupPaymentCalenderDao.batchUpdate(musicGroupPaymentCalenders);
-		//如果是合班缴费
-		autoClassGroupAdjust(batchNo);
 	}
 
 	@Override

+ 28 - 30
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -845,22 +845,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         //获取旧乐团学员注册信息
         List<StudentRegistration> studentRegistrations = studentRegistrationDao.queryByUserIdsAndMusicGroupId(studentIds,oldMusicGroupId);
         List<StudentCourseFeeDetail> studentCourseFeeDetails = new ArrayList<>();
+        BigDecimal amount = BigDecimal.ZERO;
         for (StudentRegistration studentRegistration : studentRegistrations) {
-            //用户是否在主乐团
-            StudentRegistration phoneAndMusicGroupId = studentRegistrationDao.getByPhoneAndMusicGroupId(newMusicGroupId, studentRegistration.getParentsPhone());
-            if (phoneAndMusicGroupId != null && phoneAndMusicGroupId.getMusicGroupStatus() != StudentMusicGroupStatusEnum.QUIT && phoneAndMusicGroupId.getMusicGroupStatus() != StudentMusicGroupStatusEnum.APPLY) {
-                //该学员已存在
-                continue;
-            }
-            SysUser sysUser = studentRegistrationDao.getSysUserByPhone(studentRegistration.getParentsPhone());
-            if (StringUtils.isNotEmpty(sysUser.getUsername())) {
-                if (!sysUser.getUsername().equals(studentRegistration.getName())) {
-                    //账户已被注册
-                    continue;
-                }
-            }
             //记录课程余额消费日志
-            if(studentRegistration.getSurplusCourseFee().doubleValue() > 0d){
+            if(studentRegistration.getSurplusCourseFee().doubleValue() > 0d && masterTotalPrice.doubleValue() > 0d){
                 StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
                 if(studentRegistration.getSurplusCourseFee().doubleValue() > masterTotalPrice.doubleValue()){
                     studentCourseFeeDetail.setAmount(masterTotalPrice);
@@ -869,33 +857,43 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                     studentCourseFeeDetail.setAmount(studentRegistration.getSurplusCourseFee());
                     studentCourseFeeDetail.setSurplusCourseFee(BigDecimal.ZERO);
                 }
+                amount = studentCourseFeeDetail.getAmount();
+                studentCourseFeeDetail.setStudentRegistrationId(studentRegistration.getId());
                 studentRegistration.setSurplusCourseFee(studentCourseFeeDetail.getSurplusCourseFee());
                 studentCourseFeeDetail.setMemo("跨团合班消费");
                 studentCourseFeeDetail.setOperator(sysUser1.getId());
                 studentCourseFeeDetails.add(studentCourseFeeDetail);
-            }
-            //当前学员是否以前存在过当前乐团
-            studentRegistration.setMusicGroupId(newMusicGroupId);
-            if (phoneAndMusicGroupId != null) {
-                studentRegistration.setId(phoneAndMusicGroupId.getId());
+                //修改原有乐团注册信息
                 studentRegistrationDao.update(studentRegistration);
-            } else {
+            }
+            //用户是否在主乐团
+            StudentRegistration registration = studentRegistrationDao.getByPhoneAndMusicGroupId(newMusicGroupId, studentRegistration.getParentsPhone());
+            if (registration != null) {
+                //修改剩余课程余额
+                registration.setSurplusCourseFee(registration.getSurplusCourseFee().add(amount));
+                studentRegistrationDao.update(registration);
+            }else {
+                //生成学员乐团注册表
+                studentRegistration.setSurplusCourseFee(amount);
+                studentRegistration.setMusicGroupId(newMusicGroupId);
                 studentRegistrationDao.insertBasic(studentRegistration);
+                registration = studentRegistration;
             }
-            MusicGroupStudentFee studentFeeDaoByUser = musicGroupStudentFeeDao.findByUser(studentRegistration.getUserId(), newMusicGroupId);
-            if (studentFeeDaoByUser != null) {
-//                该学员已存在
-                continue;
+            //主班新增余额日志
+            if(studentRegistration.getSurplusCourseFee().doubleValue() > 0d && masterTotalPrice.doubleValue() > 0d){
+                StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
+                studentCourseFeeDetail.setAmount(amount);
+                studentCourseFeeDetail.setSurplusCourseFee(registration.getSurplusCourseFee().add(amount));
+                studentCourseFeeDetail.setStudentRegistrationId(studentRegistration.getId());
+                studentCourseFeeDetail.setMemo("跨团合班费用转移");
+                studentCourseFeeDetail.setOperator(sysUser1.getId());
+                studentCourseFeeDetails.add(studentCourseFeeDetail);
             }
             //增加报名学生数
             musicGroupSubjectPlanService.addApplyStudentNum(newMusicGroupId, studentRegistration.getSubjectId(), 1);
             //新增Fee表
-            MusicGroupStudentFee musicGroupStudentFee = null;
-            musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(studentRegistration.getUserId(),oldMusicGroupId);
-            if(musicGroupStudentFee != null){
-                musicGroupStudentFee.setMusicGroupId(newMusicGroupId);
-                musicGroupStudentFeeDao.update(musicGroupStudentFee);
-            }else {
+            MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(studentRegistration.getUserId(),oldMusicGroupId);
+            if(musicGroupStudentFee == null){
                 musicGroupStudentFee = new MusicGroupStudentFee(newMusicGroupId,
                         studentRegistration.getUserId(), studentRegistration.getSubjectId(),BigDecimal.ZERO,
                         null, studentRegistration.getTemporaryCourseFee(), studentRegistration.getPaymentStatus()==YES?PAID_COMPLETED:NON_PAYMENT);

+ 8 - 0
mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml

@@ -580,4 +580,12 @@
         WHERE cssp.class_group_id_ = #{classGroupId} AND sr.music_group_status_ != 'QUIT'
         GROUP BY cssp.user_id_
     </select>
+
+    <select id="hasStudent" resultType="java.lang.Boolean">
+        SELECT COUNT(DISTINCT class_group_id_) FROM class_group_student_mapper
+        WHERE class_group_id_ = #{masterClassGroupId} AND user_id_ IN
+        <foreach collection="studentIds" separator="," open="(" close=")" item="item">
+            #{item}
+        </foreach>
+    </select>
 </mapper>

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

@@ -1080,7 +1080,7 @@
                cs.status_,
                sc.paran_value_
         FROM course_schedule cs
-                 LEFT JOIN sys_config sc ON sc.param_name_ = "vip_appeal_days_range"
+                 LEFT JOIN sys_config sc ON sc.param_name_ = 'vip_appeal_days_range'
         WHERE cs.id_ = #{courseScheduleId}
     </select>
 
@@ -1268,7 +1268,7 @@
             update_time_   = NOW()
         WHERE cs.music_group_id_ = #{musicGroupId}
           AND cs.group_type_ = 'MUSIC'
-          AND NOW() &lt; CONCAT(cs.class_date_, " ", cs.start_class_time_);
+          AND NOW() &lt; CONCAT(cs.class_date_,' ', cs.start_class_time_);
     </update>
     <update id="updateCourseSchoolByGroup">
         UPDATE course_schedule cs
@@ -1276,8 +1276,8 @@
             update_time_   = NOW()
         WHERE cs.music_group_id_ = #{groupId}
           AND cs.group_type_ = #{groupType}
-          AND cs.teach_mode_ = "OFFLINE"
-          AND NOW() &lt; CONCAT(cs.class_date_, " ", cs.start_class_time_);
+          AND cs.teach_mode_ = 'OFFLINE'
+          AND NOW() &lt; CONCAT(cs.class_date_,' ', cs.start_class_time_);
     </update>
 
     <update id="updateGroupCourseLock">
@@ -1286,7 +1286,7 @@
             update_time_ = NOW()
         WHERE music_group_id_ = #{groupId}
           AND group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-          AND NOW() &lt; CONCAT(class_date_, " ", start_class_time_);
+          AND NOW() &lt; CONCAT(class_date_,' ', start_class_time_);
     </update>
     <update id="batchUpdateLockByCourseIds">
         UPDATE course_schedule

+ 16 - 8
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderStudentDetailMapper.xml

@@ -16,7 +16,7 @@
 		<result column="course_type_" property="courseType" />
 		<result column="course_time_" property="courseTime" />
 		<result column="class_group_id_" property="classGroupId" />
-		<result column="calender_id_" property="calenderId" />
+		<result column="batch_no_" property="batchNo" />
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
 	</resultMap>
@@ -34,9 +34,9 @@
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderStudentDetail" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		INSERT INTO music_group_payment_calender_student_detail (id_,user_id_,phone_,username_,course_original_price_,
-																 course_current_price_,course_type_,course_time_,class_group_id_,calender_id_,create_time_,update_time_)
+																 course_current_price_,course_type_,course_time_,class_group_id_,batch_no_,create_time_,update_time_)
 		VALUES(#{id},#{userId},#{phone},#{username},#{courseOriginalPrice},#{courseCurrentPrice},
-			   #{courseType},#{courseTime},#{classGroupId},#{calenderId},NOW(),NOW())
+			   #{courseType},#{courseTime},#{classGroupId},#{batchNo},NOW(),NOW())
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
@@ -57,8 +57,8 @@
 		<if test="courseOriginalPrice != null">
 		course_original_price_ = #{courseOriginalPrice},
 		</if>
-		<if test="calenderId != null">
-		calender_id_ = #{calenderId},
+		<if test="batchNo != null">
+			batch_no_ = #{batchNo},
 		</if>
 		<if test="phone != null">
 		phone_ = #{phone},
@@ -88,12 +88,12 @@
 		SELECT COUNT(*) FROM music_group_payment_calender_student_detail
 	</select>
 	<insert id="batchInsert">
-		INSERT INTO music_group_payment_calender_student_detail (id_,user_id_,phone_,username_,course_original_price_,
-		course_current_price_,course_type_,course_time_,class_group_id_,calender_id_,create_time_,update_time_)
+		INSERT INTO music_group_payment_calender_student_detail (user_id_,phone_,username_,course_original_price_,
+		course_current_price_,course_type_,course_time_,class_group_id_,batch_no_,create_time_,update_time_)
 		VALUES
 		<foreach collection="musicGroupPaymentCalenderStudentDetails" item="item" index="index" separator=",">
 			(#{item.userId},#{item.phone},#{item.username},#{item.courseOriginalPrice},#{item.courseCurrentPrice},
-			#{item.courseType},#{item.courseTime},#{item.classGroupId},#{calenderId},NOW(),NOW())
+			#{item.courseType},#{item.courseTime},#{item.classGroupId},#{batchNo},NOW(),NOW())
 		</foreach>
 	</insert>
 
@@ -112,4 +112,12 @@
 			WHERE id_ = #{item.id}
 		</foreach>
 	</update>
+
+	<select id="findByBatchNo" resultMap="MusicGroupPaymentCalenderStudentDetail">
+		SELECT * FROM music_group_payment_calender_student_detail where batch_no_ = #{batchNo}
+	</select>
+
+	<delete id="delByBatchNo">
+		DELETE FROM music_group_payment_calender_student_detail WHERE batch_no_ = #{batchNo}
+	</delete>
 </mapper>

+ 7 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupStudentClassAdjustMapper.xml

@@ -20,6 +20,7 @@
 		<result column="student_payment_ids_" property="studentPaymentIds" />
 		<result column="class_group_students_" property="classGroupStudents" />
 		<result column="operator_id_" property="operatorId" />
+		<result column="master_class_group_id_" property="masterClassGroupId" />
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
 	</resultMap>
@@ -38,14 +39,18 @@
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		INSERT INTO music_group_student_class_adjust (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_,
-		operator_id_,student_payment_ids_,class_group_students_,default_course_type_minute_,create_time_,update_time_)
+		operator_id_,student_payment_ids_,class_group_students_,default_course_type_minute_,master_class_group_id_,create_time_,update_time_)
 		VALUES(#{musicGroupId},#{batchNo},#{newClassGroupJson},#{classGroupIds},#{studentIds},
-		#{classCourseMinute},#{allLockCourseIds},#{subLockCourseIds},#{operatorId},#{studentPaymentIds},#{classGroupStudents},#{defaultCourseTypeMinute},NOW(),NOW())
+		#{classCourseMinute},#{allLockCourseIds},#{subLockCourseIds},#{operatorId},#{studentPaymentIds},#{classGroupStudents},
+			   #{defaultCourseTypeMinute},#{masterClassGroupId},NOW(),NOW())
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust">
 		UPDATE music_group_student_class_adjust <set>
+		<if test="masterClassGroupId != null">
+			master_class_group_id_ = #{masterClassGroupId},
+		</if>
 		<if test="defaultCourseTypeMinute != null">
 			default_course_type_minute_ = #{defaultCourseTypeMinute},
 		</if>

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

@@ -60,7 +60,7 @@
 	<insert id="batchInsert">
 		INSERT INTO student_course_fee_detail (student_registration_id_,amount_,surplus_course_fee_,memo_,operator_,create_time_,update_time_)
 		VALUES
-		<foreach collection="replies" item="item" separator=",">
+		<foreach collection="studentCourseFeeDetails" item="item" separator=",">
 			(#{item.studentRegistrationId},#{item.amount},#{item.surplusCourseFee},#{item.memo},#{item.operator},NOW(),NOW())
 		</foreach>
     </insert>

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

@@ -396,7 +396,7 @@
 
     <!-- 根据乐团编号和手机号查询注册乐团注册信息-->
     <select id="getByPhoneAndMusicGroupId" resultMap="StudentRegistration">
-        SELECT * FROM student_registration WHERE music_group_id_=#{musicGroupId} AND parents_phone_ = #{parentsPhone} LIMIT 1
+        SELECT * FROM student_registration WHERE music_group_id_ = #{musicGroupId} AND parents_phone_ = #{parentsPhone} AND music_group_status_ != 'QUIT' LIMIT 1
     </select>
 
     <resultMap type="com.ym.mec.auth.api.entity.SysUser" id="FindSysUser">

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

@@ -381,7 +381,10 @@ public class ClassGroupController extends BaseController {
     @PostMapping("/queryStudentPaymentCalenders")
     @PreAuthorize("@pcs.hasPermissions('classGroup/queryStudentPaymentCalenders')")
     public HttpResponseResult queryStudentPaymentCalenders(@RequestBody MergeClassSplitClassAffirmDto mergeClassSplitClassAffirmDto) {
-        return succeed(classGroupService.queryStudentPaymentCalenders(mergeClassSplitClassAffirmDto).stream().collect(Collectors.groupingBy(e -> e.getClassGroupId())));
+        return succeed(classGroupService.queryStudentPaymentCalenders(mergeClassSplitClassAffirmDto.getMasterClassGroupId(),
+                mergeClassSplitClassAffirmDto.getClassGroupStudents(),
+                mergeClassSplitClassAffirmDto.getStudentIds())
+                .stream().collect(Collectors.groupingBy(e -> e.getClassGroupId())));
     }
 
     @ApiOperation(value = "跨团班级合并提交")