Bläddra i källkod

Merge branch 'online1' into maintenance_feature

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java
#	mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml
#	mec-common/audit-log/pom.xml
#	mec-common/audit-log/src/main/java/com/yonge/log/interceptor/AuditLogInterceptor.java
周箭河 4 år sedan
förälder
incheckning
0cee9e4ac3
26 ändrade filer med 428 tillägg och 565 borttagningar
  1. 5 42
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/IndexBaseMonthDataDao.java
  2. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/PracticeGroupDao.java
  3. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/IndexBaseDto.java
  4. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderStudentDetail.java
  5. 37 75
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/IndexDataType.java
  6. 1 59
      mec-biz/src/main/java/com/ym/mec/biz/event/listener/GroupEventListener.java
  7. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleService.java
  8. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/IndexBaseMonthDataService.java
  9. 9 9
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java
  10. 23 11
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java
  11. 5 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/EduPracticeGroupServiceImpl.java
  12. 155 75
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java
  13. 34 17
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  14. 36 16
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  15. 6 5
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java
  16. 36 194
      mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml
  17. 4 2
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml
  18. 3 0
      mec-biz/src/main/resources/config/mybatis/PracticeGroupMapper.xml
  19. 7 7
      mec-common/audit-log/pom.xml
  20. 38 32
      mec-common/audit-log/src/main/java/com/yonge/log/interceptor/AuditLogInterceptor.java
  21. 8 0
      mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupRegisterController.java
  22. 2 1
      mec-student/src/main/java/com/ym/mec/student/controller/PracticeGroupController.java
  23. 2 2
      mec-web/src/main/java/com/ym/mec/web/controller/CourseScheduleController.java
  24. 1 1
      mec-web/src/main/java/com/ym/mec/web/controller/InspectionItemPlanConclusionController.java
  25. 3 1
      mec-web/src/main/java/com/ym/mec/web/controller/education/EduPracticeGroupController.java
  26. 6 6
      mec-web/src/main/java/com/ym/mec/web/controller/education/EduRepairController.java

+ 5 - 42
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/IndexBaseMonthDataDao.java

@@ -1,7 +1,10 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.IndexBaseMonthData;
-import com.ym.mec.biz.dal.enums.*;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.IndexDataType;
+import com.ym.mec.biz.dal.enums.JobNatureEnum;
+import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.poi.ss.formula.functions.Index;
@@ -21,10 +24,6 @@ public interface IndexBaseMonthDataDao extends BaseDAO<Long, IndexBaseMonthData>
     int deleteWithMonthAndType(@Param("months") Collection months,
                                @Param("dataType")IndexDataType dataType);
 
-    IndexBaseMonthData getOrganDataWithDayAndDataType(@Param("organId") Integer organId,
-                                                      @Param("day") String day,
-                                                      @Param("dataType")IndexDataType dataType);
-
     /**
      * @describe 获取首页统计数据
      * @author Joburgess
@@ -40,36 +39,6 @@ public interface IndexBaseMonthDataDao extends BaseDAO<Long, IndexBaseMonthData>
                                               @Param("startMonth") String startMonth,
                                               @Param("endMonth") String endMonth);
 
-	List<IndexBaseMonthData> getWithDayAndDataType(@Param("day") String day,
-                                                   @Param("dataType")IndexDataType dataType);
-
-	/**
-	 * @describe 统计学员注册数据
-	 * @author Joburgess
-	 * @date 2021/2/24 0024
-	 * @param dayStr:
-	 * @return java.util.List<com.ym.mec.biz.dal.entity.IndexBaseMonthData>
-	 */
-	List<IndexBaseMonthData> getStudentRegistrationData(@Param("dayStr") String dayStr);
-
-	/**
-	 * @describe 统计新增学员注册数据
-	 * @author Joburgess
-	 * @date 2021/2/24 0024
-	 * @param dayStr:
-	 * @return java.util.List<com.ym.mec.biz.dal.entity.IndexBaseMonthData>
-	 */
-	List<IndexBaseMonthData> getAddStudentRegistrationData(@Param("dayStr") String dayStr);
-
-	/**
-	 * @describe 付费转化率
-	 * @author Joburgess
-	 * @date 2021/2/24 0024
-	 * @param dayStr:
-	 * @return java.util.List<com.ym.mec.biz.dal.entity.IndexBaseMonthData>
-	 */
-	List<IndexBaseMonthData> getChargeStudentChangeData(@Param("dayStr") String dayStr);
-
     /**
      * @describe 统计系统中指定时间段的学员注册数据
      * @author Joburgess
@@ -125,19 +94,13 @@ public interface IndexBaseMonthDataDao extends BaseDAO<Long, IndexBaseMonthData>
 
     List<IndexBaseMonthData> getOtherStudentData(@Param("dayStr") String dayStr);
 
-    List<IndexBaseMonthData> getVipPracticeAddStudentData(@Param("dayStr") String dayStr);
-
     List<IndexBaseMonthData> getTeacherData(@Param("dayStr") String dayStr,
                                             @Param("jobNature") JobNatureEnum jobNature,
                                             @Param("isDemission") Boolean isDemission);
 
     List<IndexBaseMonthData> getGroupCourseData(@Param("dayStr") String dayStr,
-                                                @Param("groupType")GroupType groupType,
-                                                @Param("courseStatus") CourseStatusEnum courseStatus);
+                                                @Param("groupType")GroupType groupType);
 
-    List<IndexBaseMonthData> getGroupSurplusCourseData(@Param("dayStr") String dayStr,
-                                                @Param("groupType")GroupType groupType,
-                                                @Param("courseStatus") CourseStatusEnum courseStatus);
 
     List<IndexBaseMonthData> getGroupCourseDataWithGroup(@Param("dayStr") String dayStr,
                                                 @Param("groupType")GroupType groupType,

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

@@ -106,7 +106,8 @@ public interface PracticeGroupDao extends com.ym.mec.common.dal.BaseDAO<Long, Pr
      * @author Joburgess
      * @date 2020/4/24
      */
-    int checkStudentExitChargePractice(@Param("studentId") Integer studentId);
+    int checkStudentExitChargePractice(@Param("studentId") Integer studentId,
+                                       @Param("startTime") String startTime);
 
     /**
      * @param userId:

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/IndexBaseDto.java

@@ -74,8 +74,8 @@ public class IndexBaseDto {
     public void setIndexMonthData(List<IndexBaseMonthData> indexMonthData, Date currentMonth) {
         this.indexMonthData = indexMonthData;
         if(!CollectionUtils.isEmpty(indexMonthData)){
-            if(dataType.getCollect()){
-                BigDecimal total = indexMonthData.stream().map(IndexBaseMonthData::getTotalNum).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal total = indexMonthData.stream().map(IndexBaseMonthData::getTotalNum).reduce(BigDecimal.ZERO, BigDecimal::add);
+            if(IndexDataType.ACTIVATION_RATE.equals(dataType)){
                 if(total.compareTo(BigDecimal.ZERO)==0){
                     this.percent = BigDecimal.ZERO;
                 }else{

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

@@ -24,7 +24,7 @@ public class MusicGroupPaymentCalenderStudentDetail {
 	private java.math.BigDecimal courseOriginalPrice;
 	
 	/** 现价 */
-	private java.math.BigDecimal courseCurrentPrice;
+	private java.math.BigDecimal courseCurrentPrice = BigDecimal.ZERO;
 
 	/** 可扣减的课程余额 */
 	private java.math.BigDecimal subCourseAmount;

+ 37 - 75
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/IndexDataType.java

@@ -1,6 +1,5 @@
 package com.ym.mec.biz.dal.enums;
 
-import com.sun.org.apache.xpath.internal.operations.Bool;
 import com.ym.mec.common.enums.BaseEnum;
 
 /**
@@ -8,71 +7,50 @@ import com.ym.mec.common.enums.BaseEnum;
  * @Date 2021/1/8 0008
  **/
 public enum IndexDataType implements BaseEnum<String, IndexDataType> {
-    //学员数据类型
-    STUDENT_REGISTRATION_NUM("STUDENT_REGISTRATION_NUM", "注册学员", false, false),
-    CHARGE_STUDENT_CHANGE_RATE("CHARGE_STUDENT_CHANGE_RATE", "付费转化率", true, false),
-    ACTIVATION_RATE("ACTIVATION_RATE","激活率", true, false),
-
-    //运营数据类型
-    SCHOOL("SCHOOL","合作单位", false, false),
-    PROGRESS_MUSIC_GROUP_NUM("PROGRESS_MUSIC_GROUP_NUM","进行中乐团", false, false),
-
-    //人事数据
-    TEACHER_NUM("TEACHER_NUM","老师总数", false, false),
-    FULL_TIME_NUM("FULL_TIME_NUM","全职人数", false, false),
-    PART_TIME_NUM("PART_TIME_NUM","兼职人数", false, false),
-
-    DIMISSION_NUM("DIMISSION_NUM","离职人数", false, false),
-
-    //剩余课时
-    SURPLUS_COURSE_NUM("SURPLUS_COURSE_NUM", "剩余课时总数", false, false),
-    SURPLUS_MUSIC_COURSE_NUM("SURPLUS_MUSIC_COURSE_NUM", "剩余乐团课时", false, false),
-    SURPLUS_VIP_COURSE_NUM("SURPLUS_VIP_COURSE_NUM", "剩余VIP课时", false, false),
-    SURPLUS_PRACTICE_COURSE_NUM("SURPLUS_PRACTICE_COURSE_NUM", "剩余网管课时", false, false),
-
-    //已消耗课时
-    OVER_COURSE_NUM("OVER_COURSE_NUM", "已消耗课时总数", false, false),
-    OVER_MUSIC_COURSE_NUM("OVER_MUSIC_COURSE_NUM", "已消耗乐团课时", false, false),
-    OVER_VIP_COURSE_NUM("OVER_VIP_COURSE_NUM", "已消耗VIP课时", false, false),
-    OVER_PRACTICE_COURSE_NUM("OVER_PRACTICE_COURSE_NUM", "已消耗网管课时", false, false),
-
-    //经营数据
-    FINANCE_PAY("FINANCE_PAY","财务支出", false, false),
-    FINANCE_BALANCE_AMOUNT("FINANCE_BALANCE_AMOUNT","余额收入", false, false),
-    FINANCE_AMOUNT("FINANCE_AMOUNT","现金收入", false, false),
-
-    //业务数据
-    HOMEWORK_CREATE_RATE("HOMEWORK_CREATE_RATE","作业布置率", true, false),
-    HOMEWORK_SUBMIT_RATE("HOMEWORK_SUBMIT_RATE","作业提交率", true, false),
-    HOMEWORK_COMMENT_RATE("HOMEWORK_COMMENT_RATE","作业点评率", true, false),
-
-    //课程数据
-    MUSIC_GROUP_COURSE("MUSIC_GROUP_COURSE","乐团课", false, false),
-    VIP_GROUP_COURSE("VIP_GROUP_COURSE","VIP课", false, false),
-    PRACTICE_GROUP_COURSE("PRACTICE_GROUP_COURSE","网管课", false, false),
-
-    //学员变动
-    ADD_STUDENT_REGISTRATION_NUM("ADD_STUDENT_REGISTRATION_NUM", "新增注册学员", false, false),
-    MUSIC_GROUP_STUDENT("MUSIC_GROUP_STUDENT","乐团在读学员", false, false),
-    NEWLY_STUDENT_NUM("NEWLY_STUDENT_NUM","乐团新增学员", false, false),
-    QUIT_MUSIC_GROUP_STUDENT_NUM("QUIT_MUSIC_GROUP_STUDENT_NUM","退团学员", false, false),
-    VIP_PRACTICE_STUDENT_NUM("VIP_PRACTICE_STUDENT_NUM", "VIP/网管在读", false, false),
-    VIP_PRACTICE_ADD_STUDENT_NUM("VIP_PRACTICE_ADD_STUDENT_NUM", "VIP/网管新增", false, false),
-    ;
+    SCHOOL("SCHOOL","合作单位"),
+    MUSIC_GROUP_NUM("MUSIC_GROUP_NUM","乐团数量"),
+    MUSIC_GROUP_STUDENT("MUSIC_GROUP_STUDENT","乐团学员"),
+    OTHER_STUDENT("OTHER_STUDENT","其他学员"),
+
+    ACTIVATION_RATE("ACTIVATION_RATE","激活率"),
+    HOMEWORK_CREATE_RATE("HOMEWORK_CREATE_RATE","作业布置率"),
+    HOMEWORK_SUBMIT_RATE("HOMEWORK_SUBMIT_RATE","作业提交率"),
+    HOMEWORK_COMMENT_RATE("HOMEWORK_COMMENT_RATE","作业点评率"),
+
+    SHOULD_INCOME_MONEY("SHOULD_INCOME_MONEY","应收金额"),
+    ANTICIPATED_INCOME_MONEY("ANTICIPATED_INCOME_MONEY","预收金额"),
+    SHOULD_EXPEND_MONEY("SHOULD_EXPEND_MONEY","预付金额"),
+    ANTICIPATED_EXPEND_MONEY("ANTICIPATED_EXPEND_MONEY","应付金额"),
+    REVENUE_MONEY("REVENUE_MONEY","营收金额"),
+
+    TEACHER_NUM("TEACHER_NUM","老师总数"),
+    FULL_TIME_NUM("FULL_TIME_NUM","全职人数"),
+    PART_TIME_NUM("PART_TIME_NUM","兼职人数"),
+    DIMISSION_NUM("DIMISSION_NUM","离职人数"),
+
+    NEWLY_STUDENT_NUM("NEWLY_STUDENT_NUM","乐团新增学员"),
+    QUIT_MUSIC_GROUP_STUDENT_NUM("QUIT_MUSIC_GROUP_STUDENT_NUM","退团学员"),
+    STUDENT_CONVERSION("STUDENT_CONVERSION","学员转化"),
+    STUDENT_CONVERSION_PRE_STUDENT_NUM("STUDENT_CONVERSION_PRE_STUDENT_NUM","预报名人数"),
+    STUDENT_CONVERSION_STUDENT_NUM("STUDENT_CONVERSION_STUDENT_NUM","报名人数"),
+    STUDENT_CONVERSION_PAYMENT_STUDENT_NUM("STUDENT_CONVERSION_PAYMENT_STUDENT_NUM","报名缴费"),
+    STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM("STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM","VIP/网管课购买"),
+
+    MUSIC_GROUP_COURSE("MUSIC_GROUP_COURSE","乐团课"),
+    VIP_GROUP_COURSE("VIP_GROUP_COURSE","VIP课"),
+    PRACTICE_GROUP_COURSE("PRACTICE_GROUP_COURSE","网管课"),
+
+    FINANCE_PAY("FINANCE_PAY","财务支出"),
+    FINANCE_BALANCE_AMOUNT("FINANCE_BALANCE_AMOUNT","余额收入"),
+    FINANCE_AMOUNT("FINANCE_AMOUNT","现金收入");
 
     private String code;
 
     private String msg;
 
-    private Boolean percent;
-
-    private Boolean collect;
-
-    IndexDataType(String code, String msg, Boolean percent, Boolean collect) {
+    IndexDataType(String code, String msg) {
         this.code = code;
         this.msg = msg;
-        this.percent = percent;
-        this.collect = collect;
     }
 
     @Override
@@ -91,20 +69,4 @@ public enum IndexDataType implements BaseEnum<String, IndexDataType> {
     public void setMsg(String msg) {
         this.msg = msg;
     }
-
-    public Boolean getCollect() {
-        return collect;
-    }
-
-    public void setCollect(Boolean collect) {
-        this.collect = collect;
-    }
-
-    public Boolean getPercent() {
-        return percent;
-    }
-
-    public void setPercent(Boolean percent) {
-        this.percent = percent;
-    }
 }

+ 1 - 59
mec-biz/src/main/java/com/ym/mec/biz/event/listener/GroupEventListener.java

@@ -38,65 +38,7 @@ public class GroupEventListener {
     @Async
     @EventListener
     public void musicGroupStudentChangeMonitor(MusicGroupStudentChangeEvent musicGroupStatusChangeEvent){
-        if(Objects.isNull(musicGroupStatusChangeEvent.getMusicGroupId())||Objects.isNull(musicGroupStatusChangeEvent.getStudentMusicGroupStatus())){
-            return;
-        }
-        MusicGroup musicGroup = musicGroupDao.get(musicGroupStatusChangeEvent.getMusicGroupId());
-        if(Objects.isNull(musicGroup)){
-            return;
-        }
-        List<Integer> studentIds = musicGroupStatusChangeEvent.getStudentIds();
-        if(CollectionUtils.isEmpty(studentIds)) {
-            List<StudentRegistration> studentRegistrations = studentRegistrationDao.queryStudentByMusicGroupId(musicGroupStatusChangeEvent.getMusicGroupId());
-            studentIds = studentRegistrations.stream().map(StudentRegistration::getUserId).collect(Collectors.toList());
-        }
-        if(CollectionUtils.isEmpty(studentIds)){
-            return;
-        }
-        List<StudentRegistration> studentNormalRegistration = studentRegistrationDao.getStudentNormalRegistration(new HashSet<>(studentIds));
-        Map<Integer, Set<String>> userGroupIdMap = studentNormalRegistration.stream().collect(Collectors.groupingBy(StudentRegistration::getUserId, Collectors.mapping(StudentRegistration::getMusicGroupId, Collectors.toSet())));
-        int updateNum = 0;
-        for (Integer studentId : studentIds) {
-            if(userGroupIdMap.containsKey(studentId)&&userGroupIdMap.get(studentId).size()>1){
-                continue;
-            }
-            if(userGroupIdMap.containsKey(studentId)&&!userGroupIdMap.get(studentId).contains(musicGroupStatusChangeEvent.getMusicGroupId())){
-                continue;
-            }
-            updateNum+=1;
-        }
-        LocalDate nowDate = LocalDate.now();
-        String dayStr = nowDate.plusDays(-1).toString();
-        IndexBaseMonthData indexBaseMonthData = null;
-        switch (musicGroupStatusChangeEvent.getStudentMusicGroupStatus()){
-            case NORMAL:
-                indexBaseMonthData = indexBaseMonthDataDao.getOrganDataWithDayAndDataType(musicGroup.getOrganId(), dayStr, IndexDataType.NEWLY_STUDENT_NUM);
-                break;
-            case QUIT:
-                indexBaseMonthData = indexBaseMonthDataDao.getOrganDataWithDayAndDataType(musicGroup.getOrganId(), dayStr, IndexDataType.QUIT_MUSIC_GROUP_STUDENT_NUM);
-                break;
-            default:
-                return;
-        }
-        if(Objects.isNull(indexBaseMonthData)){
-            indexBaseMonthData = new IndexBaseMonthData();
-            Date date = DateUtil.stringToDate(dayStr, "yyyy-MM-dd");
-            BigDecimal zero = new BigDecimal(0);
-            indexBaseMonthData.setMonth(date);
-            indexBaseMonthData.setOrganId(musicGroup.getOrganId());
-            indexBaseMonthData.setDataType(StudentMusicGroupStatusEnum.NORMAL.equals(musicGroupStatusChangeEvent.getStudentMusicGroupStatus())?IndexDataType.NEWLY_STUDENT_NUM:IndexDataType.QUIT_MUSIC_GROUP_STUDENT_NUM);
-            indexBaseMonthData.setTotalNum(zero);
-            indexBaseMonthData.setActivateNum(zero);
-            indexBaseMonthData.setPercent(zero);
-        }
-        indexBaseMonthData.setTotalNum(indexBaseMonthData.getTotalNum().add(new BigDecimal(updateNum)));
-        indexBaseMonthData.setActivateNum(indexBaseMonthData.getActivateNum().add(new BigDecimal(updateNum)));
-        indexBaseMonthData.setPercent(indexBaseMonthData.getPercent().add(new BigDecimal(updateNum)));
-        if(Objects.isNull(indexBaseMonthData.getId())){
-            indexBaseMonthDataDao.insert(indexBaseMonthData);
-        }else{
-            indexBaseMonthDataDao.update(indexBaseMonthData);
-        }
+
     }
 
 }

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

@@ -573,7 +573,7 @@ public interface CourseScheduleService extends BaseService<Long, CourseSchedule>
 	 * @param practiceGroupId
 	 * @param coursesExpireDate
 	 */
-	void updateCoursesExpireDate(String practiceGroupId, Date coursesExpireDate);
+	void updatePracticeGroupInDate(String practiceGroupId, Date courseStartDate, Date coursesExpireDate);
 
 	/**
 	 * 获取当前班级列表的所有未开始的课程

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

@@ -14,7 +14,7 @@ public interface IndexBaseMonthDataService extends BaseService<Long, IndexBaseMo
 
     List<IndexBaseDto> getIndexBaseData(IndexDataQueryInfo indexDataQueryInfo);
 
-    void indexBaseDataTask(String month);
+    Map<String, List<IndexBaseDto>> indexBaseDataTask(String month);
 
     Map<String, Object> getIndexErrData(String organIds, IndexErrorType errorType);
 

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

@@ -6,10 +6,7 @@ import java.util.Set;
 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.entity.MusicGroup;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust;
-import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
@@ -42,11 +39,14 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 	 * @return
 	 */
 	boolean makesureSchoolePaid(Long id, String memo);
-	
-	/**
-	 * 自动更新付款日历记录状态
-	 * @return
-	 */
+
+	void addStudent(MusicGroupPaymentCalender musicGroupPaymentCalender,List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList);
+
+
+		/**
+         * 自动更新付款日历记录状态
+         * @return
+         */
 	boolean autoUpdateMusicGroupPaymentCalenderStatus();
 
 	/**

+ 23 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -4937,34 +4937,46 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public void updateCoursesExpireDate(String practiceGroupId, Date coursesExpireDate) {
+	public void updatePracticeGroupInDate(String practiceGroupId, Date courseStartDate, Date coursesExpireDate) {
 		SysUser user = sysUserFeignService.queryUserInfo();
 		if (null == user) {
 			throw new BizException("获取用户信息失败");
 		}
-    	if(practiceGroupId == null || coursesExpireDate == null ){
+    	if(practiceGroupId == null || courseStartDate == null || coursesExpireDate == null){
     		throw new BizException("参数校验失败");
 		}
 		PracticeGroup practiceGroup = practiceGroupDao.get(Long.parseLong(practiceGroupId));
     	if(practiceGroup == null){
 			throw new BizException("课程组不存在");
 		}
-		if(practiceGroup.getCoursesStartDate().after(coursesExpireDate)){
-			throw new BizException("课程有效时间不能早于开始时间");
+    	if(!GroupStatusEnum.NORMAL.equals(practiceGroup.getGroupStatus())){
+    		throw new BizException("非进行中课程组不可编辑");
 		}
-		if(Objects.nonNull(practiceGroup.getBuyMonths())){
-			LocalDate courseStartDay = LocalDateTime.ofInstant(practiceGroup.getCoursesStartDate().toInstant(), DateUtil.zoneId).toLocalDate();
-			LocalDate currentExpiredDay = courseStartDay.plusMonths(practiceGroup.getBuyMonths()).plusDays(-1);
-			Date courseExpiredDateTemp=Date.from(currentExpiredDay.atStartOfDay(DateUtil.zoneId).toInstant());
-			if(coursesExpireDate.before(courseExpiredDateTemp)){
-				throw new BizException("课程结束时间不得早于,{}", DateUtil.dateToString(courseExpiredDateTemp, "yyyy年MM月dd日"));
-			}
+		if(courseStartDate.after(coursesExpireDate)){
+			throw new BizException("课程组有效结束时间不能早于课程组有效开始时间");
+		}
+		Date minCourseTime = courseScheduleDao.getMinCourseTime(PRACTICE, practiceGroupId);
+		if(Objects.nonNull(minCourseTime)&&courseStartDate.compareTo(minCourseTime)>0){
+			throw new BizException("课程组有效开始时间不得晚于第一节课开始时间");
+		}
+		Date maxCourseTime = courseScheduleDao.getMaxCourseTime(PRACTICE, practiceGroupId);
+		if(Objects.nonNull(maxCourseTime)&&!DateUtil.isSameDay(maxCourseTime, coursesExpireDate)&&coursesExpireDate.compareTo(maxCourseTime)<0){
+			throw new BizException("课程组有效结束时间不得早于最后一节课结束时间");
 		}
+//		if(Objects.nonNull(practiceGroup.getBuyMonths())){
+//			LocalDate courseStartDay = LocalDateTime.ofInstant(practiceGroup.getCoursesStartDate().toInstant(), DateUtil.zoneId).toLocalDate();
+//			LocalDate currentExpiredDay = courseStartDay.plusMonths(practiceGroup.getBuyMonths()).plusDays(-1);
+//			Date courseExpiredDateTemp=Date.from(currentExpiredDay.atStartOfDay(DateUtil.zoneId).toInstant());
+//			if(coursesExpireDate.before(courseExpiredDateTemp)){
+//				throw new BizException("课程结束时间不得早于,{}", DateUtil.dateToString(courseExpiredDateTemp, "yyyy年MM月dd日"));
+//			}
+//		}
 		CoursesGroupModifyLog coursesGroupModifyLog = new CoursesGroupModifyLog();
 		coursesGroupModifyLog.setGroupId(practiceGroupId);
 		coursesGroupModifyLog.setGroupType(PRACTICE.getCode());
 		coursesGroupModifyLog.setOperatorId(user.getId());
 		coursesGroupModifyLog.setPreviousGroup(JSONObject.toJSONString(practiceGroup));
+		practiceGroup.setCoursesStartDate(courseStartDate);
 		practiceGroup.setCoursesExpireDate(DateUtil.addSeconds(DateUtil.addDays(coursesExpireDate, 1),-1));
 		practiceGroup.setUpdateTime(new Date());
 		practiceGroupDao.update(practiceGroup);

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

@@ -192,7 +192,7 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
 
         Date now=new Date();
 
-        int studentExitChargePractices = practiceGroupDao.checkStudentExitChargePractice(practiceGroupBuyParams.getStudentId());
+        int studentExitChargePractices = practiceGroupDao.checkStudentExitChargePractice(practiceGroupBuyParams.getStudentId(), "2021-03-09 00:00:00");
 
         LocalDate courseStartDay=LocalDate.now();
         LocalDate tempCourseLocalDate=LocalDate.parse("2020-03-01", DateUtil.dateFormatter);
@@ -286,8 +286,9 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
         }
         BigDecimal oneMonthPrice;
         BigDecimal oneMonthOriginalPrice=practiceGroupBuyParams.getDrillTimesOnWeek()==1?practiceGroupSellPrice.getOnceOriginalPrice():practiceGroupSellPrice.getTwiceOriginalPrice();
-        if(practiceBuyActivityExpireDate.after(now)){
-            oneMonthPrice=practiceGroupBuyParams.getDrillTimesOnWeek()==1?practiceGroupSellPrice.getOnceActivityPrice():practiceGroupSellPrice.getTwiceActivityPrice();
+        if(practiceBuyActivityExpireDate.after(now)&&Objects.nonNull(sysUser.getOrganId())&&sysUser.getOrganId()==14&&studentExitChargePractices<=0){
+//            oneMonthPrice=practiceGroupBuyParams.getDrillTimesOnWeek()==1?practiceGroupSellPrice.getOnceActivityPrice():practiceGroupSellPrice.getTwiceActivityPrice();
+            oneMonthPrice=practiceGroupBuyParams.getDrillTimesOnWeek()==1?practiceGroupSellPrice.getOnceOriginalPrice():practiceGroupSellPrice.getTwiceOriginalPrice();
             if(!now.before(practicePromotionActivityStartDate)&&practiceGroupBuyParams.getBuyMonths()>=3&&studentExitChargePractices>0){
                 oneMonthPrice=practiceGroupBuyParams.getDrillTimesOnWeek()==1?practiceGroupSellPrice.getOnceQuartActivityPrice():practiceGroupSellPrice.getTwiceQuartActivityPrice();
             }else if(!now.before(practicePromotionActivityStartDate)&&studentExitChargePractices<=0){
@@ -298,7 +299,7 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
         }
         BigDecimal originalAmount = oneMonthOriginalPrice.multiply(new BigDecimal(practiceGroupBuyParams.getBuyMonths()));
         BigDecimal amount= oneMonthPrice.multiply(new BigDecimal(practiceGroupBuyParams.getBuyMonths()));
-        if(!now.before(practicePromotionActivityStartDate)&&now.before(practiceBuyActivityExpireDate)&&studentExitChargePractices<=0){
+        if(!now.before(practicePromotionActivityStartDate)&&now.before(practiceBuyActivityExpireDate)&&Objects.nonNull(sysUser.getOrganId())&&sysUser.getOrganId()==14&&studentExitChargePractices<=0){
             amount= oneMonthPrice.multiply(new BigDecimal(1));
         }
 

+ 155 - 75
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -23,7 +23,6 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
-import java.time.DayOfWeek;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
@@ -96,7 +95,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			indexBaseDatas = new ArrayList<>();
 		}
 
-		Map<IndexDataType, List<IndexBaseMonthData>> typeDateMap = indexBaseDatas.stream().filter(d->Objects.nonNull(d.getDataType())).collect(Collectors.groupingBy(IndexBaseMonthData::getDataType));
+		Map<IndexDataType, List<IndexBaseMonthData>> typeDateMap = indexBaseDatas.stream().collect(Collectors.groupingBy(IndexBaseMonthData::getDataType));
 
 		for (IndexDataType dataType : IndexDataType.values()) {
 			if(typeDateMap.containsKey(dataType)){
@@ -105,11 +104,6 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 
 			IndexBaseMonthData indexBaseMonthData = new IndexBaseMonthData();
 			indexBaseMonthData.setMonth(Date.from(endDate.atStartOfDay(DateUtil.zoneId).toInstant()));
-			if(IndexDataType.HOMEWORK_CREATE_RATE.equals(dataType)
-					||IndexDataType.HOMEWORK_SUBMIT_RATE.equals(dataType)
-					||IndexDataType.HOMEWORK_COMMENT_RATE.equals(dataType)){
-				indexBaseMonthData.setMonth(Date.from(endDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue()).atStartOfDay(DateUtil.zoneId).toInstant()));
-			}
 			indexBaseMonthData.setTotalNum(BigDecimal.ZERO);
 			indexBaseMonthData.setActivateNum(BigDecimal.ZERO);
 			indexBaseMonthData.setPercent(BigDecimal.ZERO);
@@ -121,13 +115,6 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			Set<String> hasMonths = typeDateMapEntry.getValue().stream().map(d -> DateUtil.dateToString(d.getMonth(), "yyyy-MM-dd")).collect(Collectors.toSet());
 			LocalDate currentMonthDate = startDate;
 			while (currentMonthDate.compareTo(endDate)<=0){
-				if((IndexDataType.HOMEWORK_CREATE_RATE.equals(typeDateMapEntry.getKey())
-					||IndexDataType.HOMEWORK_SUBMIT_RATE.equals(typeDateMapEntry.getKey())
-					||IndexDataType.HOMEWORK_COMMENT_RATE.equals(typeDateMapEntry.getKey()))
-					&&currentMonthDate.getDayOfWeek()!=DayOfWeek.MONDAY){
-					currentMonthDate = currentMonthDate.plusDays(1);
-					continue;
-				}
 				if(hasMonths.contains(currentMonthDate.toString())){
 					currentMonthDate = currentMonthDate.plusDays(1);
 					continue;
@@ -142,7 +129,9 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 				currentMonthDate = currentMonthDate.plusDays(1);
 			}
 			typeDateMapEntry.getValue().sort(Comparator.comparing(IndexBaseMonthData::getMonth));
-			if(typeDateMapEntry.getKey().getPercent()){
+			if(IndexDataType.ACTIVATION_RATE.equals(typeDateMapEntry.getKey())||IndexDataType.HOMEWORK_CREATE_RATE.equals(typeDateMapEntry.getKey())
+					||IndexDataType.HOMEWORK_SUBMIT_RATE.equals(typeDateMapEntry.getKey())||IndexDataType.HOMEWORK_COMMENT_RATE.equals(typeDateMapEntry.getKey())
+					||IndexDataType.STUDENT_CONVERSION.equals(typeDateMapEntry.getKey())){
 				for (IndexBaseMonthData indexBaseMonthData : typeDateMapEntry.getValue()) {
 					if(indexBaseMonthData.getTotalNum().compareTo(BigDecimal.ZERO)==0){
 						indexBaseMonthData.setPercent(BigDecimal.ZERO);
@@ -154,17 +143,22 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			IndexBaseDto indexBaseData = new IndexBaseDto(typeDateMapEntry.getKey(),typeDateMapEntry.getKey().getMsg());
 			indexBaseData.setIndexMonthData(typeDateMapEntry.getValue(), currentMonth);
 			if(IndexDataType.FINANCE_PAY.equals(typeDateMapEntry.getKey()) || IndexDataType.FINANCE_AMOUNT.equals(typeDateMapEntry.getKey()) ||
-				IndexDataType.FINANCE_BALANCE_AMOUNT.equals(typeDateMapEntry.getKey())){
+				IndexDataType.FINANCE_BALANCE_AMOUNT.equals(typeDateMapEntry.getKey())
+				||IndexDataType.MUSIC_GROUP_COURSE.equals(typeDateMapEntry.getKey())||IndexDataType.VIP_GROUP_COURSE.equals(typeDateMapEntry.getKey())
+					||IndexDataType.PRACTICE_GROUP_COURSE.equals(typeDateMapEntry.getKey())){
 				indexBaseData.setPercent(typeDateMapEntry.getValue().stream().map(IndexBaseMonthData::getPercent).reduce(BigDecimal.ZERO, BigDecimal::add));
 			}
 			result.add(indexBaseData);
 		}
+		countStudentConvertData(result, currentMonth);
 		return result;
 	}
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public void indexBaseDataTask(String dayStr) {
+	public Map<String, List<IndexBaseDto>> indexBaseDataTask(String dayStr) {
+		Map<String, List<IndexBaseDto>> result = new HashMap<>();
+
 		LocalDate nowDate = LocalDate.now();
 
 		List<Organization> allOrgans = organizationDao.findAllOrgans();
@@ -177,58 +171,149 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			dayStr = nowDate.plusDays(-1).toString();
 		}
 
-		LocalDate day = LocalDate.parse(dayStr, DateUtil.dateFormatter);
-		LocalDate monday = day.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
+		//运营数据
+		saveData(indexBaseMonthDataDao.getSchoolData(dayStr), dayStr, IndexDataType.SCHOOL);
+		saveData(indexBaseMonthDataDao.getMusicData(dayStr), dayStr, IndexDataType.MUSIC_GROUP_NUM);
+		saveData(indexBaseMonthDataDao.getMusicStudentData(dayStr, null), dayStr, IndexDataType.MUSIC_GROUP_STUDENT);
+		saveData(indexBaseMonthDataDao.getOtherStudentData(dayStr), dayStr, IndexDataType.OTHER_STUDENT);
 
-		//学员数据
-		saveData(indexBaseMonthDataDao.getStudentRegistrationData(dayStr), dayStr, IndexDataType.STUDENT_REGISTRATION_NUM);
-		saveData(indexBaseMonthDataDao.getChargeStudentChangeData(dayStr), dayStr, IndexDataType.CHARGE_STUDENT_CHANGE_RATE);
+		//业务数据
 		saveData(indexBaseMonthDataDao.getStudentSignUpData(dayStr), dayStr, IndexDataType.ACTIVATION_RATE);
+		saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, null), dayStr, IndexDataType.HOMEWORK_CREATE_RATE);
+		saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, "submit"), dayStr, IndexDataType.HOMEWORK_SUBMIT_RATE);
+		saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, "comment"), dayStr, IndexDataType.HOMEWORK_COMMENT_RATE);
 
-		//运营数据
-		saveData(indexBaseMonthDataDao.getSchoolData(dayStr), dayStr, IndexDataType.SCHOOL);
-		saveData(indexBaseMonthDataDao.getMusicData(dayStr), dayStr, IndexDataType.PROGRESS_MUSIC_GROUP_NUM);
+		//经营数据
+		saveData(null, dayStr, IndexDataType.SHOULD_INCOME_MONEY);
+		saveData(null, dayStr, IndexDataType.ANTICIPATED_INCOME_MONEY);
+		saveData(null, dayStr, IndexDataType.SHOULD_EXPEND_MONEY);
+		saveData(null, dayStr, IndexDataType.ANTICIPATED_EXPEND_MONEY);
+		saveData(null, dayStr, IndexDataType.REVENUE_MONEY);
 
 		//人事数据
 		saveData(indexBaseMonthDataDao.getTeacherData(dayStr, null, null), dayStr, IndexDataType.TEACHER_NUM);
 		saveData(indexBaseMonthDataDao.getTeacherData(dayStr, JobNatureEnum.FULL_TIME, null), dayStr, IndexDataType.FULL_TIME_NUM);
 		saveData(indexBaseMonthDataDao.getTeacherData(dayStr, JobNatureEnum.PART_TIME, null), dayStr, IndexDataType.PART_TIME_NUM);
-//		saveData(indexBaseMonthDataDao.getTeacherData(dayStr, null, true), dayStr, IndexDataType.DIMISSION_NUM);
+		saveData(indexBaseMonthDataDao.getTeacherData(dayStr, null, true), dayStr, IndexDataType.DIMISSION_NUM);
 
-		//剩余课时
-		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, null, CourseStatusEnum.NOT_START), dayStr, IndexDataType.SURPLUS_COURSE_NUM);
-		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.MUSIC, CourseStatusEnum.NOT_START), dayStr, IndexDataType.SURPLUS_MUSIC_COURSE_NUM);
-		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.VIP, CourseStatusEnum.NOT_START), dayStr, IndexDataType.SURPLUS_VIP_COURSE_NUM);
-		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.PRACTICE, CourseStatusEnum.NOT_START), dayStr, IndexDataType.SURPLUS_PRACTICE_COURSE_NUM);
+		//学员变动
+		saveData(indexBaseMonthDataDao.getMusicStudentData(dayStr, "ADD"), dayStr, IndexDataType.NEWLY_STUDENT_NUM);
+		saveData(indexBaseMonthDataDao.getMusicStudentData(dayStr, "QUIT"), dayStr, IndexDataType.QUIT_MUSIC_GROUP_STUDENT_NUM);
+		saveData(indexBaseMonthDataDao.getMusicGroupPreRegistrationStudentData(dayStr), dayStr, IndexDataType.STUDENT_CONVERSION_PRE_STUDENT_NUM);
+		saveData(indexBaseMonthDataDao.getMusicGroupStudentFromPreData(dayStr, null), dayStr, IndexDataType.STUDENT_CONVERSION_STUDENT_NUM);
+		saveData(indexBaseMonthDataDao.getMusicGroupStudentFromPreData(dayStr, PaymentStatusEnum.YES), dayStr, IndexDataType.STUDENT_CONVERSION_PAYMENT_STUDENT_NUM);
+		List<Integer> studentIds = indexBaseMonthDataDao.getMusicGroupStudentIdFromPre(dayStr, PaymentStatusEnum.YES);
+		List<IndexBaseMonthData> convertStudentNum = new ArrayList<>();
+		if(!CollectionUtils.isEmpty(studentIds)){
+			convertStudentNum = indexBaseMonthDataDao.getStudentConversionData(dayStr, studentIds);
+		}
+		saveData(convertStudentNum, dayStr, IndexDataType.STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM);
 
-		//已消耗课时
-		saveData(indexBaseMonthDataDao.getGroupSurplusCourseData(dayStr, null, CourseStatusEnum.OVER), dayStr, IndexDataType.OVER_COURSE_NUM);
-		saveData(indexBaseMonthDataDao.getGroupSurplusCourseData(dayStr, GroupType.MUSIC, CourseStatusEnum.OVER), dayStr, IndexDataType.OVER_MUSIC_COURSE_NUM);
-		saveData(indexBaseMonthDataDao.getGroupSurplusCourseData(dayStr, GroupType.VIP, CourseStatusEnum.OVER), dayStr, IndexDataType.OVER_VIP_COURSE_NUM);
-		saveData(indexBaseMonthDataDao.getGroupSurplusCourseData(dayStr, GroupType.PRACTICE, CourseStatusEnum.OVER), dayStr, IndexDataType.OVER_PRACTICE_COURSE_NUM);
+		//课程数据
+		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.MUSIC), dayStr, IndexDataType.MUSIC_GROUP_COURSE);
+		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.VIP), dayStr, IndexDataType.VIP_GROUP_COURSE);
+		saveData(indexBaseMonthDataDao.getGroupCourseData(dayStr, GroupType.PRACTICE), dayStr, IndexDataType.PRACTICE_GROUP_COURSE);
 
-		//经营数据
+		//财务数据
 		saveData(indexBaseMonthDataDao.getFinancePayData(dayStr),dayStr,IndexDataType.FINANCE_PAY);
 		saveData(indexBaseMonthDataDao.getFinanceBalanceData(dayStr),dayStr,IndexDataType.FINANCE_BALANCE_AMOUNT);
 		saveData(indexBaseMonthDataDao.getFinanceActualData(dayStr),dayStr,IndexDataType.FINANCE_AMOUNT);
 
-		//业务数据
-		saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, null), monday.toString(), IndexDataType.HOMEWORK_CREATE_RATE);
-		saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, "submit"), monday.toString(), IndexDataType.HOMEWORK_SUBMIT_RATE);
-		saveData(indexBaseMonthDataDao.getHomeworkData(dayStr, "comment"), monday.toString(), IndexDataType.HOMEWORK_COMMENT_RATE);
+		return result;
+	}
 
-		//课程数据
-		saveData(indexBaseMonthDataDao.getGroupCourseDataWithGroup(dayStr, GroupType.MUSIC, null), dayStr, IndexDataType.MUSIC_GROUP_COURSE);
-		saveData(indexBaseMonthDataDao.getGroupCourseDataWithGroup(dayStr, GroupType.VIP, null), dayStr, IndexDataType.VIP_GROUP_COURSE);
-		saveData(indexBaseMonthDataDao.getGroupCourseDataWithGroup(dayStr, GroupType.PRACTICE, null), dayStr, IndexDataType.PRACTICE_GROUP_COURSE);
+	private void countStudentConvertData(List<IndexBaseDto> result, Date currentMonth){
+		List<IndexBaseMonthData> convertData = new ArrayList<>();
+
+		Map<IndexDataType, IndexBaseDto> typeDataMap = result.stream().collect(Collectors.toMap(IndexBaseDto::getDataType, i -> i, (i1, i2) -> i1));
+		List<IndexBaseMonthData> preStudentNum = new ArrayList<>();
+		if(typeDataMap.containsKey(IndexDataType.STUDENT_CONVERSION_PRE_STUDENT_NUM)){
+			preStudentNum = typeDataMap.get(IndexDataType.STUDENT_CONVERSION_PRE_STUDENT_NUM).getIndexMonthData();
+		}
+
+		IndexBaseMonthData preStudentNumData = new IndexBaseMonthData();
+		preStudentNumData = preStudentNum.stream().max(Comparator.comparing(IndexBaseMonthData::getMonth)).get();
+//		preStudentNumData.setMonth(currentMonth);
+		preStudentNumData.setDataType(IndexDataType.STUDENT_CONVERSION_PRE_STUDENT_NUM);
+		preStudentNumData.setTitle(IndexDataType.STUDENT_CONVERSION_PRE_STUDENT_NUM.getMsg());
+//		preStudentNumData.setTotalNum(preStudentNum.stream().map(IndexBaseMonthData::getTotalNum).reduce(BigDecimal.ZERO, BigDecimal::add));
+//		preStudentNumData.setActivateNum(preStudentNum.stream().map(IndexBaseMonthData::getActivateNum).reduce(BigDecimal.ZERO, BigDecimal::add));
+//		preStudentNumData.setPercent(preStudentNumData.getActivateNum());
+
+		List<IndexBaseMonthData> studentNum = new ArrayList<>();
+		if(typeDataMap.containsKey(IndexDataType.STUDENT_CONVERSION_STUDENT_NUM)){
+			studentNum = typeDataMap.get(IndexDataType.STUDENT_CONVERSION_STUDENT_NUM).getIndexMonthData();
+		}
+
+		IndexBaseMonthData studentNumData = new IndexBaseMonthData();
+		studentNumData = studentNum.stream().max(Comparator.comparing(IndexBaseMonthData::getMonth)).get();
+//		studentNumData.setMonth(currentMonth);
+		studentNumData.setDataType(IndexDataType.STUDENT_CONVERSION_STUDENT_NUM);
+		studentNumData.setTitle(IndexDataType.STUDENT_CONVERSION_STUDENT_NUM.getMsg());
+//		studentNumData.setTotalNum(studentNum.stream().map(IndexBaseMonthData::getTotalNum).reduce(BigDecimal.ZERO, BigDecimal::add));
+//		studentNumData.setActivateNum(studentNum.stream().map(IndexBaseMonthData::getActivateNum).reduce(BigDecimal.ZERO, BigDecimal::add));
+
+		List<IndexBaseMonthData> paymentStudentNum = new ArrayList<>();
+		if(typeDataMap.containsKey(IndexDataType.STUDENT_CONVERSION_PAYMENT_STUDENT_NUM)){
+			paymentStudentNum = typeDataMap.get(IndexDataType.STUDENT_CONVERSION_PAYMENT_STUDENT_NUM).getIndexMonthData();
+		}
+
+		IndexBaseMonthData paymentStudentNumData = new IndexBaseMonthData();
+		paymentStudentNumData = paymentStudentNum.stream().max(Comparator.comparing(IndexBaseMonthData::getMonth)).get();
+//		paymentStudentNumData.setMonth(currentMonth);
+		paymentStudentNumData.setDataType(IndexDataType.STUDENT_CONVERSION_PAYMENT_STUDENT_NUM);
+		paymentStudentNumData.setTitle(IndexDataType.STUDENT_CONVERSION_PAYMENT_STUDENT_NUM.getMsg());
+//		paymentStudentNumData.setTotalNum(paymentStudentNum.stream().map(IndexBaseMonthData::getTotalNum).reduce(BigDecimal.ZERO, BigDecimal::add));
+//		paymentStudentNumData.setActivateNum(paymentStudentNum.stream().map(IndexBaseMonthData::getActivateNum).reduce(BigDecimal.ZERO, BigDecimal::add));
+
+		List<IndexBaseMonthData> convertStudentNum = new ArrayList<>();
+		if(typeDataMap.containsKey(IndexDataType.STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM)){
+			convertStudentNum = typeDataMap.get(IndexDataType.STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM).getIndexMonthData();
+		}
+
+		IndexBaseMonthData convertStudentNumData = new IndexBaseMonthData();
+		convertStudentNumData = convertStudentNum.stream().max(Comparator.comparing(IndexBaseMonthData::getMonth)).get();
+//		convertStudentNumData.setMonth(currentMonth);
+		convertStudentNumData.setDataType(IndexDataType.STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM);
+		convertStudentNumData.setTitle(IndexDataType.STUDENT_CONVERSION_VIP_PRACTICE_STUDENT_NUM.getMsg());
+//		convertStudentNumData.setTotalNum(convertStudentNum.stream().map(IndexBaseMonthData::getTotalNum).reduce(BigDecimal.ZERO, BigDecimal::add));
+//		convertStudentNumData.setActivateNum(convertStudentNum.stream().map(IndexBaseMonthData::getActivateNum).reduce(BigDecimal.ZERO, BigDecimal::add));
+
+		if(true){
+			studentNumData.setPercent(studentNumData.getActivateNum());
+			paymentStudentNumData.setPercent(paymentStudentNumData.getActivateNum());
+			convertStudentNumData.setPercent(convertStudentNumData.getActivateNum());
+		}else if(preStudentNumData.getActivateNum().compareTo(BigDecimal.ZERO)==0){
+			studentNumData.setPercent(BigDecimal.ZERO);
+			paymentStudentNumData.setPercent(BigDecimal.ZERO);
+			convertStudentNumData.setPercent(BigDecimal.ZERO);
+		}else{
+			studentNumData.setPercent(studentNumData.getActivateNum().divide(preStudentNumData.getActivateNum(), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
+			if(studentNumData.getActivateNum().compareTo(BigDecimal.ZERO)==0){
+				paymentStudentNumData.setPercent(BigDecimal.ZERO);
+				convertStudentNumData.setPercent(BigDecimal.ZERO);
+			}else{
+				paymentStudentNumData.setPercent(paymentStudentNumData.getActivateNum().divide(studentNumData.getActivateNum(), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
+				if(paymentStudentNumData.getActivateNum().compareTo(BigDecimal.ZERO)==0){
+					convertStudentNumData.setPercent(BigDecimal.ZERO);
+				}else{
+					convertStudentNumData.setPercent(convertStudentNumData.getActivateNum().divide(paymentStudentNumData.getActivateNum(), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
+				}
+			}
+		}
 
-		//学员变动
-		saveData(indexBaseMonthDataDao.getAddStudentRegistrationData(dayStr), dayStr, IndexDataType.ADD_STUDENT_REGISTRATION_NUM);
-		saveData(indexBaseMonthDataDao.getMusicStudentData(dayStr, null), dayStr, IndexDataType.MUSIC_GROUP_STUDENT);
-		saveData(null, dayStr, IndexDataType.NEWLY_STUDENT_NUM);
-		saveData(null, dayStr, IndexDataType.QUIT_MUSIC_GROUP_STUDENT_NUM);
-		saveData(indexBaseMonthDataDao.getOtherStudentData(dayStr), dayStr, IndexDataType.VIP_PRACTICE_STUDENT_NUM);
-		saveData(indexBaseMonthDataDao.getVipPracticeAddStudentData(dayStr), dayStr, IndexDataType.VIP_PRACTICE_ADD_STUDENT_NUM);
+		convertData.add(preStudentNumData);
+		convertData.add(studentNumData);
+		convertData.add(paymentStudentNumData);
+		convertData.add(convertStudentNumData);
+		IndexBaseDto indexBaseData = new IndexBaseDto(IndexDataType.STUDENT_CONVERSION, IndexDataType.STUDENT_CONVERSION.getMsg());
+		indexBaseData.setIndexMonthData(convertData, currentMonth);
+		if(paymentStudentNumData.getActivateNum().compareTo(BigDecimal.ZERO)==0){
+			indexBaseData.setPercent(convertStudentNumData.getPercent());
+		}else{
+			indexBaseData.setPercent(convertStudentNumData.getActivateNum().divide(paymentStudentNumData.getActivateNum(), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
+		}
+		result.add(indexBaseData);
 	}
 
 	/**
@@ -243,31 +328,14 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			dataList = new ArrayList<>();
 		}
 		Set<Integer> hasOrganIds = dataList.stream().map(IndexBaseMonthData::getOrganId).collect(Collectors.toSet());
-
-		boolean specialType = IndexDataType.NEWLY_STUDENT_NUM.equals(indexDataType)||IndexDataType.QUIT_MUSIC_GROUP_STUDENT_NUM.equals(indexDataType);
-		Set<Integer> ignoreOrganIds = new HashSet<>();
-		if(specialType){
-			List<IndexBaseMonthData> indexBaseDatas = indexBaseMonthDataDao.getWithDayAndDataType(dayStr, indexDataType);
-			if(!CollectionUtils.isEmpty(indexBaseDatas)) {
-				ignoreOrganIds = indexBaseDatas.stream().map(IndexBaseMonthData::getOrganId).collect(Collectors.toSet());
-			}
-		}
-
 		for (Integer organId : this.organIds.get()) {
 			if(hasOrganIds.contains(organId)){
 				continue;
 			}
-			if(specialType&&ignoreOrganIds.contains(organId)){
-				continue;
-			}
 			dataList.add(new IndexBaseMonthData(date, organId));
 		}
-		if(!IndexDataType.NEWLY_STUDENT_NUM.equals(indexDataType)&&!IndexDataType.QUIT_MUSIC_GROUP_STUDENT_NUM.equals(indexDataType)){
-			indexBaseMonthDataDao.deleteWithMonthAndType(Arrays.asList(dayStr), indexDataType);
-		}
-		if(!CollectionUtils.isEmpty(dataList)){
-			indexBaseMonthDataDao.batchInsertWithDataType(dataList, indexDataType);
-		}
+		indexBaseMonthDataDao.deleteWithMonthAndType(Arrays.asList(dayStr), indexDataType);
+		indexBaseMonthDataDao.batchInsertWithDataType(dataList, indexDataType);
 	}
 
 	@Override
@@ -323,10 +391,10 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			three.setDesc(IndexErrorType.TEACHER_INFO.getMsg());
 			List<IndexErrInfoDto> threeChild = new ArrayList<>();
 
-			int attendanceError = indexBaseMonthDataDao.getAttendanceError(organIds,startTime);
+			int attendanceError = indexBaseMonthDataDao.getAttendanceError(organIdsStr,startTime);
 			threeChild.add(new IndexErrInfoDto(IndexErrorType.TEACHER_EXCEPTION_ATTENDANCE, IndexErrorType.TEACHER_EXCEPTION_ATTENDANCE.getMsg(), attendanceError, null));
 
-			int noAttendance = indexBaseMonthDataDao.getNoAttendance(organIds,startTime);
+			int noAttendance = indexBaseMonthDataDao.getNoAttendance(organIdsStr,startTime);
 			threeChild.add(new IndexErrInfoDto(IndexErrorType.TEACHER_NOT_A_CLASS, IndexErrorType.TEACHER_NOT_A_CLASS.getMsg(), noAttendance, null));
 
 //			int teacherLeave = indexBaseMonthDataDao.queryTeacherLeave(organIdsStr,startTime);
@@ -421,16 +489,28 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 				flag2 = true;
 			}
 		}
+		/*if(!flag2){
+			int attendanceInfo = indexBaseMonthDataDao.queryStudentAttendanceInfo(organIds, StudentAttendanceStatusEnum.TRUANT.getCode(),startTime);
+			if(attendanceInfo > 0){
+				flag2 = true;
+			}
+		}
+		if(!flag2){
+			int attendanceInfo1 = indexBaseMonthDataDao.queryStudentAttendanceInfo(organIds, StudentAttendanceStatusEnum.LEAVE.getCode(),startTime);
+			if(attendanceInfo1 > 0){
+				flag2 = true;
+			}
+		}*/
 		resultMap.put("studentInfo",flag2);
 		boolean flag3 = false;
 		if(!flag3){
-			int attendanceError = indexBaseMonthDataDao.getAttendanceError(organIds,startTime);
+			int attendanceError = indexBaseMonthDataDao.getAttendanceError(organIdsStr,startTime);
 			if(attendanceError > 0){
 				flag3 = true;
 			}
 		}
 		if(!flag3){
-			int noAttendance = indexBaseMonthDataDao.getNoAttendance(organIds,startTime);
+			int noAttendance = indexBaseMonthDataDao.getNoAttendance(organIdsStr,startTime);
 			if(noAttendance > 0){
 				flag3 = true;
 			}

+ 34 - 17
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java

@@ -3,13 +3,17 @@ package com.ym.mec.biz.service.impl;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.STUDENT;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum.*;
 import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.NON_PAYMENT;
+import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED;
+import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.YES;
 
 import java.math.BigDecimal;
 import java.util.*;
 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.StudentMusicGroupStatusEnum;
 import com.ym.mec.biz.dal.page.ArrearageStudentsQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.QueryInfo;
@@ -20,13 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import com.ym.mec.biz.dal.dao.MusicGroupDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
-import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
-import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.FeeStudentDto;
 import com.ym.mec.biz.dal.dto.SimpleUserDto;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
@@ -65,6 +62,8 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 	@Autowired
 	private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
 	@Autowired
+	private StudentRegistrationDao studentRegistrationDao;
+	@Autowired
 	private SysMessageService sysMessageService;
 
 	@Override
@@ -86,28 +85,44 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		Date date = new Date();
 		MusicGroupPaymentCalender calender = musicGroupPaymentCalenderService.get(calenderDetails.get(0).getMusicGroupPaymentCalenderId());
 		//缴费项目已结束,并且没有单独开启缴费的学员,不能修改缴费金额
-		if(calender.getStatus() == OVER){
-			List<MusicGroupPaymentCalenderDetail> paymentCalenderDetails = calenderDetails.stream().filter(e -> e.getOpenFlag() == YesOrNoEnum.NO).collect(Collectors.toList());
-			if(paymentCalenderDetails != null && paymentCalenderDetails.size() > 0){
-				throw new BizException("修改失败:存在未开启缴费的学员");
-			}
-		}
+//		if(calender.getStatus() == OVER){
+//			List<MusicGroupPaymentCalenderDetail> paymentCalenderDetails = calenderDetails.stream().filter(e -> e.getOpenFlag() == YesOrNoEnum.NO).collect(Collectors.toList());
+//			if(paymentCalenderDetails != null && paymentCalenderDetails.size() > 0){
+//				throw new BizException("修改失败:存在未开启缴费的学员");
+//			}
+//		}
 		Set<Integer> studentIds = new HashSet<>();
 				calenderDetails.forEach(e->{
 			if(e.getPaymentStatus() == null || e.getPaymentStatus() != NON_PAYMENT){
 				throw new BizException("修改失败:缴费状态不匹配");
 			}
-			if(expectAmount.doubleValue() != 0){
-
-			}
 			e.setUpdateTime(date);
 			e.setExpectAmount(expectAmount);
 			if(expectAmount.doubleValue() > 0){
 				if((e.getOpen() != null && e.getOpen() == 1) || calender.getStatus() == PaymentCalenderStatusEnum.OPEN){
 					studentIds.add(e.getUserId());
 				}
+			}else {
+				calender.setActualNum((calender.getActualNum()==null?0:calender.getActualNum()) + 1);
+				e.setPaymentStatus(PAID_COMPLETED);
+				if(calender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.ADD_STUDENT){
+					MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(e.getUserId(), calender.getMusicGroupId());
+					if (musicGroupStudentFee != null) {
+						musicGroupStudentFee.setUpdateTime(date);
+						musicGroupStudentFee.setLatestPaidTime(date);
+						musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
+						musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
+						musicGroupStudentFeeDao.update(musicGroupStudentFee);
+					}
+					//如果是进行中加学员
+					StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(e.getUserId(), calender.getMusicGroupId());
+					studentRegistration.setPaymentStatus(YES);
+					studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
+					studentRegistrationDao.update(studentRegistration);
+				}
 			}
 		});
+		musicGroupPaymentCalenderDao.update(calender);
 		musicGroupPaymentCalenderDetailDao.batchUpdate(calenderDetails);
 		//推送消息
 		if (calender.getPayUserType() == STUDENT && studentIds.size() > 0) {
@@ -407,8 +422,8 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<MusicGroupPaymentStudentCourseDetail>();
 		
 		Long musicGroupPaymentCalenderId = null;
-		
 		for(MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenderList){
+			int paymentNum = 0;
 			
 			musicGroupPaymentCalenderId = musicGroupPaymentCalender.getId();
 			
@@ -452,6 +467,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 				musicGroupPaymentCalenderDetail.setExpectAmount(totalPrice);
 				if (musicGroupPaymentCalenderDetail.getExpectAmount().compareTo(new BigDecimal(0)) == 0) {
 					musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
+					paymentNum++;
 				} else {
 					musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
 				}
@@ -473,6 +489,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 			//更新预计缴费人数
 			musicGroupPaymentCalender.setExpectNum(musicGroupPaymentCalender.getExpectNum() + userIdList.size());
 			musicGroupPaymentCalender.setUpdateTime(date);
+			musicGroupPaymentCalender.setActualNum((musicGroupPaymentCalender.getActualNum()==null?0:musicGroupPaymentCalender.getActualNum()) + paymentNum);
 			musicGroupPaymentCalenderService.update(musicGroupPaymentCalender);
 			
 			MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;

+ 36 - 16
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -2,8 +2,7 @@ package com.ym.mec.biz.service.impl;
 
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.SCHOOL;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.STUDENT;
-import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum.AUDITING;
-import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum.REJECT;
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum.*;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.ADD_COURSE;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.ADD_STUDENT;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY;
@@ -26,6 +25,7 @@ import java.util.Set;
 import java.util.stream.Collectors;
 
 import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
 import com.ym.mec.biz.service.*;
@@ -46,25 +46,11 @@ 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.ClassGroup;
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
-import com.ym.mec.biz.dal.entity.MusicGroup;
-import com.ym.mec.biz.dal.entity.MusicGroupBuildLog;
-import com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettings;
-import com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettingsDetail;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderStudentDetail;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
-import com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust;
-import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
-import com.ym.mec.biz.dal.entity.Organization;
-import com.ym.mec.biz.dal.entity.OrganizationCourseUnitPriceSettings;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
 import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
@@ -433,6 +419,10 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 					Set<Integer> list2 = Arrays.stream(ints).boxed().collect(Collectors.toSet());
 					musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalender.getId(),list2);
 				}
+				//将0元未缴费学员缴费状态更新为已缴费
+				int j = musicGroupPaymentCalenderDetailDao.updateNoPaymentAndZeroPaymentStatus(musicGroupPaymentCalender.getId());
+				musicGroupPaymentCalender.setActualNum((musicGroupPaymentCalender.getActualNum()==null?0:musicGroupPaymentCalender.getActualNum()) + j);
+				musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
 			}
 		}
 
@@ -744,6 +734,10 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 					//如果是跨团班级合并,添加学员
 					musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalender,musicGroupPaymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails());
 				}
+				//将0元未缴费学员缴费状态更新为已缴费
+				int j = musicGroupPaymentCalenderDetailDao.updateNoPaymentAndZeroPaymentStatus(musicGroupPaymentCalender.getId());
+				musicGroupPaymentCalender.setActualNum((musicGroupPaymentCalender.getActualNum()==null?0:musicGroupPaymentCalender.getActualNum()) + j);
+				musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
 			}
 
 			if (currentMusicGroupPaymentCalenderCourseSettings.size() > 0) {
@@ -832,6 +826,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		return true;
 	}
 
+	@Transactional(rollbackFor = Exception.class)
+	@Override
 	public void addStudent(MusicGroupPaymentCalender musicGroupPaymentCalender,List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList){
 		//如果是进行中加学生
 		Date date = new Date();
@@ -859,6 +855,22 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
 
 				musicGroupPaymentCalenderDetailDao.insert(musicGroupPaymentCalenderDetail);
+				//如果是0元那么更新fee表和studentRegistration表
+				if(totalPrice.doubleValue() == 0d){
+					MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(Integer.parseInt(studentId), musicGroupPaymentCalender.getMusicGroupId());
+					if (musicGroupStudentFee != null) {
+						musicGroupStudentFee.setUpdateTime(date);
+						musicGroupStudentFee.setLatestPaidTime(date);
+						musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
+						musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
+						musicGroupStudentFeeDao.update(musicGroupStudentFee);
+					}
+					//如果是进行中加学员
+					StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(Integer.parseInt(studentId), musicGroupPaymentCalender.getMusicGroupId());
+					studentRegistration.setPaymentStatus(YES);
+					studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
+					studentRegistrationDao.update(studentRegistration);
+				}
 
 				// 学生加课程明细
 				for(MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList){
@@ -1125,6 +1137,11 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			classGroupService.spanGroupClassAdjustPass(adjust.getMasterClassGroupId()
 					,studentIds,courseIds,classGroupStudents,allLockCourseIds,batchNo,adjust.getMasterTotalPrice());
 		}
+		for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenders) {
+			//将0元未缴费学员缴费状态更新为已缴费
+			int j = musicGroupPaymentCalenderDetailDao.updateNoPaymentAndZeroPaymentStatus(musicGroupPaymentCalender.getId());
+			musicGroupPaymentCalender.setActualNum((musicGroupPaymentCalender.getActualNum()==null?0:musicGroupPaymentCalender.getActualNum()) + j);
+		}
 		musicGroupPaymentCalenderDao.batchUpdate(musicGroupPaymentCalenders);
 	}
 
@@ -1218,6 +1235,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				// “未开始”更新至“进行中”
 				mgpc.setUpdateTime(date);
 				mgpc.setStatus(PaymentCalenderStatusEnum.OPEN);
+				//将0元未缴费学员缴费状态更新为已缴费
+				int i = musicGroupPaymentCalenderDetailDao.updateNoPaymentAndZeroPaymentStatus(mgpc.getId());
+				mgpc.setActualNum((mgpc.getActualNum()==null?0:mgpc.getActualNum()) + i);
 				updateMusicGroupPaymentCalenderList.add(mgpc);
 				if(mgpc.getPayUserType() == STUDENT){
 					//推送待续费通知

+ 6 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -2786,7 +2786,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 
         Date now = new Date();
 
-        int studentExitChargePractices = practiceGroupDao.checkStudentExitChargePractice(practiceGroupBuyParams.getStudentId());
+        int studentExitChargePractices = practiceGroupDao.checkStudentExitChargePractice(practiceGroupBuyParams.getStudentId(),"2021-03-09 00:00:00");
 
         LocalDate courseStartDay = LocalDate.now();
         LocalDate tempCourseLocalDate = LocalDate.parse("2020-03-01", DateUtil.dateFormatter);
@@ -2894,8 +2894,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             throw new BizException("所在城市暂不参与此活动");
         }
         BigDecimal oneMonthPrice;
-        if (practiceBuyActivityExpireDate.after(now)) {
-            oneMonthPrice = practiceGroupBuyParams.getDrillTimesOnWeek() == 1 ? practiceGroupSellPrice.getOnceActivityPrice() : practiceGroupSellPrice.getTwiceActivityPrice();
+        if (practiceBuyActivityExpireDate.after(now)&&Objects.nonNull(sysUser.getOrganId())&&sysUser.getOrganId()==14&& studentExitChargePractices <= 0) {
+//            oneMonthPrice = practiceGroupBuyParams.getDrillTimesOnWeek() == 1 ? practiceGroupSellPrice.getOnceActivityPrice() : practiceGroupSellPrice.getTwiceActivityPrice();
+            oneMonthPrice = practiceGroupBuyParams.getDrillTimesOnWeek() == 1 ? practiceGroupSellPrice.getOnceOriginalPrice() : practiceGroupSellPrice.getTwiceOriginalPrice();
             if (!now.before(practicePromotionActivityStartDate) && practiceGroupBuyParams.getBuyMonths() >= 3 && studentExitChargePractices > 0) {
                 oneMonthPrice = practiceGroupBuyParams.getDrillTimesOnWeek() == 1 ? practiceGroupSellPrice.getOnceQuartActivityPrice() : practiceGroupSellPrice.getTwiceQuartActivityPrice();
             } else if (!now.before(practicePromotionActivityStartDate) && studentExitChargePractices <= 0) {
@@ -2905,7 +2906,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             oneMonthPrice = practiceGroupBuyParams.getDrillTimesOnWeek() == 1 ? practiceGroupSellPrice.getOnceOriginalPrice() : practiceGroupSellPrice.getTwiceOriginalPrice();
         }
         BigDecimal amount = oneMonthPrice.multiply(new BigDecimal(practiceGroupBuyParams.getBuyMonths()));
-        if (!now.before(practicePromotionActivityStartDate) && now.before(practiceBuyActivityExpireDate) && studentExitChargePractices <= 0) {
+        if (!now.before(practicePromotionActivityStartDate) && now.before(practiceBuyActivityExpireDate) && Objects.nonNull(sysUser.getOrganId())&&sysUser.getOrganId()==14 && studentExitChargePractices <= 0) {
             amount = oneMonthPrice.multiply(new BigDecimal(1));
         }
 
@@ -3730,7 +3731,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 
     @Override
     public boolean isPurchasedPracticeCourse(Integer userId) {
-        int count = practiceGroupDao.checkStudentExitChargePractice(userId);
+        int count = practiceGroupDao.checkStudentExitChargePractice(userId, null);
         if (count > 0) {
             return true;
         }

+ 36 - 194
mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml

@@ -28,10 +28,6 @@
 		SELECT * FROM index_base_month_data ORDER BY id_
 	</select>
 
-	<select id="getOrganDataWithDayAndDataType" resultMap="IndexBaseMonthData">
-		SELECT * FROM index_base_month_data WHERE organ_id_=#{organId} AND month_ = #{day} AND data_type_=#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} ORDER BY month_ DESC LIMIT 1;
-	</select>
-
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		<!--
@@ -63,32 +59,30 @@
 
 	<!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData">
-		UPDATE index_base_month_data
-		<set>
-			<if test="organId != null">
-				organ_id_ = #{organId},
-			</if>
-			<if test="id != null">
-				id_ = #{id},
-			</if>
-			<if test="activateNum != null">
-				activate_num_ = #{activateNum},
-			</if>
-			<if test="totalNum != null">
-				total_num_ = #{totalNum},
-			</if>
-			<if test="percent != null">
-				percent_ = #{percent},
-			</if>
-			<if test="month != null">
-				month_ = #{month},
-			</if>
-			<if test="dataType != null">
-				data_type_ = #{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-			</if>
-			update_time_ = NOW()
-		</set>
-		WHERE id_ = #{id}
+		UPDATE index_base_month_data <set>
+		<if test="organId != null">
+			organ_id_ = #{organId},
+		</if>
+		<if test="id != null">
+			id_ = #{id},
+		</if>
+		<if test="activateNum != null">
+			activate_num_ = #{activateNum},
+		</if>
+		<if test="totalNum != null">
+			total_num_ = #{totalNum},
+		</if>
+		<if test="percent != null">
+			percent_ = #{percent},
+		</if>
+		<if test="month != null">
+			month_ = #{month},
+		</if>
+		<if test="dataType != null">
+			data_type_ = #{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+		</if>
+		update_time_ = NOW()
+	</set> WHERE id_ = #{id}
 	</update>
 
 	<!-- 根据主键删除一条记录 -->
@@ -144,15 +138,6 @@
 		GROUP BY month_,data_type_
 	</select>
 
-	<select id="getWithDayAndDataType" resultMap="IndexBaseMonthData">
-		SELECT
-			*
-		FROM index_base_month_data
-		WHERE 1=1
-			AND data_type_ = #{dataType}
-			AND month_&gt;=#{day}
-	</select>
-
 	<select id="getStudentSignUpData" resultMap="IndexBaseMonthData">
 		SELECT
 			organ_id_,
@@ -176,8 +161,8 @@
 			 SELECT DISTINCT
 				 cssp.user_id_
 			 FROM
-				course_schedule_student_payment cssp
-				LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
+				 course_schedule_student_payment cssp
+					 LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
 			 WHERE
 				 cs.del_flag_ = 0
 			   AND ( cs.is_lock_ = 0 OR cs.is_lock_ IS NULL )
@@ -194,67 +179,10 @@
 		ORDER BY organ_id_;
 	</select>
 
-	<select id="getStudentRegistrationData" resultMap="IndexBaseMonthData">
-		SELECT
-			su.organ_id_,
-			#{dayStr} month_,
-			COUNT( DISTINCT stu.user_id_ ) total_num_,
-			COUNT( DISTINCT stu.user_id_ ) activate_num_,
-			COUNT( DISTINCT stu.user_id_ ) percent_
-		FROM
-			student stu
-			LEFT JOIN sys_user su ON stu.user_id_=su.id_
-		WHERE
-			su.del_flag_=0
-		  AND su.organ_id_ IS NOT NULL
-		  AND su.user_type_ LIKE '%STUDENT%'
-		  AND DATE_FORMAT(stu.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
-		GROUP BY organ_id_
-		ORDER BY organ_id_;
-	</select>
-
-	<select id="getAddStudentRegistrationData" resultMap="IndexBaseMonthData">
-		SELECT
-			su.organ_id_,
-			#{dayStr} month_,
-			COUNT( DISTINCT stu.user_id_ ) total_num_,
-			COUNT( DISTINCT stu.user_id_ ) activate_num_,
-			COUNT( DISTINCT stu.user_id_ ) percent_
-		FROM
-			student stu
-				LEFT JOIN sys_user su ON stu.user_id_=su.id_
-		WHERE
-			su.del_flag_=0
-		  AND su.organ_id_ IS NOT NULL
-		  AND su.user_type_ LIKE '%STUDENT%'
-		  AND DATE_FORMAT(stu.create_time_, '%Y-%m-%d')=#{dayStr}
-		GROUP BY organ_id_
-		ORDER BY organ_id_;
-	</select>
-
-	<select id="getChargeStudentChangeData" resultMap="IndexBaseMonthData">
-		SELECT
-			su.organ_id_,
-			#{dayStr} month_,
-			COUNT( DISTINCT stu.user_id_ ) total_num_,
-			COUNT( DISTINCT spo.user_id_ ) activate_num_,
-			TRUNCATE(COUNT(DISTINCT spo.user_id_)/COUNT(DISTINCT stu.user_id_)*100, 2) percent_
-		FROM
-			student stu
-			LEFT JOIN sys_user su ON stu.user_id_=su.id_
-			LEFT JOIN student_payment_order spo ON stu.user_id_=spo.user_id_ AND status_='SUCCESS' AND actual_amount_>0
-		WHERE
-			su.del_flag_=0
-		  AND su.organ_id_ IS NOT NULL
-		  AND su.user_type_ LIKE '%STUDENT%'
-		GROUP BY organ_id_
-		ORDER BY organ_id_;
-	</select>
-
 	<select id="getHomeworkData" resultMap="IndexBaseMonthData">
 		SELECT
 			su.organ_id_,
-			sees.monday_ month_,
+			#{dayStr} month_,
 			<choose>
 				<when test="type == 'submit'">
 					SUM(sees.actual_exercises_num_) total_num_,
@@ -276,8 +204,8 @@
 		LEFT JOIN sys_user su ON sees.student_id_=su.id_
 		WHERE su.del_flag_=0
 			AND su.organ_id_ IS NOT NULL
-			AND DATE_FORMAT(sees.monday_, '%Y-%m-%d')&lt;=#{dayStr}
-			AND DATE_FORMAT(sees.sunday_, '%Y-%m-%d')&gt;=#{dayStr}
+			AND (DATE_FORMAT(sees.monday_, '%Y-%m')=DATE_FORMAT(#{dayStr}, '%Y-%m')
+			        OR DATE_FORMAT(sees.sunday_, '%Y-%m')=DATE_FORMAT(#{dayStr}, '%Y-%m'))
 		GROUP BY su.organ_id_
 		ORDER BY su.organ_id_
 	</select>
@@ -398,15 +326,14 @@
 		WHERE
 			m.del_flag_ = 0
 			AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
-		  	AND m.status_ = #{courseStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+		  	AND m.status_ = 'OVER'
 			AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
-		  	AND m.group_type_!='DEMO'
 			AND m.organ_id_ IS NOT NULL
 			<if test="groupType!=null">
-				AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+				AND m.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 			</if>
 			<if test="dayStr!=null and dayStr!=''">
-				AND m.class_date_ &gt;= #{dayStr}
+				AND DATE_FORMAT(m.class_date_, '%Y-%m-%d') = #{dayStr}
 			</if>
 		GROUP BY
 			m.organ_id_
@@ -414,59 +341,6 @@
 			m.organ_id_;
 	</select>
 
-	<select id="getGroupSurplusCourseData" resultMap="IndexBaseMonthData">
-		SELECT
-			m.organ_id_,
-			#{dayStr} month_,
-			COUNT( m.id_ ) total_num_,
-			COUNT( m.id_ ) activate_num_,
-			COUNT( m.id_ ) percent_
-		FROM
-			course_schedule m
-		WHERE
-			m.del_flag_ = 0
-			AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
-			AND m.status_ = #{courseStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-			AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
-			AND m.group_type_!='DEMO'
-			AND m.organ_id_ IS NOT NULL
-			<if test="groupType!=null">
-				AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-			</if>
-			<if test="dayStr!=null and dayStr!=''">
-				AND m.class_date_ &lt;= #{dayStr}
-			</if>
-		GROUP BY m.organ_id_
-		ORDER BY m.organ_id_;
-	</select>
-
-	<select id="getGroupCourseDataWithGroup" resultMap="IndexBaseMonthData">
-		SELECT
-		m.organ_id_,
-		#{dayStr} month_,
-		COUNT( m.id_ ) total_num_,
-		COUNT( m.id_ ) activate_num_,
-		COUNT( m.id_ ) percent_
-		FROM
-		course_schedule m
-		WHERE
-		m.del_flag_ = 0
-		AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
-		AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
-		AND m.group_type_!='DEMO'
-		AND m.organ_id_ IS NOT NULL
-		<if test="groupType!=null">
-			AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-		</if>
-		<if test="dayStr!=null and dayStr!=''">
-			AND m.class_date_ = #{dayStr}
-		</if>
-		GROUP BY
-		m.organ_id_
-		ORDER BY
-		m.organ_id_;
-	</select>
-
 	<select id="getOtherStudentData" resultMap="IndexBaseMonthData">
 		SELECT
 			su.organ_id_,
@@ -493,32 +367,6 @@
 			su.organ_id_;
 	</select>
 
-	<select id="getVipPracticeAddStudentData" resultMap="IndexBaseMonthData">
-		SELECT
-			su.organ_id_,
-			#{dayStr} month_,
-			COUNT( DISTINCT s.user_id_ ) total_num_,
-			COUNT( DISTINCT s.user_id_ ) activate_num_,
-			COUNT( DISTINCT s.user_id_ ) percent_
-		FROM
-			sys_user su
-			LEFT JOIN course_schedule_student_payment s ON su.id_=s.user_id_
-			LEFT JOIN course_schedule_student_payment cssp1 ON s.user_id_=cssp1.user_id_ AND cssp1.create_time_&lt;#{dayStr}
-			LEFT JOIN course_schedule m ON s.course_schedule_id_=m.id_
-		WHERE
-			m.del_flag_ = 0
-			AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
-			AND cssp1.id_ IS NULL
-			AND su.organ_id_ IS NOT NULL
-			AND m.group_type_ IN ('VIP', 'PRACTICE')
-			AND m.status_ = 'NOT_START'
-			<if test="dayStr!=null and dayStr!=''">
-				AND DATE_FORMAT(s.create_time_, '%Y-%m-%d') = #{dayStr}
-			</if>
-		GROUP BY su.organ_id_
-		ORDER BY su.organ_id_;
-	</select>
-
 	<select id="getStudentConversionData" resultMap="IndexBaseMonthData">
 		SELECT
 			cs.organ_id_,
@@ -747,11 +595,8 @@
 		AND (((ta.sign_in_status_ = 0 OR ta.sign_out_status_ = 0) AND ta.dispose_content_ IS NULL) OR (sa.id_ IS NULL OR (sa.status_ != 'NORMAL' AND sa.visit_flag_ = 0)))
 		AND (ta.dispose_content_ IS NOT NULL OR (ta.sign_in_status_ IS NOT NULL AND ta.sign_out_status_ IS NOT NULL))
 		AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_)
-		<if test="organIds!=null and organIds.size() > 0">
-			AND cs.organ_id_ IN
-			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
-				#{organId}
-			</foreach>
+		<if test="organIds != null and organIds != ''">
+			AND FIND_IN_SET(cs.organ_id_,#{organIds})
 		</if>
 		GROUP BY cs.id_) c
 	</select>
@@ -762,11 +607,8 @@
 		AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_>='2021-02-01'
 		AND ta.sign_in_time_ IS NULL AND ta.sign_out_time_ IS NULL AND ta.dispose_content_ IS NULL
 		AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_)
-		<if test="organIds!=null and organIds.size() > 0">
-			AND cs.organ_id_ IN
-			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
-				#{organId}
-			</foreach>
+		<if test="organIds != null and organIds != ''">
+			AND FIND_IN_SET(cs.organ_id_,#{organIds})
 		</if>
 	</select>
 	<select id="queryTeacherLeave" resultType="int">

+ 4 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml

@@ -512,7 +512,9 @@
 	</select>
 
     <update id="updateNoPaymentAndZeroPaymentStatus">
-		UPDATE music_group_payment_calender_detail SET payment_status_ = 'PAID_COMPLETED',actual_amount_ = 0,update_time_ = NOW()
-		WHERE music_group_payment_calender_id_ = #{calenderId} AND expect_amount_ = 0 AND payment_status_ = 'NON_PAYMENT'
+		UPDATE music_group_payment_calender_detail mgpcd
+		SET mgpcd.payment_status_ = 'PAID_COMPLETED',mgpcd.actual_amount_ = 0,mgpcd.update_time_ = NOW()
+		WHERE mgpcd.music_group_payment_calender_id_ = #{calenderId} AND mgpcd.expect_amount_ = 0
+		AND mgpcd.payment_status_ = 'NON_PAYMENT'
 	</update>
 </mapper>

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/PracticeGroupMapper.xml

@@ -672,6 +672,9 @@
 
     <select id="checkStudentExitChargePractice" resultType="int">
         SELECT COUNT(id_) FROM practice_group WHERE type_='CHARGE' AND student_id_=#{studentId} AND group_status_ IN ('NORMAL', 'FINISH')
+        <if test="startTime!=null and startTime!=''">
+            AND create_time_>#{startTime}
+        </if>
     </select>
 
     <select id="countStudentIngTrialPractices" resultType="int">

+ 7 - 7
mec-common/audit-log/pom.xml

@@ -21,11 +21,11 @@
 			<groupId>com.yonge.mongodb</groupId>
 			<artifactId>mongo-db</artifactId>
 		</dependency>
-        <dependency>
-            <groupId>io.swagger</groupId>
-            <artifactId>swagger-annotations</artifactId>
-            <version>1.5.20</version>
-            <scope>compile</scope>
-        </dependency>
-    </dependencies>
+		<dependency>
+			<groupId>io.swagger</groupId>
+			<artifactId>swagger-annotations</artifactId>
+			<version>1.5.20</version>
+			<scope>compile</scope>
+		</dependency>
+	</dependencies>
 </project>

+ 38 - 32
mec-common/audit-log/src/main/java/com/yonge/log/interceptor/AuditLogInterceptor.java

@@ -15,8 +15,6 @@ import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.context.support.WebApplicationContextUtils;
 import org.springframework.web.method.HandlerMethod;
 import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
 
@@ -41,7 +39,7 @@ public class AuditLogInterceptor extends HandlerInterceptorAdapter {
 
 	private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
-	private static List<String> logUrl;
+	private static List<String> ignoreLogUrl;
 
 
 
@@ -52,37 +50,45 @@ public class AuditLogInterceptor extends HandlerInterceptorAdapter {
 	}
 
 	@Override
-	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
-		String servletPath = request.getServletPath();
-		HandlerMethod handlerMethod = (HandlerMethod) handler;
-		AuditLogAnnotation anno = handlerMethod.getMethodAnnotation(AuditLogAnnotation.class);
-		ApiOperation apiOperation = handlerMethod.getMethodAnnotation(ApiOperation.class);
-		String operateName = null;
-		if(StringUtils.isEmpty(operateName) && apiOperation != null){
-			operateName = apiOperation.value();
-		}
-		if(StringUtils.isEmpty(operateName) && anno != null){
-			operateName = anno.operateName();
-		}
-		if(anno != null){
-			saveLog(operateName,servletPath,request);
-			return;
-		}
-		if(servletPath.contains("/task/")){
-			return;
-		}
- 		String substring = servletPath.substring(servletPath.lastIndexOf("/") + 1).toLowerCase();
-		if(logUrl == null){
-			logUrl = new ArrayList<>();
-			logUrl.add("update");
-			logUrl.add("modify");
-			logUrl.add("del");
-		}
-		for (String e : logUrl) {
-			if(substring.contains(e)){
+	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
+		try {
+			String servletPath = request.getServletPath();
+			HandlerMethod handlerMethod = (HandlerMethod) handler;
+			AuditLogAnnotation anno = handlerMethod.getMethodAnnotation(AuditLogAnnotation.class);
+			ApiOperation apiOperation = handlerMethod.getMethodAnnotation(ApiOperation.class);
+			String operateName = null;
+			if(StringUtils.isEmpty(operateName) && apiOperation != null){
+				operateName = apiOperation.value();
+			}
+			if(StringUtils.isEmpty(operateName) && anno != null){
+				operateName = anno.operateName();
+			}
+			if(anno != null){
 				saveLog(operateName,servletPath,request);
-				break;
+				return;
+			}
+			if(servletPath.contains("/task/") || servletPath.contains("/import/") ){
+				return;
 			}
+			String substring = servletPath.substring(servletPath.lastIndexOf("/") + 1).toLowerCase();
+			if(ignoreLogUrl == null){
+				ignoreLogUrl = new ArrayList<>();
+				ignoreLogUrl.add("add");
+				ignoreLogUrl.add("insert");
+				ignoreLogUrl.add("query");
+				ignoreLogUrl.add("get");
+				ignoreLogUrl.add("find");
+				ignoreLogUrl.add("list");
+				ignoreLogUrl.add("detail");
+			}
+			for (String e : ignoreLogUrl) {
+				if(substring.contains(e)){
+					return;
+				}
+			}
+			saveLog(operateName,servletPath,request);
+		}catch (Exception e){
+			e.printStackTrace();
 		}
 	}
 

+ 8 - 0
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupRegisterController.java

@@ -6,11 +6,13 @@ import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
 import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
+import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
 import com.ym.mec.biz.service.MusicGroupService;
 import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
 import com.ym.mec.biz.service.StudentRegistrationService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.util.date.DateUtil;
 
 import io.swagger.annotations.Api;
@@ -19,6 +21,7 @@ import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.*;
 
 import java.io.IOException;
@@ -62,6 +65,11 @@ public class MusicGroupRegisterController extends BaseController {
             return succeed(studentRegistrationService.updateStudent(studentRegistration));
         }
 
+        StudentRegistration hasReg = studentRegistrationService.getByPhoneAndMusicGroupId(studentRegistration.getMusicGroupId(), studentRegistration.getParentsPhone());
+        if (hasReg != null && hasReg.getMusicGroupStatus() != StudentMusicGroupStatusEnum.QUIT) {
+            return succeed(hasReg);
+        }
+
         if (musicGroup.getStatus().equals(MusicGroupStatusEnum.PAY)) {
             studentRegistration.setPaymentStatus(PaymentStatusEnum.OPEN);
         } else {

+ 2 - 1
mec-student/src/main/java/com/ym/mec/student/controller/PracticeGroupController.java

@@ -198,8 +198,9 @@ public class PracticeGroupController extends BaseController {
         if (sysUser == null) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
-        int studentExitChargePractices = practiceGroupDao.checkStudentExitChargePractice(sysUser.getId());
+        int studentExitChargePractices = practiceGroupDao.checkStudentExitChargePractice(sysUser.getId(),"2021-03-09 00:00:00");
         Map<String, Integer> result=new HashMap<>();
+        result.put("organId", sysUser.getOrganId());
         result.put("isNewStudent", studentExitChargePractices<=0?0:1);
         return succeed(result);
     }

+ 2 - 2
mec-web/src/main/java/com/ym/mec/web/controller/CourseScheduleController.java

@@ -424,8 +424,8 @@ public class CourseScheduleController extends BaseController {
     @ApiOperation(value = "陪练课课程组有效期调整")
     @PostMapping("/updateCoursesExpireDate")
     @PreAuthorize("@pcs.hasPermissions('courseSchedule/updateCoursesExpireDate')")
-    public Object updateCoursesExpireDate(String practiceGroupId,Date coursesExpireDate){
-        courseScheduleService.updateCoursesExpireDate(practiceGroupId,coursesExpireDate);
+    public Object updateCoursesExpireDate(String practiceGroupId, Date coursesStartDate,Date coursesExpireDate){
+        courseScheduleService.updatePracticeGroupInDate(practiceGroupId, coursesStartDate,coursesExpireDate);
         return succeed();
     }
 

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

@@ -76,7 +76,7 @@ public class InspectionItemPlanConclusionController extends BaseController {
             String[] header2 = {"处理方式", planInfo.getMemo(), "", "", "", "", "", "", "", "", "", "", "", "", "", ""};
             String[] header3 = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""};
             String[] header4 = {"巡查项目", "课前管理", "", "", "", "", "课中管理", "", "", "", "", "", "", "课后管理", "", ""};
-            String[] header5 = {"", "老师是否提前准备板书(本课内容、作业)", "老师是否佩戴工牌", "老师是否仪容仪表整洁", "老师是否携带乐器", "老师是否携带教学资料、设备", "老师是否合理安排学员座位", "乐器箱包、书包是否摆放整齐", "课堂纪律是否保持良好", "老师是否全程站立教学", "老师是否全程使用节拍器或教学音频", "是否发现学员需要更换新乐器", "老师是否将上课照片/视频发送到声部群", "老师是否保持教室环境卫生", "老师是否关好所有电源、门窗", "老师是否有序组织学员放学"};
+            String[] header5 = {"", "老师是否提前准备板书(本课内容、作业)", "老师是否佩戴工牌", "老师是否仪容仪表整洁", "老师是否携带乐器", "老师是否携带教学资料、设备", "老师是否合理安排学员座位", "乐器箱包、书包是否摆放整齐", "课堂纪律是否保持良好", "老师是否全程站立教学", "老师是否全程使用节拍器或教学音频", "未发现私换乐器", "老师是否将上课照片/视频发送到声部群", "老师是否保持教室环境卫生", "老师是否关好所有电源、门窗", "老师是否有序组织学员放学"};
 
             List<String[]> headers = new LinkedList<>();
             headers.add(header);

+ 3 - 1
mec-web/src/main/java/com/ym/mec/web/controller/education/EduPracticeGroupController.java

@@ -165,8 +165,10 @@ public class EduPracticeGroupController extends BaseController {
         if(Objects.isNull(studentId)){
             throw new BizException("请指定学生");
         }
-        int studentExitChargePractices = practiceGroupDao.checkStudentExitChargePractice(studentId);
+        SysUser student = sysUserFeignService.queryUserById(studentId);
+        int studentExitChargePractices = practiceGroupDao.checkStudentExitChargePractice(studentId, "2021-03-09 00:00:00");
         Map<String, Integer> result=new HashMap<>();
+        result.put("organId", student.getOrganId());
         result.put("isNewStudent", studentExitChargePractices<=0?0:1);
         return succeed(result);
     }

+ 6 - 6
mec-web/src/main/java/com/ym/mec/web/controller/education/EduRepairController.java

@@ -106,12 +106,12 @@ public class EduRepairController extends BaseController {
         }
         repairInfo.setEmployeeId(sysUser.getId());
         repairInfo.setEmployeeName(sysUser.getRealName());
-        if(repairInfo.getSendType().equals(1)){
-            Employee employee = employeeDao.get(sysUser.getId());
-            if(StringUtils.isBlank(employee.getContactAddress())){
-                return failed("联系地址为空,请联系相关人员在\"员工管理\"完善");
-            }
-        }
+//        if(repairInfo.getSendType().equals(1)){
+//            Employee employee = employeeDao.get(sysUser.getId());
+//            if(StringUtils.isBlank(employee.getContactAddress())){
+//                return failed("联系地址为空,请联系相关人员在\"员工管理\"完善");
+//            }
+//        }
         return succeed(studentRepairService.addRepair(repairInfo));
     }