소스 검색

系统收费,缴费项目模块,
1、如果乐团创建缴费时同时有课程收费和会员收费,排课时长按乐团的收费类型来判断是取会员时长,还是课程时长
2、如果是会员收费,按默认的6*4*4*45的课程时长来计算可排课时长

zouxuan 4 년 전
부모
커밋
9b4ee473b8
21개의 변경된 파일541개의 추가작업 그리고 271개의 파일을 삭제
  1. 3 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MemberFeeSettingDao.java
  2. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MemberPrivilegesItemDao.java
  3. 33 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentCalenderDto.java
  4. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MemberPrivilegesItem.java
  5. 35 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java
  6. 24 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentCourseDetail.java
  7. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/CourseViewTypeEnum.java
  8. 5 1
      mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java
  9. 1 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MemberFeeSettingService.java
  10. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderDetailService.java
  11. 3 1
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java
  12. 19 12
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java
  13. 5 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberFeeSettingServiceImpl.java
  14. 31 14
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  15. 295 218
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  16. 5 0
      mec-biz/src/main/resources/config/mybatis/MemberFeeSettingMapper.xml
  17. 6 2
      mec-biz/src/main/resources/config/mybatis/MemberPrivilegesItemMapper.xml
  18. 25 5
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml
  19. 0 1
      mec-student/src/main/java/com/ym/mec/student/controller/ActivityController.java
  20. 27 0
      mec-web/src/main/java/com/ym/mec/web/controller/MemberFeeSettingController.java
  21. 10 10
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MemberFeeSettingDao.java

@@ -2,8 +2,10 @@ 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);
 }

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

@@ -16,5 +16,5 @@ public interface MemberPrivilegesItemDao extends BaseDAO<Integer, MemberPrivileg
      */
     List<MemberPrivilegesItem> findList(@Param("parentId") Integer parentId);
 
-    void batchDel(List<Integer> collect);
+    void batchDel(@Param("collect") List<Integer> collect);
 }

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

@@ -42,6 +42,39 @@ public class MusicGroupPaymentCalenderDto {
 
 	private BigDecimal masterTotalPrice = BigDecimal.ZERO;
 
+	//会员有效期(月)
+	private Integer memberValidDate;
+
+	//会员付款金额
+	private BigDecimal memberPaymentAmount;
+
+	//会员等级编号
+	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;
 

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

@@ -20,6 +20,8 @@ public class MemberPrivilegesItem {
 	
 	/** 编码 */
 	private String code;
+
+	private String path;
 	
 	/**  */
 	private Integer parentId = 0;
@@ -32,6 +34,14 @@ public class MemberPrivilegesItem {
 
 	private List<MemberPrivilegesItem> memberPrivilegesItems;
 
+	public String getPath() {
+		return path;
+	}
+
+	public void setPath(String path) {
+		this.path = path;
+	}
+
 	public List<MemberPrivilegesItem> getMemberPrivilegesItems() {
 		return memberPrivilegesItems;
 	}

+ 35 - 1
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;
 
@@ -163,6 +164,39 @@ public class MusicGroupPaymentCalender {
 	@ApiModelProperty(value = "课程展现形式",required = false)
 	private CourseViewTypeEnum courseViewType;
 
+	//会员有效期(月)
+	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;
+	}
+
 	public String getAuditMemo() {
 		return auditMemo;
 	}

+ 24 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentCourseDetail.java

@@ -26,8 +26,14 @@ public class MusicGroupPaymentStudentCourseDetail {
 	
 	/**  */
 	private Integer totalCourseMinutes;
+
+	/**  用来标注当前缴费项目排了哪些类型的课以及课时数*/
+	private String courseDetail;
+
+	/**  会员可排课时长*/
+	private Integer memberCourseMinutes;
 	
-	/**  */
+	/**  已消耗时长*/
 	private Integer usedCourseMinutes;
 	
 	/**  */
@@ -35,7 +41,23 @@ public class MusicGroupPaymentStudentCourseDetail {
 	
 	/**  */
 	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;
 	}

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/CourseViewTypeEnum.java

@@ -6,6 +6,8 @@ public enum CourseViewTypeEnum implements BaseEnum<Integer, CourseViewTypeEnum>
     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;

+ 5 - 1
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);
 
     /**
      * 获取未分配合奏的单技班列表

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

@@ -5,4 +5,5 @@ import com.ym.mec.common.service.BaseService;
 
 public interface MemberFeeSettingService extends BaseService<Integer, MemberFeeSetting> {
 
+    MemberFeeSetting findByRankIdAndOrganId(Integer organId, Integer rankId);
 }

+ 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);
 
 
 		/**

+ 19 - 12
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -1179,7 +1179,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);
@@ -1194,8 +1195,12 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         Date date = new Date();
         List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<CourseScheduleStudentPayment>();
 
+        //如果是会员收费的乐团,那么课程价值都是0
+        if(musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
+
+        }
         // 计算单价
-        Map<CourseScheduleType, BigDecimal> unitPriceMap = new HashMap<CourseSchedule.CourseScheduleType, BigDecimal>();
+        /*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>();
@@ -1212,7 +1217,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
             totalCurrentPriceMap.put(musicGroupPaymentCalenderCourseSettings.getCourseType(), musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice());
             totalOriginPriceMap.put(musicGroupPaymentCalenderCourseSettings.getCourseType(), musicGroupPaymentCalenderCourseSettings.getCourseOriginalPrice());
-        }
+        }*/
 
         List<Integer> classGroupIds = classGroupList.stream().map(ClassGroup::getId).collect(Collectors.toList());
         List<CourseScheduleStudentPayment> ccs = courseScheduleStudentPaymentDao.getWithClassGroupIds(classGroupIds, studentId);
@@ -1222,15 +1227,15 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             ;
         }
 
-        Map<CourseScheduleType, BigDecimal> totalPriceMap = new HashMap<CourseSchedule.CourseScheduleType, BigDecimal>();
-        Map<CourseScheduleType, BigDecimal> totalOrignPriceMap = new HashMap<CourseSchedule.CourseScheduleType, BigDecimal>();
+//        Map<CourseScheduleType, BigDecimal> totalPriceMap = new HashMap<CourseSchedule.CourseScheduleType, BigDecimal>();
+//        Map<CourseScheduleType, BigDecimal> totalOrignPriceMap = new HashMap<CourseSchedule.CourseScheduleType, BigDecimal>();
 
         List<CourseSchedule> allNotStartCourses = new ArrayList<>();
         Map<Integer, List<ClassGroupTeacherMapper>> ctm = new HashMap<>();
 
-        BigDecimal unitPrice = new BigDecimal(0);
-        BigDecimal originUnitPrice = new BigDecimal(0);
-        CourseScheduleType courseType = null;
+//        BigDecimal unitPrice = new BigDecimal(0);
+//        BigDecimal originUnitPrice = new BigDecimal(0);
+//        CourseScheduleType courseType = null;
         for (ClassGroup classGroup : classGroupList) {
             if(HIGH_ONLINE.equals(classGroup.getType())){
                 Integer studentNum = classGroupStudentMapperDao.countClassGroupStudentNum(classGroup.getId());
@@ -1274,8 +1279,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                 courseScheduleStudentPayment.setUserId(studentId);
                 courseScheduleStudentPayment.setBatchNo(batchNo);
                 courseScheduleStudentPayment.setBeMerged(false);
+                courseScheduleStudentPayment.setExpectPrice(BigDecimal.ZERO);
+                courseScheduleStudentPayment.setOriginalPrice(BigDecimal.ZERO);
 
-                unitPrice = unitPriceMap.get(courseSchedule.getType());
+                /*unitPrice = unitPriceMap.get(courseSchedule.getType());
                 if (unitPrice != null) {
                     courseType = courseSchedule.getType();
                     BigDecimal duration = new BigDecimal(DateUtil.minutesBetween(courseSchedule.getStartClassTime(), courseSchedule.getEndClassTime()));
@@ -1299,7 +1306,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                     } else {
                         totalOrignPriceMap.put(courseType, courseScheduleStudentPayment.getOriginalPrice());
                     }
-                }
+                }*/
                 courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
                 courseScheduleStudentPayment.setCreateTime(date);
                 courseScheduleStudentPayment.setUpdateTime(date);
@@ -1323,7 +1330,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         if (courseScheduleStudentPayments.size() > 0) {
             // 排序
             Collections.sort(courseScheduleStudentPayments);
-            List<CourseScheduleType> list = new ArrayList<CourseSchedule.CourseScheduleType>();
+            /*List<CourseScheduleType> list = new ArrayList<CourseSchedule.CourseScheduleType>();
             for (CourseScheduleStudentPayment courseScheduleStudentPayment : courseScheduleStudentPayments) {
                 courseType = courseScheduleStudentPayment.getCourseSchedule().getType();
                 if (!list.contains(courseType)) {
@@ -1336,7 +1343,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                     courseScheduleStudentPayment.setOriginalPrice(courseScheduleStudentPayment.getOriginalPrice().add(
                             totalOriginPriceMap.get(courseType).subtract(totalOrignPriceMap.get(courseType))));
                 }
-            }
+            }*/
             courseScheduleStudentPaymentService.batchInsert(courseScheduleStudentPayments);
             studentDao.updateStudentServiceTag(studentId, null, YesOrNoEnum.YES.getCode());
         }

+ 5 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberFeeSettingServiceImpl.java

@@ -18,5 +18,9 @@ public class MemberFeeSettingServiceImpl extends BaseServiceImpl<Integer, Member
 	public BaseDAO<Integer, MemberFeeSetting> getDAO() {
 		return memberFeeSettingDao;
 	}
-	
+
+    @Override
+    public MemberFeeSetting findByRankIdAndOrganId(Integer organId, Integer rankId) {
+		return memberFeeSettingDao.findByRankIdAndOrganId(organId,rankId);
+    }
 }

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

@@ -13,6 +13,7 @@ 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.StudentMusicGroupStatusEnum;
 import com.ym.mec.biz.dal.page.ArrearageStudentsQueryInfo;
 import com.ym.mec.biz.event.source.GroupEventSource;
@@ -287,7 +288,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,8 +310,9 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		}
 		
 		List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupPaymentCalenderId);
-		
-		BigDecimal totalPrice = new BigDecimal(0);
+
+		//总金额 = 会员费用 + 课程费用
+		BigDecimal totalPrice = musicGroupPaymentCalender.getMemberPaymentAmount();
 		if (musicGroupPaymentCalender.getPayUserType() == STUDENT) {
 			for (MusicGroupPaymentCalenderCourseSettings courseSettings : courseSettingsList) {
 				// 剔除可选课程
@@ -319,7 +321,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 				}
 			}
 		}
-		
+
 		Date date = new Date();
 		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
 		Map<Integer,MusicGroupPaymentCalenderDetail> userMap = new HashMap<Integer, MusicGroupPaymentCalenderDetail>();
@@ -354,27 +356,42 @@ 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;
-				}
+		//如果是会员收费,按默认的6*4*4*45的课程时长来计算可排课时长(临时加课走原来的逻辑)
+		if(musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE && musicGroupPaymentCalender.getPaymentType() != MusicGroupPaymentCalender.PaymentType.ADD_COURSE){
+			for(Integer studentId : userIdList){
 				musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
-				musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
 				musicGroupPaymentStudentCourseDetail.setCreateTime(date);
 				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalenderId);
 				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(userMap.get(studentId).getId());
-				musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
+				musicGroupPaymentStudentCourseDetail.setMemberCourseMinutes(6*4*4*45);
 				musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
 				musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
 				musicGroupPaymentStudentCourseDetail.setUserId(studentId);
-				
 				musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
 			}
+		}else {
+			//创建学生课排课分钟数
+			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);
+				}
+			}
 		}
 		
 		if(musicGroupPaymentStudentCourseDetailList.size() > 0){

+ 295 - 218
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -123,6 +123,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	private StudentRegistrationDao studentRegistrationDao;
 	@Autowired
 	private GroupEventSource groupEventSource;
+	@Autowired
+	private MemberFeeSettingDao memberFeeSettingDao;
 
 	@Override
 	public BaseDAO<Long, MusicGroupPaymentCalender> getDAO() {
@@ -200,73 +202,101 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		// 获取设置的课程
 		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) {
+//			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
+//		}
+
+		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时不支持多周期缴费");
+				}
 			}
 		}
 
 		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(status != AUDITING && musicGroupPaymentCalenderDto.getMemberRankSettingId() != null){
+				//会员价格是否变动
+				MemberFeeSetting memberFee = memberFeeSettingDao.findByRankIdAndOrganId(musicGroup.getOrganId(), musicGroupPaymentCalenderDto.getMemberRankSettingId());
+				if(memberFee == null){
+					throw new BizException("操作失败:请配置当前分部会员收费标准");
+				}
+				BigDecimal memberPaymentAmount;
+				switch (musicGroupPaymentCalenderDto.getMemberValidDate()){
+					case 1 :
+						memberPaymentAmount = memberFee.getCurrentMonthFee();
+						break;
+					case 6 :
+						memberPaymentAmount = memberFee.getCurrentHalfYearFee();
+						break;
+					case 12 :
+						memberPaymentAmount = memberFee.getCurrentYearFee();
+						break;
+					default:
+						throw new BizException("请选择正确的会员有效期");
+				}
+				if(memberPaymentAmount.compareTo(musicGroupPaymentCalenderDto.getMemberPaymentAmount()) != 0){
+					status = AUDITING;
 				}
-			}else if(paymentType == SPAN_GROUP_CLASS_ADJUST){
-				status = musicGroupPaymentCalenderDto.getStatus();
 			}
 		}
 
@@ -294,48 +324,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));
+			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());
@@ -387,6 +416,9 @@ 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);
 
@@ -394,7 +426,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			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 +449,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 +457,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());
@@ -454,7 +486,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);
 				}
 			}
 		}
@@ -541,87 +573,113 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		// 获取设置的课程
 		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderDto
 				.getMusicGroupPaymentCalenderCourseSettingsList();
-		if (musicGroupPaymentCalenderCourseSettingsList == null) {
-			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
-		}
+//		if (musicGroupPaymentCalenderCourseSettingsList == null) {
+//			musicGroupPaymentCalenderCourseSettingsList = new ArrayList<>();
+//		}
 
 		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(status != AUDITING && musicGroupPaymentCalenderDto.getMemberRankSettingId() != null){
+				//会员价格是否变动
+				MemberFeeSetting memberFee = memberFeeSettingDao.findByRankIdAndOrganId(musicGroup.getOrganId(), musicGroupPaymentCalenderDto.getMemberRankSettingId());
+				if(memberFee == null){
+					throw new BizException("操作失败:请配置当前分部会员收费标准");
+				}
+				BigDecimal memberPaymentAmount;
+				switch (musicGroupPaymentCalenderDto.getMemberValidDate()){
+					case 1 :
+						memberPaymentAmount = memberFee.getCurrentMonthFee();
+						break;
+					case 6 :
+						memberPaymentAmount = memberFee.getCurrentHalfYearFee();
+						break;
+					case 12 :
+						memberPaymentAmount = memberFee.getCurrentYearFee();
+						break;
+					default:
+						throw new BizException("请选择正确的会员有效期");
+				}
+				if(memberPaymentAmount.compareTo(musicGroupPaymentCalenderDto.getMemberPaymentAmount()) != 0){
 					status = AUDITING;
-					//保存新的学员详情
 				}
-				//删除之前的记录
-				musicGroupPaymentCalenderStudentDetailDao.delByBatchNo(batchNo);
-				//保存现有记录
-				musicGroupPaymentCalenderStudentDetailDao.batchInsert(calenderStudentDetails,batchNo);
 			}
 		}
 
@@ -648,47 +706,49 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			musicGroupPaymentCalender.setMemo(musicGroupPaymentCalenderDto.getMemo());
 			musicGroupPaymentCalender.setMusicGroupId(musicGroupId);
 			musicGroupPaymentCalender.setMusicGroupOrganizationCourseSettingId(musicGroupPaymentCalenderDto.getMusicGroupOrganizationCourseSettingId());
+			BigDecimal totalPaymentAmount = musicGroupPaymentCalender.getMemberPaymentAmount();
+			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.setPaymentPattern(musicGroupPaymentCalenderDto.getPaymentPattern());
@@ -751,7 +811,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 +854,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 +914,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>();
@@ -901,26 +965,38 @@ 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(musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
 					musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
-					musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
+//					musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
 					musicGroupPaymentStudentCourseDetail.setCreateTime(date);
 					musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
 					musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
-					musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
+					musicGroupPaymentStudentCourseDetail.setMemberCourseMinutes(6*4*4*45);
 					musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
-					musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(courseSettings.getCourseTotalMinuties());
+//					musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(6*4*4*45);
 					musicGroupPaymentStudentCourseDetail.setUserId(Integer.parseInt(studentId));
+				}else {
+					// 学生加课程明细
+					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);
+					}
 
-					musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
-				}
-
-				if(musicGroupPaymentStudentCourseDetailList.size() > 0){
-					musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
+					if(musicGroupPaymentStudentCourseDetailList.size() > 0){
+						musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
+					}
 				}
 			}
 		}
@@ -1055,12 +1131,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;
@@ -1106,7 +1183,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 +1196,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){
@@ -1136,11 +1215,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<>();
@@ -1185,7 +1262,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){

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

@@ -82,4 +82,9 @@
 	<select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM member_fee_setting
 	</select>
+    <select id="findByRankIdAndOrganId" resultMap="MemberFeeSetting">
+		SELECT mfs.* FROM member_rank_organization_fee_mapper mro
+		LEFT JOIN member_fee_setting mfs ON mfs.id_ = mro.member_fee_setting_id_
+		WHERE mro.member_rank_setting_id_ = #{rankId} AND mro.organ_id_ = #{organId}
+	</select>
 </mapper>

+ 6 - 2
mec-biz/src/main/resources/config/mybatis/MemberPrivilegesItemMapper.xml

@@ -11,6 +11,7 @@
 		<result column="name_" property="name" />
 		<result column="desc_" property="desc" />
 		<result column="code_" property="code" />
+		<result column="path_" property="path" />
 		<result column="parent_id_" property="parentId" />
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
@@ -34,13 +35,16 @@
 	
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MemberPrivilegesItem" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		INSERT INTO member_privileges_item (name_,desc_,code_,parent_id_,create_time_,update_time_)
-		 VALUES(#{name},#{desc},#{code},#{parentId},NOW(),NOW())
+		INSERT INTO member_privileges_item (name_,desc_,code_,parent_id_,path_,create_time_,update_time_)
+		 VALUES(#{name},#{desc},#{code},#{parentId},#{path},NOW(),NOW())
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.MemberPrivilegesItem">
 		UPDATE member_privileges_item <set>
+		<if test="path != null">
+			path_ = #{path},
+		</if>
 		<if test="parentId != null">
 			parent_id_ = #{parentId},
 		</if>

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

@@ -31,7 +31,9 @@
         <result column="attribute1_" property="attribute1"/>
         <result column="attribute2_" property="attribute2"/>
         <result column="student_ids_" property="studentIds"/>
-
+        <result column="member_payment_amount_" property="memberPaymentAmount"/>
+        <result column="member_rank_setting_id_" property="memberRankSettingId"/>
+        <result column="member_valid_date_" property="memberValidDate"/>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -50,12 +52,12 @@
         INSERT INTO music_group_payment_calender
         (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
         actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,
-        payment_pattern_,payment_type_,payment_amount_,batch_no_,audit_memo_,operator_,attribute1_,attribute2_,student_ids_)
+        payment_pattern_,payment_type_,payment_amount_,batch_no_,audit_memo_,operator_,attribute1_,attribute2_,student_ids_,member_payment_amount_,member_rank_setting_id_,member_valid_date_)
         VALUES(#{musicGroupId},#{musicGroupOrganizationCourseSettingId},#{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{rejectReason},#{startPaymentDate},#{deadlinePaymentDate},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{expectNum},#{actualNum},#{memo},#{isGiveMusicNetwork},now(),now(),
         #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-        #{paymentAmount},#{batchNo},#{auditMemo},#{operator},#{attribute1},#{attribute2},#{studentIds})
+        #{paymentAmount},#{batchNo},#{auditMemo},#{operator},#{attribute1},#{attribute2},#{studentIds},#{memberPaymentAmount},#{memberRankSettingId},#{memberValidDate})
     </insert>
 
     <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
@@ -63,13 +65,13 @@
         INSERT INTO music_group_payment_calender
         (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
         actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_,payment_amount_,
-        payment_type_,batch_no_,audit_memo_,operator_,attribute1_,attribute2_,student_ids_)
+        payment_type_,batch_no_,audit_memo_,operator_,attribute1_,attribute2_,student_ids_,member_payment_amount_,member_rank_setting_id_,member_valid_date_)
         VALUES
         <foreach collection="list" item="item" index="index" separator=",">
         (#{item.musicGroupId},#{item.musicGroupOrganizationCourseSettingId},#{item.payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.rejectReason},#{item.startPaymentDate},#{item.deadlinePaymentDate},#{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{item.expectNum},#{item.actualNum},#{item.memo},#{item.isGiveMusicNetwork},now(),now(),
         #{item.paymentValidStartDate},#{item.paymentValidEndDate},#{item.paymentPattern},#{item.paymentAmount},#{item.paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-        #{item.batchNo},#{item.auditMemo},#{item.operator},#{item.attribute1},#{item.attribute2},#{item.studentIds})
+        #{item.batchNo},#{item.auditMemo},#{item.operator},#{item.attribute1},#{item.attribute2},#{item.studentIds},#{item.memberPaymentAmount},#{item.memberRankSettingId},#{item.memberValidDate})
         </foreach>
     </insert>
 
@@ -77,6 +79,15 @@
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
         UPDATE music_group_payment_calender
         <set>
+            <if test="memberPaymentAmount != null">
+                member_payment_amount_ = #{memberPaymentAmount},
+            </if>
+            <if test="memberRankSettingId != null">
+                member_rank_setting_id_ = #{memberRankSettingId},
+            </if>
+            <if test="memberValidDate != null">
+                member_valid_date_ = #{memberValidDate},
+            </if>
             <if test="studentIds != null and studentIds != ''">
                 student_ids_ = #{studentIds},
             </if>
@@ -149,6 +160,15 @@
 	    <foreach collection="list" item="item" index="index" open="" close="" separator=";">
 	        UPDATE music_group_payment_calender
 	        <set>
+                <if test="item.memberPaymentAmount != null">
+                    member_payment_amount_ = #{item.memberPaymentAmount},
+                </if>
+                <if test="item.memberRankSettingId != null">
+                    member_rank_setting_id_ = #{item.memberRankSettingId},
+                </if>
+                <if test="item.memberValidDate != null">
+                    member_valid_date_ = #{item.memberValidDate},
+                </if>
                 <if test="item.studentIds != null and item.studentIds != ''">
                     student_ids_ = #{item.studentIds},
                 </if>

+ 0 - 1
mec-student/src/main/java/com/ym/mec/student/controller/ActivityController.java

@@ -12,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-
 import java.util.Comparator;
 import java.util.List;
 

+ 27 - 0
mec-web/src/main/java/com/ym/mec/web/controller/MemberFeeSettingController.java

@@ -0,0 +1,27 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.biz.service.MemberFeeSettingService;
+import com.ym.mec.common.controller.BaseController;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RequestMapping("memberFeeSetting")
+@Api(tags = "会员收费标准")
+@RestController
+public class MemberFeeSettingController extends BaseController {
+
+    @Autowired
+    private MemberFeeSettingService memberFeeSettingService;
+
+    @ApiOperation(value = "根据会员等级编号和分部编号获取收费标准")
+    @GetMapping("/findByRankId")
+    @PreAuthorize("@pcs.hasPermissions('memberPrivilegesItem/findByRankId')")
+    public Object add(Integer organId,Integer rankId) {
+        return succeed(memberFeeSettingService.findByRankIdAndOrganId(organId,rankId));
+    }
+}

+ 10 - 10
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

@@ -119,17 +119,17 @@ public class MusicGroupPaymentCalenderController extends BaseController {
         if (sysUser == null) {
             return failed("用户信息获取失败");
         }
-            Employee employee = employeeDao.get(sysUser.getId());
-            if (StringUtils.isEmpty(queryInfo.getOrganId())) {
-                queryInfo.setOrganId(employee.getOrganIdList());
-            }else if(StringUtils.isEmpty(employee.getOrganIdList())){
-                return failed("用户所在分部异常");
-            }else {
-                List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
-                if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
-                    return failed("非法请求");
-                }
+        Employee employee = employeeDao.get(sysUser.getId());
+        if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+            queryInfo.setOrganId(employee.getOrganIdList());
+        }else if(StringUtils.isEmpty(employee.getOrganIdList())){
+            return failed("用户所在分部异常");
+        }else {
+            List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+            if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
+                return failed("非法请求");
             }
+        }
         return succeed(musicGroupPaymentCalenderService.auditList(queryInfo));
     }