Переглянути джерело

Merge branch 'system_fee' of http://git.dayaedu.com/yonge/mec

 Conflicts:
	mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentRegistrationDao.java
	mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
	mec-biz/src/main/resources/config/mybatis/StudentMapper.xml
	mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml
	mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java
	mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java
zouxuan 4 роки тому
батько
коміт
9b943428b6
100 змінених файлів з 4382 додано та 517 видалено
  1. 19 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CloudTeacherOrderDao.java
  2. 52 4
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java
  3. 6 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java
  4. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleTeacherSalaryDao.java
  5. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ExtracurricularExercisesDao.java
  6. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MemberFeeSettingDao.java
  7. 22 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MemberPrivilegesItemDao.java
  8. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MemberRankOrganizationFeeMapperDao.java
  9. 17 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MemberRankPrivilegesDao.java
  10. 13 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MemberRankSettingDao.java
  11. 7 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentMemberCourseDetailDao.java
  12. 36 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupSchoolTermCourseDetailDao.java
  13. 102 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupSchoolTermStudentCourseDetailDao.java
  14. 8 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentDao.java
  15. 15 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentRegistrationDao.java
  16. 22 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroup4MixDto.java
  17. 22 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroupTeachersDto.java
  18. 38 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CloudTeacherOrderDto.java
  19. 32 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CourseHomeworkStudentDetailDto.java
  20. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CourseTimeDto.java
  21. 20 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ExtraExerciseStudentsDto.java
  22. 26 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MemberFeeDto.java
  23. 22 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentCalenderAuditDto.java
  24. 34 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentCalenderDto.java
  25. 18 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupSubjectGoodsAndInfoDto.java
  26. 3 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RemainCourseTypeDurationDto.java
  27. 23 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/TeacherAttendanceDto.java
  28. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CloudTeacherOrder.java
  29. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseHomework.java
  30. 39 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseSchedule.java
  31. 20 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ExtracurricularExercises.java
  32. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ExtracurricularExercisesMessage.java
  33. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ImGroupMember.java
  34. 114 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MemberFeeSetting.java
  35. 115 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MemberPrivilegesItem.java
  36. 121 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MemberRankOrganizationFeeMapper.java
  37. 37 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MemberRankPrivileges.java
  38. 134 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MemberRankSetting.java
  39. 61 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java
  40. 4 5
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentCourseDetail.java
  41. 115 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentMemberCourseDetail.java
  42. 127 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupSchoolTermCourseDetail.java
  43. 114 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupSchoolTermStudentCourseDetail.java
  44. 43 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Student.java
  45. 21 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentCourseHomework.java
  46. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrderDetail.java
  47. 6 4
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/CourseViewTypeEnum.java
  48. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/GroupType.java
  49. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderTypeEnum.java
  50. 29 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/PeriodEnum.java
  51. 30 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/CloudTeacherOrderQueryInfo.java
  52. 17 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/MemberPrivilegesItemQueryInfo.java
  53. 15 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/MemberRankFeeQueryInfo.java
  54. 34 2
      mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java
  55. 15 0
      mec-biz/src/main/java/com/ym/mec/biz/service/CloudTeacherOrderService.java
  56. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/CourseReviewService.java
  57. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleStudentPaymentService.java
  58. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/ExtracurricularExercisesService.java
  59. 0 1
      mec-biz/src/main/java/com/ym/mec/biz/service/IndexErrDataRecordService.java
  60. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MemberFeeSettingService.java
  61. 17 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MemberPrivilegesItemService.java
  62. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MemberRankOrganizationFeeMapperService.java
  63. 17 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MemberRankPrivilegesService.java
  64. 39 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MemberRankSettingService.java
  65. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderDetailService.java
  66. 3 1
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java
  67. 13 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupSchoolTermCourseDetailService.java
  68. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupSchoolTermStudentCourseDetailService.java
  69. 3 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java
  70. 25 3
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentService.java
  71. 597 135
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java
  72. 36 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CloudTeacherOrderServiceImpl.java
  73. 4 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ContractServiceImpl.java
  74. 3 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseReviewServiceImpl.java
  75. 24 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java
  76. 41 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java
  77. 4 7
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesMessageServiceImpl.java
  78. 4 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesReplyServiceImpl.java
  79. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesServiceImpl.java
  80. 26 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberFeeSettingServiceImpl.java
  81. 79 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberPrivilegesItemServiceImpl.java
  82. 66 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberRankOrganizationFeeMapperServiceImpl.java
  83. 82 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberRankPrivilegesServiceImpl.java
  84. 372 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberRankSettingServiceImpl.java
  85. 47 33
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  86. 373 247
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  87. 158 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupSchoolTermCourseDetailServiceImpl.java
  88. 22 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupSchoolTermStudentCourseDetailServiceImpl.java
  89. 16 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  90. 9 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupSubjectPlanServiceImpl.java
  91. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentCourseHomeworkServiceImpl.java
  92. 92 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  93. 3 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  94. 8 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java
  95. 132 7
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServiceImpl.java
  96. 53 4
      mec-biz/src/main/resources/config/mybatis/CloudTeacherOrderMapper.xml
  97. 77 13
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  98. 5 1
      mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml
  99. 18 1
      mec-biz/src/main/resources/config/mybatis/CourseScheduleTeacherSalaryMapper.xml
  100. 17 10
      mec-biz/src/main/resources/config/mybatis/ExtracurricularExercisesMapper.xml

+ 19 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CloudTeacherOrderDao.java

@@ -1,12 +1,21 @@
 package com.ym.mec.biz.dal.dao;
 
-import com.ym.mec.biz.dal.entity.CloudTeacherOrder;
-import com.ym.mec.common.dal.BaseDAO;
+import java.util.List;
+
 import org.apache.ibatis.annotations.Param;
 
-import java.util.List;
+import com.ym.mec.biz.dal.dto.CloudTeacherOrderDto;
+import com.ym.mec.biz.dal.entity.CloudTeacherOrder;
+import com.ym.mec.common.dal.BaseDAO;
 
 public interface CloudTeacherOrderDao extends BaseDAO<Long, CloudTeacherOrder> {
+	
+	/**
+	 * 根据studentPaymentOrder表id查询对象
+	 * @param orderId
+	 * @return
+	 */
+	CloudTeacherOrder queryByOrderId(Long orderId);
 
     /**
      * 获取未生效的云教练订单
@@ -31,4 +40,11 @@ public interface CloudTeacherOrderDao extends BaseDAO<Long, CloudTeacherOrder> {
      * @return
      */
     CloudTeacherOrder getStudentCloudTeacherOrder(@Param("studentId") Integer studentId, @Param("musicGroupId") String musicGroupId);
+    
+    /**
+     * 根据订单编号查询订单详情
+     * @param orderId
+     * @return
+     */
+    CloudTeacherOrderDto queryOrderInfoByOrderId(Long orderId);
 }

+ 52 - 4
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -1110,6 +1110,14 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
     List<Map<Integer, Long>> countTotalNumByClassGroupId(@Param("classGroupIds") List<Integer> classGroupIds, @Param("classDate") Date classDate);
 
     /**
+     * 根据班级编号count总课时
+     *
+     * @param classGroupIds
+     * @return
+     */
+    List<Map<Integer, Long>> countPreTotalNumByClassGroupId(@Param("classGroupIds") List<Integer> classGroupIds);
+
+    /**
      * 根据班级编号count当前课时(已上总数)
      *
      * @param classGroupIds
@@ -1464,7 +1472,8 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @author zouxuan
      */
     int batchUpdateLockByCourseIds(@Param("courseId") List<Long> courseId,
-                                   @Param("isLock") Integer isLock);
+                                   @Param("isLock") Integer isLock,
+                                   @Param("preCourseFlag") Integer preCourseFlag);
 
 
     /**
@@ -1669,15 +1678,13 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      */
     List<Map<Integer, Integer>> queryHasReatClass(@Param("classGroupIds") Set<String> classGroupIds, @Param("teacherId") String teacherId);
 
-
     /**
      * 查询班级未上的课程类型对应的时长
      *
      * @param classGroupIdList
      * @return
      */
-    List<RemainCourseTypeDurationDto> queryRemainCourseTypeDuration(String classGroupIdList);
-
+    List<RemainCourseTypeDurationDto> queryRemainCourseTypeDuration(@Param("classGroupIdList") String classGroupIdList, @Param("memberFlag") Integer memberFlag);
 
     /**
      * @return java.util.List<com.ym.mec.biz.dal.dto.CourseRepeatCheckDto>
@@ -1843,4 +1850,45 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @return java.util.List<com.ym.mec.biz.dal.entity.CourseSchedule>
      */
     List<CourseSchedule> getBeMergeCourseWithMainCourseIds(@Param("courseIds") List<Long> courseIds);
+
+    /**
+     * 删除乐团预排课课程
+     * @param musicGroupId
+     */
+    void deletePreCourse(String musicGroupId);
+
+    /**
+     * 获取预排课程列表
+     * @param musicGroupId
+     * @return
+     */
+    List<CourseSchedule> queryPreCourseListByMusicGroupId(String musicGroupId);
+
+    /**
+     * 获取预排课程列表
+     * @param classGroupId
+     * @return
+     */
+    List<CourseSchedule> queryPreCourseListByClassGroupId(Integer classGroupId);
+
+    /**
+     * 根据课程编号获取总时长
+     * @param courseScheduleIds
+     * @return
+     */
+    int sumCourseMinutes(@Param("courseScheduleIds") List<Long> courseScheduleIds);
+
+    /**
+     * 获取班级最小剩余可排课时长
+     * @param classGroupSet
+     * @return
+     */
+    List<Map<Integer, Long>> countPreSubMinutesByClassGroupId(@Param("classGroupSet") List<Integer> classGroupSet, @Param("courseDetailId") Integer courseDetailId);
+
+    /**
+     * 获取进行中或已结束的预排课课程
+     * @param musicGroupId
+     * @return
+     */
+    int queryOverPreCourseListByMusicGroupId(String musicGroupId);
 }

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java

@@ -526,4 +526,10 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
      * @return
      */
     String getStudentEduTeacher(@Param("studentId") Integer studentId);
+
+    /**
+     * 删除关联的预排课课程
+     * @param musicGroupId
+     */
+    void deletePreCourse(String musicGroupId);
 }

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleTeacherSalaryDao.java

@@ -523,6 +523,14 @@ public interface CourseScheduleTeacherSalaryDao extends BaseDAO<Long, CourseSche
 	 * @return
 	 */
 	List<Map<Long, String>> queryTeacherIdMap(@Param("courseScheduleIds") List<Long> courseScheduleIds, @Param("teacherRole") String teacherRole);
+	/**
+	 * 获取课程关联的教师列表
+	 * @zouxuan
+	 * @param courseScheduleIds
+	 * @param teacherRole
+	 * @return
+	 */
+	List<Map<Long, String>> queryTeacherNameMap(@Param("courseScheduleIds") List<Long> courseScheduleIds, @Param("teacherRole") String teacherRole);
 
 	/**
 	 * @describe 获取指定时间段内已结算的教师课酬记录
@@ -568,4 +576,5 @@ public interface CourseScheduleTeacherSalaryDao extends BaseDAO<Long, CourseSche
 	 */
 	List<Integer> getTodayHasCourseTeacherIds();
 
+    void deletePreCourse(String musicGroupId);
 }

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

@@ -39,6 +39,7 @@ public interface ExtracurricularExercisesDao extends BaseDAO<Long, Extracurricul
                                                                     @Param("musicGroupId") String musicGroupId,
                                                                     @Param("classGroupId") Long classGroupId,
                                                                     @Param("subjectId") Integer subjectId,
-                                                                    @Param("search") String search);
+                                                                    @Param("search") String search,
+                                                                    @Param("hasMember") Integer hasMember);
 
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MemberFeeSettingDao.java

@@ -0,0 +1,11 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.biz.dal.entity.MemberFeeSetting;
+import org.apache.ibatis.annotations.Param;
+
+public interface MemberFeeSettingDao extends BaseDAO<Integer, MemberFeeSetting> {
+
+
+    MemberFeeSetting findByRankIdAndOrganId(@Param("organId") Integer organId, @Param("rankId") Integer rankId);
+}

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MemberPrivilegesItemDao.java

@@ -0,0 +1,22 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.biz.dal.entity.MemberPrivilegesItem;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface MemberPrivilegesItemDao extends BaseDAO<Integer, MemberPrivilegesItem> {
+
+
+    /**
+     * 获取所有功能列表
+     * @param parentId
+     * @return
+     */
+    List<MemberPrivilegesItem> findList(@Param("parentId") Integer parentId);
+
+    void batchDel(@Param("collect") List<Integer> collect);
+    
+    List<MemberPrivilegesItem> findById(List<Integer> idList);
+}

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MemberRankOrganizationFeeMapperDao.java

@@ -0,0 +1,11 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.biz.dal.entity.MemberRankOrganizationFeeMapper;
+import org.apache.ibatis.annotations.Param;
+
+public interface MemberRankOrganizationFeeMapperDao extends BaseDAO<Integer, MemberRankOrganizationFeeMapper> {
+
+
+    MemberRankOrganizationFeeMapper findByOrganIdAndRankId(@Param("organId") Integer organId, @Param("memberRankSettingId") Integer memberRankSettingId);
+}

+ 17 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MemberRankPrivilegesDao.java

@@ -0,0 +1,17 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.MemberRankPrivileges;
+import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface MemberRankPrivilegesDao extends BaseDAO<Integer, MemberRankPrivileges>{
+
+
+    void batchInsert(@Param("memberRankSettingId") Integer memberRankSettingId, @Param("memberPrivilegesItemIdList") List<Integer> memberPrivilegesItemIdList);
+
+    List<MemberRankPrivileges> findByRankSettingId(Integer memberRankSettingId);
+
+    void deleteByRankSettingId(Integer memberRankSettingId);
+}

+ 13 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MemberRankSettingDao.java

@@ -0,0 +1,13 @@
+package com.ym.mec.biz.dal.dao;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.ym.mec.biz.dal.entity.MemberRankSetting;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface MemberRankSettingDao extends BaseDAO<Integer, MemberRankSetting> {
+
+	List<MemberRankSetting> queryListByIsDefault(@Param("isDefault") Boolean isDefault);
+}

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentMemberCourseDetailDao.java

@@ -0,0 +1,7 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentMemberCourseDetail;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface MusicGroupPaymentStudentMemberCourseDetailDao extends BaseDAO<Long, MusicGroupPaymentStudentMemberCourseDetail> {
+}

+ 36 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupSchoolTermCourseDetailDao.java

@@ -0,0 +1,36 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.MusicGroupSchoolTermStudentCourseDetail;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.biz.dal.entity.MusicGroupSchoolTermCourseDetail;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
+
+public interface MusicGroupSchoolTermCourseDetailDao extends BaseDAO<Integer, MusicGroupSchoolTermCourseDetail> {
+
+
+    /**
+     * 获取所选时间乐团的预排课明细
+     * @param musicGroupId
+     * @param startCourseDate
+     * @return
+     */
+    MusicGroupSchoolTermCourseDetail findByCourseDateAndMusicGroupId(@Param("musicGroupId") String musicGroupId,
+                                                                     @Param("startCourseDate") Date startCourseDate,
+                                                                     @Param("courseFlag") Integer courseFlag);
+
+    /**
+     * 获取所选时间乐团的预排课明细
+     * @param musicGroupId
+     * @return
+     */
+    List<MusicGroupSchoolTermCourseDetail> findByMusicGroupId(@Param("musicGroupId") String musicGroupId);
+
+    /**
+     * 获取所有未确认的预排课数据
+     * @return
+     */
+    List<MusicGroupSchoolTermCourseDetail> queryAllNoCourse();
+}

+ 102 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupSchoolTermStudentCourseDetailDao.java

@@ -0,0 +1,102 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.biz.dal.entity.MusicGroupSchoolTermStudentCourseDetail;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface MusicGroupSchoolTermStudentCourseDetailDao extends BaseDAO<Long, MusicGroupSchoolTermStudentCourseDetail> {
+
+
+    /**
+     * 初始化会员团学员排课详情
+     * @param studentCourseDetail
+     * @param studentIds
+     */
+    void init(@Param("studentCourseDetail") MusicGroupSchoolTermStudentCourseDetail studentCourseDetail, @Param("studentIds") List<Integer> studentIds);
+
+    /**
+     * 删除预排课计划
+     * @param courseDetailId
+     */
+    void deleteByDetailId(@Param("courseDetailId") Integer courseDetailId, @Param("studentId") Integer studentId);
+
+    /**
+     * 获取预排课计划
+     * @param courseDetailId
+     */
+    List<MusicGroupSchoolTermStudentCourseDetail> findByDetailId(Integer courseDetailId);
+
+    /**
+     * 获取所选学员最小可排课时长
+     * @param musicGroupSchoolTermCourseDetailId
+     * @param studentIds
+     * @return
+     */
+    int getMixCourseMinutes(@Param("courseDetailId") Integer musicGroupSchoolTermCourseDetailId, @Param("studentIds") List<Integer> studentIds);
+
+    /**
+     * 获取所选学员最大的已消耗的单技课时长
+     * @param musicGroupSchoolTermCourseDetailId
+     * @param studentIds
+     * @return
+     */
+    int getMaxSingleCourseMinutes(@Param("courseDetailId") Integer musicGroupSchoolTermCourseDetailId, @Param("studentIds") List<Integer> studentIds);
+
+    /**
+     * 获取所选学员最大的已消耗的合奏课时长
+     * @param musicGroupSchoolTermCourseDetailId
+     * @param studentIds
+     * @return
+     */
+    int getMaxMixCourseMinutes(@Param("courseDetailId") Integer musicGroupSchoolTermCourseDetailId, @Param("studentIds") List<Integer> studentIds);
+
+    /**
+     * 是否有学员课时没有消耗
+     * @param musicGroupSchoolTermCourseDetailId
+     * @return
+     */
+    boolean checkNoCourse(Integer musicGroupSchoolTermCourseDetailId);
+
+    /**
+     * 更新学员排课时长
+     * @param musicGroupSchoolTermCourseDetailId
+     * @param preMemberCourseMinutes
+     * @param mixCourseMinutes
+     * @param singleCourseMinutes
+     * @param studentIds
+     */
+    void updateMinutes(@Param("musicGroupSchoolTermCourseDetailId") Integer musicGroupSchoolTermCourseDetailId,
+                       @Param("preMemberCourseMinutes") Integer preMemberCourseMinutes,
+                       @Param("mixCourseMinutes") Integer mixCourseMinutes,
+                       @Param("singleCourseMinutes") Integer singleCourseMinutes,
+                       @Param("studentIds") List<Integer> studentIds);
+
+    /**
+     * 更新学员排课时长
+     * @param musicGroupSchoolTermCourseDetailId
+     * @param preMemberCourseMinutes
+     * @param mixCourseMinutes
+     * @param singleCourseMinutes
+     */
+    void cutMinutes(@Param("musicGroupSchoolTermCourseDetailId") Integer musicGroupSchoolTermCourseDetailId,
+                       @Param("preMemberCourseMinutes") Integer preMemberCourseMinutes,
+                       @Param("mixCourseMinutes") Integer mixCourseMinutes,
+                       @Param("singleCourseMinutes") Integer singleCourseMinutes,
+                       @Param("studentId") Integer studentId);
+
+    /**
+     * 清空预排课
+     * @param musicGroupSchoolTermCourseDetailId
+     */
+    void cleanMinutes(Integer musicGroupSchoolTermCourseDetailId);
+
+    /**
+     * 获取学员预排课计划
+     * @param courseDetailId
+     * @param userId
+     * @return
+     */
+    MusicGroupSchoolTermStudentCourseDetailDao findByDetailIdAndStudentId(@Param("courseDetailId") Integer courseDetailId, @Param("userId") Integer userId);
+}

+ 8 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentDao.java

@@ -18,7 +18,7 @@ import java.util.Set;
 public interface StudentDao extends com.ym.mec.common.dal.BaseDAO<Integer, Student> {
 	
 	Student getLocked(Integer userId);
-
+	
     int lockUser(@Param("userId") Integer userId);
 
     List<Student> findByStudentIds(@Param("studentIds") List<Integer> studentIds);
@@ -223,4 +223,11 @@ public interface StudentDao extends com.ym.mec.common.dal.BaseDAO<Integer, Stude
      * @return int
      */
     int updateNewStudentsToOld(@Param("userIds") List<Integer> userIds);
+
+    /**
+     * 获取有会员的学员列表
+     * @param studentIdsStr
+     * @return
+     */
+    int getMemberNum(@Param("studentIdsStr") String studentIdsStr);
 }

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

@@ -285,6 +285,14 @@ public interface StudentRegistrationDao extends BaseDAO<Long, StudentRegistratio
     List<Map<String, Integer>> countNormalNum(String musicGroupIds);
 
     /**
+     * 获取乐团在读人数
+     *
+     * @param musicGroupId
+     * @return
+     */
+    List<Integer> queryNormalUser(String musicGroupId);
+
+    /**
      * 获取学员基本信息
      *
      * @param mobile
@@ -600,4 +608,11 @@ public interface StudentRegistrationDao extends BaseDAO<Long, StudentRegistratio
      * @return
      */
     int countPayAndCheckNum(@Param("musicGroupId") String musicGroupId);
+
+    /**
+     * 是否所有的学员都在班
+     * @param musicGroupId
+     * @return
+     */
+    boolean checkHasNotClass(@Param("musicGroupId") String musicGroupId);
 }

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroup4MixDto.java

@@ -40,6 +40,9 @@ public class ClassGroup4MixDto implements Cloneable{
     @ApiModelProperty(value = "排课次数", required = true)
     private Integer courseTimes;
 
+    @ApiModelProperty(value = "排课时长", required = true)
+    private Integer courseMinutes;
+
     @ApiModelProperty(value = "课程类型", required = true)
     private CourseSchedule.CourseScheduleType courseType;
 
@@ -73,6 +76,25 @@ public class ClassGroup4MixDto implements Cloneable{
     @ApiModelProperty(value = "确认生成课程")
     private Boolean confirmGenerate;
 
+    @ApiModelProperty(value = "预排课学期编号")
+    private Integer musicGroupSchoolTermCourseDetailId;
+
+    public Integer getMusicGroupSchoolTermCourseDetailId() {
+        return musicGroupSchoolTermCourseDetailId;
+    }
+
+    public void setMusicGroupSchoolTermCourseDetailId(Integer musicGroupSchoolTermCourseDetailId) {
+        this.musicGroupSchoolTermCourseDetailId = musicGroupSchoolTermCourseDetailId;
+    }
+
+    public Integer getCourseMinutes() {
+        return courseMinutes;
+    }
+
+    public void setCourseMinutes(Integer courseMinutes) {
+        this.courseMinutes = courseMinutes;
+    }
+
     public Boolean getConfirmGenerate() {
         return confirmGenerate;
     }

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroupTeachersDto.java

@@ -21,6 +21,28 @@ public class ClassGroupTeachersDto extends ClassGroup {
 
 	private String bishopTeacherName;
 
+	/** 预排课时 */
+	private Integer preTotalClassTimes;
+
+	/** 剩余可排课时长 */
+	private Integer preSubMinutes;
+
+	public Integer getPreSubMinutes() {
+		return preSubMinutes;
+	}
+
+	public void setPreSubMinutes(Integer preSubMinutes) {
+		this.preSubMinutes = preSubMinutes;
+	}
+
+	public Integer getPreTotalClassTimes() {
+		return preTotalClassTimes;
+	}
+
+	public void setPreTotalClassTimes(Integer preTotalClassTimes) {
+		this.preTotalClassTimes = preTotalClassTimes;
+	}
+
 	public String getTeachingTeacherName() {
 		return teachingTeacherName;
 	}

+ 38 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CloudTeacherOrderDto.java

@@ -0,0 +1,38 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.entity.CloudTeacherOrder;
+import com.ym.mec.biz.dal.entity.MemberRankSetting;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+
+public class CloudTeacherOrderDto {
+
+	private CloudTeacherOrder cloudTeacherOrder;
+	
+	private StudentPaymentOrder studentPaymentOrder;
+	
+	private MemberRankSetting memberRankSetting;
+
+	public CloudTeacherOrder getCloudTeacherOrder() {
+		return cloudTeacherOrder;
+	}
+
+	public void setCloudTeacherOrder(CloudTeacherOrder cloudTeacherOrder) {
+		this.cloudTeacherOrder = cloudTeacherOrder;
+	}
+
+	public StudentPaymentOrder getStudentPaymentOrder() {
+		return studentPaymentOrder;
+	}
+
+	public void setStudentPaymentOrder(StudentPaymentOrder studentPaymentOrder) {
+		this.studentPaymentOrder = studentPaymentOrder;
+	}
+
+	public MemberRankSetting getMemberRankSetting() {
+		return memberRankSetting;
+	}
+
+	public void setMemberRankSetting(MemberRankSetting memberRankSetting) {
+		this.memberRankSetting = memberRankSetting;
+	}
+}

+ 32 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CourseHomeworkStudentDetailDto.java

@@ -57,8 +57,40 @@ public class CourseHomeworkStudentDetailDto {
 
     private String teacherName;
 
+    @ApiModelProperty(value = "伴奏编号",required = false)
+    private Integer musicScoreId;
+
+    private String musicScoreName;
+
     private String type;
 
+    @ApiModelProperty(value = "是否有会员",required = false)
+    private Integer hasMember;
+
+    public Integer getHasMember() {
+        return hasMember;
+    }
+
+    public void setHasMember(Integer hasMember) {
+        this.hasMember = hasMember;
+    }
+
+    public Integer getMusicScoreId() {
+        return musicScoreId;
+    }
+
+    public void setMusicScoreId(Integer musicScoreId) {
+        this.musicScoreId = musicScoreId;
+    }
+
+    public String getMusicScoreName() {
+        return musicScoreName;
+    }
+
+    public void setMusicScoreName(String musicScoreName) {
+        this.musicScoreName = musicScoreName;
+    }
+
     public String getType() {
         return type;
     }

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

@@ -31,6 +31,9 @@ public class CourseTimeDto {
     @ApiModelProperty(value = "预计排课次数")
     private int expectCourseNum;
 
+    @ApiModelProperty(value = "预计排课时长")
+    private int expectCourseMinutes;
+
     @ApiModelProperty(value = "已生成课程数量")
     private int courseNum;
 
@@ -40,6 +43,14 @@ public class CourseTimeDto {
     @ApiModelProperty(value = "老师设置", required = true)
     private List<ClassGroupTeacherMapper> classGroupTeacherMapperList;
 
+    public int getExpectCourseMinutes() {
+        return expectCourseMinutes;
+    }
+
+    public void setExpectCourseMinutes(int expectCourseMinutes) {
+        this.expectCourseMinutes = expectCourseMinutes;
+    }
+
     public List<ClassGroupTeacherMapper> getClassGroupTeacherMapperList() {
         return classGroupTeacherMapperList;
     }

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ExtraExerciseStudentsDto.java

@@ -17,6 +17,10 @@ public class ExtraExerciseStudentsDto extends ExtracurricularExercisesReply {
 
     private String teacherName;
 
+    private Integer musicScoreId;
+
+    private String musicScoreName;
+
     private String headUrl;
 
     private String title;
@@ -37,6 +41,22 @@ public class ExtraExerciseStudentsDto extends ExtracurricularExercisesReply {
 
     private String existVipCourseStr;
 
+    public Integer getMusicScoreId() {
+        return musicScoreId;
+    }
+
+    public void setMusicScoreId(Integer musicScoreId) {
+        this.musicScoreId = musicScoreId;
+    }
+
+    public String getMusicScoreName() {
+        return musicScoreName;
+    }
+
+    public void setMusicScoreName(String musicScoreName) {
+        this.musicScoreName = musicScoreName;
+    }
+
     public String getHeadUrl() {
         return headUrl;
     }

+ 26 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MemberFeeDto.java

@@ -0,0 +1,26 @@
+package com.ym.mec.biz.dal.dto;
+
+import java.math.BigDecimal;
+
+public class MemberFeeDto {
+
+    private BigDecimal currentAmount;
+
+    private BigDecimal originalAmount;
+
+    public BigDecimal getCurrentAmount() {
+        return currentAmount;
+    }
+
+    public void setCurrentAmount(BigDecimal currentAmount) {
+        this.currentAmount = currentAmount;
+    }
+
+    public BigDecimal getOriginalAmount() {
+        return originalAmount;
+    }
+
+    public void setOriginalAmount(BigDecimal originalAmount) {
+        this.originalAmount = originalAmount;
+    }
+}

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentCalenderAuditDto.java

@@ -83,6 +83,28 @@ public class MusicGroupPaymentCalenderAuditDto {
     @ApiModelProperty(value = "是否赠送网管课",required = false)
     private Boolean isGiveMusicNetwork;
 
+    @ApiModelProperty(value = "会员原价",required = false)
+    private BigDecimal originalMemberPaymentAmount = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "会员现价",required = false)
+    private BigDecimal memberPaymentAmount = BigDecimal.ZERO;
+
+    public BigDecimal getOriginalMemberPaymentAmount() {
+        return originalMemberPaymentAmount;
+    }
+
+    public void setOriginalMemberPaymentAmount(BigDecimal originalMemberPaymentAmount) {
+        this.originalMemberPaymentAmount = originalMemberPaymentAmount;
+    }
+
+    public BigDecimal getMemberPaymentAmount() {
+        return memberPaymentAmount;
+    }
+
+    public void setMemberPaymentAmount(BigDecimal memberPaymentAmount) {
+        this.memberPaymentAmount = memberPaymentAmount;
+    }
+
     public Integer getMusicGroupOrganizationCourseSettingsId() {
         return musicGroupOrganizationCourseSettingsId;
     }

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

@@ -28,6 +28,7 @@ public class MusicGroupPaymentCalenderDto {
 
 	private Boolean isGiveMusicNetwork;
 
+	//进行中加学员时,用户选择加入的班级
 	private String attribute1;
 
 	private String attribute2;
@@ -42,6 +43,39 @@ public class MusicGroupPaymentCalenderDto {
 
 	private BigDecimal masterTotalPrice = BigDecimal.ZERO;
 
+	//会员有效期(月)
+	private Integer memberValidDate;
+
+	//会员申请付款金额
+	private BigDecimal memberPaymentAmount = BigDecimal.ZERO;
+
+	//会员等级编号
+	private Integer memberRankSettingId;
+
+	public Integer getMemberValidDate() {
+		return memberValidDate;
+	}
+
+	public void setMemberValidDate(Integer memberValidDate) {
+		this.memberValidDate = memberValidDate;
+	}
+
+	public BigDecimal getMemberPaymentAmount() {
+		return memberPaymentAmount;
+	}
+
+	public void setMemberPaymentAmount(BigDecimal memberPaymentAmount) {
+		this.memberPaymentAmount = memberPaymentAmount;
+	}
+
+	public Integer getMemberRankSettingId() {
+		return memberRankSettingId;
+	}
+
+	public void setMemberRankSettingId(Integer memberRankSettingId) {
+		this.memberRankSettingId = memberRankSettingId;
+	}
+
 	@ApiModelProperty(value = "跨团合并时缴费项目中学员的缴费明细")
 	private List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails;
 

+ 18 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupSubjectGoodsAndInfoDto.java

@@ -1,12 +1,18 @@
 package com.ym.mec.biz.dal.dto;
 
-import com.ym.mec.biz.dal.entity.*;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
+import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.MemberPrivilegesItem;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
+
 /**
  * 乐团报名缴费相关信息
  */
@@ -38,6 +44,9 @@ public class MusicGroupSubjectGoodsAndInfoDto {
 
     @ApiModelProperty(value = "乐团云教练+价格",required = false)
     private BigDecimal cloudTeacherPlusFee;
+    
+    @ApiModelProperty(value = "会员权益",required = false)
+    private List<MemberPrivilegesItem> memberPrivilegesItemList;
 
     public Map getCourseScheduleInfo() {
         return CourseScheduleInfo;
@@ -110,4 +119,12 @@ public class MusicGroupSubjectGoodsAndInfoDto {
     public void setCloudTeacherPlusFee(BigDecimal cloudTeacherPlusFee) {
         this.cloudTeacherPlusFee = cloudTeacherPlusFee;
     }
+
+	public List<MemberPrivilegesItem> getMemberPrivilegesItemList() {
+		return memberPrivilegesItemList;
+	}
+
+	public void setMemberPrivilegesItemList(List<MemberPrivilegesItem> memberPrivilegesItemList) {
+		this.memberPrivilegesItemList = memberPrivilegesItemList;
+	}
 }

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RemainCourseTypeDurationDto.java

@@ -4,8 +4,10 @@ import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 
 public class RemainCourseTypeDurationDto {
 
+	//课程类型
 	private CourseScheduleType courseType;
-	
+
+	//剩余时长
 	private Integer remainMinutes;
 	
 	private Integer tempMergedCourseNum;

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/TeacherAttendanceDto.java

@@ -4,6 +4,7 @@ import com.ym.mec.biz.dal.entity.ClassGroup;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 import com.ym.mec.biz.dal.enums.CourseStatusEnum;
+import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
 import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -98,10 +99,32 @@ public class TeacherAttendanceDto {
     @ApiModelProperty(value = "是否已经发送过到课提醒:0否,1已发送")
     private int normalRemind;
 
+    @ApiModelProperty(value = "是否有会员:0否,1已发送")
+    private int hasMember;
+
+    @ApiModelProperty(value = "乐团收费方式")
+    private CourseViewTypeEnum courseViewType;
+
     private Integer enableStudentAttendanceTimeRange;
 
     private Integer enableStudentAttendanceTimeRangeVip;
 
+    public CourseViewTypeEnum getCourseViewType() {
+        return courseViewType;
+    }
+
+    public void setCourseViewType(CourseViewTypeEnum courseViewType) {
+        this.courseViewType = courseViewType;
+    }
+
+    public int getHasMember() {
+        return hasMember;
+    }
+
+    public void setHasMember(int hasMember) {
+        this.hasMember = hasMember;
+    }
+
     public CourseSchedule.CourseScheduleType getCourseType() {
         return courseType;
     }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CloudTeacherOrder.java

@@ -102,6 +102,8 @@ public class CloudTeacherOrder {
     private Date updateTime;
 
     private String musicGroupId;
+    
+    private StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
 
     public Long getId() {
         return id;
@@ -251,4 +253,12 @@ public class CloudTeacherOrder {
     public void setMusicGroupId(String musicGroupId) {
         this.musicGroupId = musicGroupId;
     }
+
+	public StudentPaymentOrder getStudentPaymentOrder() {
+		return studentPaymentOrder;
+	}
+
+	public void setStudentPaymentOrder(StudentPaymentOrder studentPaymentOrder) {
+		this.studentPaymentOrder = studentPaymentOrder;
+	}
 }

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

@@ -52,6 +52,17 @@ public class CourseHomework {
 	@ApiModelProperty(value = "预计完成人数",required = false)
 	private Integer expectNum;
 
+	@ApiModelProperty(value = "伴奏编号",required = false)
+	private Integer musicScoreId;
+
+	public Integer getMusicScoreId() {
+		return musicScoreId;
+	}
+
+	public void setMusicScoreId(Integer musicScoreId) {
+		this.musicScoreId = musicScoreId;
+	}
+
 	public Date getExpiryDate() {
 		return expiryDate;
 	}

+ 39 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseSchedule.java

@@ -29,9 +29,12 @@ public class CourseSchedule {
 
 	public enum CourseScheduleType implements BaseEnum<String, CourseScheduleType> {
 
-		SINGLE("SINGLE", "声部课"), MIX("MIX", "合奏课"), HIGH("HIGH", "小班课"), VIP("VIP", "vip课"), DEMO("DEMO", "试听课"), COMPREHENSIVE("COMPREHENSIVE", "综合课"), PRACTICE(
-				"PRACTICE", "网管课"), ENLIGHTENMENT("ENLIGHTENMENT", "启蒙课"), TRAINING_SINGLE("TRAINING_SINGLE", "集训声部课"), TRAINING_MIX("TRAINING_MIX", "集训合奏课"), CLASSROOM(
-				"CLASSROOM", "课堂课"),COMM("COMM","对外课程"),HIGH_ONLINE("HIGH_ONLINE","网络基础训练课"),MUSIC_NETWORK("MUSIC_NETWORK","乐团网管课");
+		SINGLE("SINGLE", "声部课"), MIX("MIX", "合奏课"), HIGH("HIGH", "小班课"), VIP("VIP", "vip课"),
+		DEMO("DEMO", "试听课"), COMPREHENSIVE("COMPREHENSIVE", "综合课"), PRACTICE(
+				"PRACTICE", "网管课"), ENLIGHTENMENT("ENLIGHTENMENT", "启蒙课"), TRAINING_SINGLE("TRAINING_SINGLE", "集训声部课"),
+		TRAINING_MIX("TRAINING_MIX", "集训合奏课"), CLASSROOM(
+				"CLASSROOM", "课堂课"),COMM("COMM","对外课程"),HIGH_ONLINE("HIGH_ONLINE","网络基础训练课"),
+		MUSIC_NETWORK("MUSIC_NETWORK","乐团网管课");
 
 		private String code;
 
@@ -173,6 +176,39 @@ public class CourseSchedule {
 
 	private int isSignOut = 3;
 
+	//是否是会员收费的排课
+	private Integer memberFlag = 0;
+
+	//是否是预排课
+	private Integer preCourseFlag = 0;
+
+	//课程调整不的超过该时间限制
+	private Date validEndTime;
+
+	public Date getValidEndTime() {
+		return validEndTime;
+	}
+
+	public void setValidEndTime(Date validEndTime) {
+		this.validEndTime = validEndTime;
+	}
+
+	public Integer getPreCourseFlag() {
+		return preCourseFlag;
+	}
+
+	public void setPreCourseFlag(Integer preCourseFlag) {
+		this.preCourseFlag = preCourseFlag;
+	}
+
+	public Integer getMemberFlag() {
+		return memberFlag;
+	}
+
+	public void setMemberFlag(Integer memberFlag) {
+		this.memberFlag = memberFlag;
+	}
+
 	public String getTeachingTeacherNames() {
 		return teachingTeacherNames;
 	}

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ExtracurricularExercises.java

@@ -58,6 +58,26 @@ public class ExtracurricularExercises {
 
 	private ImSendTypeEnum msgType = ImSendTypeEnum.TXT;
 
+	private Integer musicScoreId;
+
+	private String musicScoreName;
+
+	public String getMusicScoreName() {
+		return musicScoreName;
+	}
+
+	public void setMusicScoreName(String musicScoreName) {
+		this.musicScoreName = musicScoreName;
+	}
+
+	public Integer getMusicScoreId() {
+		return musicScoreId;
+	}
+
+	public void setMusicScoreId(Integer musicScoreId) {
+		this.musicScoreId = musicScoreId;
+	}
+
 	public ImSendTypeEnum getMsgType() {
 		return msgType;
 	}

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ExtracurricularExercisesMessage.java

@@ -31,6 +31,8 @@ public class ExtracurricularExercisesMessage {
 
 	private ImSendTypeEnum msgType = ImSendTypeEnum.TXT;
 
+	private Integer musicScoreId;
+
 	public ImSendTypeEnum getMsgType() {
 		return msgType;
 	}

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ImGroupMember.java

@@ -29,7 +29,7 @@ public class ImGroupMember {
 	
 	/**  */
 	private java.util.Date updateTime;
-	
+
 	public void setId(Long id){
 		this.id = id;
 	}

+ 114 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MemberFeeSetting.java

@@ -0,0 +1,114 @@
+package com.ym.mec.biz.dal.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(member_fee_setting):
+ */
+public class MemberFeeSetting {
+
+	/**  */
+	private Integer id;
+	
+	/**  */
+	private java.math.BigDecimal currentDayFee;
+	
+	/**  */
+	private java.math.BigDecimal originalDayFee;
+	
+	/**  */
+	private java.math.BigDecimal currentMonthFee;
+	
+	/**  */
+	private java.math.BigDecimal originalMonthFee;
+	
+	/**  */
+	private java.math.BigDecimal currentHalfYearFee;
+	
+	/**  */
+	private java.math.BigDecimal originalHalfYearFee;
+	
+	/**  */
+	private java.math.BigDecimal currentYearFee;
+	
+	/**  */
+	private java.math.BigDecimal originalYearFee;
+	
+	public void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setCurrentDayFee(java.math.BigDecimal currentDayFee){
+		this.currentDayFee = currentDayFee;
+	}
+	
+	public java.math.BigDecimal getCurrentDayFee(){
+		return this.currentDayFee;
+	}
+			
+	public void setOriginalDayFee(java.math.BigDecimal originalDayFee){
+		this.originalDayFee = originalDayFee;
+	}
+	
+	public java.math.BigDecimal getOriginalDayFee(){
+		return this.originalDayFee;
+	}
+			
+	public void setCurrentMonthFee(java.math.BigDecimal currentMonthFee){
+		this.currentMonthFee = currentMonthFee;
+	}
+	
+	public java.math.BigDecimal getCurrentMonthFee(){
+		return this.currentMonthFee;
+	}
+			
+	public void setOriginalMonthFee(java.math.BigDecimal originalMonthFee){
+		this.originalMonthFee = originalMonthFee;
+	}
+	
+	public java.math.BigDecimal getOriginalMonthFee(){
+		return this.originalMonthFee;
+	}
+			
+	public void setCurrentHalfYearFee(java.math.BigDecimal currentHalfYearFee){
+		this.currentHalfYearFee = currentHalfYearFee;
+	}
+	
+	public java.math.BigDecimal getCurrentHalfYearFee(){
+		return this.currentHalfYearFee;
+	}
+			
+	public void setOriginalHalfYearFee(java.math.BigDecimal originalHalfYearFee){
+		this.originalHalfYearFee = originalHalfYearFee;
+	}
+	
+	public java.math.BigDecimal getOriginalHalfYearFee(){
+		return this.originalHalfYearFee;
+	}
+			
+	public void setCurrentYearFee(java.math.BigDecimal currentYearFee){
+		this.currentYearFee = currentYearFee;
+	}
+	
+	public java.math.BigDecimal getCurrentYearFee(){
+		return this.currentYearFee;
+	}
+			
+	public void setOriginalYearFee(java.math.BigDecimal originalYearFee){
+		this.originalYearFee = originalYearFee;
+	}
+	
+	public java.math.BigDecimal getOriginalYearFee(){
+		return this.originalYearFee;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 115 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MemberPrivilegesItem.java

@@ -0,0 +1,115 @@
+package com.ym.mec.biz.dal.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 对应数据库表(member_privileges_item):
+ */
+public class MemberPrivilegesItem {
+
+	/**  */
+	private Integer id;
+	
+	/** 名称 */
+	private String name;
+	
+	/** 描述 */
+	private String desc;
+	
+	/** 编码 */
+	private String code;
+
+	private String path;
+	
+	/**  */
+	private Integer parentId = 0;
+
+	/**  */
+	private java.util.Date createTime;
+	
+	/**  */
+	private java.util.Date updateTime;
+
+	private List<MemberPrivilegesItem> memberPrivilegesItems = new ArrayList<MemberPrivilegesItem>();
+
+	public String getPath() {
+		return path;
+	}
+
+	public void setPath(String path) {
+		this.path = path;
+	}
+
+	public List<MemberPrivilegesItem> getMemberPrivilegesItems() {
+		return memberPrivilegesItems;
+	}
+
+	public void setMemberPrivilegesItems(List<MemberPrivilegesItem> memberPrivilegesItems) {
+		this.memberPrivilegesItems = memberPrivilegesItems;
+	}
+
+	public void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setName(String name){
+		this.name = name;
+	}
+	
+	public String getName(){
+		return this.name;
+	}
+			
+	public void setDesc(String desc){
+		this.desc = desc;
+	}
+	
+	public String getDesc(){
+		return this.desc;
+	}
+			
+	public void setCode(String code){
+		this.code = code;
+	}
+	
+	public String getCode(){
+		return this.code;
+	}
+			
+	public void setParentId(Integer parentId){
+		this.parentId = parentId;
+	}
+	
+	public Integer getParentId(){
+		return this.parentId;
+	}
+			
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+	
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 121 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MemberRankOrganizationFeeMapper.java

@@ -0,0 +1,121 @@
+package com.ym.mec.biz.dal.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(member_rank_organization_fee_mapper):
+ */
+public class MemberRankOrganizationFeeMapper {
+
+	/**  */
+	private Integer id;
+	
+	/**  */
+	private Integer organId;
+	
+	/**  */
+	private Integer memberRankSettingId;
+
+	/**  */
+	private Integer operatorId;
+	
+	/**  */
+	private java.util.Date createTime;
+	
+	/**  */
+	private java.util.Date updateTime;
+
+	private String rankName;
+
+	private String organName;
+
+	private Integer memberFeeSettingId;
+
+	private MemberFeeSetting memberFeeSetting;
+	
+	public MemberFeeSetting getMemberFeeSetting() {
+		return memberFeeSetting;
+	}
+
+	public void setMemberFeeSetting(MemberFeeSetting memberFeeSetting) {
+		this.memberFeeSetting = memberFeeSetting;
+	}
+
+	public Integer getMemberFeeSettingId() {
+		return memberFeeSettingId;
+	}
+
+	public void setMemberFeeSettingId(Integer memberFeeSettingId) {
+		this.memberFeeSettingId = memberFeeSettingId;
+	}
+
+	public String getRankName() {
+		return rankName;
+	}
+
+	public void setRankName(String rankName) {
+		this.rankName = rankName;
+	}
+
+	public String getOrganName() {
+		return organName;
+	}
+
+	public void setOrganName(String organName) {
+		this.organName = organName;
+	}
+
+	public void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setOrganId(Integer organId){
+		this.organId = organId;
+	}
+	
+	public Integer getOrganId(){
+		return this.organId;
+	}
+			
+	public void setMemberRankSettingId(Integer memberRankSettingId){
+		this.memberRankSettingId = memberRankSettingId;
+	}
+	
+	public Integer getMemberRankSettingId(){
+		return this.memberRankSettingId;
+	}
+
+	public void setOperatorId(Integer operatorId){
+		this.operatorId = operatorId;
+	}
+	
+	public Integer getOperatorId(){
+		return this.operatorId;
+	}
+			
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+	
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 37 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MemberRankPrivileges.java

@@ -0,0 +1,37 @@
+package com.ym.mec.biz.dal.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(member_rank_privileges):
+ */
+public class MemberRankPrivileges {
+
+	/** 会员等级编号 */
+	private Integer memberRankId;
+	
+	/** 会员特权编号 */
+	private Integer memberPrivilegesId;
+	
+	public void setMemberRankId(Integer memberRankId){
+		this.memberRankId = memberRankId;
+	}
+	
+	public Integer getMemberRankId(){
+		return this.memberRankId;
+	}
+			
+	public void setMemberPrivilegesId(Integer memberPrivilegesId){
+		this.memberPrivilegesId = memberPrivilegesId;
+	}
+	
+	public Integer getMemberPrivilegesId(){
+		return this.memberPrivilegesId;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 134 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MemberRankSetting.java

@@ -0,0 +1,134 @@
+package com.ym.mec.biz.dal.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import java.util.List;
+
+/**
+ * 对应数据库表(member_rank_setting):
+ */
+public class MemberRankSetting {
+
+	/**  */
+	private Integer id;
+	
+	/**  */
+	private String name;
+	
+	/**  */
+	private String intro;
+	
+	/**  */
+	private String icon;
+	
+	private Boolean isDefault;
+
+	/**  */
+	private List<Integer> memberPrivilegesItemIdList;
+	
+	private List<MemberPrivilegesItem> memberPrivilegesItemList;
+	
+	/**  */
+	private java.util.Date createTime;
+	
+	/**  */
+	private java.util.Date updateTime;
+
+	private List<MemberRankPrivileges> memberRankPrivileges;
+	
+	private MemberFeeSetting memberFeeSetting;
+
+	public List<MemberRankPrivileges> getMemberRankPrivileges() {
+		return memberRankPrivileges;
+	}
+
+	public void setMemberRankPrivileges(List<MemberRankPrivileges> memberRankPrivileges) {
+		this.memberRankPrivileges = memberRankPrivileges;
+	}
+
+	public void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setName(String name){
+		this.name = name;
+	}
+	
+	public String getName(){
+		return this.name;
+	}
+			
+	public void setIntro(String intro){
+		this.intro = intro;
+	}
+	
+	public String getIntro(){
+		return this.intro;
+	}
+			
+	public void setIcon(String icon){
+		this.icon = icon;
+	}
+	
+	public String getIcon(){
+		return this.icon;
+	}
+
+	public Boolean getIsDefault() {
+		return isDefault;
+	}
+
+	public void setIsDefault(Boolean isDefault) {
+		this.isDefault = isDefault;
+	}
+
+	public List<Integer> getMemberPrivilegesItemIdList() {
+		return memberPrivilegesItemIdList;
+	}
+
+	public void setMemberPrivilegesItemIdList(List<Integer> memberPrivilegesItemIdList) {
+		this.memberPrivilegesItemIdList = memberPrivilegesItemIdList;
+	}
+
+	public List<MemberPrivilegesItem> getMemberPrivilegesItemList() {
+		return memberPrivilegesItemList;
+	}
+
+	public void setMemberPrivilegesItemList(List<MemberPrivilegesItem> memberPrivilegesItemList) {
+		this.memberPrivilegesItemList = memberPrivilegesItemList;
+	}
+
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+	
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+
+	public MemberFeeSetting getMemberFeeSetting() {
+		return memberFeeSetting;
+	}
+
+	public void setMemberFeeSetting(MemberFeeSetting memberFeeSetting) {
+		this.memberFeeSetting = memberFeeSetting;
+	}
+
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 61 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java

@@ -74,7 +74,8 @@ public class MusicGroupPaymentCalender {
 	}
 
 	public enum PaymentType implements BaseEnum<String, PaymentType> {
-		ADD_STUDENT("新增学员"), ADD_COURSE("临时加课"), MUSIC_APPLY("乐团报名"),MUSIC_RENEW("乐团续费"),SPAN_GROUP_CLASS_ADJUST("跨团班级调整");
+		ADD_STUDENT("新增学员"), ADD_COURSE("临时加课"), MUSIC_APPLY("乐团报名"),
+		MUSIC_RENEW("乐团续费"),SPAN_GROUP_CLASS_ADJUST("跨团班级调整");
 
 		private String desc;
 
@@ -119,7 +120,8 @@ public class MusicGroupPaymentCalender {
 
 	@ApiModelProperty(value = "缴费类型", required = false)
 	private PaymentType paymentType;
-	
+
+	@ApiModelProperty(value = "课程价格费用", required = false)
 	private BigDecimal paymentAmount = new BigDecimal(0);
 
 	@ApiModelProperty(value = "状态", required = false)
@@ -145,7 +147,8 @@ public class MusicGroupPaymentCalender {
 	private java.util.Date createTime;
 
 	private java.util.Date updateTime;
-	
+
+	//进行中加学员时学员选择加入的班级
 	private String attribute1;
 	
 	private String attribute2;
@@ -163,6 +166,61 @@ public class MusicGroupPaymentCalender {
 	@ApiModelProperty(value = "课程展现形式",required = false)
 	private CourseViewTypeEnum courseViewType;
 
+	//会员有效期(月)
+	private Integer memberValidDate;
+
+	//会员付款金额
+	private BigDecimal memberPaymentAmount = BigDecimal.ZERO;
+
+	//会员原付款金额
+	private BigDecimal originalMemberPaymentAmount = BigDecimal.ZERO;
+
+	//会员等级编号
+	private Integer memberRankSettingId;
+
+	//会员等级名称
+	private String memberRankSettingName;
+
+	public String getMemberRankSettingName() {
+		return memberRankSettingName;
+	}
+
+	public void setMemberRankSettingName(String memberRankSettingName) {
+		this.memberRankSettingName = memberRankSettingName;
+	}
+
+	public BigDecimal getOriginalMemberPaymentAmount() {
+		return originalMemberPaymentAmount;
+	}
+
+	public void setOriginalMemberPaymentAmount(BigDecimal originalMemberPaymentAmount) {
+		this.originalMemberPaymentAmount = originalMemberPaymentAmount;
+	}
+
+	public Integer getMemberValidDate() {
+		return memberValidDate;
+	}
+
+	public void setMemberValidDate(Integer memberValidDate) {
+		this.memberValidDate = memberValidDate;
+	}
+
+	public BigDecimal getMemberPaymentAmount() {
+		return memberPaymentAmount;
+	}
+
+	public void setMemberPaymentAmount(BigDecimal memberPaymentAmount) {
+		this.memberPaymentAmount = memberPaymentAmount;
+	}
+
+	public Integer getMemberRankSettingId() {
+		return memberRankSettingId;
+	}
+
+	public void setMemberRankSettingId(Integer memberRankSettingId) {
+		this.memberRankSettingId = memberRankSettingId;
+	}
+
 	public String getAuditMemo() {
 		return auditMemo;
 	}

+ 4 - 5
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentCourseDetail.java

@@ -1,8 +1,7 @@
 package com.ym.mec.biz.dal.entity;
 
-import org.apache.commons.lang3.builder.ToStringBuilder;
-
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
  * 对应数据库表(music_group_payment_student_course_detail):
@@ -26,8 +25,8 @@ public class MusicGroupPaymentStudentCourseDetail {
 	
 	/**  */
 	private Integer totalCourseMinutes;
-	
-	/**  */
+
+	/**  已消耗时长*/
 	private Integer usedCourseMinutes;
 	
 	/**  */
@@ -35,7 +34,7 @@ public class MusicGroupPaymentStudentCourseDetail {
 	
 	/**  */
 	private java.util.Date updateTime;
-	
+
 	public void setId(Long id){
 		this.id = id;
 	}

+ 115 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentMemberCourseDetail.java

@@ -0,0 +1,115 @@
+package com.ym.mec.biz.dal.entity;
+
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(music_group_payment_student_member_course_detail):
+ */
+public class MusicGroupPaymentStudentMemberCourseDetail {
+
+	/**  */
+	private Long id;
+	
+	/**  */
+	private Long musicGroupPaymentCalenderId;
+	
+	/**  */
+	private Long musicGroupPaymentCalenderDetailId;
+	
+	/**  */
+	private Integer userId;
+
+	/**  用来标注当前缴费项目排了哪些类型的课以及课时数*/
+	private String courseDetail;
+
+	/**  会员可排课时长*/
+	private Integer memberCourseMinutes;
+	
+	/**  已消耗时长*/
+	private Integer usedCourseMinutes;
+	
+	/**  */
+	private java.util.Date createTime;
+	
+	/**  */
+	private java.util.Date updateTime;
+
+	public String getCourseDetail() {
+		return courseDetail;
+	}
+
+	public void setCourseDetail(String courseDetail) {
+		this.courseDetail = courseDetail;
+	}
+
+	public Integer getMemberCourseMinutes() {
+		return memberCourseMinutes;
+	}
+
+	public void setMemberCourseMinutes(Integer memberCourseMinutes) {
+		this.memberCourseMinutes = memberCourseMinutes;
+	}
+
+	public void setId(Long id){
+		this.id = id;
+	}
+	
+	public Long getId(){
+		return this.id;
+	}
+			
+	public void setMusicGroupPaymentCalenderId(Long musicGroupPaymentCalenderId){
+		this.musicGroupPaymentCalenderId = musicGroupPaymentCalenderId;
+	}
+	
+	public Long getMusicGroupPaymentCalenderId(){
+		return this.musicGroupPaymentCalenderId;
+	}
+			
+	public void setMusicGroupPaymentCalenderDetailId(Long musicGroupPaymentCalenderDetailId){
+		this.musicGroupPaymentCalenderDetailId = musicGroupPaymentCalenderDetailId;
+	}
+	
+	public Long getMusicGroupPaymentCalenderDetailId(){
+		return this.musicGroupPaymentCalenderDetailId;
+	}
+			
+	public void setUserId(Integer userId){
+		this.userId = userId;
+	}
+	
+	public Integer getUserId(){
+		return this.userId;
+	}
+			
+	public void setUsedCourseMinutes(Integer usedCourseMinutes){
+		this.usedCourseMinutes = usedCourseMinutes;
+	}
+	
+	public Integer getUsedCourseMinutes(){
+		return this.usedCourseMinutes;
+	}
+			
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+	
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 127 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupSchoolTermCourseDetail.java

@@ -0,0 +1,127 @@
+package com.ym.mec.biz.dal.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import java.util.Date;
+
+/**
+ * 对应数据库表(music_group_school_term_course_detail):
+ */
+public class MusicGroupSchoolTermCourseDetail {
+
+	/**  */
+	private Integer id;
+	
+	/**  */
+	private String musicGroupId;
+	
+	/** 开课日期 */
+	private java.util.Date startCourseDate;
+	
+	/** 学期开始时间 */
+	private java.util.Date startSchoolTerm;
+	
+	/** 学期截止时间 */
+	private java.util.Date endSchoolTerm;
+	
+	/** 是否排课 */
+	private boolean courseFlag;
+	
+	/** 可排课时长 */
+	private Integer totalCourseTime;
+	
+	/**  */
+	private java.util.Date updateTime;
+	
+	/**  */
+	private java.util.Date createTime;
+
+	/** 是否清空预排课 */
+	private boolean cleanPreCourseFlag;
+
+	public boolean getCleanPreCourseFlag() {
+		return cleanPreCourseFlag;
+	}
+
+	public void setCleanPreCourseFlag(boolean cleanPreCourseFlag) {
+		this.cleanPreCourseFlag = cleanPreCourseFlag;
+	}
+
+	public void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setMusicGroupId(String musicGroupId){
+		this.musicGroupId = musicGroupId;
+	}
+	
+	public String getMusicGroupId(){
+		return this.musicGroupId;
+	}
+
+	public Date getStartCourseDate() {
+		return startCourseDate;
+	}
+
+	public void setStartCourseDate(Date startCourseDate) {
+		this.startCourseDate = startCourseDate;
+	}
+
+	public Date getStartSchoolTerm() {
+		return startSchoolTerm;
+	}
+
+	public void setStartSchoolTerm(Date startSchoolTerm) {
+		this.startSchoolTerm = startSchoolTerm;
+	}
+
+	public Date getEndSchoolTerm() {
+		return endSchoolTerm;
+	}
+
+	public void setEndSchoolTerm(Date endSchoolTerm) {
+		this.endSchoolTerm = endSchoolTerm;
+	}
+
+	public void setCourseFlag(boolean courseFlag){
+		this.courseFlag = courseFlag;
+	}
+	
+	public boolean isCourseFlag(){
+		return this.courseFlag;
+	}
+			
+	public void setTotalCourseTime(Integer totalCourseTime){
+		this.totalCourseTime = totalCourseTime;
+	}
+	
+	public Integer getTotalCourseTime(){
+		return this.totalCourseTime;
+	}
+			
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+	
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+			
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 114 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupSchoolTermStudentCourseDetail.java

@@ -0,0 +1,114 @@
+package com.ym.mec.biz.dal.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(music_group_school_term_student_course_detail):
+ */
+public class MusicGroupSchoolTermStudentCourseDetail {
+
+	/**  */
+	private Long id;
+	
+	/**  */
+	private Integer musicGroupSchoolTermCourseDetailId;
+	
+	/**  */
+	private Integer userId;
+	
+	/** 会员可排课时长 */
+	private Integer memberCourseMinutes = 0;
+	
+	/** 预排课消耗时长 */
+	private Integer preMemberCourseMinutes = 0;
+	
+	/**  合奏课消耗的时长*/
+	private Integer mixCourseMinutes = 0;
+	
+	/** 单技课消耗的时长 */
+	private Integer singleCourseMinutes = 0;
+
+	/**  */
+	private java.util.Date createTime;
+	
+	/**  */
+	private java.util.Date updateTime;
+
+	public Integer getMixCourseMinutes() {
+		return mixCourseMinutes;
+	}
+
+	public void setMixCourseMinutes(Integer mixCourseMinutes) {
+		this.mixCourseMinutes = mixCourseMinutes;
+	}
+
+	public Integer getSingleCourseMinutes() {
+		return singleCourseMinutes;
+	}
+
+	public void setSingleCourseMinutes(Integer singleCourseMinutes) {
+		this.singleCourseMinutes = singleCourseMinutes;
+	}
+
+	public void setId(Long id){
+		this.id = id;
+	}
+	
+	public Long getId(){
+		return this.id;
+	}
+			
+	public void setMusicGroupSchoolTermCourseDetailId(Integer musicGroupSchoolTermCourseDetailId){
+		this.musicGroupSchoolTermCourseDetailId = musicGroupSchoolTermCourseDetailId;
+	}
+	
+	public Integer getMusicGroupSchoolTermCourseDetailId(){
+		return this.musicGroupSchoolTermCourseDetailId;
+	}
+			
+	public void setUserId(Integer userId){
+		this.userId = userId;
+	}
+	
+	public Integer getUserId(){
+		return this.userId;
+	}
+			
+	public void setMemberCourseMinutes(Integer memberCourseMinutes){
+		this.memberCourseMinutes = memberCourseMinutes;
+	}
+	
+	public Integer getMemberCourseMinutes(){
+		return this.memberCourseMinutes;
+	}
+			
+	public void setPreMemberCourseMinutes(Integer preMemberCourseMinutes){
+		this.preMemberCourseMinutes = preMemberCourseMinutes;
+	}
+	
+	public Integer getPreMemberCourseMinutes(){
+		return this.preMemberCourseMinutes;
+	}
+			
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+	
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 43 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Student.java

@@ -1,6 +1,9 @@
 package com.ym.mec.biz.dal.entity;
 
 import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import com.ym.mec.auth.api.entity.SysUser;
@@ -55,6 +58,14 @@ public class Student extends SysUser {
 	private String currentClass;
 
 	private Integer cooperationOrganId;
+	
+	private Integer memberRankSettingId;
+	
+	private Date membershipStartTime;
+	
+	private Date membershipEndTime;
+	
+	private String memberRankImg;
 
 	@ApiModelProperty(value = "活动排课信息")
 	private String activityCourseDetail;
@@ -214,4 +225,36 @@ public class Student extends SysUser {
 	public void setCurrentClass(String currentClass) {
 		this.currentClass = currentClass;
 	}
+
+	public Integer getMemberRankSettingId() {
+		return memberRankSettingId;
+	}
+
+	public void setMemberRankSettingId(Integer memberRankSettingId) {
+		this.memberRankSettingId = memberRankSettingId;
+	}
+
+	public Date getMembershipStartTime() {
+		return membershipStartTime;
+	}
+
+	public void setMembershipStartTime(Date membershipStartTime) {
+		this.membershipStartTime = membershipStartTime;
+	}
+
+	public Date getMembershipEndTime() {
+		return membershipEndTime;
+	}
+
+	public void setMembershipEndTime(Date membershipEndTime) {
+		this.membershipEndTime = membershipEndTime;
+	}
+
+	public String getMemberRankImg() {
+		return memberRankImg;
+	}
+
+	public void setMemberRankImg(String memberRankImg) {
+		this.memberRankImg = memberRankImg;
+	}
 }

+ 21 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentCourseHomework.java

@@ -54,6 +54,27 @@ public class StudentCourseHomework {
 
 	private ImSendTypeEnum msgType = ImSendTypeEnum.TXT;
 
+	//伴奏编号
+	private Integer musicScoreId;
+	//伴奏编号
+	private String musicScoreName;
+
+	public String getMusicScoreName() {
+		return musicScoreName;
+	}
+
+	public void setMusicScoreName(String musicScoreName) {
+		this.musicScoreName = musicScoreName;
+	}
+
+	public Integer getMusicScoreId() {
+		return musicScoreId;
+	}
+
+	public void setMusicScoreId(Integer musicScoreId) {
+		this.musicScoreId = musicScoreId;
+	}
+
 	public ImSendTypeEnum getMsgType() {
 		return msgType;
 	}

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

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.entity;
 
+import com.ym.mec.biz.dal.dto.CloudTeacherOrderDto;
 import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
 
@@ -59,6 +60,8 @@ public class StudentPaymentOrderDetail {
 
 	@ApiModelProperty(value = "子商品列表",required = false)
 	private List<Goods> childGoodsList;
+	
+	private CloudTeacherOrderDto cloudTeacherOrderDto;
 
 	public void setId(Long id){
 		this.id = id;
@@ -176,4 +179,12 @@ public class StudentPaymentOrderDetail {
 	public void setIsRenew(Integer isRenew) {
 		this.isRenew = isRenew;
 	}
+
+	public CloudTeacherOrderDto getCloudTeacherOrderDto() {
+		return cloudTeacherOrderDto;
+	}
+
+	public void setCloudTeacherOrderDto(CloudTeacherOrderDto cloudTeacherOrderDto) {
+		this.cloudTeacherOrderDto = cloudTeacherOrderDto;
+	}
 }

+ 6 - 4
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/CourseViewTypeEnum.java

@@ -3,10 +3,12 @@ package com.ym.mec.biz.dal.enums;
 import com.ym.mec.common.enums.BaseEnum;
 
 public enum CourseViewTypeEnum implements BaseEnum<Integer, CourseViewTypeEnum> {
-    COURSE_lIST(0, "课程详情", 2),
-    AMR(1, "器乐练习系统", 4),
-    CLOUD_TEACHER(2, "云教练收费", 4),
-    CLOUD_TEACHER_PLUS(3, "云教练+收费", 5);
+//    COURSE_lIST(0, "课程详情", 2),
+//    AMR(1, "器乐练习系统", 4),
+//    CLOUD_TEACHER(2, "云教练收费", 4),
+    COURSE_FEE(0, "课程收费", 2),
+    MEMBER_FEE(1, "会员收费", 4);
+//    CLOUD_TEACHER_PLUS(3, "云教练+收费", 5);
 
     private Integer code;
 

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/GroupType.java

@@ -15,7 +15,8 @@ public enum GroupType implements BaseEnum<String, GroupType> {
 	SUBJECT_CHANGE("声部更换"),
 	MAINTENANCE("乐保"),
 	REPLACEMENT("乐器置换"),
-	DEGREE("6.1考级活动");
+	DEGREE("6.1考级活动"),
+	MEMBER("购买会员");
 
 	private String desc;
 

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderTypeEnum.java

@@ -24,7 +24,8 @@ public enum OrderTypeEnum implements BaseEnum<String, OrderTypeEnum> {
 	DEGREE_REGISTRATION("DEGREE_REGISTRATION", "考级报名"),
 	MAINTENANCE("MAINTENANCE","乐保"),
 	REPLACEMENT("REPLACEMENT","乐器置换"),
-	DEGREE("DEGREE","6.1考级活动");
+	DEGREE("DEGREE","6.1考级活动"),
+	MEMBER("MEMBER", "购买会员");
 
 
 	private String code;

+ 29 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/PeriodEnum.java

@@ -0,0 +1,29 @@
+package com.ym.mec.biz.dal.enums;
+
+import com.ym.mec.common.enums.BaseEnum;
+
+/**
+ * 周期
+ */
+public enum PeriodEnum implements BaseEnum<String, PeriodEnum> {
+	DAY("日"), MONTH("月"), YEAR_HALF("半年"), YEAR("年");
+
+	private String msg;
+
+	PeriodEnum(String msg) {
+		this.msg = msg;
+	}
+
+	public String getMsg() {
+		return msg;
+	}
+
+	public void setMsg(String msg) {
+		this.msg = msg;
+	}
+
+	@Override
+	public String getCode() {
+		return this.name();
+	}
+}

+ 30 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/CloudTeacherOrderQueryInfo.java

@@ -0,0 +1,30 @@
+package com.ym.mec.biz.dal.page;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import com.ym.mec.common.page.QueryInfo;
+
+public class CloudTeacherOrderQueryInfo extends QueryInfo {
+
+	@ApiModelProperty(value = "交易状态(0-待生效 1-生效中 2-已生效 3-已退)", required = false)
+	private Integer status;
+
+	@ApiModelProperty(value = "学生编号", required = false)
+	private Integer studentId;
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public Integer getStudentId() {
+		return studentId;
+	}
+
+	public void setStudentId(Integer studentId) {
+		this.studentId = studentId;
+	}
+}

+ 17 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/MemberPrivilegesItemQueryInfo.java

@@ -0,0 +1,17 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+public class MemberPrivilegesItemQueryInfo extends QueryInfo {
+    @ApiModelProperty(value = "父节点编号,默认0",required = false)
+    private Integer parentId = 0;
+
+    public Integer getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Integer parentId) {
+        this.parentId = parentId;
+    }
+}

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/MemberRankFeeQueryInfo.java

@@ -0,0 +1,15 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+
+public class MemberRankFeeQueryInfo extends QueryInfo {
+    private String organId;
+
+    public String getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(String organId) {
+        this.organId = organId;
+    }
+}

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

@@ -189,7 +189,11 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
      * @param classGroupIdListStr
      * @return
      */
-    boolean addStudentToClassGroupAndCourseArranging(Integer studentId, String classGroupIdListStr, String batchNo, List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList);
+    boolean addStudentToClassGroupAndCourseArranging(Integer studentId,
+                                                     String classGroupIdListStr,
+                                                     String batchNo,
+                                                     List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList,
+                                                     MusicGroup musicGroup);
 
     /**
      * 获取未分配合奏的单技班列表
@@ -295,6 +299,13 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
     HttpResponseResult classGroupUpdate(List<ClassGroup4MixDto> classGroup4MixDtos) throws Exception;
 
     /**
+     * 班级预排课
+     * @param classGroup4MixDtos
+     * @return
+     */
+    HttpResponseResult preCourseSchedule(List<ClassGroup4MixDto> classGroup4MixDtos);
+
+    /**
      * 班级调整(增加临时班级)
      * @param classGroup4MixDtos
      * @return
@@ -465,7 +476,7 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
      * @param classGroupIdList
      * @return
      */
-    List<RemainCourseTypeDurationDto> queryRemainCourseTypeDuration(String classGroupIdList);
+    List<RemainCourseTypeDurationDto> queryRemainCourseTypeDuration(String classGroupIdList,Integer memberFlag);
 
     /**
      * 进行中乐团-修改-班级详情-学员班级调整详情
@@ -553,4 +564,25 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
      * @param classGroupStudents
      */
     void spanGroupClassAdjustPass(Integer masterClassGroupId,List<Integer> studentIds,List<Long> courseIds,List<Map> classGroupStudents,List<Long> allLockCourseIds,String batchNo,BigDecimal masterTotalPrice);
+
+    /**
+     * 获取班级的预排课课程列表
+     * @param classGroupId
+     * @return
+     */
+    List<CourseSchedule> queryPreCourseList(Integer classGroupId);
+
+    /**
+     * 确认预排课
+     * @param musicGroupSchoolTermCourseDetailId
+     * @return
+     */
+    void confirmPreCourseSchedule(Integer musicGroupSchoolTermCourseDetailId);
+
+    /**
+     * 取消预排课
+     * @param musicGroupSchoolTermCourseDetailId
+     * @param classGroupId
+     */
+    void cancelPreCourseSchedule(Integer musicGroupSchoolTermCourseDetailId, Integer classGroupId);
 }

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CloudTeacherOrderService.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service;
 
+import com.ym.mec.biz.dal.dto.CloudTeacherOrderDto;
 import com.ym.mec.biz.dal.entity.CloudTeacher;
 import com.ym.mec.biz.dal.entity.CloudTeacherOrder;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
@@ -61,5 +62,19 @@ public interface CloudTeacherOrderService extends BaseService<Long, CloudTeacher
      * @return
      */
     Boolean quitCloudTeacherOrder(CloudTeacherOrder order, BigDecimal refundAmount);
+	
+	/**
+	 * 根据studentPaymentOrder表id查询对象
+	 * @param orderId
+	 * @return
+	 */
+	CloudTeacherOrder queryByOrderId(Long orderId);
+    
+    /**
+     * 根据订单编号查询订单详情
+     * @param orderId
+     * @return
+     */
+    CloudTeacherOrderDto queryOrderInfoByOrderId(Long orderId);
 
 }

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

@@ -105,7 +105,7 @@ public interface CourseReviewService extends BaseService<Integer, CourseSchedule
 	 * @param expiryDate
 	 * @return
 	 */
-	CourseHomework addHomeWork(Integer courseScheduleId,String content, Date expiryDate);
+	CourseHomework addHomeWork(Integer courseScheduleId,String content, Date expiryDate,Integer musicScoreId);
 
 	/**
 	 * 获取网管课列表

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleStudentPaymentService.java

@@ -69,6 +69,17 @@ public interface CourseScheduleStudentPaymentService extends BaseService<Long, C
 	void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds);
 
 	/**
+	 * @describe 创建课程缴费记录-会员乐团
+	 * @author Joburgess
+	 * @date 2020.10.27
+	 * @param musicGroupId: 乐团编号
+	 * @param courseSchedules: 课程计划列表
+	 * @param studentIds: 课程学员列表
+	 * @return void
+	 */
+	void createForMemberMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds);
+
+	/**
 	 * @describe 创建课程缴费记录-乐团-用于合班拆班自动排课
 	 * @author zouxuan
 	 * @date 2020.10.27

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

@@ -36,7 +36,7 @@ public interface ExtracurricularExercisesService extends BaseService<Long, Extra
      * @param search:
      * @return java.util.List<com.ym.mec.biz.dal.dto.SimpleUserDto>
      */
-    List<BasicUserDto> getDontServeStudents(Integer teacherId, String search, String musicGroupId,Long classGroupId,Integer subjectId);
+    List<BasicUserDto> getDontServeStudents(Integer teacherId, String search, String musicGroupId,Long classGroupId,Integer subjectId,Integer hasMember);
 
     /**
      * @describe 应布置课外训练提醒

+ 0 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/IndexErrDataRecordService.java

@@ -83,5 +83,4 @@ public interface IndexErrDataRecordService extends BaseService<Long, IndexErrDat
      * @return com.ym.mec.common.page.PageInfo<java.util.List<com.ym.mec.biz.dal.dto.CourseScheduleEndDto>>
      */
     PageInfo<CourseScheduleEndDto> queryHistoryErrCourseData(EndCourseScheduleQueryInfo queryInfo);
-
 }

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

@@ -0,0 +1,9 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.MemberFeeSetting;
+import com.ym.mec.common.service.BaseService;
+
+public interface MemberFeeSettingService extends BaseService<Integer, MemberFeeSetting> {
+
+    MemberFeeSetting findByRankIdAndOrganId(Integer organId, Integer rankId);
+}

+ 17 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MemberPrivilegesItemService.java

@@ -0,0 +1,17 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.MemberPrivilegesItem;
+import com.ym.mec.biz.dal.page.MemberPrivilegesItemQueryInfo;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.service.BaseService;
+
+import java.util.List;
+
+public interface MemberPrivilegesItemService extends BaseService<Integer, MemberPrivilegesItem> {
+
+    void recursiveDel(Integer id);
+
+    PageInfo<MemberPrivilegesItem> queryItemPage(MemberPrivilegesItemQueryInfo queryInfo);
+
+    List<MemberPrivilegesItem> findAllItem(MemberPrivilegesItemQueryInfo queryInfo);
+}

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MemberRankOrganizationFeeMapperService.java

@@ -0,0 +1,11 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.MemberRankOrganizationFeeMapper;
+import com.ym.mec.common.service.BaseService;
+
+public interface MemberRankOrganizationFeeMapperService extends BaseService<Integer,MemberRankOrganizationFeeMapper>{
+
+    void add(MemberRankOrganizationFeeMapper memberRankOrganizationFeeMapper);
+
+    void updateFee(MemberRankOrganizationFeeMapper memberRankOrganizationFeeMapper);
+}

+ 17 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MemberRankPrivilegesService.java

@@ -0,0 +1,17 @@
+package com.ym.mec.biz.service;
+
+import java.util.List;
+
+import com.ym.mec.biz.dal.entity.MemberPrivilegesItem;
+import com.ym.mec.biz.dal.entity.MemberRankPrivileges;
+import com.ym.mec.common.service.BaseService;
+
+public interface MemberRankPrivilegesService extends BaseService<Integer, MemberRankPrivileges> {
+
+	/**
+	 * 获取指定会员等级的特权项目(树状结构)
+	 * @param memberRankId 会员等级编号
+	 * @return
+	 */
+	List<MemberPrivilegesItem> queryByMemberRankId(Integer memberRankId);
+}

+ 39 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MemberRankSettingService.java

@@ -0,0 +1,39 @@
+package com.ym.mec.biz.service;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
+import com.ym.mec.biz.dal.entity.MemberRankSetting;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.enums.PeriodEnum;
+import com.ym.mec.common.service.BaseService;
+
+public interface MemberRankSettingService extends BaseService<Integer, MemberRankSetting> {
+
+	void add(MemberRankSetting memberRankSetting);
+
+	MemberRankSetting getDetail(Integer memberRankSettingId);
+
+	void updateSetting(MemberRankSetting memberRankSetting);
+
+	List<MemberRankSetting> queryListByIsDefault(Boolean isDefault);
+
+	/**
+	 * 会员购买
+	 * @param userId 会员编号
+	 * @param memberRankId 会员等级编号
+	 * @param periodEnum 会员周期
+	 * @param amount 金额
+	 * @param isUseBalance 是否使用余额
+	 * @return
+	 */
+	Map buy(Integer userId, Integer memberRankId, PeriodEnum periodEnum, BigDecimal amount, boolean isUseBalance) throws Exception;
+	
+	/**
+	 * 订单回调
+	 * @param studentPaymentOrder
+	 * @return
+	 */
+	boolean orderCallback(StudentPaymentOrder studentPaymentOrder);
+}

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

@@ -58,7 +58,7 @@ public interface MusicGroupPaymentCalenderDetailService extends BaseService<Long
      * @param musicGroupPaymentCalenderId
      * @param userIdList
      */
-    void batchAdd(Long musicGroupPaymentCalenderId, Set<Integer> userIdList);
+    void batchAdd(Long musicGroupPaymentCalenderId, Set<Integer> userIdList,MusicGroup musicGroup);
 
     /**
      * 乐团缴费记录新增学员

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java

@@ -40,7 +40,9 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 	 */
 	boolean makesureSchoolePaid(Long id, String memo);
 
-	void addStudent(MusicGroupPaymentCalender musicGroupPaymentCalender,List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList);
+	void addStudent(MusicGroupPaymentCalender musicGroupPaymentCalender,
+					List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList,
+					MusicGroup musicGroup);
 
 
 		/**

+ 13 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupSchoolTermCourseDetailService.java

@@ -0,0 +1,13 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.MusicGroupSchoolTermCourseDetail;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.service.BaseService;
+
+public interface MusicGroupSchoolTermCourseDetailService extends BaseService<Integer, MusicGroupSchoolTermCourseDetail> {
+
+    MusicGroupSchoolTermCourseDetail findByMusicGroupId(String musicGroupId);
+
+    HttpResponseResult upset(MusicGroupSchoolTermCourseDetail musicGroupSchoolTermCourseDetail);
+
+}

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupSchoolTermStudentCourseDetailService.java

@@ -0,0 +1,8 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.MusicGroupSchoolTermStudentCourseDetail;
+import com.ym.mec.common.service.BaseService;
+
+public interface MusicGroupSchoolTermStudentCourseDetailService extends BaseService<Long, MusicGroupSchoolTermStudentCourseDetail> {
+
+}

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

@@ -10,6 +10,7 @@ import com.ym.mec.biz.dal.dto.StudentPaymentOrderDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
@@ -20,6 +21,8 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
 public interface StudentPaymentOrderService extends BaseService<Long, StudentPaymentOrder> {
+	
+	Map createOrder(StudentPaymentOrder studentPaymentOrder, List<StudentPaymentOrderDetail> details, String payReceiver) throws Exception;
 
     /**
      * 查询商品列表

+ 25 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/StudentService.java

@@ -1,12 +1,12 @@
 package com.ym.mec.biz.service;
 
 import java.text.ParseException;
+import java.util.List;
 
 import com.ym.mec.biz.dal.entity.CooperationOrgan;
-import com.ym.mec.biz.dal.enums.GradeTypeEnum;
-import org.springframework.http.ResponseEntity;
-
 import com.ym.mec.biz.dal.entity.Student;
+import com.ym.mec.biz.dal.enums.GradeTypeEnum;
+import com.ym.mec.biz.dal.enums.PeriodEnum;
 import com.ym.mec.biz.dal.page.StudentQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
@@ -66,4 +66,26 @@ public interface StudentService extends BaseService<Integer, Student> {
      * @return
      */
     CooperationOrgan getStudentEduTeacher(Integer userId);
+
+    /**
+     * 更新学员会员信息
+     */
+    void updateMemberRank(Integer userId, Integer rankSettingId, PeriodEnum periodEnum, int quantityPerPeriod);
+
+    /**
+     * 更新学员会员信息
+     */
+    void batchUpdateMemberRank(List<Integer> studentIds, Integer rankSettingId, PeriodEnum periodEnum, int quantityPerPeriod);
+
+    /**
+     * 更新服务指标
+     * @param studentId
+     * @param studentIds
+     * @param serviceTag
+     */
+    void updateStudentServiceTag(Integer studentId,List<Integer> studentIds,Integer serviceTag);
+
+    List<String> getStudentNames(List<Integer> studentIdList);
+
+    Student getLocked(Integer userId);
 }

+ 597 - 135
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

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

+ 36 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CloudTeacherOrderServiceImpl.java

@@ -1,13 +1,17 @@
 package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dto.CloudTeacherOrderDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.PeriodEnum;
 import com.ym.mec.biz.service.CloudTeacherOrderService;
+import com.ym.mec.biz.service.StudentService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.date.DateUtil;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -27,6 +31,9 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
     private CourseScheduleDao courseScheduleDao;
     @Autowired
     private CloudTeacherDao cloudTeacherDao;
+    
+    @Autowired
+    private StudentService studentService;
 
 
     @Override
@@ -79,6 +86,25 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
         Date startTime = null;
         Date endTime = null;
         Date endBaseTime = null;
+        
+        PeriodEnum periodEnum = PeriodEnum.MONTH;
+		switch (cloudTeacherOrder.getType()) {
+		case 1:
+			periodEnum = PeriodEnum.DAY;
+			break;
+		case 2:
+			periodEnum = PeriodEnum.MONTH;
+			break;
+		case 3:
+			periodEnum = PeriodEnum.YEAR;
+			break;
+
+		default:
+			break;
+		}
+        //更新student表信息
+        studentService.updateMemberRank(cloudTeacherOrder.getStudentId(), cloudTeacherOrder.getLevel(), periodEnum, cloudTeacherOrder.getTime());
+        
         if (cloudTeacher == null) {
             cloudTeacher = new CloudTeacher();
             startTime = DateUtil.trunc(nowDate);
@@ -166,4 +192,14 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
         }
         return true;
     }
+
+	@Override
+	public CloudTeacherOrder queryByOrderId(Long orderId) {
+		return cloudTeacherOrderDao.queryByOrderId(orderId);
+	}
+
+	@Override
+	public CloudTeacherOrderDto queryOrderInfoByOrderId(Long orderId) {
+		return cloudTeacherOrderDao.queryOrderInfoByOrderId(orderId);
+	}
 }

+ 4 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ContractServiceImpl.java

@@ -1019,7 +1019,7 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
 
 		params.put("isShowVisualSeal", false);
 
-		CourseViewTypeEnum ownershipType = CourseViewTypeEnum.COURSE_lIST;
+		CourseViewTypeEnum ownershipType = CourseViewTypeEnum.COURSE_FEE;
 
 		if(StringUtils.isBlank(musicGroupId)){
 			params.put("ownershipType", "OWN");
@@ -1117,8 +1117,8 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
 		params.put("isShowVisualSeal", true);
 
 		Map<String, Object> result = new HashMap<>();
-		result.put("courseViewType", CourseViewTypeEnum.COURSE_lIST);
-		CourseViewTypeEnum ownershipType = CourseViewTypeEnum.COURSE_lIST;
+		result.put("courseViewType", CourseViewTypeEnum.COURSE_FEE);
+		CourseViewTypeEnum ownershipType = CourseViewTypeEnum.COURSE_FEE;
 
 		if(StringUtils.isBlank(musicGroupId)){
 			params.put("ownershipType", "OWN");
@@ -1206,7 +1206,7 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
 
 		params.put("isShowVisualSeal", false);
 
-		CourseViewTypeEnum courseViewType = CourseViewTypeEnum.COURSE_lIST;
+		CourseViewTypeEnum courseViewType = CourseViewTypeEnum.COURSE_FEE;
 		params.put("ownershipType", "OWN");
 
 		List<SysUserContracts> userContracts = sysUserContractsService.getUserContractWithType(userId, ContractType.PRODUCT, 2);

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseReviewServiceImpl.java

@@ -532,7 +532,7 @@ public class CourseReviewServiceImpl extends BaseServiceImpl<Integer, CourseSche
 
     @Override
     @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-    public CourseHomework addHomeWork(Integer courseScheduleId, String content, Date expiryDate) {
+    public CourseHomework addHomeWork(Integer courseScheduleId, String content, Date expiryDate,Integer musicScoreId) {
         if (StringUtils.isBlank(content)) {
             throw new BizException("作业内容不能为空");
         }
@@ -566,8 +566,10 @@ public class CourseReviewServiceImpl extends BaseServiceImpl<Integer, CourseSche
             courseHomework.setId(existHomework.getId());
             courseHomework.setContent(content);
             courseHomework.setExpiryDate(expiryDate);
+            courseHomework.setMusicScoreId(musicScoreId);
             courseHomeworkService.update(courseHomework);
         } else {
+            courseHomework.setMusicScoreId(musicScoreId);
             courseHomework.setContent(content);
             courseHomework.setCourseScheduleId(courseSchedule.getId());
             courseHomework.setMusicGroupId(courseSchedule.getMusicGroupId());

+ 24 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -154,6 +154,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 	private EmployeeDao employeeDao;
     @Autowired
 	private VipGroupActivityDao vipGroupActivityDao;
+    @Autowired
+	private StudentDao studentDao;
 
     private final Logger LOGGER = LoggerFactory
             .getLogger(this.getClass());
@@ -219,11 +221,18 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         int normalRemindNum = studentAttendanceDao.countNormalRemindNum(courseID);
         currentCourseDetail.setNormalRemind(normalRemindNum<=0?0:1);
 
-        currentCourseDetail.setCurrentTime(new Date());
+		CourseSchedule courseSchedule = courseScheduleDao.get(courseID);
+		MusicGroup musicGroup = musicGroupDao.get(courseSchedule.getMusicGroupId());
+		if(musicGroup != null){
+			currentCourseDetail.setCourseViewType(musicGroup.getCourseViewType());
+		}
+		currentCourseDetail.setCurrentTime(new Date());
         currentCourseDetail.setAdvanceSignInMinutes(Integer.parseInt(sysConfigDao.findConfigValue(SysConfigService.ADVANCE_SIGN_IN_MINUTES)));
 		currentCourseDetail.setAttendanceRange(CourseScheduleType.VIP.equals(currentCourseDetail.getCourseType())?Integer.parseInt(sysConfigDao.findConfigValue(SysConfigService.ATTENDANCE_RANGE_VIP)):Integer.parseInt(sysConfigDao.findConfigValue(SysConfigService.ATTENDANCE_RANGE)));
         currentCourseDetail.setAdvanceSignOutMinutes(Integer.parseInt(sysConfigDao.findConfigValue(SysConfigService.ADVANCE_SIGN_OUT_MINUTES)));
-        return currentCourseDetail;
+		Student student = studentDao.get(user.getId());
+		currentCourseDetail.setHasMember(student.getMemberRankSettingId() == null?0:1);
+		return currentCourseDetail;
     }
 
     @Override
@@ -1904,6 +1913,12 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                 existClassDateCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
                 newClassDateCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
                 for (CourseSchedule preCourseSchedule : newClassDateCourses) {
+                	//调整后的课程截止日期不能超过学期时间
+					if(preCourseSchedule.getValidEndTime() != null){
+						if(preCourseSchedule.getValidEndTime().compareTo(preCourseSchedule.getClassDate()) < 0){
+							throw new BizException("操作失败:不允许跨学期调整");
+						}
+					}
                     for (CourseSchedule backCourseSchedule : existClassDateCourses) {
 
                         //判断前后两节课是否存在冲突
@@ -3360,6 +3375,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
             if (Objects.isNull(newCourseSchedule.getGroupType())) {
                 newCourseSchedule.setGroupType(oldCourseSchedule.getGroupType());
             }
+			newCourseSchedule.setValidEndTime(oldCourseSchedule.getValidEndTime());
             
             //课程是否已结算
             int settlementNum = courseScheduleTeacherSalaryDao.checkCourseIsSettlement(oldCourseSchedule.getId().intValue());
@@ -3476,11 +3492,16 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
             if (newCourseSchedule.getEndClassTime().before(date)) {
                 newCourseSchedule.setStatus(CourseStatusEnum.OVER);
             }
+			//调整后的课程截止日期不能超过学期时间
+			if(newCourseSchedule.getValidEndTime() != null){
+				if(newCourseSchedule.getValidEndTime().compareTo(newCourseSchedule.getClassDate()) < 0){
+					throw new BizException("操作失败:不允许跨学期调整");
+				}
+			}
 
 			if(newCourseSchedule.getStartClassTime().compareTo(date)<0){
 				throw new BizException("调整无效,不能调整至已结束");
 			}
-            
 			if (newCourseSchedule.getType() == CourseScheduleType.PRACTICE) {
 				PracticeGroup practiceGroup = practiceGroupDao.get(Long.parseLong(newCourseSchedule.getMusicGroupId()));
 				if (practiceGroup.getType() != TRIAL) {

+ 41 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -549,6 +549,47 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 
 	@Override
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
+	public void createForMemberMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds) {
+		Map<CourseSchedule.CourseScheduleType, List<CourseSchedule>> typeCourseMap = courseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getType));
+		List<CourseScheduleStudentPayment> css = courseScheduleStudentPaymentDao.getWithGroup(musicGroupId, GroupType.MUSIC, studentIds);
+		Map<Integer, Set<Long>> studentCourseIdsMap = new HashMap<>();
+		if(!CollectionUtils.isEmpty(css)){
+			studentCourseIdsMap = css.stream().collect(Collectors.groupingBy(CourseScheduleStudentPayment::getUserId, Collectors.mapping(CourseScheduleStudentPayment::getCourseScheduleId, Collectors.toSet())));
+		}
+		List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
+
+		for (Integer studentId : studentIds) {
+			Set<Long> existCourseIds = new HashSet<>();
+			if(studentCourseIdsMap.containsKey(studentId)){
+				existCourseIds = studentCourseIdsMap.get(studentId);
+			}
+			for (Map.Entry<CourseSchedule.CourseScheduleType, List<CourseSchedule>> courseScheduleTypeListEntry : typeCourseMap.entrySet()) {
+				String batchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, studentId, courseScheduleTypeListEntry.getKey(),null);
+				courseScheduleTypeListEntry.getValue().sort(Comparator.comparing(CourseSchedule::getStartClassTime));
+				for (CourseSchedule courseSchedule : courseScheduleTypeListEntry.getValue()) {
+					if(existCourseIds.contains(courseSchedule.getId())){
+						throw new BizException("该学员已在此班级{}课程中", courseSchedule.getId());
+					}
+					CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
+					cssp.setGroupType(courseSchedule.getGroupType());
+					cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
+					cssp.setCourseScheduleId(courseSchedule.getId());
+					cssp.setClassGroupId(courseSchedule.getClassGroupId());
+					cssp.setBatchNo(batchNo);
+					cssp.setUserId(studentId);
+					cssp.setOriginalPrice(BigDecimal.ZERO);
+					cssp.setExpectPrice(BigDecimal.ZERO);
+					cssp.setActualPrice(BigDecimal.ZERO);
+					cssp.setBeMerged(false);
+					courseScheduleStudentPayments.add(cssp);
+				}
+			}
+		}
+		courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	public void updateForMusicGroupWithPaymentCalender(String batchNo) {
 		List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByBatchNo(batchNo);
 		if(CollectionUtils.isEmpty(courseScheduleStudentPayments)){

+ 4 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesMessageServiceImpl.java

@@ -1,12 +1,14 @@
 package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dao.ExtracurricularExercisesDao;
+import com.ym.mec.biz.dal.dao.ExtracurricularExercisesMessageDao;
+import com.ym.mec.biz.dal.dao.ExtracurricularExercisesReplyDao;
+import com.ym.mec.biz.dal.dao.TeacherDao;
 import com.ym.mec.biz.dal.dto.StudentCourseHomeworkCommentDto;
 import com.ym.mec.biz.dal.entity.ExtracurricularExercises;
 import com.ym.mec.biz.dal.entity.ExtracurricularExercisesMessage;
 import com.ym.mec.biz.dal.entity.ExtracurricularExercisesReply;
-import com.ym.mec.biz.dal.entity.StudentExtracurricularExercisesSituation;
 import com.ym.mec.biz.dal.enums.ImSendTypeEnum;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.dal.page.StudentCourseHomeworkReplyQueryInfo;
@@ -26,17 +28,12 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.time.DayOfWeek;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
 import java.util.*;
 
 @Service
 public class ExtracurricularExercisesMessageServiceImpl extends BaseServiceImpl<Long, ExtracurricularExercisesMessage> implements ExtracurricularExercisesMessageService {
 
 	@Autowired
-	private StudentExtracurricularExercisesSituationDao studentExtracurricularExercisesSituationDao;
-	@Autowired
 	private ExtracurricularExercisesMessageDao extracurricularExercisesMessageDao;
 	@Autowired
 	private ExtracurricularExercisesReplyDao extracurricularExercisesReplyDao;

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesReplyServiceImpl.java

@@ -102,6 +102,10 @@ public class ExtracurricularExercisesReplyServiceImpl extends BaseServiceImpl<Lo
 		detail.setStudentName(extraExerciseReply.getStudentName());
 		detail.setExpiryDate(extraExerciseReply.getExpireDate());
 		detail.setType("EXTRA");
+		Student student = studentDao.get(extraExerciseReply.getUserId());
+		detail.setHasMember(student.getMemberRankSettingId()==null?0:1);
+		detail.setMusicScoreId(extraExerciseReply.getMusicScoreId());
+		detail.setMusicScoreName(extraExerciseReply.getMusicScoreName());
 		return detail;
 	}
 

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

@@ -168,10 +168,10 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
 	}
 
 	@Override
-	public List<BasicUserDto> getDontServeStudents(Integer teacherId, String search, String musicGroupId,Long classGroupId,Integer subjectId) {
+	public List<BasicUserDto> getDontServeStudents(Integer teacherId, String search, String musicGroupId,Long classGroupId,Integer subjectId,Integer hasMember) {
 		LocalDate nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
 		LocalDate monDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
-		return extracurricularExercisesDao.findNoExercisesStudentsInThisWeekWithTeacher(teacherId, monDayDate.toString(), musicGroupId, classGroupId, subjectId, search);
+		return extracurricularExercisesDao.findNoExercisesStudentsInThisWeekWithTeacher(teacherId, monDayDate.toString(), musicGroupId, classGroupId, subjectId, search,hasMember);
 	}
 
 	@Override

+ 26 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberFeeSettingServiceImpl.java

@@ -0,0 +1,26 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.common.dal.BaseDAO;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.biz.dal.entity.MemberFeeSetting;
+import com.ym.mec.biz.service.MemberFeeSettingService;
+import com.ym.mec.biz.dal.dao.MemberFeeSettingDao;
+import org.springframework.stereotype.Service;
+
+@Service
+public class MemberFeeSettingServiceImpl extends BaseServiceImpl<Integer, MemberFeeSetting>  implements MemberFeeSettingService {
+	
+	@Autowired
+	private MemberFeeSettingDao memberFeeSettingDao;
+
+	@Override
+	public BaseDAO<Integer, MemberFeeSetting> getDAO() {
+		return memberFeeSettingDao;
+	}
+
+    @Override
+    public MemberFeeSetting findByRankIdAndOrganId(Integer organId, Integer rankId) {
+		return memberFeeSettingDao.findByRankIdAndOrganId(organId,rankId);
+    }
+}

+ 79 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberPrivilegesItemServiceImpl.java

@@ -0,0 +1,79 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.MemberPrivilegesItemDao;
+import com.ym.mec.biz.dal.entity.MemberPrivilegesItem;
+import com.ym.mec.biz.dal.page.MemberPrivilegesItemQueryInfo;
+import com.ym.mec.biz.service.MemberPrivilegesItemService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+public class MemberPrivilegesItemServiceImpl extends BaseServiceImpl<Integer, MemberPrivilegesItem>  implements MemberPrivilegesItemService {
+	
+	@Autowired
+	private MemberPrivilegesItemDao memberPrivilegesItemDao;
+
+	@Override
+	public BaseDAO<Integer, MemberPrivilegesItem> getDAO() {
+		return memberPrivilegesItemDao;
+	}
+
+	private MemberPrivilegesItem getTree(MemberPrivilegesItem item){
+		List<MemberPrivilegesItem> privilegesItems = memberPrivilegesItemDao.findList(item.getId());
+		if(privilegesItems != null && privilegesItems.size() > 0) {
+			item.setMemberPrivilegesItems(privilegesItems);
+			for (MemberPrivilegesItem privilegesItem : privilegesItems) {
+				getTree(privilegesItem);
+			}
+		}
+		return item;
+	}
+
+    @Override
+	@Transactional(rollbackFor = Exception.class)
+    public void recursiveDel(Integer parentId) {
+		List<MemberPrivilegesItem> memberPrivilegesItems = memberPrivilegesItemDao.findList(parentId);
+		for (MemberPrivilegesItem item : memberPrivilegesItems) {
+			item = getTree(item);
+		}
+		List<Integer> collect = memberPrivilegesItems.stream().map(e -> e.getId()).collect(Collectors.toList());
+		if(collect == null || collect.size() <= 0){
+			memberPrivilegesItemDao.delete(parentId);
+			return;
+		}
+		collect.add(parentId);
+		memberPrivilegesItemDao.batchDel(collect);
+    }
+
+	@Override
+	public PageInfo<MemberPrivilegesItem> queryItemPage(MemberPrivilegesItemQueryInfo queryInfo) {
+		PageInfo<MemberPrivilegesItem> memberPrivilegesItemPageInfo = this.queryPage(queryInfo);
+		List<MemberPrivilegesItem> rows = memberPrivilegesItemPageInfo.getRows();
+		if(rows == null || rows.size() == 0){
+			return memberPrivilegesItemPageInfo;
+		}
+		for (MemberPrivilegesItem item : rows) {
+			item = getTree(item);
+		}
+		return memberPrivilegesItemPageInfo;
+	}
+
+	@Override
+	public List<MemberPrivilegesItem> findAllItem(MemberPrivilegesItemQueryInfo queryInfo) {
+		List<MemberPrivilegesItem> rows = memberPrivilegesItemDao.findList(queryInfo.getParentId());
+		if(rows == null || rows.size() == 0){
+			return rows;
+		}
+		for (MemberPrivilegesItem item : rows) {
+			item = getTree(item);
+		}
+		return rows;
+	}
+}

+ 66 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberRankOrganizationFeeMapperServiceImpl.java

@@ -0,0 +1,66 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.MemberRankOrganizationFeeMapperDao;
+import com.ym.mec.biz.dal.entity.MemberFeeSetting;
+import com.ym.mec.biz.dal.entity.MemberRankOrganizationFeeMapper;
+import com.ym.mec.biz.service.MemberFeeSettingService;
+import com.ym.mec.biz.service.MemberRankOrganizationFeeMapperService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+public class MemberRankOrganizationFeeMapperServiceImpl extends BaseServiceImpl<Integer, MemberRankOrganizationFeeMapper>  implements MemberRankOrganizationFeeMapperService {
+
+	@Autowired
+	private MemberRankOrganizationFeeMapperDao memberRankOrganizationFeeMapperDao;
+	@Autowired
+	private MemberFeeSettingService memberFeeSettingService;
+
+	@Override
+	public BaseDAO<Integer, MemberRankOrganizationFeeMapper> getDAO() {
+		return memberRankOrganizationFeeMapperDao;
+	}
+
+    @Override
+	@Transactional(rollbackFor = Exception.class)
+    public void add(MemberRankOrganizationFeeMapper memberRankOrganizationFeeMapper) {
+		//一个分部只能关联一个会员
+		MemberRankOrganizationFeeMapper feeMapper = memberRankOrganizationFeeMapperDao.findByOrganIdAndRankId(memberRankOrganizationFeeMapper.getOrganId(),memberRankOrganizationFeeMapper.getMemberRankSettingId());
+		if(feeMapper != null){
+			throw new BizException("操作失败: 该分部会员收费标准已存在");
+		}
+		MemberFeeSetting memberFeeSetting = memberRankOrganizationFeeMapper.getMemberFeeSetting();
+		if(memberFeeSetting == null){
+			throw new BizException("操作失败: 请设置收费标准");
+		}
+		memberFeeSettingService.insert(memberFeeSetting);
+		memberRankOrganizationFeeMapper.setMemberFeeSettingId(memberFeeSetting.getId());
+		memberRankOrganizationFeeMapperDao.insert(memberRankOrganizationFeeMapper);
+    }
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateFee(MemberRankOrganizationFeeMapper memberRankOrganizationFeeMapper) {
+		MemberRankOrganizationFeeMapper feeMapper = memberRankOrganizationFeeMapperDao.get(memberRankOrganizationFeeMapper.getId());
+		if(feeMapper == null){
+			throw new BizException("修改失败: 收费标准不存在");
+		}
+		MemberFeeSetting memberFeeSetting = memberRankOrganizationFeeMapper.getMemberFeeSetting();
+		if(memberFeeSetting == null){
+			throw new BizException("修改失败: 请设置收费标准");
+		}
+		if(feeMapper.getOrganId() != memberRankOrganizationFeeMapper.getOrganId()){
+			MemberRankOrganizationFeeMapper organIdAndRankId = memberRankOrganizationFeeMapperDao.findByOrganIdAndRankId(memberRankOrganizationFeeMapper.getOrganId(), memberRankOrganizationFeeMapper.getMemberRankSettingId());
+			if(organIdAndRankId != null){
+				throw new BizException("修改失败: 该分部会员收费标准已存在");
+			}
+		}
+		memberFeeSetting.setId(feeMapper.getMemberFeeSettingId());
+		memberFeeSettingService.update(memberFeeSetting);
+		memberRankOrganizationFeeMapperDao.update(memberRankOrganizationFeeMapper);
+	}
+}

+ 82 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberRankPrivilegesServiceImpl.java

@@ -0,0 +1,82 @@
+package com.ym.mec.biz.service.impl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.ym.mec.biz.dal.dao.MemberPrivilegesItemDao;
+import com.ym.mec.biz.dal.dao.MemberRankPrivilegesDao;
+import com.ym.mec.biz.dal.entity.MemberPrivilegesItem;
+import com.ym.mec.biz.dal.entity.MemberRankPrivileges;
+import com.ym.mec.biz.service.MemberRankPrivilegesService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+
+@Service
+public class MemberRankPrivilegesServiceImpl extends BaseServiceImpl<Integer, MemberRankPrivileges> implements MemberRankPrivilegesService {
+
+	@Autowired
+	private MemberRankPrivilegesDao memberRankPrivilegesDao;
+
+	@Autowired
+	private MemberPrivilegesItemDao memberPrivilegesItemDao;
+
+	@Override
+	public BaseDAO<Integer, MemberRankPrivileges> getDAO() {
+		return memberRankPrivilegesDao;
+	}
+
+	@Override
+	public List<MemberPrivilegesItem> queryByMemberRankId(Integer memberRankId) {
+		List<Integer> memberPrivilegesIdList = memberRankPrivilegesDao.findByRankSettingId(memberRankId).stream().map(e -> e.getMemberPrivilegesId())
+				.collect(Collectors.toList());
+
+		List<MemberPrivilegesItem> memberPrivilegesItemList = memberPrivilegesItemDao.findById(memberPrivilegesIdList);
+
+		Map<Integer, MemberPrivilegesItem> map = new HashMap<Integer, MemberPrivilegesItem>();
+
+		for (MemberPrivilegesItem item : memberPrivilegesItemList) {
+
+			MemberPrivilegesItem memberPrivilegesItem = queryParentBysubId(item);
+
+			if (map.containsKey(memberPrivilegesItem.getId())) {
+
+				memberPrivilegesItem = addSubItemToParent(map.get(memberPrivilegesItem.getId()), memberPrivilegesItem);
+			}
+			map.put(memberPrivilegesItem.getId(), memberPrivilegesItem);
+		}
+
+		return map.values().stream().collect(Collectors.toList());
+	}
+
+	private MemberPrivilegesItem queryParentBysubId(MemberPrivilegesItem memberPrivilegesItem) {
+
+		if (memberPrivilegesItem != null && (memberPrivilegesItem.getParentId() != 0 && memberPrivilegesItem.getParentId() != null)) {
+			Integer parentId = memberPrivilegesItem.getParentId();
+			MemberPrivilegesItem parentItem = memberPrivilegesItemDao.get(parentId);
+			if (parentItem != null) {
+				parentItem.getMemberPrivilegesItems().add(memberPrivilegesItem);
+				return queryParentBysubId(parentItem);
+			}
+		}
+
+		return memberPrivilegesItem;
+	}
+
+	private MemberPrivilegesItem addSubItemToParent(MemberPrivilegesItem parentItem, MemberPrivilegesItem subItem) {
+		if (subItem.getParentId().equals(parentItem.getId())) {
+			parentItem.getMemberPrivilegesItems().add(subItem);
+		} else {
+			for (MemberPrivilegesItem item : parentItem.getMemberPrivilegesItems()) {
+				addSubItemToParent(item, subItem);
+			}
+		}
+
+		return parentItem;
+	}
+
+}

+ 372 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberRankSettingServiceImpl.java

@@ -0,0 +1,372 @@
+package com.ym.mec.biz.service.impl;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+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.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.MemberRankPrivilegesDao;
+import com.ym.mec.biz.dal.dao.MemberRankSettingDao;
+import com.ym.mec.biz.dal.entity.CloudTeacherOrder;
+import com.ym.mec.biz.dal.entity.MemberFeeSetting;
+import com.ym.mec.biz.dal.entity.MemberRankPrivileges;
+import com.ym.mec.biz.dal.entity.MemberRankSetting;
+import com.ym.mec.biz.dal.entity.Student;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.entity.SysUserCashAccount;
+import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.enums.PeriodEnum;
+import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
+import com.ym.mec.biz.service.CloudTeacherOrderService;
+import com.ym.mec.biz.service.ContractService;
+import com.ym.mec.biz.service.MemberFeeSettingService;
+import com.ym.mec.biz.service.MemberRankSettingService;
+import com.ym.mec.biz.service.StudentPaymentOrderService;
+import com.ym.mec.biz.service.StudentService;
+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.exception.BizException;
+import com.ym.mec.common.service.IdGeneratorService;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.util.date.DateUtil;
+
+@Service
+public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, MemberRankSetting> implements MemberRankSettingService {
+
+	@Autowired
+	private MemberRankSettingDao memberRankSettingDao;
+	@Autowired
+	private MemberRankPrivilegesDao memberRankPrivilegesDao;
+
+	@Autowired
+	private MemberFeeSettingService memberFeeSettingService;
+
+	@Autowired
+	private StudentService studentService;
+
+	@Autowired
+	private StudentPaymentOrderService studentPaymentOrderService;
+
+	@Autowired
+	private SysUserCashAccountService sysUserCashAccountService;
+
+	@Autowired
+	private SysUserCashAccountDetailService sysUserCashAccountDetailService;
+
+	@Autowired
+	private ContractService contractService;
+
+	@Autowired
+	private SysUserFeignService sysUserFeignService;
+
+	@Autowired
+	private CloudTeacherOrderService cloudTeacherOrderService;
+
+	@Autowired
+	private IdGeneratorService idGeneratorService;
+
+	private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+	@Override
+	public BaseDAO<Integer, MemberRankSetting> getDAO() {
+		return memberRankSettingDao;
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void add(MemberRankSetting memberRankSetting) {
+		memberRankSettingDao.insert(memberRankSetting);
+		List<Integer> memberPrivilegesItemIdList = memberRankSetting.getMemberPrivilegesItemIdList();
+		if (memberPrivilegesItemIdList == null || memberPrivilegesItemIdList.size() == 0) {
+			throw new BizException("操作失败:请配置会员权益");
+		}
+		memberRankPrivilegesDao.batchInsert(memberRankSetting.getId(), memberPrivilegesItemIdList);
+	}
+
+	@Override
+	public MemberRankSetting getDetail(Integer memberRankSettingId) {
+		MemberRankSetting memberRankSetting = memberRankSettingDao.get(memberRankSettingId);
+		List<MemberRankPrivileges> byRankSettingId = memberRankPrivilegesDao.findByRankSettingId(memberRankSettingId);
+		if (byRankSettingId != null && byRankSettingId.size() > 0) {
+			memberRankSetting.setMemberRankPrivileges(byRankSettingId);
+			memberRankSetting.setMemberPrivilegesItemIdList(byRankSettingId.stream().map(e -> e.getMemberPrivilegesId()).collect(Collectors.toList()));
+		}
+		return memberRankSetting;
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateSetting(MemberRankSetting memberRankSetting) {
+		memberRankSettingDao.update(memberRankSetting);
+		memberRankPrivilegesDao.deleteByRankSettingId(memberRankSetting.getId());
+		List<Integer> memberPrivilegesItemIdList = memberRankSetting.getMemberPrivilegesItemIdList();
+		if (memberPrivilegesItemIdList != null && memberPrivilegesItemIdList.size() > 0) {
+			memberRankPrivilegesDao.batchInsert(memberRankSetting.getId(), memberPrivilegesItemIdList);
+		}
+	}
+
+	@Override
+	public List<MemberRankSetting> queryListByIsDefault(Boolean isDefault) {
+		return memberRankSettingDao.queryListByIsDefault(isDefault);
+	}
+
+	@Override
+	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+	public Map buy(Integer userId, Integer memberRankId, PeriodEnum periodEnum, BigDecimal amount, boolean isUseBalance) throws Exception {
+		Student student = studentService.get(userId);
+		if (student == null) {
+			throw new BizException("非法访问");
+		}
+
+		SysUser user = sysUserFeignService.queryUserById(userId);
+
+		Integer organId = user.getOrganId();
+		if (organId == null) {
+			throw new BizException("学生没有分部编号");
+		}
+
+		MemberRankSetting memberRankSetting = memberRankSettingDao.get(memberRankId);
+		if (memberRankSetting == null) {
+			throw new BizException("会员等级错误");
+		}
+
+		MemberFeeSetting memberFeeSetting = memberFeeSettingService.findByRankIdAndOrganId(organId, memberRankId);
+
+		if (memberFeeSetting == null) {
+			throw new BizException("分部会员价格出现异常");
+		}
+
+		CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
+
+		BigDecimal actualAmount = BigDecimal.ZERO;
+
+		switch (periodEnum) {
+		case DAY:
+			actualAmount = memberFeeSetting.getCurrentDayFee();
+			cloudTeacherOrder.setType(1);
+			cloudTeacherOrder.setTime(1);
+			break;
+		case MONTH:
+			actualAmount = memberFeeSetting.getCurrentMonthFee();
+			cloudTeacherOrder.setType(2);
+			cloudTeacherOrder.setTime(1);
+			break;
+		case YEAR_HALF:
+			actualAmount = memberFeeSetting.getCurrentHalfYearFee();
+			cloudTeacherOrder.setType(2);
+			cloudTeacherOrder.setTime(6);
+			break;
+		case YEAR:
+			actualAmount = memberFeeSetting.getCurrentYearFee();
+			cloudTeacherOrder.setType(3);
+			cloudTeacherOrder.setTime(1);
+			break;
+
+		default:
+			break;
+		}
+
+		// 判断金额是否正确
+		if (actualAmount.compareTo(amount) != 0) {
+			throw new BizException("非法请求");
+		}
+
+		Date date = new Date();
+
+		StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
+		studentPaymentOrder.setUserId(userId);
+		studentPaymentOrder.setOrganId(organId);
+		studentPaymentOrder.setRoutingOrganId(organId);
+		studentPaymentOrder.setCreateTime(date);
+		studentPaymentOrder.setUpdateTime(date);
+		studentPaymentOrder.setExpectAmount(amount);
+		studentPaymentOrder.setActualAmount(amount);
+		studentPaymentOrder.setBalancePaymentAmount(BigDecimal.ZERO);
+		studentPaymentOrder.setStatus(DealStatusEnum.ING);
+		studentPaymentOrder.setVersion(0);
+		studentPaymentOrder.setType(OrderTypeEnum.MEMBER);
+		studentPaymentOrder.setGroupType(GroupType.MEMBER);
+		studentPaymentOrder.setRemitFee(BigDecimal.ZERO);
+		studentPaymentOrder.setCourseRemitFee(BigDecimal.ZERO);
+		studentPaymentOrder.setMemo(memberRankSetting.getName());
+		studentPaymentOrder.setPaymentChannel("BALANCE");
+		studentPaymentOrder.setMusicGroupId(memberRankId + "");
+
+		if (isUseBalance) {
+			SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
+			if (userCashAccount == null) {
+				throw new BizException("用户账户找不到");
+			}
+			studentPaymentOrder.setPaymentChannel("BALANCE");
+			if (userCashAccount.getBalance().subtract(amount).doubleValue() >= 0) {
+				studentPaymentOrder.setActualAmount(BigDecimal.ZERO);
+				studentPaymentOrder.setBalancePaymentAmount(amount);
+				studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
+				sysUserCashAccountService.updateBalance(userId, amount.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "购买会员");
+
+			} else {
+				if (userCashAccount.getBalance().doubleValue() > 0) {
+					sysUserCashAccountService.updateBalance(userId, userCashAccount.getBalance().negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "购买会员");
+					studentPaymentOrder.setBalancePaymentAmount(userCashAccount.getBalance());
+					studentPaymentOrder.setActualAmount(studentPaymentOrder.getExpectAmount().subtract(userCashAccount.getBalance()));
+				}
+			}
+		}
+		String orderNo = idGeneratorService.generatorId("payment") + "";
+		studentPaymentOrder.setOrderNo(orderNo);
+		studentPaymentOrder.setCreateTime(date);
+		studentPaymentOrder.setUpdateTime(date);
+		studentPaymentOrder.setVersion(0);
+		studentPaymentOrderService.insert(studentPaymentOrder);
+
+		// 订单明细
+		cloudTeacherOrder.setOrganId(studentPaymentOrder.getOrganId());
+		cloudTeacherOrder.setStudentId(studentPaymentOrder.getUserId());
+		cloudTeacherOrder.setLevel(memberRankId);
+		cloudTeacherOrder.setAmount(studentPaymentOrder.getExpectAmount());
+		cloudTeacherOrder.setStatus(0);
+		cloudTeacherOrder.setOrderId(studentPaymentOrder.getId());
+		cloudTeacherOrder.setCreateTime(date);
+		cloudTeacherOrder.setUpdateTime(date);
+		cloudTeacherOrderService.insert(cloudTeacherOrder);
+
+		Map result = studentPaymentOrderService.createOrder(studentPaymentOrder, null, "BUY_MEMBER");
+
+		return result;
+	}
+
+	@Override
+	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+	public boolean orderCallback(StudentPaymentOrder studentPaymentOrder) {
+
+		Integer userId = studentPaymentOrder.getUserId();
+
+		Student student = studentService.getLocked(userId);
+		if (student == null) {
+			throw new BizException("学员信息不存在");
+		}
+		
+		Date nowDate = new Date();
+		// 更新订单信息
+		studentPaymentOrder.setUpdateTime(nowDate);
+		studentPaymentOrderService.update(studentPaymentOrder);
+
+		if (studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
+
+			if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
+				sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(),
+						PlatformCashAccountDetailTypeEnum.REFUNDS, "购买会员支付失败");
+			}
+
+			return true;
+		}
+
+		// 支付成功
+		if (studentPaymentOrder.getStatus() == DealStatusEnum.SUCCESS) {
+			// 查询会员订单信息
+			CloudTeacherOrder cloudTeacherOrder = cloudTeacherOrderService.queryByOrderId(studentPaymentOrder.getId());
+			cloudTeacherOrder.setStatus(2);
+			cloudTeacherOrder.setUpdateTime(nowDate);
+
+			PeriodEnum periodEnum = PeriodEnum.MONTH;
+			switch (cloudTeacherOrder.getType()) {
+			case 1:
+				periodEnum = PeriodEnum.DAY;
+				break;
+			case 2:
+				periodEnum = PeriodEnum.MONTH;
+				break;
+			case 3:
+				periodEnum = PeriodEnum.YEAR;
+				break;
+
+			default:
+				break;
+			}
+
+			if (student.getMemberRankSettingId() == null || nowDate.after(student.getMembershipEndTime())) {
+				cloudTeacherOrder.setStartTime(nowDate);
+				if (cloudTeacherOrder.getType() == 1) {
+					cloudTeacherOrder.setEndTime(DateUtil.addDays(nowDate, cloudTeacherOrder.getTime()));
+				} else if (cloudTeacherOrder.getType() == 2) {
+					cloudTeacherOrder.setEndTime(DateUtil.addMonths(nowDate, cloudTeacherOrder.getTime()));
+				} else if (cloudTeacherOrder.getType() == 3) {
+					cloudTeacherOrder.setEndTime(DateUtil.addYears(nowDate, cloudTeacherOrder.getTime()));
+				} else {
+					throw new BizException("不支持的周期类型");
+				}
+			} else {
+				cloudTeacherOrder.setStartTime(DateUtil.addDays(student.getMembershipEndTime(), 1));
+				if (cloudTeacherOrder.getType() == 1) {
+					cloudTeacherOrder.setEndTime(DateUtil.addDays(student.getMembershipEndTime(), cloudTeacherOrder.getTime()));
+				} else if (cloudTeacherOrder.getType() == 2) {
+					cloudTeacherOrder.setEndTime(DateUtil.addMonths(student.getMembershipEndTime(), cloudTeacherOrder.getTime()));
+				} else if (cloudTeacherOrder.getType() == 3) {
+					cloudTeacherOrder.setEndTime(DateUtil.addYears(student.getMembershipEndTime(), cloudTeacherOrder.getTime()));
+				} else {
+					throw new BizException("不支持的周期类型");
+				}
+			}
+
+			cloudTeacherOrderService.update(cloudTeacherOrder);
+			// 添加会员有效时长
+			studentService.updateMemberRank(userId, Integer.parseInt(studentPaymentOrder.getMusicGroupId()), periodEnum, cloudTeacherOrder.getTime());
+
+			// 插入交易明细
+			BigDecimal amount = studentPaymentOrder.getActualAmount();
+			if (amount.compareTo(BigDecimal.ZERO) > 0) {
+				SysUserCashAccount cashAccount = sysUserCashAccountService.get(userId);
+				// 充值
+				SysUserCashAccountDetail rechargeDetail = new SysUserCashAccountDetail();
+				rechargeDetail.setAmount(amount);
+				rechargeDetail.setBalance(cashAccount.getBalance().add(amount));
+				rechargeDetail.setComment("缴费前充值");
+				rechargeDetail.setCreateTime(nowDate);
+				rechargeDetail.setStatus(DealStatusEnum.SUCCESS);
+				rechargeDetail.setTransNo(studentPaymentOrder.getTransNo());
+				rechargeDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
+				rechargeDetail.setUpdateTime(nowDate);
+				rechargeDetail.setUserId(userId);
+				rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+				rechargeDetail.setComAmount(studentPaymentOrder.getComAmount());
+				rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount());
+				sysUserCashAccountDetailService.insert(rechargeDetail);
+
+				// 缴费
+				SysUserCashAccountDetail paymentDetail = new SysUserCashAccountDetail();
+				paymentDetail.setAmount(amount.negate());
+				paymentDetail.setBalance(cashAccount.getBalance());
+				paymentDetail.setComment("购买会员");
+				paymentDetail.setCreateTime(nowDate);
+				paymentDetail.setStatus(DealStatusEnum.SUCCESS);
+				paymentDetail.setTransNo(studentPaymentOrder.getTransNo());
+				paymentDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
+				paymentDetail.setUpdateTime(nowDate);
+				paymentDetail.setUserId(userId);
+				rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+				sysUserCashAccountDetailService.insert(paymentDetail);
+			}
+
+			try {
+				contractService.transferProduceContract(userId, null);
+			} catch (Exception e) {
+				logger.error("产品协议生成失败", e);
+			}
+		}
+		return true;
+	}
+}

+ 47 - 33
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java

@@ -13,12 +13,16 @@ import java.util.stream.Collectors;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.MusicArrearageStudentDto;
 import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
+import com.ym.mec.biz.dal.enums.PeriodEnum;
 import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
 import com.ym.mec.biz.dal.page.ArrearageStudentsQueryInfo;
 import com.ym.mec.biz.event.source.GroupEventSource;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.biz.dal.enums.YesOrNoEnum;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,10 +34,6 @@ import com.ym.mec.biz.dal.dto.SimpleUserDto;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
-import com.ym.mec.biz.service.MusicGroupPaymentCalenderDetailService;
-import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
-import com.ym.mec.biz.service.SysConfigService;
-import com.ym.mec.biz.service.SysMessageService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
@@ -68,6 +68,8 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 	private SysMessageService sysMessageService;
 	@Autowired
 	private GroupEventSource groupEventSource;
+	@Autowired
+	private StudentService studentService;
 
 	@Override
 	public BaseDAO<Long, MusicGroupPaymentCalenderDetail> getDAO() {
@@ -96,7 +98,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 //		}
 		//为了解决学员欠费数量的问题,只要学员没有缴费就可以修改金额
 		Set<Integer> studentIds = new HashSet<>();
-				calenderDetails.forEach(e->{
+		calenderDetails.forEach(e->{
 			if(e.getPaymentStatus() == null || e.getPaymentStatus() != NON_PAYMENT){
 				throw new BizException("修改失败:缴费状态不匹配");
 			}
@@ -107,6 +109,10 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 					studentIds.add(e.getUserId());
 				}
 			}else {
+				// 添加会员有效时长
+				if(calender.getMemberRankSettingId() != null){
+					studentService.updateMemberRank(e.getUserId(),calender.getMemberRankSettingId(),PeriodEnum.MONTH,6);
+				}
 				calender.setActualNum((calender.getActualNum()==null?0:calender.getActualNum()) + 1);
 				e.setPaymentStatus(PAID_COMPLETED);
 				if(calender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.ADD_STUDENT){
@@ -260,7 +266,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(calender.getDeadlinePaymentDate());
 		musicGroupPaymentCalenderDetail.setResponsibleUserId(calender.getOperator());
 		musicGroupPaymentCalenderDetailDao.insert(musicGroupPaymentCalenderDetail);
-		
+
 		List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<MusicGroupPaymentStudentCourseDetail>();
 		MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
 		for (MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList) {
@@ -287,7 +293,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public void batchAdd(Long musicGroupPaymentCalenderId, Set<Integer> userIdList) {
+	public void batchAdd(Long musicGroupPaymentCalenderId, Set<Integer> userIdList,MusicGroup musicGroup) {
 		
 		MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderService.get(musicGroupPaymentCalenderId);
 		if(musicGroupPaymentCalender == null){
@@ -309,17 +315,20 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		}
 		
 		List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupPaymentCalenderId);
-		
-		BigDecimal totalPrice = new BigDecimal(0);
-		if (musicGroupPaymentCalender.getPayUserType() == STUDENT) {
-			for (MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList) {
-				// 剔除可选课程
-				if (courseSettings.getIsStudentOptional() == false) {
-					totalPrice = totalPrice.add(courseSettings.getCourseCurrentPrice());
+
+		//总金额 = 会员费用 + 课程费用
+		BigDecimal totalPrice = musicGroupPaymentCalender.getMemberPaymentAmount();
+		if(courseSettingsList.size() > 0){
+			if (musicGroupPaymentCalender.getPayUserType() == STUDENT) {
+				for (MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList) {
+					// 剔除可选课程
+					if (courseSettings.getIsStudentOptional() == false) {
+						totalPrice = totalPrice.add(courseSettings.getCourseCurrentPrice());
+					}
 				}
 			}
 		}
-		
+
 		Date date = new Date();
 		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
 		Map<Integer,MusicGroupPaymentCalenderDetail> userMap = new HashMap<Integer, MusicGroupPaymentCalenderDetail>();
@@ -354,29 +363,30 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		musicGroupPaymentCalender.setExpectNum(musicGroupPaymentCalender.getExpectNum() + userIdList.size());
 		musicGroupPaymentCalender.setUpdateTime(date);
 		musicGroupPaymentCalenderService.update(musicGroupPaymentCalender);
-		
+
 		List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<MusicGroupPaymentStudentCourseDetail>();
 		MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
-		//创建学生课排课分钟数
-		for(Integer studentId : userIdList){
-			for(MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList){
-				if (courseSettings.getIsStudentOptional() == true || courseSettings.getCourseTotalMinuties() == null || courseSettings.getCourseTotalMinuties() == 0) {
-					continue;
+		if(courseSettingsList.size() > 0){
+			//创建学生课排课分钟数
+			for(Integer studentId : userIdList){
+				for(MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList){
+					if (courseSettings.getIsStudentOptional() == true || courseSettings.getCourseTotalMinuties() == null || courseSettings.getCourseTotalMinuties() == 0) {
+						continue;
+					}
+					musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+					musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
+					musicGroupPaymentStudentCourseDetail.setCreateTime(date);
+					musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalenderId);
+					musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(userMap.get(studentId).getId());
+					musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
+					musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
+					musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
+					musicGroupPaymentStudentCourseDetail.setUserId(studentId);
+					musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
 				}
-				musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
-				musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
-				musicGroupPaymentStudentCourseDetail.setCreateTime(date);
-				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalenderId);
-				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(userMap.get(studentId).getId());
-				musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
-				musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
-				musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
-				musicGroupPaymentStudentCourseDetail.setUserId(studentId);
-				
-				musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
 			}
 		}
-		
+
 		if(musicGroupPaymentStudentCourseDetailList.size() > 0){
 			musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
 		}
@@ -497,6 +507,10 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 				musicGroupPaymentCalenderDetail.setCreateTime(date);
 				musicGroupPaymentCalenderDetail.setExpectAmount(totalPrice);
 				if (musicGroupPaymentCalenderDetail.getExpectAmount().compareTo(new BigDecimal(0)) == 0) {
+					// 添加会员有效时长
+					if(musicGroupPaymentCalender.getMemberRankSettingId() != null){
+						studentService.updateMemberRank(studentId,musicGroupPaymentCalender.getMemberRankSettingId(),PeriodEnum.MONTH,6);
+					}
 					musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
 					paymentNum++;
 				} else {

+ 373 - 247
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -15,7 +15,9 @@ import java.util.*;
 import java.util.Map.Entry;
 import java.util.stream.Collectors;
 
+import com.alibaba.fastjson.JSONObject;
 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.event.source.GroupEventSource;
@@ -31,11 +33,6 @@ import com.alibaba.fastjson.JSON;
 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.dto.CalenderPushDto;
-import com.ym.mec.biz.dal.dto.ClassGroup4MixDto;
-import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDetailDto;
-import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDto;
-import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderDto;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderDto.MusicGroupPaymentDateRange;
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType;
@@ -76,6 +73,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	
 	@Autowired
 	private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
+
+	@Autowired
+	private MusicGroupSchoolTermCourseDetailDao musicGroupSchoolTermCourseDetailDao;
 	
 	@Autowired
 	private IdGeneratorService idGeneratorService;
@@ -123,6 +123,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	private StudentRegistrationDao studentRegistrationDao;
 	@Autowired
 	private GroupEventSource groupEventSource;
+	@Autowired
+	private MemberFeeSettingDao memberFeeSettingDao;
+	@Autowired
+	private MemberRankSettingDao memberRankSettingDao;
+	@Autowired
+	private StudentService studentService;
 
 	@Override
 	public BaseDAO<Long, MusicGroupPaymentCalender> getDAO() {
@@ -141,13 +147,19 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 		List<MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList = musicGroupPaymentCalenderDto.getMusicGroupPaymentDateRangeList();
 
+		if(musicGroupPaymentCalenderDto.getMemberRankSettingId() != null){
+			if(paymentType != ADD_STUDENT && paymentType != MUSIC_APPLY){
+				throw new BizException("操作失败:{} 不支持会员收费",paymentType.getDesc());
+			}
+		}
+
 		if ((paymentType == PaymentType.ADD_COURSE)) {
 			if(musicGroupPaymentDateRangeList.size() > 1){
 				throw new BizException("[临时加课]不支持多周期缴费");
 			}
 		}
-		
-		if ((paymentType == PaymentType.ADD_STUDENT)) {
+
+		if (paymentType == PaymentType.ADD_STUDENT) {
 			//获取缴费状态在审核中或者已拒绝的缴费项目的学员
 			Integer userId = Integer.parseInt(musicGroupPaymentCalenderDto.getStudentIds());
 			String studentIds = musicGroupPaymentCalenderDao.queryCalenderStudentIds(musicGroupId,null);
@@ -169,13 +181,16 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		}
 		
 		if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS && musicGroup.getStatus() != MusicGroupStatusEnum.PRE_BUILD_FEE) {
-			throw new BizException("创建失败:乐团当前状态不能创建缴费");
+			throw new BizException("创建缴费失败:已存在缴费项目");
 		}
 		
 		SysUser sysUser = sysUserFeignService.queryUserInfo();
 		if (sysUser == null) {
 			throw new BizException("请登录");
 		}
+		if (musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE && musicGroupPaymentDateRangeList.size() > 1) {
+			throw new BizException("创建缴费失败:会员收费乐团不支持多周期缴费");
+		}
 		// 所有缴费项目已完成排课才能创建下一个缴费项目
 		String orignBatchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, null, null,musicGroupPaymentCalenderDto.getIgnoreBatchNoList());
 		if (StringUtils.isNoneBlank(orignBatchNo)) {
@@ -197,76 +212,101 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		Date date = new Date();
 		String batchNo = idGeneratorService.generatorId() + "";
 
-		// 获取设置的课程
+		// 获取设置的课程收费标准
 		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderDto
 				.getMusicGroupPaymentCalenderCourseSettingsList();
-		if (musicGroupPaymentCalenderCourseSettingsList == null) {
-			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
-		}
 
-		// 必须课程缴费金额为0时,报名、续费不能建多期
-		if(paymentType == MUSIC_APPLY || paymentType == MUSIC_RENEW){
-			BigDecimal noOptionalCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream()
-					.filter(e -> !e.getIsStudentOptional()).map(MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice)
-					.reduce(BigDecimal.ZERO, BigDecimal::add);
-			if(noOptionalCoursePrice.compareTo(BigDecimal.ZERO) <= 0 && musicGroupPaymentDateRangeList.size() > 1){
-				throw new BizException("必选课程缴费金额为0时不支持多周期缴费");
+		if(musicGroupPaymentCalenderCourseSettingsList != null){
+			// 必须课程缴费金额为0时,报名、续费不能建多期
+			if(paymentType == MUSIC_APPLY || paymentType == MUSIC_RENEW){
+				BigDecimal noOptionalCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream()
+						.filter(e -> !e.getIsStudentOptional()).map(MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice)
+						.reduce(BigDecimal.ZERO, BigDecimal::add);
+				if(noOptionalCoursePrice.compareTo(BigDecimal.ZERO) <= 0 && musicGroupPaymentDateRangeList.size() > 1){
+					throw new BizException("必选课程缴费金额为0时不支持多周期缴费");
+				}
 			}
 		}
-
+		//会员原价
+		BigDecimal memberPaymentAmount = BigDecimal.ZERO;
 		if (payUserType == SCHOOL) {
 			status = AUDITING;
 		} else {
-			if (paymentType == MUSIC_APPLY || paymentType == MUSIC_RENEW) {
-				// 当前缴费的课程费用
-				Map<CourseScheduleType, BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(
-						Collectors
-								.toMap(MusicGroupPaymentCalenderCourseSettings::getCourseType, MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice));
-
-				// 查询默认课程费用
-				Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId();
-				Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao
-						.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId)
-						.stream()
-						.collect(
-								Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail::getCourseType,
-										MusicGroupOrganizationCourseSettingsDetail::getCourseCurrentPrice));
-
-				// 相同类型的课程如果修改了课程费用,需要走审批
-				for (Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()) {
-					if (defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0) {
-						status = AUDITING;
-						break;
-					}
-				}
-			} else if (paymentType == PaymentType.ADD_COURSE || paymentType == PaymentType.ADD_STUDENT) {
-				PaymentCalenderStatusEnum dtoStatus = musicGroupPaymentCalenderDto.getStatus();
-				if(dtoStatus != null && dtoStatus == AUDITING){
-					status = AUDITING;
-				}else {
-					// 如果是临时加课,判断是否审核
-					for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
-						OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
-								musicGroup.getOrganId(), courseSettings.getCourseType(), musicGroup.getChargeTypeId());
-						if (defaultUnitPrice == null) {
-							throw new BizException("请先设置分部课程类型单价");
+			if(musicGroupPaymentCalenderCourseSettingsList != null){
+				if (paymentType == MUSIC_APPLY || paymentType == MUSIC_RENEW) {
+					// 当前缴费的课程费用
+					Map<CourseScheduleType, BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(
+							Collectors
+									.toMap(MusicGroupPaymentCalenderCourseSettings::getCourseType, MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice));
+
+					// 查询默认课程费用
+					Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId();
+					Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao
+							.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId)
+							.stream()
+							.collect(
+									Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail::getCourseType,
+											MusicGroupOrganizationCourseSettingsDetail::getCourseCurrentPrice));
+
+					// 相同类型的课程如果修改了课程费用,需要走审批
+					for (Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()) {
+						if (defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0) {
+							status = AUDITING;
+							break;
 						}
-						if (courseSettings.getCourseTotalMinuties() != 0) {
-							
-							if (defaultUnitPrice.getUnitPrice().multiply(new BigDecimal(courseSettings.getCourseTotalMinuties())).setScale(0, BigDecimal.ROUND_HALF_UP)
-									.compareTo(courseSettings.getCourseCurrentPrice()) != 0) {
+					}
+				} else if (paymentType == PaymentType.ADD_COURSE || paymentType == PaymentType.ADD_STUDENT) {
+					PaymentCalenderStatusEnum dtoStatus = musicGroupPaymentCalenderDto.getStatus();
+					if(dtoStatus != null && dtoStatus == AUDITING){
+						status = AUDITING;
+					}else {
+						// 如果是课程收费,判断是否审核
+						for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
+							OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
+									musicGroup.getOrganId(), courseSettings.getCourseType(), musicGroup.getChargeTypeId());
+							if (defaultUnitPrice == null) {
+								throw new BizException("请先设置分部课程类型单价");
+							}
+							if (courseSettings.getCourseTotalMinuties() != 0) {
+
+								if (defaultUnitPrice.getUnitPrice().multiply(new BigDecimal(courseSettings.getCourseTotalMinuties())).setScale(0, BigDecimal.ROUND_HALF_UP)
+										.compareTo(courseSettings.getCourseCurrentPrice()) != 0) {
 
+									status = AUDITING;
+									break;
+								}
+							} else {
 								status = AUDITING;
 								break;
 							}
-						} else {
-							status = AUDITING;
-							break;
 						}
 					}
+				}else if(paymentType == SPAN_GROUP_CLASS_ADJUST){
+					status = musicGroupPaymentCalenderDto.getStatus();
+				}
+			}
+			if(musicGroupPaymentCalenderDto.getMemberRankSettingId() != null){
+				//会员价格是否变动
+				MemberFeeSetting memberFee = memberFeeSettingDao.findByRankIdAndOrganId(musicGroup.getOrganId(), musicGroupPaymentCalenderDto.getMemberRankSettingId());
+				if(memberFee == null){
+					throw new BizException("操作失败:请配置当前分部会员收费标准");
+				}
+				switch (musicGroupPaymentCalenderDto.getMemberValidDate()){
+					case 1 :
+						memberPaymentAmount = memberFee.getCurrentMonthFee().setScale(0, BigDecimal.ROUND_HALF_UP);
+						break;
+					case 6 :
+						memberPaymentAmount = memberFee.getCurrentHalfYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
+						break;
+					case 12 :
+						memberPaymentAmount = memberFee.getCurrentYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
+						break;
+					default:
+						throw new BizException("请选择正确的会员有效期");
+				}
+				if(memberPaymentAmount.compareTo(musicGroupPaymentCalenderDto.getMemberPaymentAmount()) != 0){
+					status = AUDITING;
 				}
-			}else if(paymentType == SPAN_GROUP_CLASS_ADJUST){
-				status = musicGroupPaymentCalenderDto.getStatus();
 			}
 		}
 
@@ -287,6 +327,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 			MusicGroupPaymentCalender musicGroupPaymentCalender = new MusicGroupPaymentCalender();
 			musicGroupPaymentCalender.setAttribute1(musicGroupPaymentCalenderDto.getAttribute1());
+			musicGroupPaymentCalender.setOriginalMemberPaymentAmount(memberPaymentAmount);
 			musicGroupPaymentCalender.setAttribute2(musicGroupPaymentCalenderDto.getAttribute2());
 			musicGroupPaymentCalender.setDeadlinePaymentDate(musicGroupPaymentDateRange.getDeadlinePaymentDate());
 			musicGroupPaymentCalender.setIsGiveMusicNetwork(musicGroupPaymentCalenderDto.getIsGiveMusicNetwork());
@@ -294,48 +335,47 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			musicGroupPaymentCalender.setMusicGroupId(musicGroupId);
 			musicGroupPaymentCalender.setMusicGroupOrganizationCourseSettingId(musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId());
 
-			List<MusicGroupPaymentCalenderCourseSettings> newCSList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>(
-					musicGroupPaymentCalenderCourseSettingsList.size());
-
-			BigDecimal totalPaymentAmount = musicGroupPaymentCalenderDto.getMasterTotalPrice();
-			for (MusicGroupPaymentCalenderCourseSettings pccs : musicGroupPaymentCalenderCourseSettingsList) {
-				
-				MusicGroupPaymentCalenderCourseSettings tempPccs = new MusicGroupPaymentCalenderCourseSettings();
-				try {
-					BeanUtils.copyProperties(tempPccs, pccs);
-				} catch (Exception e) {
-					throw new BizException("克隆对象出错", e);
-				}
-				if (i == 0) {
-					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), 0, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
-										.setScale(0, BigDecimal.ROUND_DOWN)));
-						tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().subtract(
-								pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
-										.setScale(0, BigDecimal.ROUND_DOWN)));
-						tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() - pccs.getCourseTotalMinuties() / times * (times - 1));
+			BigDecimal totalPaymentAmount = BigDecimal.ZERO;
+			if(musicGroupPaymentCalenderCourseSettingsList != null){
+				List<MusicGroupPaymentCalenderCourseSettings> newCSList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>(
+						musicGroupPaymentCalenderCourseSettingsList.size());
+				for (MusicGroupPaymentCalenderCourseSettings pccs : musicGroupPaymentCalenderCourseSettingsList) {
+
+					MusicGroupPaymentCalenderCourseSettings tempPccs = new MusicGroupPaymentCalenderCourseSettings();
+					try {
+						BeanUtils.copyProperties(tempPccs, pccs);
+					} catch (Exception e) {
+						throw new BizException("克隆对象出错", e);
 					}
-				} else {
-					if (!pccs.getIsStudentOptional()) {
-						tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN));
-						tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN));
-						tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() / times);
+					if (i == 0) {
+						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), 0, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
+											.setScale(0, BigDecimal.ROUND_DOWN)));
+							tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().subtract(
+									pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
+											.setScale(0, BigDecimal.ROUND_DOWN)));
+							tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() - pccs.getCourseTotalMinuties() / times * (times - 1));
+						}
 					} else {
-						continue;
+						if (!pccs.getIsStudentOptional()) {
+							tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN));
+							tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN));
+							tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() / times);
+						} else {
+							continue;
+						}
 					}
+					totalPaymentAmount = totalPaymentAmount.add(tempPccs.getCourseCurrentPrice());
+					newCSList.add(tempPccs);
 				}
-				totalPaymentAmount = totalPaymentAmount.add(tempPccs.getCourseCurrentPrice());
-				newCSList.add(tempPccs);
+				musicGroupPaymentCalender.setMusicGroupPaymentCalenderCourseSettingsList(newCSList);
 			}
-			
-			musicGroupPaymentCalender.setMusicGroupPaymentCalenderCourseSettingsList(newCSList);
 			musicGroupPaymentCalender.setPaymentAmount(totalPaymentAmount);
-
 			musicGroupPaymentCalender.setPaymentPattern(musicGroupPaymentCalenderDto.getPaymentPattern());
 			musicGroupPaymentCalender.setPaymentValidEndDate(musicGroupPaymentDateRange.getPaymentValidEndDate());
 			musicGroupPaymentCalender.setPaymentValidStartDate(musicGroupPaymentDateRange.getPaymentValidStartDate());
@@ -357,14 +397,18 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			musicGroupPaymentCalender.setUpdateTime(date);
 			musicGroupPaymentCalender.setStatus(status);
 
+			//缴费截止日期默认三天后
 			if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null && payUserType == PayUserType.STUDENT) {
 				musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
 			}
+			//校验缴费有效期冲突
 			if (paymentType != ADD_STUDENT && paymentType != ADD_COURSE && paymentType != SPAN_GROUP_CLASS_ADJUST) {
-				int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(),
-						musicGroupPaymentCalender.getPaymentValidStartDate(), musicGroupPaymentCalender.getPaymentValidEndDate(), null);
-				if (count > 0) {
-					throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
+				if(musicGroupPaymentCalender.getPaymentValidStartDate() != null){
+					int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(),
+							musicGroupPaymentCalender.getPaymentValidStartDate(), musicGroupPaymentCalender.getPaymentValidEndDate(), null);
+					if (count > 0) {
+						throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
+					}
 				}
 			}
 
@@ -387,14 +431,18 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 			// 设置批次号
 			musicGroupPaymentCalender.setBatchNo(batchNo);
+			//设置会员缴费金额、级别以及有效期
+			musicGroupPaymentCalender.setMemberPaymentAmount(musicGroupPaymentCalenderDto.getMemberPaymentAmount());
+			musicGroupPaymentCalender.setMemberRankSettingId(musicGroupPaymentCalenderDto.getMemberRankSettingId());
+			musicGroupPaymentCalender.setMemberValidDate(musicGroupPaymentCalenderDto.getMemberValidDate());
 			musicGroupPaymentCalenderDto.setBatchNo(batchNo);
 			musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
 
-
+			//课程费用列表
 			List<MusicGroupPaymentCalenderCourseSettings> currentMusicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalender
 					.getMusicGroupPaymentCalenderCourseSettingsList();
 
-			if (currentMusicGroupPaymentCalenderCourseSettings.size() > 0) {
+			if (currentMusicGroupPaymentCalenderCourseSettings != null && currentMusicGroupPaymentCalenderCourseSettings.size() > 0) {
 				MusicGroupOrganizationCourseSettings courseSettings = musicGroupOrganizationCourseSettingsDao.get(musicGroupPaymentCalender
 						.getMusicGroupOrganizationCourseSettingId());
 				for (MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : currentMusicGroupPaymentCalenderCourseSettings) {
@@ -417,7 +465,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			if (musicGroupPaymentCalender.getStatus() != AUDITING) {
 				// 如果是进行中加学生
 				if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
-					addStudent(musicGroupPaymentCalender, currentMusicGroupPaymentCalenderCourseSettings);
+					addStudent(musicGroupPaymentCalender, currentMusicGroupPaymentCalenderCourseSettings,musicGroup);
 				}else if(musicGroupPaymentCalender.getPaymentType() == SPAN_GROUP_CLASS_ADJUST){
 					//如果是跨团班级合并,添加学员
 					musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalender,musicGroupPaymentCalenderStudentDetails);
@@ -425,7 +473,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 					//缴费项目添加学员
 					int[] ints = Arrays.stream(musicGroupPaymentCalenderDto.getStudentIds().split(",")).mapToInt(Integer::parseInt).toArray();
 					Set<Integer> list2 = Arrays.stream(ints).boxed().collect(Collectors.toSet());
-					musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalender.getId(),list2);
+					musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalender.getId(),list2,musicGroup);
 				}
 				//将0元未缴费学员缴费状态更新为已缴费
 				int j = musicGroupPaymentCalenderDetailDao.updateNoPaymentAndZeroPaymentStatus(musicGroupPaymentCalender.getId());
@@ -448,14 +496,11 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			musicGroup.setUpdateTime(date);
 			musicGroupDao.update(musicGroup);
 		} else if (paymentType == ADD_STUDENT) {
-
 			if (status != AUDITING) {
 				// 学生加到班级
 				String classGroupIdStr = musicGroupPaymentCalenderDto.getAttribute1();
-				if (StringUtils.isNotBlank(classGroupIdStr)) {
-					classGroupService.addStudentToClassGroupAndCourseArranging(Integer.parseInt(musicGroupPaymentCalenderDto.getStudentIds()), classGroupIdStr,
-							batchNo, musicGroupPaymentCalenderCourseSettingsList);
-				}
+				classGroupService.addStudentToClassGroupAndCourseArranging(Integer.parseInt(musicGroupPaymentCalenderDto.getStudentIds()), classGroupIdStr,
+						batchNo, musicGroupPaymentCalenderCourseSettingsList,musicGroup);
 			}
 		}
 
@@ -515,6 +560,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 		List<MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList = musicGroupPaymentCalenderDto.getMusicGroupPaymentDateRangeList();
 
+		if(musicGroupPaymentCalenderDto.getMemberRankSettingId() != null){
+			if(paymentType != ADD_STUDENT && paymentType != MUSIC_APPLY){
+				throw new BizException("操作失败:{} 不支持会员收费",paymentType.getDesc());
+			}
+		}
+
 		if ((paymentType == PaymentType.ADD_COURSE) && musicGroupPaymentDateRangeList.size() > 1) {
 			throw new BizException("[临时加课]不支持多周期缴费");
 		}
@@ -528,6 +579,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		if (sysUser == null) {
 			throw new BizException("请登录");
 		}
+		if (musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE && musicGroupPaymentDateRangeList.size() > 1) {
+			throw new BizException("创建缴费失败:会员收费乐团不支持多周期缴费");
+		}
 
 		List<Long> calenderIds = musicGroupPaymentCalenderList.stream().map(MusicGroupPaymentCalender :: getId).collect(Collectors.toList());
 		//删除原来数据
@@ -541,87 +595,114 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		// 获取设置的课程
 		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderDto
 				.getMusicGroupPaymentCalenderCourseSettingsList();
-		if (musicGroupPaymentCalenderCourseSettingsList == null) {
-			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
-		}
+//		if (musicGroupPaymentCalenderCourseSettingsList == null) {
+//			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
+//		}
 
+		//会员原价
+		BigDecimal memberPaymentAmount = BigDecimal.ZERO;
 		if (payUserType == SCHOOL) {
 			status = AUDITING;
 		} else {
-			if (paymentType == MUSIC_APPLY || paymentType == MUSIC_RENEW) {
-				// 当前缴费的课程费用
-				Map<CourseScheduleType, BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(
-						Collectors
-								.toMap(MusicGroupPaymentCalenderCourseSettings::getCourseType, MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice));
-
-				// 查询默认课程费用
-				Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId();
-				Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao
-						.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId)
-						.stream()
-						.collect(
-								Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail::getCourseType,
-										MusicGroupOrganizationCourseSettingsDetail::getCourseCurrentPrice));
-
-				// 相同类型的课程如果修改了课程费用,需要走审批
-				for (Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()) {
-					if (defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0) {
-						status = AUDITING;
-						break;
-					}
-				}
-			} else if (paymentType == PaymentType.ADD_COURSE || paymentType == PaymentType.ADD_STUDENT) {
-				// 如果是临时加课,判断是否审核
-				for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
-					OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
-							musicGroup.getOrganId(), courseSettings.getCourseType(), musicGroup.getChargeTypeId());
-					if (defaultUnitPrice == null) {
-						throw new BizException("请先设置分部课程类型单价");
+			if(musicGroupPaymentCalenderCourseSettingsList != null){
+				if (paymentType == MUSIC_APPLY || paymentType == MUSIC_RENEW) {
+					// 当前缴费的课程费用
+					Map<CourseScheduleType, BigDecimal> currentCoursePrice = musicGroupPaymentCalenderCourseSettingsList.stream().collect(
+							Collectors
+									.toMap(MusicGroupPaymentCalenderCourseSettings::getCourseType, MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice));
+
+					// 查询默认课程费用
+					Integer musicGroupOrganizationCourseSettingId = musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId();
+					Map<CourseScheduleType, BigDecimal> defaultCoursePrice = musicGroupOrganizationCourseSettingsDetailDao
+							.queryByMusicGroupOrganizationCourseSettingsId(musicGroupOrganizationCourseSettingId)
+							.stream()
+							.collect(
+									Collectors.toMap(MusicGroupOrganizationCourseSettingsDetail::getCourseType,
+											MusicGroupOrganizationCourseSettingsDetail::getCourseCurrentPrice));
+
+					// 相同类型的课程如果修改了课程费用,需要走审批
+					for (Entry<CourseScheduleType, BigDecimal> entry : currentCoursePrice.entrySet()) {
+						if (defaultCoursePrice.get(entry.getKey()).compareTo(entry.getValue()) != 0) {
+							status = AUDITING;
+							break;
+						}
 					}
-					if (courseSettings.getCourseTotalMinuties() != 0) {
-						if (defaultUnitPrice.getUnitPrice().multiply(new BigDecimal(courseSettings.getCourseTotalMinuties())).setScale(0, BigDecimal.ROUND_HALF_UP)
-								.compareTo(courseSettings.getCourseCurrentPrice()) != 0) {
+				} else if (paymentType == PaymentType.ADD_COURSE || paymentType == PaymentType.ADD_STUDENT) {
+					// 如果是临时加课,判断是否审核
+					for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
+						OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
+								musicGroup.getOrganId(), courseSettings.getCourseType(), musicGroup.getChargeTypeId());
+						if (defaultUnitPrice == null) {
+							throw new BizException("请先设置分部课程类型单价");
+						}
+						if (courseSettings.getCourseTotalMinuties() != 0) {
+							if (defaultUnitPrice.getUnitPrice().multiply(new BigDecimal(courseSettings.getCourseTotalMinuties())).setScale(0, BigDecimal.ROUND_HALF_UP)
+									.compareTo(courseSettings.getCourseCurrentPrice()) != 0) {
 
+								status = AUDITING;
+								break;
+							}
+						} else {
 							status = AUDITING;
 							break;
 						}
-					} else {
-						status = AUDITING;
-						break;
 					}
-				}
-			}else if(paymentType == SPAN_GROUP_CLASS_ADJUST){
-				MusicGroupStudentClassAdjust adjust = musicGroupStudentClassAdjustDao.findByBatchNo(batchNo);
-				//获取默认的学员缴费详情
-				List<Integer> studentIdList = JSON.parseArray(adjust.getStudentIds(), Integer.class);
-				//获取欠费学员列表
-				List<Integer> noPaymentUserIds = musicGroupPaymentCalenderDetailDao.queryNoPaymentUserIds(musicGroup.getId(), studentIdList);
-				if(noPaymentUserIds.size() > 0){
-					throw new BizException("操作失败:有欠费的学员不允许创建缴费");
-				}
-				//获取缴费状态在审核中或者已拒绝的缴费项目的学员
-				String studentIds = musicGroupPaymentCalenderDao.queryCalenderStudentIds(musicGroupId,batchNo);
-				if(StringUtils.isNotEmpty(studentIds)){
-					for (Integer integer : studentIdList) {
-						if(studentIds.contains(integer.toString())){
-							throw new BizException("操作失败:所选学员有待审核或已拒绝的缴费项目");
+				}else if(paymentType == SPAN_GROUP_CLASS_ADJUST){
+					MusicGroupStudentClassAdjust adjust = musicGroupStudentClassAdjustDao.findByBatchNo(batchNo);
+					//获取默认的学员缴费详情
+					List<Integer> studentIdList = JSON.parseArray(adjust.getStudentIds(), Integer.class);
+					//获取欠费学员列表
+					List<Integer> noPaymentUserIds = musicGroupPaymentCalenderDetailDao.queryNoPaymentUserIds(musicGroup.getId(), studentIdList);
+					if(noPaymentUserIds.size() > 0){
+						throw new BizException("操作失败:有欠费的学员不允许创建缴费");
+					}
+					//获取缴费状态在审核中或者已拒绝的缴费项目的学员
+					String studentIds = musicGroupPaymentCalenderDao.queryCalenderStudentIds(musicGroupId,batchNo);
+					if(StringUtils.isNotEmpty(studentIds)){
+						for (Integer integer : studentIdList) {
+							if(studentIds.contains(integer.toString())){
+								throw new BizException("操作失败:所选学员有待审核或已拒绝的缴费项目");
+							}
 						}
 					}
-				}
 
-				List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails = classGroupService.queryStudentPaymentCalenders(adjust.getMasterClassGroupId(),
-						adjust.getClassGroupStudents(),studentIdList);
-				List<MusicGroupPaymentCalenderStudentDetail> calenderStudentDetails = musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails();
+					List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails = classGroupService.queryStudentPaymentCalenders(adjust.getMasterClassGroupId(),
+							adjust.getClassGroupStudents(),studentIdList);
+					List<MusicGroupPaymentCalenderStudentDetail> calenderStudentDetails = musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails();
 
-				boolean containsAll = musicGroupPaymentCalenderStudentDetails.containsAll(calenderStudentDetails);
-				if(!containsAll){
+					boolean containsAll = musicGroupPaymentCalenderStudentDetails.containsAll(calenderStudentDetails);
+					if(!containsAll){
+						status = AUDITING;
+						//保存新的学员详情
+					}
+					//删除之前的记录
+					musicGroupPaymentCalenderStudentDetailDao.delByBatchNo(batchNo);
+					//保存现有记录
+					musicGroupPaymentCalenderStudentDetailDao.batchInsert(calenderStudentDetails,batchNo);
+				}
+			}
+			if(musicGroupPaymentCalenderDto.getMemberRankSettingId() != null){
+				//会员价格是否变动
+				MemberFeeSetting memberFee = memberFeeSettingDao.findByRankIdAndOrganId(musicGroup.getOrganId(), musicGroupPaymentCalenderDto.getMemberRankSettingId());
+				if(memberFee == null){
+					throw new BizException("操作失败:请配置当前分部会员收费标准");
+				}
+				switch (musicGroupPaymentCalenderDto.getMemberValidDate()){
+					case 1 :
+						memberPaymentAmount = memberFee.getCurrentMonthFee().setScale(0, BigDecimal.ROUND_HALF_UP);
+						break;
+					case 6 :
+						memberPaymentAmount = memberFee.getCurrentHalfYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
+						break;
+					case 12 :
+						memberPaymentAmount = memberFee.getCurrentYearFee().setScale(0, BigDecimal.ROUND_HALF_UP);
+						break;
+					default:
+						throw new BizException("请选择正确的会员有效期");
+				}
+				if(memberPaymentAmount.compareTo(musicGroupPaymentCalenderDto.getMemberPaymentAmount()) != 0){
 					status = AUDITING;
-					//保存新的学员详情
 				}
-				//删除之前的记录
-				musicGroupPaymentCalenderStudentDetailDao.delByBatchNo(batchNo);
-				//保存现有记录
-				musicGroupPaymentCalenderStudentDetailDao.batchInsert(calenderStudentDetails,batchNo);
 			}
 		}
 
@@ -643,54 +724,56 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			MusicGroupPaymentCalender musicGroupPaymentCalender = new MusicGroupPaymentCalender();
 			musicGroupPaymentCalender.setAttribute1(musicGroupPaymentCalenderDto.getAttribute1());
 			musicGroupPaymentCalender.setAttribute2(musicGroupPaymentCalenderDto.getAttribute2());
+			musicGroupPaymentCalender.setOriginalMemberPaymentAmount(memberPaymentAmount);
 			musicGroupPaymentCalender.setDeadlinePaymentDate(musicGroupPaymentDateRange.getDeadlinePaymentDate());
 			musicGroupPaymentCalender.setIsGiveMusicNetwork(musicGroupPaymentCalenderDto.getIsGiveMusicNetwork());
 			musicGroupPaymentCalender.setMemo(musicGroupPaymentCalenderDto.getMemo());
 			musicGroupPaymentCalender.setMusicGroupId(musicGroupId);
 			musicGroupPaymentCalender.setMusicGroupOrganizationCourseSettingId(musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId());
+			BigDecimal totalPaymentAmount = BigDecimal.ZERO;
+			if(musicGroupPaymentCalenderCourseSettingsList != null){
+				List<MusicGroupPaymentCalenderCourseSettings> newCSList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>(
+						musicGroupPaymentCalenderCourseSettingsList.size());
 
-			List<MusicGroupPaymentCalenderCourseSettings> newCSList = new ArrayList<MusicGroupPaymentCalenderCourseSettings>(
-					musicGroupPaymentCalenderCourseSettingsList.size());
-
-			BigDecimal totalPaymentAmount = new BigDecimal(0);
-			if(musicGroupPaymentCalenderDto.getPaymentType() == SPAN_GROUP_CLASS_ADJUST){
-				totalPaymentAmount = musicGroupPaymentDateRange.getPaymentAmount();
-			}
-			for (MusicGroupPaymentCalenderCourseSettings pccs : musicGroupPaymentCalenderCourseSettingsList) {
-
-				MusicGroupPaymentCalenderCourseSettings tempPccs = new MusicGroupPaymentCalenderCourseSettings();
-				try {
-					BeanUtils.copyProperties(tempPccs, pccs);
-				} catch (Exception e) {
-					throw new BizException("克隆对象出错", e);
+				if(musicGroupPaymentCalenderDto.getPaymentType() == SPAN_GROUP_CLASS_ADJUST){
+					totalPaymentAmount = musicGroupPaymentDateRange.getPaymentAmount();
 				}
-				if (i == 0) {
-					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), 0, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
-										.setScale(0, BigDecimal.ROUND_DOWN)));
-						tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().subtract(
-								pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
-										.setScale(0, BigDecimal.ROUND_DOWN)));
-						tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() - pccs.getCourseTotalMinuties() / times * (times - 1));
+				for (MusicGroupPaymentCalenderCourseSettings pccs : musicGroupPaymentCalenderCourseSettingsList) {
+
+					MusicGroupPaymentCalenderCourseSettings tempPccs = new MusicGroupPaymentCalenderCourseSettings();
+					try {
+						BeanUtils.copyProperties(tempPccs, pccs);
+					} catch (Exception e) {
+						throw new BizException("克隆对象出错", e);
 					}
-				} else {
-					if (!pccs.getIsStudentOptional()) {
-						tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN));
-						tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN));
-						tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() / times);
+					if (i == 0) {
+						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), 0, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
+											.setScale(0, BigDecimal.ROUND_DOWN)));
+							tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().subtract(
+									pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(times - 1))
+											.setScale(0, BigDecimal.ROUND_DOWN)));
+							tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() - pccs.getCourseTotalMinuties() / times * (times - 1));
+						}
+					} else {
+						if (!pccs.getIsStudentOptional()) {
+							tempPccs.setCourseCurrentPrice(pccs.getCourseCurrentPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN));
+							tempPccs.setCourseOriginalPrice(pccs.getCourseOriginalPrice().divide(new BigDecimal(times), 0, BigDecimal.ROUND_DOWN));
+							tempPccs.setCourseTotalMinuties(pccs.getCourseTotalMinuties() / times);
+						}
 					}
+					totalPaymentAmount = totalPaymentAmount.add(tempPccs.getCourseCurrentPrice());
+					newCSList.add(tempPccs);
 				}
-				totalPaymentAmount = totalPaymentAmount.add(tempPccs.getCourseCurrentPrice());
-				newCSList.add(tempPccs);
+				musicGroupPaymentCalender.setMusicGroupPaymentCalenderCourseSettingsList(newCSList);
 			}
-			musicGroupPaymentCalender.setMusicGroupPaymentCalenderCourseSettingsList(newCSList);
-			musicGroupPaymentCalender.setPaymentAmount(totalPaymentAmount);
 
+			musicGroupPaymentCalender.setPaymentAmount(totalPaymentAmount);
 			musicGroupPaymentCalender.setPaymentPattern(musicGroupPaymentCalenderDto.getPaymentPattern());
 			musicGroupPaymentCalender.setPaymentValidEndDate(musicGroupPaymentDateRange.getPaymentValidEndDate());
 			musicGroupPaymentCalender.setPaymentValidStartDate(musicGroupPaymentDateRange.getPaymentValidStartDate());
@@ -718,10 +801,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
 			}
 			if (paymentType != ADD_STUDENT && paymentType != ADD_COURSE && paymentType != SPAN_GROUP_CLASS_ADJUST) {
-				int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(),
-						musicGroupPaymentCalender.getPaymentValidStartDate(), musicGroupPaymentCalender.getPaymentValidEndDate(), null);
-				if (count > 0) {
-					throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
+				if(musicGroupPaymentCalender.getPaymentValidStartDate() != null){
+					int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(),
+							musicGroupPaymentCalender.getPaymentValidStartDate(), musicGroupPaymentCalender.getPaymentValidEndDate(), null);
+					if (count > 0) {
+						throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
+					}
 				}
 			}
 
@@ -744,6 +829,11 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 			// 设置批次号
 			musicGroupPaymentCalender.setBatchNo(batchNo);
+			//设置会员缴费金额、级别以及有效期
+			musicGroupPaymentCalender.setMemberPaymentAmount(musicGroupPaymentCalenderDto.getMemberPaymentAmount());
+			musicGroupPaymentCalender.setMemberRankSettingId(musicGroupPaymentCalenderDto.getMemberRankSettingId());
+			musicGroupPaymentCalender.setMemberValidDate(musicGroupPaymentCalenderDto.getMemberValidDate());
+			musicGroupPaymentCalenderDto.setBatchNo(batchNo);
 			musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
 			List<MusicGroupPaymentCalenderCourseSettings> currentMusicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalender
 					.getMusicGroupPaymentCalenderCourseSettingsList();
@@ -751,7 +841,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			if (musicGroupPaymentCalender.getStatus() != AUDITING) {
 				// 如果是进行中加学生
 				if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
-					addStudent(musicGroupPaymentCalender, currentMusicGroupPaymentCalenderCourseSettings);
+					addStudent(musicGroupPaymentCalender, currentMusicGroupPaymentCalenderCourseSettings,musicGroup);
 				}else if(musicGroupPaymentCalender.getPaymentType() == SPAN_GROUP_CLASS_ADJUST){
 					//如果是跨团班级合并,添加学员
 					musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalender,musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails());
@@ -794,7 +884,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				String classGroupIdStr = musicGroupPaymentCalenderDto.getAttribute1();
 				if (StringUtils.isNotBlank(classGroupIdStr)) {
 					classGroupService.addStudentToClassGroupAndCourseArranging(Integer.parseInt(musicGroupPaymentCalenderDto.getStudentIds()), classGroupIdStr,
-							batchNo, musicGroupPaymentCalenderCourseSettingsList);
+							batchNo, musicGroupPaymentCalenderCourseSettingsList,musicGroup);
 				}
 			}
 		}
@@ -854,15 +944,19 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 	@Transactional(rollbackFor = Exception.class)
 	@Override
-	public void addStudent(MusicGroupPaymentCalender musicGroupPaymentCalender,List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList){
+	public void addStudent(MusicGroupPaymentCalender musicGroupPaymentCalender,
+						   List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList,
+						   MusicGroup musicGroup){
 		//如果是进行中加学生
 		Date date = new Date();
 		String studentIdStr = musicGroupPaymentCalender.getStudentIds();
 		if (StringUtils.isNoneBlank(studentIdStr)) {
 			//计算总费用
-			BigDecimal totalPrice = new BigDecimal(0);
-			for(MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList){
-				totalPrice = totalPrice.add(musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice());
+			BigDecimal totalPrice = musicGroupPaymentCalender.getMemberPaymentAmount();
+			if(musicGroupPaymentCalenderCourseSettingsList != null && musicGroupPaymentCalenderCourseSettingsList.size() > 0){
+				for(MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList){
+					totalPrice = totalPrice.add(musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice());
+				}
 			}
 
 			List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<MusicGroupPaymentStudentCourseDetail>();
@@ -883,6 +977,10 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				musicGroupPaymentCalenderDetailDao.insert(musicGroupPaymentCalenderDetail);
 				//如果是0元那么更新fee表和studentRegistration表
 				if(totalPrice.doubleValue() == 0d){
+					// 添加会员有效时长
+					if(musicGroupPaymentCalender.getMemberRankSettingId() != null){
+						studentService.updateMemberRank(Integer.parseInt(studentId),musicGroupPaymentCalender.getMemberRankSettingId(),PeriodEnum.MONTH,6);
+					}
 					MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(Integer.parseInt(studentId), musicGroupPaymentCalender.getMusicGroupId());
 					if (musicGroupStudentFee != null) {
 						musicGroupStudentFee.setUpdateTime(date);
@@ -900,25 +998,46 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 					//统计变更学员数
 					groupEventSource.musicGroupStudentChangeEvent(musicGroupPaymentCalender.getMusicGroupId(), StudentMusicGroupStatusEnum.NORMAL, new ArrayList<>(Arrays.asList(Integer.parseInt(studentId))));
 				}
-
-				// 学生加课程明细
-				for(MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList){
-					if (courseSettings.getIsStudentOptional() == true) {
-						continue;
+				if(musicGroupPaymentCalenderCourseSettingsList != null && musicGroupPaymentCalenderCourseSettingsList.size() > 0){
+					// 学生加课程明细
+					for(MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList){
+						if (courseSettings.getIsStudentOptional() == true) {
+							continue;
+						}
+						musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+						musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
+						musicGroupPaymentStudentCourseDetail.setCreateTime(date);
+						musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+						musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
+						musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
+						musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
+						musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(courseSettings.getCourseTotalMinuties());
+						musicGroupPaymentStudentCourseDetail.setUserId(Integer.parseInt(studentId));
+						musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
 					}
-					musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
-					musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
-					musicGroupPaymentStudentCourseDetail.setCreateTime(date);
-					musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
-					musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
-					musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
-					musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
-					musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(courseSettings.getCourseTotalMinuties());
-					musicGroupPaymentStudentCourseDetail.setUserId(Integer.parseInt(studentId));
-
-					musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
-				}
 
+				}
+				//如果是系统收费乐团
+				/*if(musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
+					//获取会员收费排课的课程
+					List<RemainCourseTypeDurationDto> durationDtos = courseScheduleDao.queryRemainCourseTypeDuration(musicGroupPaymentCalender.getAttribute1(), 1);
+					if(durationDtos != null && durationDtos.size() > 0){
+						Integer totalMinutes = durationDtos.stream().map(e -> e.getRemainMinutes()).reduce(0, Integer::sum);
+						musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+						musicGroupPaymentStudentCourseDetail.setCreateTime(date);
+						musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+						musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
+						//默认的会员总时长
+						musicGroupPaymentStudentCourseDetail.setMemberCourseMinutes(6*4*4*45);
+						//排课情况
+						musicGroupPaymentStudentCourseDetail.setCourseDetail(JSONObject.toJSONString(durationDtos));
+						musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
+						//消耗的时长
+						musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(totalMinutes);
+						musicGroupPaymentStudentCourseDetail.setUserId(Integer.parseInt(studentId));
+						musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
+					}
+				}*/
 				if(musicGroupPaymentStudentCourseDetailList.size() > 0){
 					musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
 				}
@@ -1025,6 +1144,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		List<MusicGroupPaymentCalender> groupPaymentCalenders = musicGroupPaymentCalenderDao.findByBatchNo(batchNo);
 		calenderAuditDetailDto.setMusicGroupPaymentCalenders(groupPaymentCalenders);
 		MusicGroupPaymentCalender paymentCalender = groupPaymentCalenders.get(0);
+		if(paymentCalender.getMemberRankSettingId() != null){
+			MemberRankSetting memberRankSetting = memberRankSettingDao.get(paymentCalender.getMemberRankSettingId());
+			if(memberRankSetting != null){
+				paymentCalender.setMemberRankSettingName(memberRankSetting.getName());
+			}
+		}
 		if(paymentCalender.getPaymentType() == ADD_STUDENT){
 			try {
 				String studentIds = groupPaymentCalenders.get(0).getStudentIds();
@@ -1055,12 +1180,13 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			}
 		}
 		List<ClassGroup4MixDto> classGroup4MixDtos = JSON.parseArray(musicGroupStudentClassAdjust.getNewClassGroupJson(), ClassGroup4MixDto.class);
-
+		String musicGroupId = musicGroupPaymentCalenders.get(0).getMusicGroupId();
+		MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
 		for (MusicGroupPaymentCalender calender : musicGroupPaymentCalenders) {
 			//缴费项目添加学员
 			int[] ints = Arrays.stream(calender.getStudentIds().split(",")).mapToInt(Integer::parseInt).toArray();
 			Set<Integer> list2 = Arrays.stream(ints).boxed().collect(Collectors.toSet());
-			musicGroupPaymentCalenderDetailService.batchAdd(calender.getId(),list2);
+			musicGroupPaymentCalenderDetailService.batchAdd(calender.getId(),list2,musicGroup);
 		}
 		//每种课程类型单独排课
 		ClassGroup classGroup = null;
@@ -1076,7 +1202,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudents(courseIds,studentIds);
 		//解冻课程
 		List<Long> allCourseIds = JSON.parseArray(musicGroupStudentClassAdjust.getAllLockCourseIds(), Long.class);
-		courseScheduleDao.batchUpdateLockByCourseIds(allCourseIds,0);
+		courseScheduleDao.batchUpdateLockByCourseIds(allCourseIds,0,null);
 		//解冻班级
 		List<Integer> classGroupIds = JSON.parseArray(musicGroupStudentClassAdjust.getClassGroupIds(), Integer.class);
 		classGroupDao.batchUpdateLockByClassGroupIds(classGroupIds,0);
@@ -1106,7 +1232,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(delCourseIds);
 		}
 		classGroupService.batchUpdateTeacherSalary(classGroupIds);
-		imUserFriendService.refreshGroupImUserFriend(musicGroupPaymentCalenders.get(0).getMusicGroupId(),GroupType.MUSIC);
+		imUserFriendService.refreshGroupImUserFriend(musicGroupId,GroupType.MUSIC);
 	}
 
 	@Override
@@ -1119,6 +1245,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			if(musicGroupPaymentCalenders == null || musicGroupPaymentCalenders.size() == 0){
 				throw new BizException("缴费项目不存在");
 			}
+			MusicGroupPaymentCalender calender = musicGroupPaymentCalenders.get(0);
+			MusicGroup musicGroup = musicGroupDao.get(calender.getMusicGroupId());
 			for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenders) {
 				//如果是报名项目,将乐团改为审核中,缴费项目修改状态,审核状态改为审核通过
 				if(musicGroupPaymentCalender.getPayUserType() == SCHOOL){
@@ -1140,11 +1268,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
 					musicGroupPaymentCalender.setExpectNum(1);
 					List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.queryCalenderCourseSettings(musicGroupPaymentCalender.getId());
-					addStudent(musicGroupPaymentCalender,musicGroupPaymentCalenderCourseSettings);
+					addStudent(musicGroupPaymentCalender,musicGroupPaymentCalenderCourseSettings,musicGroup);
 				}
 			}
-			MusicGroupPaymentCalender calender = musicGroupPaymentCalenders.get(0);
-			MusicGroup musicGroup = musicGroupDao.get(calender.getMusicGroupId());
 			if(calender.getPaymentType() == ADD_STUDENT || calender.getPaymentType() == SPAN_GROUP_CLASS_ADJUST){
 				// 所有缴费项目已完成排课才能创建下一个缴费项目
 				List<String> batchNoList = new ArrayList<>();
@@ -1189,7 +1315,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				String classGroupIdStr = calender.getAttribute1();
 				if (StringUtils.isNotBlank(classGroupIdStr)) {
 					classGroupService.addStudentToClassGroupAndCourseArranging(Integer.parseInt(calender.getStudentIds()), classGroupIdStr, batchNo,
-							musicGroupPaymentCalenderCourseSettingsDao.queryCalenderCourseSettingsByBatchNo(batchNo));
+							musicGroupPaymentCalenderCourseSettingsDao.queryCalenderCourseSettingsByBatchNo(batchNo),musicGroup);
 				}
 				MusicGroupStudentClassAdjust musicGroupStudentClassAdjust = musicGroupStudentClassAdjustDao.findByBatchNo(batchNo);
 				if(musicGroupStudentClassAdjust != null){

+ 158 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupSchoolTermCourseDetailServiceImpl.java

@@ -0,0 +1,158 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentMemberCourseDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupSchoolTermCourseDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupSchoolTermStudentCourseDetail;
+import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
+import com.ym.mec.biz.service.MusicGroupSchoolTermCourseDetailService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.util.date.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class MusicGroupSchoolTermCourseDetailServiceImpl extends BaseServiceImpl<Integer, MusicGroupSchoolTermCourseDetail>  implements MusicGroupSchoolTermCourseDetailService {
+	
+	@Autowired
+	private MusicGroupSchoolTermCourseDetailDao musicGroupSchoolTermCourseDetailDao;
+	@Autowired
+	private MusicGroupSchoolTermStudentCourseDetailDao musicGroupSchoolTermStudentCourseDetailDao;
+	@Autowired
+	private StudentRegistrationDao studentRegistrationDao;
+	@Autowired
+	private MusicGroupDao musicGroupDao;
+	@Autowired
+	private CourseScheduleDao courseScheduleDao;
+	@Autowired
+	private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
+	@Autowired
+	private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
+
+	@Override
+	public BaseDAO<Integer, MusicGroupSchoolTermCourseDetail> getDAO() {
+		return musicGroupSchoolTermCourseDetailDao;
+	}
+
+    @Override
+    public MusicGroupSchoolTermCourseDetail findByMusicGroupId(String musicGroupId) {
+		return musicGroupSchoolTermCourseDetailDao.findByCourseDateAndMusicGroupId(musicGroupId,null,0);
+    }
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public HttpResponseResult upset(MusicGroupSchoolTermCourseDetail musicGroupSchoolTermCourseDetail) {
+		Date startCourseDate = musicGroupSchoolTermCourseDetail.getStartCourseDate();
+		String musicGroupId = musicGroupSchoolTermCourseDetail.getMusicGroupId();
+		MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
+		if(musicGroup.getCourseViewType() != CourseViewTypeEnum.MEMBER_FEE){
+			throw new BizException("操作失败:该功能只适用于系统收费团");
+		}
+		//校验当前乐团是否所有学员都在班
+		if(studentRegistrationDao.checkHasNotClass(musicGroupId)){
+			throw new BizException("操作失败:请确保所有在读学员都在班级");
+		}
+		MusicGroupSchoolTermCourseDetail courseDetail = musicGroupSchoolTermCourseDetailDao.
+				findByCourseDateAndMusicGroupId(musicGroupId,startCourseDate,0);
+		Date date = DateUtil.stringToDate(DateUtil.format(new Date(),DateUtil.ISO_EXPANDED_DATE_FORMAT),DateUtil.ISO_EXPANDED_DATE_FORMAT);
+		if(startCourseDate != null){
+			MusicGroupSchoolTermCourseDetail courseDetail1 = musicGroupSchoolTermCourseDetailDao.findByCourseDateAndMusicGroupId(musicGroupId,startCourseDate,1);
+			if(courseDetail1 != null){
+				throw new BizException("操作失败:所选时间段已排课,请勿重复操作");
+			}
+			if(DateUtil.daysBetween(date, startCourseDate) < 0){
+				//如果所选时间小于当前时间
+				throw new BizException("操作失败:开课时间不得小于当前时间");
+			}
+		}
+		if(courseDetail != null){
+			if(startCourseDate != null){
+				//如果是重新选择的预排课时间
+//				if(DateUtil.daysBetween(startCourseDate, courseDetail.getStartCourseDate()) != 0){
+					//清空预排课
+					if(musicGroupSchoolTermCourseDetail.getCleanPreCourseFlag()){
+						//删除乐团预排的课程
+						courseScheduleStudentPaymentDao.deletePreCourse(musicGroupId);
+						courseScheduleTeacherSalaryDao.deletePreCourse(musicGroupId);
+						courseScheduleDao.deletePreCourse(musicGroupId);
+						courseDetail.setStartCourseDate(startCourseDate);
+						getCourseDetail(courseDetail);
+						musicGroupSchoolTermCourseDetailDao.update(courseDetail);
+						//删除学员排课时长
+						musicGroupSchoolTermStudentCourseDetailDao.deleteByDetailId(courseDetail.getId(),null);
+						//生成学员可排课时长
+						MusicGroupSchoolTermStudentCourseDetail studentCourseDetail = new MusicGroupSchoolTermStudentCourseDetail();
+						studentCourseDetail.setMusicGroupSchoolTermCourseDetailId(courseDetail.getId());
+						studentCourseDetail.setMemberCourseMinutes(courseDetail.getTotalCourseTime());
+						//获取乐团所有在读学员
+						List<Integer> studentIds = studentRegistrationDao.queryNormalUser(musicGroupId);
+						if(studentIds == null || studentIds.size() == 0){
+							throw new BizException("操作失败:该乐团没有在读学员");
+						}
+						musicGroupSchoolTermStudentCourseDetailDao.init(studentCourseDetail,studentIds);
+					}else {
+						return BaseController.failed(HttpStatus.MULTI_STATUS, "修改开课日期会清空预排课,请再次确认");
+					}
+//				}
+			}else {
+				//如果所选时间小于当前时间
+				if(DateUtil.daysBetween(date, courseDetail.getStartCourseDate()) < 0){
+					throw new BizException("开课时间不得小于当前时间,请重新配置");
+				}
+			}
+		}else {
+			if(startCourseDate != null){
+				courseDetail = new MusicGroupSchoolTermCourseDetail();
+				courseDetail.setMusicGroupId(musicGroupId);
+				courseDetail.setCourseFlag(false);
+				courseDetail.setStartCourseDate(startCourseDate);
+				getCourseDetail(courseDetail);
+				musicGroupSchoolTermCourseDetailDao.insert(courseDetail);
+				//生成学员可排课时长
+				MusicGroupSchoolTermStudentCourseDetail studentCourseDetail = new MusicGroupSchoolTermStudentCourseDetail();
+				studentCourseDetail.setMusicGroupSchoolTermCourseDetailId(courseDetail.getId());
+				studentCourseDetail.setMemberCourseMinutes(courseDetail.getTotalCourseTime());
+				//获取乐团所有在读学员
+				List<Integer> studentIds = studentRegistrationDao.queryNormalUser(musicGroupId);
+				if(studentIds == null || studentIds.size() == 0){
+					throw new BizException("操作失败:该乐团没有在读学员");
+				}
+				musicGroupSchoolTermStudentCourseDetailDao.init(studentCourseDetail,studentIds);
+			}
+		}
+		return BaseController.succeed(courseDetail);
+	}
+
+	private MusicGroupSchoolTermCourseDetail getCourseDetail(MusicGroupSchoolTermCourseDetail courseDetail){
+		Date startCourseDate = courseDetail.getStartCourseDate();
+		//一个学期默认为6个月,9月1日—2月28、29日,3月1日—8月31日
+		Integer month = Integer.parseInt(DateUtil.getMonth(startCourseDate));
+		String year = DateUtil.getYear(startCourseDate);
+		if(month >= 9 && month <= 2){
+			if(month >= 9){
+				year = DateUtil.getYear(DateUtil.addYears(startCourseDate, 1));
+			}
+			courseDetail.setEndSchoolTerm(DateUtil.getLastDayOfMonth(DateUtil.stringToDate(year + "-02-01")));
+		}else {
+			courseDetail.setEndSchoolTerm(DateUtil.stringToDate(year + "-08-31 00:00:00"));
+		}
+		courseDetail.setStartSchoolTerm(startCourseDate);
+		//计算可排课时长
+//		int week = LocalDateTime.ofInstant(startCourseDate.toInstant(),DateUtil.zoneId).getDayOfWeek().getValue();
+		int week = DateUtil.date2Week1(startCourseDate);
+		int weekSize = DateUtil.getWeekDays(startCourseDate, courseDetail.getEndSchoolTerm(), week).size();
+		courseDetail.setTotalCourseTime(weekSize * 4 * 45);
+		courseDetail.setStartCourseDate(startCourseDate);
+		return courseDetail;
+	}
+}

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupSchoolTermStudentCourseDetailServiceImpl.java

@@ -0,0 +1,22 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.common.dal.BaseDAO;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.biz.dal.entity.MusicGroupSchoolTermStudentCourseDetail;
+import com.ym.mec.biz.service.MusicGroupSchoolTermStudentCourseDetailService;
+import com.ym.mec.biz.dal.dao.MusicGroupSchoolTermStudentCourseDetailDao;
+import org.springframework.stereotype.Service;
+
+@Service
+public class MusicGroupSchoolTermStudentCourseDetailServiceImpl extends BaseServiceImpl<Long, MusicGroupSchoolTermStudentCourseDetail>  implements MusicGroupSchoolTermStudentCourseDetailService {
+	
+	@Autowired
+	private MusicGroupSchoolTermStudentCourseDetailDao musicGroupSchoolTermStudentCourseDetailDao;
+
+	@Override
+	public BaseDAO<Long, MusicGroupSchoolTermStudentCourseDetail> getDAO() {
+		return musicGroupSchoolTermStudentCourseDetailDao;
+	}
+	
+}

+ 16 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -209,6 +209,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     @Autowired
     private CloudTeacherOrderService cloudTeacherOrderService;
 
+    @Autowired
+    private MusicGroupSchoolTermCourseDetailDao musicGroupSchoolTermCourseDetailDao;
+
+    @Autowired
+    private MusicGroupSchoolTermStudentCourseDetailDao musicGroupSchoolTermStudentCourseDetailDao;
+
     private SimpleDateFormat sdf_ymd = new SimpleDateFormat("yyyy-MM-dd");
 
     private SimpleDateFormat sdf_hms = new SimpleDateFormat("HH:mm:ss");
@@ -1844,7 +1850,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             if (hasPaid && musicGroupSubjectPlan != null) {
                 musicGroupSubjectPlan.setUpdateTime(date);
                 //减去缴费人数(器乐收费,0元时不减缴费人数)
-                if (musicGroup.getCourseViewType().equals(CourseViewTypeEnum.CLOUD_TEACHER) || musicGroup.getCourseViewType().equals(CourseViewTypeEnum.CLOUD_TEACHER_PLUS)) {
+                if (musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE) || musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE)) {
                     if (studentPaymentOrder != null && studentPaymentOrder.getPaymentAccountNo() != null && studentPaymentOrder.getPaymentAccountNo().equals("200")) {
                         musicGroupSubjectPlan.setPaidZeroNum(musicGroupSubjectPlan.getPaidZeroNum() - 1);
                         musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
@@ -1973,6 +1979,14 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (courseScheduleList != null && courseScheduleList.size() > 0) {
             throw new BizException("退团失败,存在[进行中]的课程");
         }
+        //如果是会员团,并且有预排课计划
+        MusicGroupSchoolTermCourseDetail termCourseDetail = musicGroupSchoolTermCourseDetailDao.findByCourseDateAndMusicGroupId(musicGroupId, null, 0);
+        if(termCourseDetail != null){
+            MusicGroupSchoolTermStudentCourseDetailDao studentCourseDetailDao = musicGroupSchoolTermStudentCourseDetailDao.findByDetailIdAndStudentId(termCourseDetail.getId(),userId);
+            if(studentCourseDetailDao != null){
+                throw new BizException("退团失败:该学员存在预排课安排,请先取消预排课");
+            }
+        }
 
         courseScheduleStudentPaymentService.updateCourseActualPrice(Arrays.asList(musicGroupId), Arrays.asList(userId), GroupType.MUSIC);
 
@@ -2078,7 +2092,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (hasPaid && musicGroupSubjectPlan != null) {
             musicGroupSubjectPlan.setUpdateTime(date);
             //减去缴费人数(器乐收费,0元时不减缴费人数)
-            if (musicGroup.getCourseViewType().equals(CourseViewTypeEnum.CLOUD_TEACHER) || musicGroup.getCourseViewType().equals(CourseViewTypeEnum.CLOUD_TEACHER_PLUS)) {
+            if (musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE) || musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE)) {
                 if (studentPaymentOrder != null && studentPaymentOrder.getPaymentAccountNo() != null && studentPaymentOrder.getPaymentAccountNo().equals("200")) {
                     musicGroupSubjectPlan.setPaidZeroNum(musicGroupSubjectPlan.getPaidZeroNum() - 1);
                     musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);

+ 9 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupSubjectPlanServiceImpl.java

@@ -10,6 +10,7 @@ import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.MusicGroupGoodsAndDiscountDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
+
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -18,6 +19,7 @@ import com.alibaba.fastjson.JSON;
 import com.ym.mec.biz.dal.dto.MusicGroupRegRespDto;
 import com.ym.mec.biz.dal.dto.MusicGroupSubjectGoodsAndInfoDto;
 import com.ym.mec.biz.service.GoodsService;
+import com.ym.mec.biz.service.MemberRankPrivilegesService;
 import com.ym.mec.biz.service.MusicGroupService;
 import com.ym.mec.biz.service.MusicGroupSubjectGoodsGroupService;
 import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
@@ -60,6 +62,9 @@ public class MusicGroupSubjectPlanServiceImpl extends BaseServiceImpl<Integer, M
     @Autowired
     private OrganizationCloudTeacherFeeDao organizationCloudTeacherFeeDao;
 
+	@Autowired
+	private MemberRankPrivilegesService memberRankPrivilegesService;
+
     @Override
     public BaseDAO<Integer, MusicGroupSubjectPlan> getDAO() {
         return musicGroupSubjectPlanDao;
@@ -127,10 +132,13 @@ public class MusicGroupSubjectPlanServiceImpl extends BaseServiceImpl<Integer, M
         musicGroupSubjectGoodsAndInfo.setMusicGroupPaymentCalender(musicGroupRegCalender);
         musicGroupSubjectGoodsAndInfo.setMusicGroupSubjectGoodsGroupList(goodsGroups);
         musicGroupSubjectGoodsAndInfo.setMusicGroup(musicGroup);
-        if (musicGroup.getCourseViewType().equals(CourseViewTypeEnum.CLOUD_TEACHER) || musicGroup.getCourseViewType().equals(CourseViewTypeEnum.CLOUD_TEACHER_PLUS)) {
+        if (musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE)) {
             OrganizationCloudTeacherFee cloudTeacherFee = organizationCloudTeacherFeeDao.getByOrganId(musicGroup.getOrganId());
             musicGroupSubjectGoodsAndInfo.setCloudTeacherFee(cloudTeacherFee.getPrice());
             musicGroupSubjectGoodsAndInfo.setCloudTeacherPlusFee(cloudTeacherFee.getPlusPrice());
+            if(musicGroupRegCalender != null) {
+            	musicGroupSubjectGoodsAndInfo.setMemberPrivilegesItemList(memberRankPrivilegesService.queryByMemberRankId(musicGroupRegCalender.getMemberRankSettingId()));
+            }
         }
         return musicGroupSubjectGoodsAndInfo;
     }

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

@@ -60,8 +60,6 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
     @Autowired
     private TeacherDao teacherDao;
     @Autowired
-    private StudentExtracurricularExercisesSituationDao studentExtracurricularExercisesSituationDao;
-    @Autowired
     private StudentDao studentDao;
     @Autowired
     private SubjectDao subjectDao;
@@ -213,6 +211,8 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
             }
         }
         courseHomeworkStudentDetail.setType("HOMEWORK");
+        Student student = studentDao.get(userId.intValue());
+        courseHomeworkStudentDetail.setHasMember(student.getMemberRankSettingId()==null?0:1);
         return courseHomeworkStudentDetail;
     }
 

+ 92 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import com.alibaba.fastjson.JSON;
@@ -25,6 +26,9 @@ import com.ym.mec.biz.dal.dto.PageInfoOrder;
 import com.ym.mec.biz.dal.dto.SporadicChargeInfoDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
+import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
@@ -77,6 +81,10 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     private DegreeRegistrationService degreeRegistrationService;
     @Autowired
     private StudentPaymentRouteOrderDao studentPaymentRouteOrderDao;
+
+    @Autowired
+    private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
+
     @Autowired
     private IdGeneratorService idGeneratorService;
     @Autowired
@@ -90,12 +98,91 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     @Autowired
     private ChildrenDayReserveService childrenDayReserveService;
 
+    @Autowired
+    private MemberRankSettingService memberRankSettingService;
+    @Autowired
+    private PayService payService;
+    @Autowired
+    private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
+
+    @Autowired
+    private CloudTeacherOrderService cloudTeacherOrderService;
+
     @Override
     public BaseDAO<Long, StudentPaymentOrder> getDAO() {
         return studentPaymentOrderDao;
     }
 
     @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+	public Map createOrder(StudentPaymentOrder studentPaymentOrder, List<StudentPaymentOrderDetail> details, String payReceiver)
+			throws Exception {
+
+    	BigDecimal cashAmount = studentPaymentOrder.getActualAmount();
+    	BigDecimal expectAmount = studentPaymentOrder.getExpectAmount();
+    	BigDecimal balance = studentPaymentOrder.getBalancePaymentAmount();
+
+		if (cashAmount.add(balance).compareTo(expectAmount) != 0) {
+			throw new BizException("支付金额不正确,请重试");
+		}
+
+		Date date = new Date();
+		studentPaymentOrder.setUpdateTime(date);
+
+		StudentPaymentOrder orignStudentPaymentOrder = get(studentPaymentOrder.getId());
+		if(orignStudentPaymentOrder == null){
+
+			String orderNo = idGeneratorService.generatorId("payment") + "";
+			studentPaymentOrder.setOrderNo(orderNo);
+			studentPaymentOrder.setCreateTime(date);
+			studentPaymentOrder.setUpdateTime(date);
+			studentPaymentOrder.setVersion(0);
+			insert(studentPaymentOrder);
+		}
+
+		if(details != null && details.size() > 0){
+			for(StudentPaymentOrderDetail spod : details){
+				spod.setPaymentOrderId(studentPaymentOrder.getId());
+				spod.setCreateTime(date);
+				spod.setUpdateTime(date);
+			}
+
+			studentPaymentOrderDetailService.batchAdd(details);
+		}
+
+		String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
+
+		if (cashAmount.compareTo(BigDecimal.ZERO) == 0) {
+            studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
+            studentPaymentOrder.setRoutingOrganId(studentPaymentOrder.getOrganId());
+            studentPaymentOrder.setUpdateTime(date);
+            studentPaymentOrder.setPayTime(date);
+            update(studentPaymentOrder);
+
+			studentPaymentRouteOrderService.addRouteOrder(studentPaymentOrder.getOrderNo(), studentPaymentOrder.getOrganId(), balance);
+
+			callOrderCallBack(studentPaymentOrder);
+
+			Map<String, String> notifyMap = new HashMap<>(4);
+			notifyMap.put("tradeState", "1");
+			notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
+			notifyMap.put("channelType", "");
+			notifyMap.put("orderNo", "");
+			updateOrder(notifyMap);
+			return notifyMap;
+		}
+
+		Map<String, Object> payMap = payService.getPayMap(cashAmount, balance, studentPaymentOrder.getOrderNo(), baseApiUrl + "/api-student/studentOrder/notify", baseApiUrl
+				+ "/api-student/studentOrder/paymentResult?orderNo=" + studentPaymentOrder.getOrderNo(), studentPaymentOrder.getMemo(), studentPaymentOrder.getMemo(), studentPaymentOrder.getOrganId(), payReceiver);
+
+		studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
+		studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
+		studentPaymentOrder.setUpdateTime(date);
+		update(studentPaymentOrder);
+		return payMap;
+	}
+
+	@Override
     public List<Goods> queryApplyGoodsList(String musicGroupId, OrderDetailTypeEnum type) {
         return studentPaymentOrderDao.queryApplyGoodsList(musicGroupId, type);
     }
@@ -376,6 +463,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             replacementInstrumentActivityService.orderCallback(order);
         }else if (order.getType().equals(OrderTypeEnum.DEGREE)) {
             childrenDayReserveService.orderCallback(order);
+        }else if (order.getType().equals(OrderTypeEnum.MEMBER)) {
+        	memberRankSettingService.orderCallback(order);
         }
     }
 
@@ -543,6 +632,9 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                 if (StringUtils.isNotBlank(childGoodIds)) {
                     studentPaymentOrderDetail.setChildGoodsList(goodsDao.findGoodsByIds(childGoodIds));
                 }
+                if(studentPaymentOrderDetail.getType() == OrderDetailTypeEnum.CLOUD_TEACHER ||studentPaymentOrderDetail.getType() == OrderDetailTypeEnum.CLOUD_TEACHER_PLUS){
+                	studentPaymentOrderDetail.setCloudTeacherOrderDto(cloudTeacherOrderService.queryOrderInfoByOrderId(studentPaymentOrderDetail.getPaymentOrderId()));
+                }
             }
         }
         return orders;

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

@@ -504,8 +504,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
         int paidNum = musicOneSubjectClassPlan.getPaidStudentNum() == null ? 0 : musicOneSubjectClassPlan.getPaidStudentNum();
         int paidZeroNum = musicOneSubjectClassPlan.getPaidZeroNum() == null ? 0 : musicOneSubjectClassPlan.getPaidZeroNum();
-        if ((musicGroup.getCourseViewType().equals(CourseViewTypeEnum.CLOUD_TEACHER) && !buyCloudTeacher) ||
-                (musicGroup.getCourseViewType().equals(CourseViewTypeEnum.CLOUD_TEACHER_PLUS) && !buyCloudTeacherPlus)
+        if ((musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE) && !buyCloudTeacher) ||
+                (musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE) && !buyCloudTeacherPlus)
         ) {
             paidZeroFlag = true;
             if (studentRegistration.getNoneNeedCloudTeacher().equals(1)) {
@@ -1223,7 +1223,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             studentRegistrationDao.update(studentRegistration);
 
             //减去缴费人数(器乐收费,0元时不减缴费人数)
-            if (musicGroup.getCourseViewType().equals(CourseViewTypeEnum.CLOUD_TEACHER) || musicGroup.getCourseViewType().equals(CourseViewTypeEnum.CLOUD_TEACHER_PLUS)) {
+            if (musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE) || musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE)) {
                 if (studentPaymentOrder.getPaymentAccountNo() != null && studentPaymentOrder.getPaymentAccountNo().equals("200")) {
                     musicOneSubjectClassPlan.setPaidZeroNum(musicOneSubjectClassPlan.getPaidZeroNum() - 1);
                     musicOneSubjectClassPlan.setPaidStudentNum(musicOneSubjectClassPlan.getPaidStudentNum() - 1);

+ 8 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java

@@ -45,11 +45,11 @@ public class StudentServeServiceImpl implements StudentServeService {
     @Autowired
     private StudentServeService studentServeService;
     @Autowired
-    private ClassGroupTeacherMapperDao classGroupTeacherMapperDao;
-    @Autowired
     private SysConfigService sysConfigService;
     @Autowired
     private ClassGroupStudentMapperDao classGroupStudentMapperDao;
+    @Autowired
+    private MusicGroupDao musicGroupDao;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -912,6 +912,8 @@ public class StudentServeServiceImpl implements StudentServeService {
         }
         List<Integer> studentIds=new ArrayList<>();
         if(StringUtils.isNotBlank(studentIdsStr)){
+            //获取有会员的学员数
+            result.put("memberNum", studentDao.getMemberNum(studentIdsStr));
             studentIds= Arrays.asList(studentIdsStr.split(",")).stream().map(id->Integer.valueOf(id)).collect(Collectors.toList());
         }
 
@@ -923,6 +925,10 @@ public class StudentServeServiceImpl implements StudentServeService {
                 result.put("isAssignHomework", 0);
                 return result;
             }
+            MusicGroup musicGroup = musicGroupDao.get(courseSchedule.getMusicGroupId());
+            if(musicGroup != null){
+                result.put("courseViewType", CourseViewTypeEnum.MEMBER_FEE);
+            }
             localDate=LocalDateTime.ofInstant(courseSchedule.getClassDate().toInstant(), DateUtil.zoneId).toLocalDate();
             List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByCourseSchedule(courseScheduleId);
             if(CollectionUtils.isEmpty(courseScheduleStudentPayments)){

+ 132 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServiceImpl.java

@@ -1,30 +1,45 @@
 package com.ym.mec.biz.service.impl;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
-import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.dto.StudentClassInfoDto;
-import com.ym.mec.biz.dal.entity.CooperationOrgan;
-import com.ym.mec.biz.dal.enums.FivePlusGradeEnum;
-import com.ym.mec.biz.dal.enums.GradeTypeEnum;
-import com.ym.mec.biz.dal.enums.SixPlusGradeEnum;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
+import com.ym.mec.biz.dal.dao.CourseScheduleDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
+import com.ym.mec.biz.dal.dao.PracticeGroupDao;
+import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
+import com.ym.mec.biz.dal.dto.StudentClassInfoDto;
 import com.ym.mec.biz.dal.dto.StudentCourseTimesDto;
 import com.ym.mec.biz.dal.dto.StudentTeacherCourseDto;
+import com.ym.mec.biz.dal.entity.CooperationOrgan;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.Student;
+import com.ym.mec.biz.dal.enums.FivePlusGradeEnum;
+import com.ym.mec.biz.dal.enums.GradeTypeEnum;
+import com.ym.mec.biz.dal.enums.PeriodEnum;
+import com.ym.mec.biz.dal.enums.SixPlusGradeEnum;
 import com.ym.mec.biz.dal.page.StudentQueryInfo;
 import com.ym.mec.biz.service.StudentService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
+import com.ym.mec.util.date.DateUtil;
 
 @Service
 public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implements StudentService {
@@ -261,4 +276,114 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
         cooperationOrgan.setLinkman(studentEduTeacher);
         return cooperationOrgan;
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateMemberRank(Integer userId, Integer rankSettingId, PeriodEnum periodEnum, int quantityPerPeriod) {
+        // 添加会员有效时长
+        Student student = this.get(userId);
+        if (student == null) {
+            throw new BizException("学员信息不存在");
+        }
+        
+        Date nowDate = new Date();
+        if (student.getMemberRankSettingId() == null || nowDate.after(student.getMembershipEndTime())) {
+        	switch (periodEnum) {
+    		case DAY:
+                student.setMembershipEndTime(DateUtil.addDays(nowDate, quantityPerPeriod));
+    			break;
+    		case MONTH:
+    		case YEAR_HALF:
+                student.setMembershipEndTime(DateUtil.addMonths(nowDate, quantityPerPeriod));
+    			break;
+    		case YEAR:
+                student.setMembershipEndTime(DateUtil.addYears(nowDate, quantityPerPeriod));
+    			break;
+
+    		default:
+    			break;
+    		}
+            student.setMembershipStartTime(nowDate);
+        } else {
+        	switch (periodEnum) {
+    		case DAY:
+            	student.setMembershipEndTime(DateUtil.addDays(student.getMembershipEndTime(), quantityPerPeriod));
+    			break;
+    		case MONTH:
+    		case YEAR_HALF:
+            	student.setMembershipEndTime(DateUtil.addMonths(student.getMembershipEndTime(), quantityPerPeriod));
+    			break;
+    		case YEAR:
+            	student.setMembershipEndTime(DateUtil.addYears(student.getMembershipEndTime(), quantityPerPeriod));
+    			break;
+
+    		default:
+    			break;
+    		}
+        }
+        student.setMemberRankSettingId(rankSettingId);
+        student.setUpdateTime(nowDate);
+        this.update(student);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void batchUpdateMemberRank(List<Integer> studentIds, Integer rankSettingId, PeriodEnum periodEnum, int quantityPerPeriod) {
+        // 添加会员有效时长
+        List<Student> studentList = studentDao.findByStudentIds(studentIds);
+        Date nowDate = new Date();
+        for (Student student : studentList) {
+            if (student.getMemberRankSettingId() == null || nowDate.after(student.getMembershipEndTime())) {
+                switch (periodEnum) {
+                    case DAY:
+                        student.setMembershipEndTime(DateUtil.addDays(nowDate, quantityPerPeriod));
+                        break;
+                    case MONTH:
+                    case YEAR_HALF:
+                        student.setMembershipEndTime(DateUtil.addMonths(nowDate, quantityPerPeriod));
+                        break;
+                    case YEAR:
+                        student.setMembershipEndTime(DateUtil.addYears(nowDate, quantityPerPeriod));
+                        break;
+                    default:
+                        break;
+                }
+                student.setMembershipStartTime(nowDate);
+            } else {
+                switch (periodEnum) {
+                    case DAY:
+                        student.setMembershipEndTime(DateUtil.addMonths(student.getMembershipEndTime(), quantityPerPeriod));
+                        break;
+                    case MONTH:
+                    case YEAR_HALF:
+                        student.setMembershipEndTime(DateUtil.addMonths(student.getMembershipEndTime(), quantityPerPeriod));
+                        break;
+                    case YEAR:
+                        student.setMembershipEndTime(DateUtil.addMonths(student.getMembershipEndTime(), quantityPerPeriod));
+                        break;
+
+                    default:
+                        break;
+                }
+            }
+            student.setMemberRankSettingId(rankSettingId);
+            student.setUpdateTime(nowDate);
+        }
+        studentDao.batchUpdate(studentList);
+    }
+
+    @Override
+    public void updateStudentServiceTag(Integer studentId,List<Integer> studentIds,Integer serviceTag) {
+        studentDao.updateStudentServiceTag(studentId, studentIds, serviceTag);
+    }
+
+    @Override
+    public List<String> getStudentNames(List<Integer> studentIdList) {
+        return studentDao.getStudentNames(studentIdList);
+    }
+
+	@Override
+	public Student getLocked(Integer userId) {
+		return studentDao.getLocked(userId);
+	}
 }

+ 53 - 4
mec-biz/src/main/resources/config/mybatis/CloudTeacherOrderMapper.xml

@@ -22,6 +22,25 @@
         <result column="update_time_" property="updateTime"/>
         <result column="music_group_id_" property="musicGroupId"/>
     </resultMap>
+    
+    <resultMap type="com.ym.mec.biz.dal.dto.CloudTeacherOrderDto" id="CloudTeacherOrderDto">
+    	<id column="id_" property="cloudTeacherOrder.id"/>
+        <result column="organ_id_" property="cloudTeacherOrder.organId"/>
+        <result column="student_id_" property="cloudTeacherOrder.studentId"/>
+        <result column="type_" property="cloudTeacherOrder.type"/>
+        <result column="level_" property="cloudTeacherOrder.level"/>
+        <result column="time_" property="cloudTeacherOrder.time"/>
+        <result column="amount_" property="cloudTeacherOrder.amount"/>
+        <result column="refund_amount_" property="cloudTeacherOrder.refundAmount"/>
+        <result column="status_" property="cloudTeacherOrder.status"/>
+        <result column="start_time_" property="cloudTeacherOrder.startTime"/>
+        <result column="end_time_" property="cloudTeacherOrder.endTime"/>
+        <result column="order_id_" property="cloudTeacherOrder.orderId"/>
+        <result column="trans_status_" property="studentPaymentOrder.status"/>
+        <result column="expect_amount_" property="studentPaymentOrder.expectAmount"/>
+        <result column="name_" property="memberRankSetting.name"/>
+        <result column="icon_" property="memberRankSetting.icon"/>
+    </resultMap>
 
     <select id="get" resultMap="CloudTeacherOrder">
         <!--@mbg.generated-->
@@ -97,15 +116,33 @@
     </select>
 
     <!-- 分页查询 -->
-    <select id="queryPage" resultMap="CloudTeacherOrder" parameterType="map">
-        SELECT * FROM cloud_teacher_order
+    <select id="queryPage" resultMap="CloudTeacherOrderDto" parameterType="map">
+        SELECT cto.*,spo.status_ trans_status_,spo.expect_amount_,mrs.name_,mrs.icon_ FROM cloud_teacher_order cto 
+        left join student_payment_order spo on cto.organ_id_ = spo.id_
+        left join member_rank_setting mrs on mrs.id_ = cto.level_
+        where spo.type_ = 'MEMBER'
+        <if test="status != null">
+        	and cto.status_ = #{status}
+        </if>
+        <if test="studentId != null">
+        	and cto.student_id_ = #{studentId}
+        </if>
+        order by spo.pay_time_ desc,spo.id_ desc
         <include refid="global.limit"/>
     </select>
 
     <!-- 查询当前表的总记录数 -->
     <select id="queryCount" resultType="int">
-        SELECT COUNT(*)
-        FROM cloud_teacher_order
+        SELECT COUNT(cto.id_)
+        FROM cloud_teacher_order cto left join student_payment_order spo on cto.organ_id_ = spo.id_
+        where spo.type_ = 'MEMBER'
+        <if test="status != null">
+        	and cto.status_ = #{status}
+        </if>
+        <if test="studentId != null">
+        	and cto.student_id_ = #{studentId}
+        </if>
+        order by cto.create_time_ desc
     </select>
 
     <select id="getNoStartCloudTeacherOrder" resultMap="CloudTeacherOrder">
@@ -153,4 +190,16 @@
           AND student_id_ = #{studentId}
           AND status_ IN (1, 2)
     </select>
+
+    <select id="queryByOrderId" resultMap="CloudTeacherOrder">
+        SELECT cto.* FROM cloud_teacher_order cto
+        WHERE order_id_ = #{orderId}
+    </select>
+    
+    <select id="queryOrderInfoByOrderId" resultMap="CloudTeacherOrderDto">
+        SELECT cto.*,spo.status_ trans_status_,spo.expect_amount_,mrs.name_,mrs.icon_ FROM cloud_teacher_order cto 
+        left join student_payment_order spo on cto.organ_id_ = spo.id_
+        left join member_rank_setting mrs on mrs.id_ = cto.level_
+        where spo.type_ = 'MEMBER' and order_id_ = #{orderId}
+    </select>
 </mapper>

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

@@ -36,6 +36,9 @@
         <result column="teaching_content_" property="teachingContent"/>
         <result column="note_" property="note"/>
         <result column="organ_id_" property="organId"/>
+        <result column="member_flag_" property="memberFlag"/>
+        <result column="pre_course_flag_" property="preCourseFlag"/>
+        <result column="valid_end_time_" property="validEndTime"/>
     </resultMap>
 
     <resultMap type="com.ym.mec.biz.dal.dto.Mapper" id="Mapper">
@@ -157,7 +160,10 @@
         cs.teaching_content_,
         cs.note_,
         cs.organ_id_,
-        cs.new_course_id_
+        cs.new_course_id_,
+        cs.member_flag_,
+        cs.valid_end_time_,
+        cs.pre_course_flag_
     </sql>
 
     <!-- 根据主键查询一条记录 -->
@@ -178,15 +184,15 @@
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CourseSchedule" useGeneratedKeys="true" keyColumn="id"
             keyProperty="id">
         INSERT INTO course_schedule
-        (id_,group_type_,music_group_id_,class_group_id_,status_,subsidy_,class_date_,start_class_time_,end_class_time_,
+        (group_type_,music_group_id_,class_group_id_,status_,subsidy_,class_date_,start_class_time_,end_class_time_,
         teacher_id_,actual_teacher_id_,create_time_,update_time_,type_,name_,teach_mode_,student_num_,leave_student_num_,
-        schoole_id_,is_lock_,note_,teaching_content_,organ_id_)
-        VALUES(#{id},#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{classGroupId},
+        schoole_id_,is_lock_,note_,teaching_content_,organ_id_,member_flag_,pre_course_flag_,valid_end_time_)
+        VALUES(#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{classGroupId},
         #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{subsidy},#{classDate},#{startClassTime},
         #{endClassTime},#{teacherId},#{teacherId},now(),now(),
         #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{name},
         #{teachMode,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{studentNum},#{leaveStudentNum},
-        #{schoolId},#{isLock},#{note},#{teachingContent},#{organId})
+        #{schoolId},#{isLock},#{note},#{teachingContent},#{organId},#{memberFlag},#{preCourseFlag},#{validEndTime})
     </insert>
 
     <insert id="batchAddCourseSchedules" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
@@ -194,7 +200,7 @@
         INSERT INTO course_schedule
         (group_type_,music_group_id_,class_group_id_,status_,subsidy_,class_date_,start_class_time_,end_class_time_,
         teacher_id_,actual_teacher_id_,create_time_,update_time_,type_,name_,teach_mode_,student_num_,leave_student_num_,
-        schoole_id_,is_lock_,note_,teaching_content_,organ_id_)
+        schoole_id_,is_lock_,note_,teaching_content_,organ_id_,member_flag_,pre_course_flag_,valid_end_time_)
         VALUE
         <foreach collection="list" item="course" separator=",">
             (#{course.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{course.musicGroupId},
@@ -202,7 +208,8 @@
             #{course.subsidy},#{course.classDate},#{course.startClassTime},#{course.endClassTime},#{course.teacherId},
             #{course.teacherId},now(),now(),#{course.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             #{course.name},#{course.teachMode,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{course.studentNum},
-            #{course.leaveStudentNum},#{course.schoolId},#{course.isLock},#{course.note},#{course.teachingContent},#{course.organId})
+            #{course.leaveStudentNum},#{course.schoolId},#{course.isLock},#{course.note},#{course.teachingContent},
+            #{course.organId},#{course.memberFlag},#{course.preCourseFlag},#{course.validEndTime})
         </foreach>
     </insert>
 
@@ -210,6 +217,15 @@
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.CourseSchedule">
         UPDATE course_schedule
         <set>
+            <if test="validEndTime != null">
+                valid_end_time_ = #{validEndTime},
+            </if>
+            <if test="preCourseFlag != null">
+                pre_course_flag_ = #{preCourseFlag},
+            </if>
+            <if test="memberFlag != null">
+                member_flag_ = #{memberFlag},
+            </if>
             <if test="organId != null">
                 organ_id_ = #{organId},
             </if>
@@ -1358,6 +1374,9 @@
     <update id="batchUpdateLockByCourseIds">
         UPDATE course_schedule
         SET is_lock_ = #{isLock}, update_time_ = NOW()
+        <if test="preCourseFlag != null">
+            ,pre_course_flag_ = #{preCourseFlag}
+        </if>
         WHERE id_ IN
         <foreach collection="courseId" open="(" close=")" item="item" separator=",">
             #{item}
@@ -2154,6 +2173,9 @@
         WHERE music_group_id_ = #{groupId}
           AND group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
     </delete>
+    <delete id="deletePreCourse">
+        DELETE FROM course_schedule WHERE music_group_id_ = #{musicGroupId} AND group_type_ = 'MUSIC' AND pre_course_flag_ = 1
+    </delete>
 
     <select id="queryUnsignedStudentList" resultMap="StudentAttendance">
         SELECT cssp.user_id_,
@@ -2306,6 +2328,15 @@
         AND cs.del_flag_ = 0
         GROUP BY cs.class_group_id_
     </select>
+    <select id="countPreTotalNumByClassGroupId" resultType="java.util.Map">
+        SELECT cs.class_group_id_ 'key',COUNT(cs.id_) 'value' FROM course_schedule cs
+        WHERE cs.class_group_id_ IN
+        <foreach collection="classGroupIds" item="item" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND cs.del_flag_ = 0 AND pre_course_flag_ = 1
+        GROUP BY cs.class_group_id_
+    </select>
     <select id="countCurrentNumByClassGroupId" resultType="java.util.Map">
         SELECT cs.class_group_id_ 'key',COUNT(cs.id_) 'value' FROM course_schedule cs
         WHERE cs.class_group_id_ IN
@@ -3531,14 +3562,16 @@
     </select>
 
     <select id="queryRemainCourseTypeDuration" resultMap="RemainCourseTypeDurationDto">
-		SELECT a.course_type_,SUM(remain_minutes_) remain_minutes_ FROM 
+		SELECT a.course_type_,SUM(remain_minutes_) remain_minutes_,SUM(temp_merged_course_num_) temp_merged_course_num_ FROM
 		(SELECT cs.type_ course_type_,SUM(TIMESTAMPDIFF(MINUTE,STR_TO_DATE(concat(cs.class_date_,' ',cs.start_class_time_),'%Y-%m-%d %H:%i:%s'),
-        STR_TO_DATE(concat(cs.class_date_,' ',cs.end_class_time_),'%Y-%m-%d %H:%i:%s'))) remain_minutes_
-		from course_schedule cs where FIND_IN_SET(cs.class_group_id_,#{classgroupId}) and cs.status_ = 'NOT_START' and (cs.new_course_id_ is null or cs.new_course_id_ = 0) group by cs.type_
-		UNION all
+        STR_TO_DATE(concat(cs.class_date_,' ',cs.end_class_time_),'%Y-%m-%d %H:%i:%s'))) remain_minutes_,COUNT(cs.id_) temp_merged_course_num_
+		FROM course_schedule cs WHERE FIND_IN_SET(cs.class_group_id_,#{classGroupIdList}) AND cs.status_ = 'NOT_START'
+		AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = 0) AND cs.member_flag_ = #{memberFlag} GROUP BY cs.type_
+		UNION ALL
 		SELECT ncs.type_ course_type_,SUM(TIMESTAMPDIFF(MINUTE,STR_TO_DATE(concat(ncs.class_date_,' ',ncs.start_class_time_),'%Y-%m-%d %H:%i:%s'),
-        STR_TO_DATE(concat(ncs.class_date_,' ',ncs.end_class_time_),'%Y-%m-%d %H:%i:%s'))) remain_minutes_ FROM course_schedule cs LEFT JOIN course_schedule ncs ON ncs.id_ = cs.new_course_id_ 
-		  WHERE FIND_IN_SET(cs.class_group_id_,#{classgroupId}) and cs.new_course_id_ &gt; 0 AND ncs.status_ = 'NOT_START' GROUP BY ncs.type_) a
+        STR_TO_DATE(concat(ncs.class_date_,' ',ncs.end_class_time_),'%Y-%m-%d %H:%i:%s'))) remain_minutes_,COUNT(cs.id_) temp_merged_course_num_
+		FROM course_schedule cs LEFT JOIN course_schedule ncs ON ncs.id_ = cs.new_course_id_
+		WHERE FIND_IN_SET(cs.class_group_id_,#{classGroupIdList}) AND cs.new_course_id_ &gt; 0 AND ncs.status_ = 'NOT_START' AND cs.member_flag_ = #{memberFlag} GROUP BY ncs.type_) a
 		group BY a.course_type_
     </select>
 
@@ -3850,4 +3883,35 @@
                 #{courseId}
             </foreach>
     </select>
+    <select id="queryPreCourseListByClassGroupId" resultMap="CourseSchedule">
+        SELECT <include refid="resultSql"/> FROM course_schedule cs WHERE class_group_id_ = #{classGroupId}
+        AND is_lock_ = 1 AND pre_course_flag_ = 1
+    </select>
+
+    <select id="queryPreCourseListByMusicGroupId" resultMap="CourseSchedule">
+        SELECT * FROM course_schedule WHERE music_group_id_ = #{musicGroupId} AND group_type_ = 'MUSIC' AND is_lock_ = 1 AND pre_course_flag_ = 1
+    </select>
+    <select id="sumCourseMinutes" resultType="int">
+        SELECT SUM(c.course_mintues_) FROM (SELECT FLOOR((UNIX_TIMESTAMP(CONCAT(class_date_, ' ', end_class_time_)) -
+        UNIX_TIMESTAMP(CONCAT(class_date_, ' ', start_class_time_))) / 60) course_mintues_ FROM course_schedule
+        WHERE id_ IN
+        <foreach collection="courseScheduleIds" item="courseId" open="(" close=")" separator=",">
+            #{courseId}
+        </foreach>) c
+    </select>
+    <select id="countPreSubMinutesByClassGroupId" resultType="java.util.Map">
+        SELECT cgsm.class_group_id_ 'key',MIN(mgst.member_course_minutes_ - mgst.pre_member_course_minutes_) 'value'
+        FROM class_group_student_mapper cgsm
+        LEFT JOIN music_group_school_term_student_course_detail mgst ON mgst.user_id_ = cgsm.user_id_
+        WHERE cgsm.class_group_id_ IN
+        <foreach collection="classGroupSet" open="(" close=")" item="classGroupId" separator=",">
+            #{classGroupId}
+        </foreach>
+        AND mgst.music_group_school_term_course_detail_id_ = #{courseDetailId}
+        GROUP BY cgsm.class_group_id_
+    </select>
+    <select id="queryOverPreCourseListByMusicGroupId" resultType="int">
+        SELECT count(id_) FROM course_schedule WHERE music_group_id_ = #{musicGroupId} AND group_type_ = 'MUSIC' AND is_lock_ = 1 AND pre_course_flag_ = 1
+                                        AND CONCAT(class_date_,' ', start_class_time_) &lt;= NOW()
+    </select>
 </mapper>

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

@@ -430,8 +430,12 @@
 	<delete id="deleteByGroup">
 		DELETE FROM course_schedule_student_payment WHERE music_group_id_=#{groupId} AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 	</delete>
+    <delete id="deletePreCourse">
+		DELETE FROM course_schedule_student_payment WHERE course_schedule_id_ IN (
+		SELECT id_ FROM course_schedule WHERE music_group_id_ = #{musicGroupId} AND group_type_ = 'MUSIC' AND pre_course_flag_ = 1)
+	</delete>
 
-	<select id="queryStudentNotStartCourseTimesOfOnline" resultMap="studentCourseTimesDto">
+    <select id="queryStudentNotStartCourseTimesOfOnline" resultMap="studentCourseTimesDto">
 		SELECT cssp.`user_id_`,count(*) totalTimes,
 		sum(CASE pg.type_ WHEN 'FREE' THEN 0 WHEN 'CHARGE' THEN 1 END) practiceTmes,
 		sum(case when (pg.type_='FREE' AND cssp.`group_type_` = 'PRACTICE' ) then 1 ELSE 0 END) freePracticeTimes

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

@@ -602,8 +602,12 @@
 	<delete id="deleteByGroup">
 		DELETE FROM course_schedule_teacher_salary WHERE music_group_id_=#{groupId} AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 	</delete>
+	<delete id="deletePreCourse">
+		DELETE FROM course_schedule_teacher_salary WHERE course_schedule_id_ IN (
+			SELECT id_ FROM course_schedule WHERE music_group_id_ = #{musicGroupId} AND group_type_ = 'MUSIC' AND pre_course_flag_ = 1)
+	</delete>
 
-	<select id="queryUserNoSettlementListByTypeAndStartClassDate" resultMap="CourseScheduleTeacherSalary">
+    <select id="queryUserNoSettlementListByTypeAndStartClassDate" resultMap="CourseScheduleTeacherSalary">
 		SELECT ts.*,cs.type_,cs.teach_mode_,cs.class_date_,cs.start_class_time_,cs.end_class_time_ FROM course_schedule_teacher_salary ts LEFT JOIN course_schedule cs ON ts.course_schedule_id_ = cs.id_
 		WHERE FIND_IN_SET(cs.type_, #{typeList}) AND ts.user_id_ = #{userId} AND ts.settlement_time_ IS NULL AND cs.class_date_ &gt;= #{startClassDate}
 	</select>
@@ -1077,6 +1081,19 @@
 		</if>
 		GROUP BY course_schedule_id_
 	</select>
+	<select id="queryTeacherNameMap" resultType="java.util.Map">
+		SELECT course_schedule_id_ 'key',GROUP_CONCAT(DISTINCT su.real_name_) 'value'
+		FROM course_schedule_teacher_salary csts
+		LEFT JOIN sys_user su ON su.id_ = csts.user_id_
+		WHERE course_schedule_id_ IN
+		<foreach collection="courseScheduleIds" open="(" close=")" separator="," item="item">
+			#{item}
+		</foreach>
+		<if test="teacherRole != null">
+			AND teacher_role_ = #{teacherRole}
+		</if>
+		GROUP BY course_schedule_id_
+	</select>
 
 	<select id="getIsSalaryWithDate" resultMap="CourseScheduleTeacherSalary">
 		SELECT

+ 17 - 10
mec-biz/src/main/resources/config/mybatis/ExtracurricularExercisesMapper.xml

@@ -21,6 +21,8 @@
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
 		<result column="organ_name_" property="organName" />
+		<result column="music_score_id_" property="musicScoreId" />
+		<result column="music_score_name_" property="musicScoreName"/>
 	</resultMap>
 
 	<sql id="queryPageCondition">
@@ -58,19 +60,19 @@
 	
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercises" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		<!--
-		<selectKey resultClass="int" keyProperty="id" > 
-		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
-		</selectKey>
-		-->
-		INSERT INTO extracurricular_exercises (id_,teacher_id_,student_id_list_,batch_no_,title_,attachments_,content_,expire_date_,completed_num_,expect_num_,create_time_,update_time_)
-		VALUES(#{id},#{teacherId},#{studentIdList},#{batchNo},#{title},#{attachments},#{content},#{expireDate},#{completedNum},#{expectNum},NOW(), NOW())
+		INSERT INTO extracurricular_exercises (teacher_id_,student_id_list_,batch_no_,
+		                                       title_,attachments_,content_,expire_date_,completed_num_,expect_num_,create_time_,update_time_,music_score_id_)
+		VALUES(#{teacherId},#{studentIdList},#{batchNo},#{title},#{attachments},
+		       #{content},#{expireDate},#{completedNum},#{expectNum},NOW(), NOW(),#{musicScoreId})
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercises">
 		UPDATE extracurricular_exercises
 		<set>
+			<if test="musicScoreId != null">
+				music_score_id_ = #{musicScoreId},
+			</if>
 			<if test="studentIdList != null">
 			student_id_list_ = #{studentIdList},
 			</if>
@@ -80,9 +82,6 @@
 			<if test="batchNo != null">
 			batch_no_ = #{batchNo},
 			</if>
-			<if test="id != null">
-			id_ = #{id},
-			</if>
 			<if test="teacherId != null">
 			teacher_id_ = #{teacherId},
 			</if>
@@ -183,6 +182,14 @@
 			AND sees.teacher_id_ = #{teacherId}
 			AND sees.actual_exercises_num_ &lt; sees.expect_exercises_num_
 			AND sees.serve_type_ = 'EXERCISE'
+			<if test="hasMember != null">
+				<if test="hasMember == 1">
+					AND stu.member_rank_setting_id_ IS NOT NULL
+				</if>
+				<if test="hasMember == 0">
+					AND stu.member_rank_setting_id_ IS NULL
+				</if>
+			</if>
 			<if test="musicGroupId!=null and musicGroupId!=''">
 				AND sr.music_group_id_=#{musicGroupId}
 			</if>

Деякі файли не було показано, через те що забагато файлів було змінено