Sfoglia il codice sorgente

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

zouxuan 5 anni fa
parent
commit
4e7b3494c0
23 ha cambiato i file con 1217 aggiunte e 106 eliminazioni
  1. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupDao.java
  2. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java
  3. 13 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java
  4. 4 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/GroupDao.java
  5. 9 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/PracticeGroupDao.java
  6. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentAttendanceDao.java
  7. 28 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PracticeDrillTimeDto.java
  8. 56 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PracticeGroupBuyDto.java
  9. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseSchedule.java
  10. 31 0
      mec-biz/src/main/java/com/ym/mec/biz/service/GroupService.java
  11. 50 0
      mec-biz/src/main/java/com/ym/mec/biz/service/PracticeGroupService.java
  12. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/service/SysConfigService.java
  13. 55 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/GroupServiceImpl.java
  14. 825 95
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java
  15. 4 0
      mec-biz/src/main/resources/config/mybatis/ClassGroupMapper.xml
  16. 3 0
      mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml
  17. 18 7
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  18. 1 1
      mec-biz/src/main/resources/config/mybatis/CourseScheduleTeacherSalaryMapper.xml
  19. 14 0
      mec-biz/src/main/resources/config/mybatis/GroupMapper.xml
  20. 8 2
      mec-biz/src/main/resources/config/mybatis/PracticeGroupMapper.xml
  21. 4 0
      mec-biz/src/main/resources/config/mybatis/StudentAttendanceMapper.xml
  22. 20 0
      mec-student/src/main/java/com/ym/mec/student/controller/PracticeGroupController.java
  23. 19 0
      mec-util/src/main/java/com/ym/mec/util/date/DateUtil.java

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupDao.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.dal.dao;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.ClassGroup;
 import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
+import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.ImGroupModel;
@@ -616,4 +617,15 @@ public interface ClassGroupDao extends BaseDAO<Integer, ClassGroup> {
      * @return
      */
     List<Map<Integer, String>> findClassGroupSubjectNameMaps(@Param("courseScheduleIds") List<Long> courseScheduleIds);
+
+    /**
+     * @describe 根据团体删除班级
+     * @author Joburgess
+     * @date 2020/2/17
+     * @param groupId:
+     * @param groupType:
+     * @return int
+     */
+    int deleteByGroup(@Param("groupId") String groupId,
+                      @Param("groupType")GroupType groupType);
 }

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

@@ -60,6 +60,17 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
     void deleteByClassId(Integer classGroupId);
 
     /**
+     * @describe 根据团体删除班上的学生
+     * @author Joburgess
+     * @date 2020/2/17
+     * @param groupId:
+     * @param groupType:
+     * @return int
+     */
+    int deleteByGroup(@Param("groupId") String groupId,
+                      @Param("groupType") GroupType groupType);
+
+    /**
      * @return int
      * @Author: Joburgess
      * @Date: 2019/10/17

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

@@ -1150,4 +1150,17 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      */
     List<Map<Long, String>> queryTeacherName(@Param("courseScheduleIds") List<Long> courseScheduleIds);
 
+    /**
+     * @describe 更改团体下课程的冻结状态
+     * @author Joburgess
+     * @date 2020/2/17
+     * @param groupId:
+     * @param groupType:
+     * @param isLock: 冻结状态:1、冻结,0、正常
+     * @return int
+     */
+    int updateGroupCourseLock(@Param("groupId") String groupId,
+                              @Param("groupType") GroupType groupType,
+                              @Param("isLock") Integer isLock);
+
 }

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/GroupDao.java

@@ -12,6 +12,10 @@ import java.util.Map;
  */
 public interface GroupDao {
 
+
+    int deleteGroup(@Param("groupId") String groupId,
+                    @Param("groupType") String groupType);
+
     /**
      * @describe 搜索团体
      * @author Joburgess

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

@@ -2,7 +2,6 @@ package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.dto.PracticeGroupDto;
 import com.ym.mec.biz.dal.entity.PracticeGroup;
-import com.ym.mec.biz.dal.entity.VipGroup;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.Date;
@@ -60,4 +59,13 @@ public interface PracticeGroupDao extends com.ym.mec.common.dal.BaseDAO<Long, Pr
      * @param teacherId
      */
     void updateUserId(@Param("practiceGroupId") String practiceGroupId, @Param("teacherId") Integer teacherId);
+
+    /**
+     * @describe 获取学生最后一次购买的陪练课组
+     * @author Joburgess
+     * @date 2020/2/17
+     * @param userId: 学生编号
+     * @return com.ym.mec.biz.dal.entity.PracticeGroup
+     */
+    PracticeGroup findUserLatestPracticeGroup(@Param("userId") Integer userId);
 }

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentAttendanceDao.java

@@ -5,6 +5,7 @@ import com.ym.mec.biz.dal.dto.StudentAttendanceStatusCountDto;
 import com.ym.mec.biz.dal.dto.StudentPersonalAttendanceDto;
 import com.ym.mec.biz.dal.dto.StudentStatusCountUtilEntity;
 import com.ym.mec.biz.dal.entity.StudentAttendance;
+import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Param;
@@ -236,4 +237,15 @@ public interface StudentAttendanceDao extends BaseDAO<Long, StudentAttendance> {
      * @return
      */
     int countStudentAttendance(Map<String, Object> params);
+
+    /**
+     * @describe 根据团体删除数据
+     * @author Joburgess
+     * 020/2/17
+     * @param groupId:
+     * @param groupType:
+     * @return int
+     */
+    int deleteByGroup(@Param("groupId") String groupId,
+                      @Param("groupType")GroupType groupType);
 }

+ 28 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PracticeDrillTimeDto.java

@@ -0,0 +1,28 @@
+package com.ym.mec.biz.dal.dto;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/2/17
+ */
+public class PracticeDrillTimeDto {
+
+    private Integer weekNum;
+
+    private String timeStr;
+
+    public Integer getWeekNum() {
+        return weekNum;
+    }
+
+    public void setWeekNum(Integer weekNum) {
+        this.weekNum = weekNum;
+    }
+
+    public String getTimeStr() {
+        return timeStr;
+    }
+
+    public void setTimeStr(String timeStr) {
+        this.timeStr = timeStr;
+    }
+}

+ 56 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PracticeGroupBuyDto.java

@@ -0,0 +1,56 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.entity.PracticeGroup;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/2/17
+ */
+public class PracticeGroupBuyDto extends PracticeGroup {
+
+    @ApiModelProperty(value = "购买月数",required = true)
+    private Integer buyMonths;
+
+    @ApiModelProperty(value = "单周训练次数",required = true)
+    private Integer drillTimesOnWeek;
+
+    @ApiModelProperty(value = "是否使用账户余额支付")
+    private boolean useBalancePayment;
+
+    private List<PracticeDrillTimeDto> drillTimes;
+
+    public boolean isUseBalancePayment() {
+        return useBalancePayment;
+    }
+
+    public void setUseBalancePayment(boolean useBalancePayment) {
+        this.useBalancePayment = useBalancePayment;
+    }
+
+    public List<PracticeDrillTimeDto> getDrillTimes() {
+        return drillTimes;
+    }
+
+    public void setDrillTimes(List<PracticeDrillTimeDto> drillTimes) {
+        this.drillTimes = drillTimes;
+    }
+
+    public Integer getBuyMonths() {
+        return buyMonths;
+    }
+
+    public void setBuyMonths(Integer buyMonths) {
+        this.buyMonths = buyMonths;
+    }
+
+    public Integer getDrillTimesOnWeek() {
+        return drillTimesOnWeek;
+    }
+
+    public void setDrillTimesOnWeek(Integer drillTimesOnWeek) {
+        this.drillTimesOnWeek = drillTimesOnWeek;
+    }
+}

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

@@ -137,6 +137,16 @@ public class CourseSchedule {
 
 	private java.util.Date coursesExpireDate;
 
+	private Integer isLock;
+
+	public Integer getIsLock() {
+		return isLock;
+	}
+
+	public void setIsLock(Integer isLock) {
+		this.isLock = isLock;
+	}
+
 	public Date getCoursesExpireDate() {
 		return coursesExpireDate;
 	}

+ 31 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/GroupService.java

@@ -0,0 +1,31 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.enums.GroupType;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/2/17
+ **/
+public interface GroupService {
+
+    /**
+     * @describe 删除团体信息
+     * @author Joburgess
+     * @date 2020/2/17
+     * @param groupId: 团体编号
+     * @param groupType: 团体类型
+     * @return boolean
+     */
+    boolean deleteGroupInfo(String groupId, GroupType groupType);
+
+    /**
+     * @describe 清理团新相关信息
+     * @author Joburgess
+     * @date 2020/2/17
+     * @param groupId: 团体编号
+     * @param groupType: 团体类型
+     * @return boolean
+     */
+    boolean cleanGroupInfo(String groupId, GroupType groupType);
+
+}

+ 50 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/PracticeGroupService.java

@@ -1,10 +1,13 @@
 package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.dto.CourseScheduleDto;
+import com.ym.mec.biz.dal.dto.PracticeGroupBuyDto;
 import com.ym.mec.biz.dal.dto.PracticeGroupDto;
 import com.ym.mec.biz.dal.dto.SimpleUserDto;
 import com.ym.mec.biz.dal.entity.PracticeGroup;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.page.PracticeGroupQueryInfo;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
@@ -112,4 +115,51 @@ public interface PracticeGroupService extends BaseService<Long, PracticeGroup> {
 	 * @return
 	 */
 	Object findPracticeGroupCourseSchedules(PracticeGroupQueryInfo queryInfo);
+
+    /**
+     * @describe 获取陪练课预约参数——付费
+     * @author Joburgess
+     * @date 2020/1/31
+     * @param userId: 用户编号
+     * @return java.util.Map
+     */
+    Map getPayPracticeApplyParams(Integer userId);
+
+    /**
+     * @describe 获取指定教师的空闲时间——付费
+     * @author Joburgess
+     * @date 2020/2/10
+     * @param userId: 用户编号
+     * @param teacherId: 教师编号
+     * @param firstClassTime: 第一节课开始时间
+     * @param buyMonths: 购买月数
+     * @return java.util.Map
+     */
+    Map getPayPracticeTeacherFreeTimes(Integer userId, Integer teacherId, Integer buyMonths, Date firstClassTime);
+
+    /**
+     * @describe 获取一周内可以预约课程的时间——付费
+     * @author Joburgess
+     * @date 2020/2/2
+     * @return java.util.Map
+     */
+    Map<Integer, List<String>> getEnableApplyDatesWithWeek();
+
+    /**
+     * @describe 陪练课购买
+     * @author Joburgess
+     * @date 2020/2/17
+     * @param practiceGroupBuyParams: 购买参数
+     * @return void
+     */
+    HttpResponseResult buyPracticeGroup(PracticeGroupBuyDto practiceGroupBuyParams);
+
+    /**
+     * @describe 支付订单回调
+     * @author Joburgess
+     * @date 2020/2/17
+     * @param order: 支付订单
+     * @return void
+     */
+	void orderCallback(StudentPaymentOrder order);
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysConfigService.java

@@ -138,6 +138,16 @@ public interface SysConfigService extends BaseService<Long, SysConfig> {
     String ONLINE_CONTINUE_COURSE_TIME = "online_continue_course_time";
 
     /**
+     * @describe 付费陪练课可购买最大月数
+     */
+    String PRACTICE_PAY_MAX_MONTH = "practice_pay_max_month";
+
+    /**
+     * @describe 付费陪练课单月上课数量
+     */
+    String PRACTICE_PAY_DRILL_TIMES_ON_ONE_WEEK = "practice_pay_drill_times_on_one_week";
+
+    /**
      * @return com.ym.mec.biz.dal.entity.SysConfig
      * @params paramName
      * @describe 根据配置名称获取配置信息

+ 55 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GroupServiceImpl.java

@@ -0,0 +1,55 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.service.GroupService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/2/17
+ */
+@Service
+public class GroupServiceImpl implements GroupService {
+
+    @Autowired
+    private GroupDao groupDao;
+    @Autowired
+    private ClassGroupDao classGroupDao;
+    @Autowired
+    private ClassGroupTeacherMapperDao classGroupTeacherMapperDao;
+    @Autowired
+    private ClassGroupTeacherSalaryDao classGroupTeacherSalaryDao;
+    @Autowired
+    private ClassGroupStudentMapperDao classGroupStudentMapperDao;
+    @Autowired
+    private CourseScheduleDao courseScheduleDao;
+    @Autowired
+    private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
+    @Autowired
+    private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
+    @Autowired
+    private TeacherAttendanceDao teacherAttendanceDao;
+    @Autowired
+    private StudentAttendanceDao studentAttendanceDao;
+
+    @Override
+    public boolean deleteGroupInfo(String groupId, GroupType groupType) {
+        groupDao.deleteGroup(groupId,groupType.getCode());
+        classGroupDao.deleteByGroup(groupId,groupType);
+        classGroupStudentMapperDao.deleteByGroup(groupId,groupType);
+        courseScheduleDao.deleteCourseSchedulesByMusicGroupID(groupId,groupType);
+        courseScheduleTeacherSalaryDao.deleteByMusicGroupId(groupId,groupType);
+        courseScheduleStudentPaymentDao.deleteByMusicGroupId(groupId,groupType);
+        teacherAttendanceDao.deleteByMusicGroupId(groupId,groupType);
+        studentAttendanceDao.deleteByGroup(groupId,groupType);
+        return true;
+    }
+
+    @Override
+    public boolean cleanGroupInfo(String groupId, GroupType groupType) {
+
+        return false;
+    }
+}

+ 825 - 95
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -1,5 +1,7 @@
 package com.ym.mec.biz.service.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
@@ -8,15 +10,15 @@ import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.PracticeGroupQueryInfo;
-import com.ym.mec.biz.service.PracticeGroupService;
-import com.ym.mec.biz.service.SysConfigService;
-import com.ym.mec.biz.service.SysMessageService;
-import com.ym.mec.biz.service.TeacherService;
+import com.ym.mec.biz.service.*;
+import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.ImGroupMember;
 import com.ym.mec.common.entity.ImGroupModel;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.im.ImFeignService;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
@@ -24,6 +26,7 @@ import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
@@ -31,6 +34,9 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
+import java.time.*;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.WeekFields;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -79,6 +85,24 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
     private ImFeignService imFeignService;
     @Autowired
     private TeacherFreeTimeDao teacherFreeTimeDao;
+    @Autowired
+    private CourseScheduleService courseScheduleService;
+    @Autowired
+    private IdGeneratorService idGeneratorService;
+    @Autowired
+    private PayService payService;
+    @Autowired
+    private StudentPaymentOrderService studentPaymentOrderService;
+    @Autowired
+    private SysUserCashAccountService sysUserCashAccountService;
+    @Autowired
+    private SysUserCashAccountDetailService sysUserCashAccountDetailService;
+    @Autowired
+    private SysConfigDao sysConfigDao;
+    @Autowired
+    private StudentPaymentOrderDao studentPaymentOrderDao;
+    @Autowired
+    private GroupService groupService;
 
     private static Map<Integer, Map<Integer, List<Integer>>> schoolSubjectTeachersMap;
 
@@ -92,7 +116,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 
     private static Date activityStartDate, activityEndDate, applyStartDay, courseExpireDate;
 
-    private static List<String> applyDayTimes=new ArrayList<>();
+    private static List<String> applyDayTimes = new ArrayList<>();
 
     static {
         applyStartDay = DateUtil.stringToDate("2020-02-08 00:00:00");
@@ -735,28 +759,28 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 
         List<CourseSchedule> userCourses = courseScheduleDao.findUserCourses(userId, allTeacherIds);
 
-        if(!CollectionUtils.isEmpty(userCourses)){
+        if (!CollectionUtils.isEmpty(userCourses)) {
             Map<CourseSchedule.CourseScheduleType, List<CourseSchedule>> courseTypeCourseMap = userCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getType));
-            List<CourseSchedule> vipCourses=courseTypeCourseMap.get(CourseSchedule.CourseScheduleType.VIP);
-            if(!CollectionUtils.isEmpty(vipCourses)){
+            List<CourseSchedule> vipCourses = courseTypeCourseMap.get(CourseSchedule.CourseScheduleType.VIP);
+            if (!CollectionUtils.isEmpty(vipCourses)) {
                 for (CourseSchedule vipCourse : vipCourses) {
-                    if(!includeTeacherIds.contains(vipCourse.getTeacherId())){
+                    if (!includeTeacherIds.contains(vipCourse.getTeacherId())) {
                         includeTeacherIds.add(vipCourse.getTeacherId());
                     }
                 }
             }
-            List<CourseSchedule> singleCourses=courseTypeCourseMap.get(CourseSchedule.CourseScheduleType.SINGLE);
-            if(!CollectionUtils.isEmpty(singleCourses)){
+            List<CourseSchedule> singleCourses = courseTypeCourseMap.get(CourseSchedule.CourseScheduleType.SINGLE);
+            if (!CollectionUtils.isEmpty(singleCourses)) {
                 for (CourseSchedule singleCourse : singleCourses) {
-                    if(!includeTeacherIds.contains(singleCourse.getTeacherId())){
+                    if (!includeTeacherIds.contains(singleCourse.getTeacherId())) {
                         includeTeacherIds.add(singleCourse.getTeacherId());
                     }
                 }
             }
-            List<CourseSchedule> highCourses=courseTypeCourseMap.get(CourseSchedule.CourseScheduleType.HIGH);
-            if(!CollectionUtils.isEmpty(highCourses)){
+            List<CourseSchedule> highCourses = courseTypeCourseMap.get(CourseSchedule.CourseScheduleType.HIGH);
+            if (!CollectionUtils.isEmpty(highCourses)) {
                 for (CourseSchedule highCourse : highCourses) {
-                    if(!includeTeacherIds.contains(highCourse.getTeacherId())){
+                    if (!includeTeacherIds.contains(highCourse.getTeacherId())) {
                         includeTeacherIds.add(highCourse.getTeacherId());
                     }
                 }
@@ -765,7 +789,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 
         for (ExtendTeacherBasicDto organAndSubjectTeacher : organAndSubjectTeachers) {
             if (!includeTeacherIds.contains(organAndSubjectTeacher.getId())
-                &&1 == organAndSubjectTeacher.getIsSupportExtraPracticeLesson()) {
+                    && 1 == organAndSubjectTeacher.getIsSupportExtraPracticeLesson()) {
                 includeTeacherIds.add(organAndSubjectTeacher.getId());
             }
         }
@@ -774,11 +798,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             return new ArrayList<>();
         }
 
-        List<SimpleUserDto> userInfos=new ArrayList<>();
-        Map<Integer, ExtendTeacherBasicDto> idTeacherMap = organAndSubjectTeachers.stream().collect(Collectors.toMap(ExtendTeacherBasicDto::getId,teacher->teacher));
+        List<SimpleUserDto> userInfos = new ArrayList<>();
+        Map<Integer, ExtendTeacherBasicDto> idTeacherMap = organAndSubjectTeachers.stream().collect(Collectors.toMap(ExtendTeacherBasicDto::getId, teacher -> teacher));
         for (Integer includeTeacherId : includeTeacherIds) {
             ExtendTeacherBasicDto teacher = idTeacherMap.get(includeTeacherId);
-            userInfos.add(new SimpleUserDto(includeTeacherId,teacher.getRealName()));
+            userInfos.add(new SimpleUserDto(includeTeacherId, teacher.getRealName()));
         }
 
         return userInfos;
@@ -815,15 +839,37 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 
         Set<Integer> disableApplyWeekNum = new HashSet<>();
 
-        TeacherFreeTime teacherFreeTime=teacherFreeTimeDao.findTeacherFreeTime(teacherId);
-        Integer maxTeacherCourses=null;
-        int holiday=0;
-        if(Objects.nonNull(teacherFreeTime)){
-            if(Objects.nonNull(teacherFreeTime.getTotalTimes())){
-                maxTeacherCourses=teacherFreeTime.getTotalTimes();
+        TeacherFreeTime teacherFreeTime = teacherFreeTimeDao.findTeacherFreeTime(teacherId);
+        JSONObject teacherFreeTimes=new JSONObject();
+        Integer maxTeacherCourses = null;
+        int holiday = 0;
+        if (Objects.nonNull(teacherFreeTime)) {
+            if (Objects.nonNull(teacherFreeTime.getTotalTimes())) {
+                maxTeacherCourses = teacherFreeTime.getTotalTimes();
+            }
+            if (Objects.nonNull(teacherFreeTime.getHoliday())) {
+                holiday = DateUtil.normalWeekNumCalendarWeekNumMap.get(teacherFreeTime.getHoliday());
             }
-            if(Objects.nonNull(teacherFreeTime.getHoliday())){
-                holiday=DateUtil.normalWeekNumCalendarWeekNumMap.get(teacherFreeTime.getHoliday());
+            if(Objects.nonNull(teacherFreeTime.getMonday())){
+                teacherFreeTimes.put(String.valueOf(Calendar.MONDAY), JSON.parseArray(teacherFreeTime.getMonday()));
+            }
+            if(Objects.nonNull(teacherFreeTime.getMonday())){
+                teacherFreeTimes.put(String.valueOf(Calendar.TUESDAY), JSON.parseArray(teacherFreeTime.getTuesday()));
+            }
+            if(Objects.nonNull(teacherFreeTime.getMonday())){
+                teacherFreeTimes.put(String.valueOf(Calendar.WEDNESDAY), JSON.parseArray(teacherFreeTime.getWednesday()));
+            }
+            if(Objects.nonNull(teacherFreeTime.getMonday())){
+                teacherFreeTimes.put(String.valueOf(Calendar.THURSDAY), JSON.parseArray(teacherFreeTime.getThursday()));
+            }
+            if(Objects.nonNull(teacherFreeTime.getMonday())){
+                teacherFreeTimes.put(String.valueOf(Calendar.FRIDAY), JSON.parseArray(teacherFreeTime.getFriday()));
+            }
+            if(Objects.nonNull(teacherFreeTime.getMonday())){
+                teacherFreeTimes.put(String.valueOf(Calendar.SATURDAY), JSON.parseArray(teacherFreeTime.getSaturday()));
+            }
+            if(Objects.nonNull(teacherFreeTime.getMonday())){
+                teacherFreeTimes.put(String.valueOf(Calendar.SUNDAY), JSON.parseArray(teacherFreeTime.getSunday()));
             }
         }
 
@@ -841,15 +887,15 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         Date firstMonday = DateUtil.getWeekDayWithDate(applyStartDate, Calendar.MONDAY);
         Date secondSunday = DateUtil.getWeekDayWithDate(applyEndDate, Calendar.SUNDAY);
 
-        Date yesterday=null;
-        Date tomorrow=null;
-        if(Objects.nonNull(firstClassTime)){
-            Calendar tempCalendar=Calendar.getInstance();
+        Date yesterday = null;
+        Date tomorrow = null;
+        if (Objects.nonNull(firstClassTime)) {
+            Calendar tempCalendar = Calendar.getInstance();
             tempCalendar.setTime(firstClassTime);
-            tempCalendar.add(Calendar.DATE,-1);
-            yesterday=tempCalendar.getTime();
-            tempCalendar.add(Calendar.DATE,2);
-            tomorrow=tempCalendar.getTime();
+            tempCalendar.add(Calendar.DATE, -1);
+            yesterday = tempCalendar.getTime();
+            tempCalendar.add(Calendar.DATE, 2);
+            tomorrow = tempCalendar.getTime();
         }
 
         List<Date> enableApplyDates = getEnableApplyDates(applyStartDate, applyEndDate);
@@ -868,11 +914,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
                 applyDateRangeCourses.add(teacherCourse);
             }
             courseCalendar.setTime(teacherCourse.getClassDate());
-            if (i==0&&teacherCourse.getGroupType().equals(GroupType.PRACTICE)) {
-                practiceCourseNum+=1;
+            if (i == 0 && teacherCourse.getGroupType().equals(GroupType.PRACTICE)) {
+                practiceCourseNum += 1;
                 courseWeekNum = courseCalendar.get(Calendar.WEEK_OF_YEAR);
             }
-            if(Objects.nonNull(maxTeacherCourses)&&practiceCourseNum>=maxTeacherCourses){
+            if (Objects.nonNull(maxTeacherCourses) && practiceCourseNum >= maxTeacherCourses) {
                 disableApplyWeekNum.add(courseWeekNum);
             }
             if (courseCalendar.get(Calendar.WEEK_OF_YEAR) != courseWeekNum) {
@@ -880,7 +926,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
                 practiceCourseNum = 0;
             }
             if (teacherCourse.getGroupType().equals(GroupType.PRACTICE)) {
-                practiceCourseNum+=1;
+                practiceCourseNum += 1;
             }
         }
 
@@ -896,13 +942,13 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         if (CollectionUtils.isEmpty(applyDateRangeCourses)) {
             for (Date enableApplyDate : enableApplyDates) {
                 if (Objects.nonNull(firstClassTime)) {
-                    if(DateUtil.isSameDay(enableApplyDate, firstClassTime)){
+                    if (DateUtil.isSameDay(enableApplyDate, firstClassTime)) {
                         continue;
                     }
-                    if(DateUtil.isSameDay(enableApplyDate, tomorrow)){
+                    if (DateUtil.isSameDay(enableApplyDate, tomorrow)) {
                         continue;
                     }
-                    if(DateUtil.isSameDay(enableApplyDate, yesterday)){
+                    if (DateUtil.isSameDay(enableApplyDate, yesterday)) {
                         continue;
                     }
                 }
@@ -943,43 +989,63 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
                     }
                 }
                 calendar.setTime(enableApplyDate);
-                if (calendar.get(Calendar.DAY_OF_WEEK)!=holiday) {
+                int dayOfWeek=calendar.get(Calendar.DAY_OF_WEEK);
+                JSONArray teacherWeekDayFreeTimes = teacherFreeTimes.getJSONArray(String.valueOf(dayOfWeek));
+                if(Objects.nonNull(teacherWeekDayFreeTimes)){
+                    LocalTime enableApplyStartTime=LocalDateTime.ofInstant(enableApplyDate.toInstant(),DateUtil.zoneId).toLocalTime();
+                    LocalTime enableApplyEndTime=LocalDateTime.ofInstant(enableApplyDateCourseEndTime.toInstant(),DateUtil.zoneId).toLocalTime();
+                    boolean isInclude=false;
+                    for (Object teacherWeekDayFreeTimeObject : teacherWeekDayFreeTimes) {
+                        JSONObject teacherWeekDayFreeTime=JSONObject.parseObject(teacherWeekDayFreeTimeObject.toString());
+                        LocalTime teacherFreeStartTime=LocalTime.parse(teacherWeekDayFreeTime.getString("startTime"),DateUtil.timeFormatter);
+                        LocalTime teacherFreeEndTime=LocalTime.parse(teacherWeekDayFreeTime.getString("endTime"),DateUtil.timeFormatter);
+                        if(enableApplyStartTime.isBefore(teacherFreeEndTime)
+                            &&enableApplyEndTime.isAfter(teacherFreeStartTime)){
+                            isInclude=true;
+                            break;
+                        }
+                    }
+                    if(!isInclude){
+                        continue;
+                    }
+                }
+                if (dayOfWeek != holiday) {
                     allTeacherFreeDates.add(enableApplyDate);
                 }
             }
             if (!CollectionUtils.isEmpty(allTeacherFreeDates)) {
-                List<Date> tempDates=new ArrayList<>();
-                if(Objects.nonNull(firstClassTime)){
+                List<Date> tempDates = new ArrayList<>();
+                if (Objects.nonNull(firstClassTime)) {
                     calendar.setTime(firstClassTime);
                     calendar.add(Calendar.DATE, -6);
                     calendar.set(Calendar.HOUR_OF_DAY, 0);
                     calendar.set(Calendar.MINUTE, 0);
                     calendar.set(Calendar.SECOND, 0);
                     calendar.set(Calendar.MILLISECOND, 0);
-                    applyStartDate=calendar.getTime();
+                    applyStartDate = calendar.getTime();
                     calendar.setTime(firstClassTime);
                     calendar.add(Calendar.DATE, 7);
                     calendar.set(Calendar.HOUR_OF_DAY, 0);
                     calendar.set(Calendar.MINUTE, 0);
                     calendar.set(Calendar.SECOND, 0);
                     calendar.set(Calendar.MILLISECOND, 0);
-                    applyEndDate=calendar.getTime();
+                    applyEndDate = calendar.getTime();
                     for (Date teacherFreeDate : allTeacherFreeDates) {
-                        if(!teacherFreeDate.before(applyStartDate)
-                            &&!teacherFreeDate.after(applyEndDate)){
+                        if (!teacherFreeDate.before(applyStartDate)
+                                && !teacherFreeDate.after(applyEndDate)) {
                             tempDates.add(teacherFreeDate);
                         }
                     }
                 }
-                if(CollectionUtils.isEmpty(tempDates)){
-                    tempDates=new ArrayList<>(allTeacherFreeDates);
+                if (CollectionUtils.isEmpty(tempDates)) {
+                    tempDates = new ArrayList<>(allTeacherFreeDates);
                 }
                 tempDates.sort(Comparator.comparing(Date::getTime));
                 Set<String> days = tempDates.stream()
                         .map(date -> DateUtil.dateToString(date, "yyyy-MM-dd")).collect(Collectors.toSet());
-                List<Date> tempDays=days.stream().map(dateStr -> DateUtil.stringToDate(dateStr,"yyyy-MM-dd")).collect(Collectors.toList());
+                List<Date> tempDays = days.stream().map(dateStr -> DateUtil.stringToDate(dateStr, "yyyy-MM-dd")).collect(Collectors.toList());
                 tempDays.sort(Comparator.comparing(Date::getTime));
-                result.put("teacherFreeDays", tempDays.stream().map(day->DateUtil.dateToString(day, "yyyy-MM-dd")).collect(Collectors.toList()));
+                result.put("teacherFreeDays", tempDays.stream().map(day -> DateUtil.dateToString(day, "yyyy-MM-dd")).collect(Collectors.toList()));
                 result.put("teacherFreeDates", tempDates);
             } else {
                 result.put("teacherFreeDays", new ArrayList<>());
@@ -991,13 +1057,13 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         for (Date enableApplyDate : enableApplyDates) {
             Date enableApplyDateCourseEndTime = DateUtil.addMinutes(enableApplyDate, practiceCourseMinutes);
             if (Objects.nonNull(firstClassTime)) {
-                if(DateUtil.isSameDay(enableApplyDate, firstClassTime)){
+                if (DateUtil.isSameDay(enableApplyDate, firstClassTime)) {
                     continue;
                 }
-                if(DateUtil.isSameDay(enableApplyDate, tomorrow)){
+                if (DateUtil.isSameDay(enableApplyDate, tomorrow)) {
                     continue;
                 }
-                if(DateUtil.isSameDay(enableApplyDate, yesterday)){
+                if (DateUtil.isSameDay(enableApplyDate, yesterday)) {
                     continue;
                 }
             }
@@ -1039,7 +1105,28 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             }
             calendar.setTime(enableApplyDate);
 
-            if (calendar.get(Calendar.DAY_OF_WEEK)==holiday) {
+            int dayOfWeek=calendar.get(Calendar.DAY_OF_WEEK);
+            JSONArray teacherWeekDayFreeTimes = teacherFreeTimes.getJSONArray(String.valueOf(dayOfWeek));
+            if(Objects.nonNull(teacherWeekDayFreeTimes)){
+                LocalTime enableApplyStartTime=LocalDateTime.ofInstant(enableApplyDate.toInstant(),DateUtil.zoneId).toLocalTime();
+                LocalTime enableApplyEndTime=LocalDateTime.ofInstant(enableApplyDateCourseEndTime.toInstant(),DateUtil.zoneId).toLocalTime();
+                boolean isInclude=false;
+                for (Object teacherWeekDayFreeTimeObject : teacherWeekDayFreeTimes) {
+                    JSONObject teacherWeekDayFreeTime=JSONObject.parseObject(teacherWeekDayFreeTimeObject.toString());
+                    LocalTime teacherFreeStartTime=LocalTime.parse(teacherWeekDayFreeTime.getString("startTime"),DateUtil.timeFormatter);
+                    LocalTime teacherFreeEndTime=LocalTime.parse(teacherWeekDayFreeTime.getString("endTime"),DateUtil.timeFormatter);
+                    if(enableApplyStartTime.isBefore(teacherFreeEndTime)
+                            &&enableApplyEndTime.isAfter(teacherFreeStartTime)){
+                        isInclude=true;
+                        break;
+                    }
+                }
+                if(!isInclude){
+                    continue;
+                }
+            }
+
+            if (dayOfWeek == holiday) {
                 continue;
             }
 
@@ -1091,38 +1178,38 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             }
         }
         if (!CollectionUtils.isEmpty(allTeacherFreeDates)) {
-            List<Date> tempDates=new ArrayList<>();
-            if(Objects.nonNull(firstClassTime)){
+            List<Date> tempDates = new ArrayList<>();
+            if (Objects.nonNull(firstClassTime)) {
                 calendar.setTime(firstClassTime);
                 calendar.add(Calendar.DATE, -6);
                 calendar.set(Calendar.HOUR_OF_DAY, 0);
                 calendar.set(Calendar.MINUTE, 0);
                 calendar.set(Calendar.SECOND, 0);
                 calendar.set(Calendar.MILLISECOND, 0);
-                applyStartDate=calendar.getTime();
+                applyStartDate = calendar.getTime();
                 calendar.setTime(firstClassTime);
                 calendar.add(Calendar.DATE, 7);
                 calendar.set(Calendar.HOUR_OF_DAY, 0);
                 calendar.set(Calendar.MINUTE, 0);
                 calendar.set(Calendar.SECOND, 0);
                 calendar.set(Calendar.MILLISECOND, 0);
-                applyEndDate=calendar.getTime();
+                applyEndDate = calendar.getTime();
                 for (Date teacherFreeDate : allTeacherFreeDates) {
-                    if(!teacherFreeDate.before(applyStartDate)
-                            &&!teacherFreeDate.after(applyEndDate)){
+                    if (!teacherFreeDate.before(applyStartDate)
+                            && !teacherFreeDate.after(applyEndDate)) {
                         tempDates.add(teacherFreeDate);
                     }
                 }
             }
-            if(CollectionUtils.isEmpty(tempDates)){
-                tempDates=new ArrayList<>(allTeacherFreeDates);
+            if (CollectionUtils.isEmpty(tempDates)) {
+                tempDates = new ArrayList<>(allTeacherFreeDates);
             }
             tempDates.sort(Comparator.comparing(Date::getTime));
             Set<String> days = tempDates.stream()
                     .map(date -> DateUtil.dateToString(date, "yyyy-MM-dd")).collect(Collectors.toSet());
-            List<Date> tempDays=days.stream().map(dateStr -> DateUtil.stringToDate(dateStr,"yyyy-MM-dd")).collect(Collectors.toList());
+            List<Date> tempDays = days.stream().map(dateStr -> DateUtil.stringToDate(dateStr, "yyyy-MM-dd")).collect(Collectors.toList());
             tempDays.sort(Comparator.comparing(Date::getTime));
-            result.put("teacherFreeDays", tempDays.stream().map(day->DateUtil.dateToString(day, "yyyy-MM-dd")).collect(Collectors.toList()));
+            result.put("teacherFreeDays", tempDays.stream().map(day -> DateUtil.dateToString(day, "yyyy-MM-dd")).collect(Collectors.toList()));
             result.put("teacherFreeDates", tempDates);
         }
         return result;
@@ -1455,9 +1542,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             Calendar applyStartCalendar = Calendar.getInstance();
             applyStartCalendar.setTime(enableApplyDayStartTime);
             for (String applyDayTime : applyDayTimes) {
-                String temp=DateUtil.dateToString(applyStartCalendar.getTime(),"yyyy-MM-dd");
-                temp=temp+" "+applyDayTime;
-                result.add(DateUtil.stringToDate(temp,"yyyy-MM-dd HH:mm:ss"));
+                String temp = DateUtil.dateToString(applyStartCalendar.getTime(), "yyyy-MM-dd");
+                temp = temp + " " + applyDayTime;
+                result.add(DateUtil.stringToDate(temp, "yyyy-MM-dd HH:mm:ss"));
             }
         }
         return result;
@@ -1466,13 +1553,13 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
     @Override
     @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
     public Map practiceApply(PracticeGroup practiceGroup) {
-        if(Objects.isNull(practiceGroup.getUserId())){
+        if (Objects.isNull(practiceGroup.getUserId())) {
             throw new BizException("请选择老师");
         }
         Map result = new HashMap();
         SysConfig practiceSubjectIdListConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_SUBJECT_ID_LIST);
         if (Objects.isNull(practiceGroup.getSubjectId())
-                ||!Arrays.asList(practiceSubjectIdListConfig.getParanValue().split(",")).contains(practiceGroup.getSubjectId().toString())) {
+                || !Arrays.asList(practiceSubjectIdListConfig.getParanValue().split(",")).contains(practiceGroup.getSubjectId().toString())) {
             result.put("status", "DISABLE_SUBJECT");
             result.put("info", "预约失败,声部选择错误,请重试。");
             return result;
@@ -1548,13 +1635,13 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         practiceGroup.setCoursesStartDate(allCourseDates.get(0));
         practiceGroup.setCoursesExpireDate(courseExpireDate);
         Teacher teacher = teacherService.getDetail(practiceGroup.getUserId());
-        if(Objects.isNull(teacher)){
+        if (Objects.isNull(teacher)) {
             throw new BizException("老师不存在");
         }
 
         List<SimpleUserDto> enableApplyTeachers = getEnableApplyTeachers(practiceGroup.getStudentId(), practiceGroup.getSubjectId());
         Set<Integer> enableApplyTeacherIds = enableApplyTeachers.stream().map(SimpleUserDto::getUserId).collect(Collectors.toSet());
-        if(!enableApplyTeacherIds.contains(practiceGroup.getUserId())){
+        if (!enableApplyTeacherIds.contains(practiceGroup.getUserId())) {
             throw new BizException("预约失败,老师选择错误,请重试");
         }
 
@@ -1567,51 +1654,51 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             return result;
         }
 
-        TeacherFreeTime teacherFreeTime=teacherFreeTimeDao.findTeacherFreeTime(practiceGroup.getUserId());
-        Integer maxTeacherCourses=null;
-        if(Objects.nonNull(teacherFreeTime)){
-            if(Objects.nonNull(teacherFreeTime.getTotalTimes())){
-                maxTeacherCourses=teacherFreeTime.getTotalTimes();
+        TeacherFreeTime teacherFreeTime = teacherFreeTimeDao.findTeacherFreeTime(practiceGroup.getUserId());
+        Integer maxTeacherCourses = null;
+        if (Objects.nonNull(teacherFreeTime)) {
+            if (Objects.nonNull(teacherFreeTime.getTotalTimes())) {
+                maxTeacherCourses = teacherFreeTime.getTotalTimes();
             }
         }
 
         Date monday1 = DateUtil.getWeekDayWithDate(allCourseDates.get(0), Calendar.MONDAY);
         Date sunday1 = DateUtil.getWeekDayWithDate(allCourseDates.get(0), Calendar.SUNDAY);
         int tp1 = courseScheduleDao.countTeacherPracticeCourse(practiceGroup.getUserId(), monday1, sunday1);
-        if(Objects.nonNull(maxTeacherCourses)&&tp1>=maxTeacherCourses){
+        if (Objects.nonNull(maxTeacherCourses) && tp1 >= maxTeacherCourses) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             result.put("status", "TEACHER_PRACTICE_REPEAT");
-            result.put("info", "抱歉啦,当前所选时段组合,「" + teacher.getRealName() +"」老师已被预约,请重新选择时段或更换老师后重试。");
+            result.put("info", "抱歉啦,当前所选时段组合,「" + teacher.getRealName() + "」老师已被预约,请重新选择时段或更换老师后重试。");
             return result;
         }
 
         Date monday2 = DateUtil.getWeekDayWithDate(allCourseDates.get(1), Calendar.MONDAY);
         Date sunday2 = DateUtil.getWeekDayWithDate(allCourseDates.get(1), Calendar.SUNDAY);
         int tp2 = courseScheduleDao.countTeacherPracticeCourse(practiceGroup.getUserId(), monday2, sunday2);
-        if(Objects.nonNull(maxTeacherCourses)&&tp2>=maxTeacherCourses){
+        if (Objects.nonNull(maxTeacherCourses) && tp2 >= maxTeacherCourses) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             result.put("status", "TEACHER_PRACTICE_REPEAT");
-            result.put("info", "抱歉啦,当前所选时段组合,「" + teacher.getRealName() +"」老师已被预约,请重新选择时段或更换老师后重试。");
+            result.put("info", "抱歉啦,当前所选时段组合,「" + teacher.getRealName() + "」老师已被预约,请重新选择时段或更换老师后重试。");
             return result;
         }
 
         Date monday3 = DateUtil.getWeekDayWithDate(allCourseDates.get(2), Calendar.MONDAY);
         Date sunday3 = DateUtil.getWeekDayWithDate(allCourseDates.get(2), Calendar.SUNDAY);
         int tp3 = courseScheduleDao.countTeacherPracticeCourse(practiceGroup.getUserId(), monday3, sunday3);
-        if(Objects.nonNull(maxTeacherCourses)&&tp3>=maxTeacherCourses){
+        if (Objects.nonNull(maxTeacherCourses) && tp3 >= maxTeacherCourses) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             result.put("status", "TEACHER_PRACTICE_REPEAT");
-            result.put("info", "抱歉啦,当前所选时段组合,「" + teacher.getRealName() +"」老师已被预约,请重新选择时段或更换老师后重试。");
+            result.put("info", "抱歉啦,当前所选时段组合,「" + teacher.getRealName() + "」老师已被预约,请重新选择时段或更换老师后重试。");
             return result;
         }
 
         Date monday4 = DateUtil.getWeekDayWithDate(allCourseDates.get(3), Calendar.MONDAY);
         Date sunday4 = DateUtil.getWeekDayWithDate(allCourseDates.get(3), Calendar.SUNDAY);
         int tp4 = courseScheduleDao.countTeacherPracticeCourse(practiceGroup.getUserId(), monday4, sunday4);
-        if(Objects.nonNull(maxTeacherCourses)&&tp4>=maxTeacherCourses){
+        if (Objects.nonNull(maxTeacherCourses) && tp4 >= maxTeacherCourses) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             result.put("status", "TEACHER_PRACTICE_REPEAT");
-            result.put("info", "抱歉啦,当前所选时段组合,「" + teacher.getRealName() +"」老师已被预约,请重新选择时段或更换老师后重试。");
+            result.put("info", "抱歉啦,当前所选时段组合,「" + teacher.getRealName() + "」老师已被预约,请重新选择时段或更换老师后重试。");
             return result;
         }
 
@@ -1621,7 +1708,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         List<CourseSchedule> courseSchedules9 = courseScheduleDao.findTeacherCoursesWithIncludeDateRange(practiceGroup.getUserId(), allCourseDates.get(3), DateUtil.addMinutes(allCourseDates.get(3), practiceCourseMinutes));
 
         if (!CollectionUtils.isEmpty(courseSchedules6) || !CollectionUtils.isEmpty(courseSchedules7)
-                ||!CollectionUtils.isEmpty(courseSchedules8) || !CollectionUtils.isEmpty(courseSchedules9)) {
+                || !CollectionUtils.isEmpty(courseSchedules8) || !CollectionUtils.isEmpty(courseSchedules9)) {
             if (courseSchedules6 == null) {
                 courseSchedules6 = new ArrayList<>();
             }
@@ -1641,7 +1728,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
                 if (courseSchedules6.get(i).getGroupType().equals(GroupType.PRACTICE)) {
                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                     result.put("status", "TEACHER_PRACTICE_REPEAT");
-                    result.put("info", "抱歉啦,当前所选时段组合,「" + teacher.getRealName() +"」老师已被预约,请选择其他时段或更换老师后重试。");
+                    result.put("info", "抱歉啦,当前所选时段组合,「" + teacher.getRealName() + "」老师已被预约,请选择其他时段或更换老师后重试。");
                     return result;
                 }
             }
@@ -1785,28 +1872,28 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         if (!CollectionUtils.isEmpty(studentRepeatCourse1)) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             result.put("status", "STUDENT_COURSE_REPEAT");
-            result.put("info", "抱歉啦,当前所选时段组合,与您现有课程「"+studentRepeatCourse1.get(0).getName()+"」时段冲突,请选择其他时段重试。");
+            result.put("info", "抱歉啦,当前所选时段组合,与您现有课程「" + studentRepeatCourse1.get(0).getName() + "」时段冲突,请选择其他时段重试。");
             return result;
         }
         List<CourseSchedule> studentRepeatCourse2 = courseScheduleDao.findStudentCoursesWithIncludeDateRange(practiceGroup.getStudentId(), allCourseDates.get(1), DateUtil.addMinutes(allCourseDates.get(1), practiceCourseMinutes));
         if (!CollectionUtils.isEmpty(studentRepeatCourse2)) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             result.put("status", "STUDENT_COURSE_REPEAT");
-            result.put("info", "抱歉啦,当前所选时段组合,与您现有课程「"+studentRepeatCourse2.get(0).getName()+"」时段冲突,请选择其他时段重试。");
+            result.put("info", "抱歉啦,当前所选时段组合,与您现有课程「" + studentRepeatCourse2.get(0).getName() + "」时段冲突,请选择其他时段重试。");
             return result;
         }
         List<CourseSchedule> studentRepeatCourse3 = courseScheduleDao.findStudentCoursesWithIncludeDateRange(practiceGroup.getStudentId(), allCourseDates.get(2), DateUtil.addMinutes(allCourseDates.get(2), practiceCourseMinutes));
         if (!CollectionUtils.isEmpty(studentRepeatCourse3)) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             result.put("status", "STUDENT_COURSE_REPEAT");
-            result.put("info", "抱歉啦,当前所选时段组合,与您现有课程「"+studentRepeatCourse3.get(0).getName()+"」时段冲突,请选择其他时段重试。");
+            result.put("info", "抱歉啦,当前所选时段组合,与您现有课程「" + studentRepeatCourse3.get(0).getName() + "」时段冲突,请选择其他时段重试。");
             return result;
         }
         List<CourseSchedule> studentRepeatCourse4 = courseScheduleDao.findStudentCoursesWithIncludeDateRange(practiceGroup.getStudentId(), allCourseDates.get(3), DateUtil.addMinutes(allCourseDates.get(3), practiceCourseMinutes));
         if (!CollectionUtils.isEmpty(studentRepeatCourse4)) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             result.put("status", "STUDENT_COURSE_REPEAT");
-            result.put("info", "抱歉啦,当前所选时段组合,与您现有课程「"+studentRepeatCourse4.get(0).getName()+"」时段冲突,请选择其他时段重试。");
+            result.put("info", "抱歉啦,当前所选时段组合,与您现有课程「" + studentRepeatCourse4.get(0).getName() + "」时段冲突,请选择其他时段重试。");
             return result;
         }
         courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
@@ -1817,7 +1904,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         List<CourseSchedule> courseSchedules3 = courseScheduleDao.findTeacherCoursesWithIncludeDateRange(practiceGroup.getUserId(), allCourseDates.get(2), DateUtil.addMinutes(allCourseDates.get(2), practiceCourseMinutes));
         List<CourseSchedule> courseSchedules5 = courseScheduleDao.findTeacherCoursesWithIncludeDateRange(practiceGroup.getUserId(), allCourseDates.get(3), DateUtil.addMinutes(allCourseDates.get(3), practiceCourseMinutes));
         if (!CollectionUtils.isEmpty(courseSchedules1) || !CollectionUtils.isEmpty(courseSchedules2)
-                ||!CollectionUtils.isEmpty(courseSchedules3) || !CollectionUtils.isEmpty(courseSchedules5)) {
+                || !CollectionUtils.isEmpty(courseSchedules3) || !CollectionUtils.isEmpty(courseSchedules5)) {
             if (courseSchedules1 == null) {
                 courseSchedules1 = new ArrayList<>();
             }
@@ -1842,7 +1929,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
                     } else {
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                         result.put("status", "TEACHER_PRACTICE_REPEAT");
-                        result.put("info", "抱歉啦,当前所选时段组合,「" + teacher.getRealName() +"」老师已被预约,请选择其他时段或更换老师后重试。");
+                        result.put("info", "抱歉啦,当前所选时段组合,「" + teacher.getRealName() + "」老师已被预约,请选择其他时段或更换老师后重试。");
                         return result;
                     }
                 }
@@ -1963,4 +2050,647 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         return result;
     }
 
+
+    @Override
+    public Map getPayPracticeApplyParams(Integer userId) {
+        Map result = new HashMap();
+        SysConfig practiceSubjectIdListConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_SUBJECT_ID_LIST);
+        SysConfig practiceApplyStartTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_START_TIME);
+        SysConfig practiceApplyEndTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_END_TIME);
+        SysConfig practiceApplyIntervalTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_INTERVAL_TIME);
+        SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
+        SysConfig practicePayMaxMonthConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_PAY_MAX_MONTH);
+        SysConfig practicePayDrillTimesOnOneWeekConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_PAY_DRILL_TIMES_ON_ONE_WEEK);
+        Student student = studentDao.get(userId);
+        List<Subject> subjects = subjectDao.findBySubjectByIdList(practiceSubjectIdListConfig.getParanValue());
+        List<Integer> subjectIds = Arrays.asList(practiceSubjectIdListConfig.getParanValue().split(",")).stream().mapToInt(idStr -> Integer.valueOf(idStr)).boxed().collect(Collectors.toList());
+        List<Integer> userDefaultSubjectIds = Objects.isNull(student) || Objects.isNull(student.getSubjectIdList()) ? null : Arrays.asList(student.getSubjectIdList().split(",")).stream().mapToInt(idStr -> Integer.valueOf(idStr)).boxed().collect(Collectors.toList());
+        if (!CollectionUtils.isEmpty(userDefaultSubjectIds)) {
+            userDefaultSubjectIds = userDefaultSubjectIds.stream().filter(userDefaultSubjectId -> subjectIds.contains(userDefaultSubjectId)).collect(Collectors.toList());
+        } else {
+            userDefaultSubjectIds = new ArrayList<>();
+        }
+
+        result.put("subjects", subjects);
+        result.put("practiceApplyStartTime", practiceApplyStartTimeConfig.getParanValue());
+        result.put("practiceApplyEndTime", practiceApplyEndTimeConfig.getParanValue());
+        result.put("userDefaultSubjectIds", StringUtils.join(userDefaultSubjectIds.toArray(), ","));
+        result.put("practiceApplyIntervalMinutes", practiceApplyIntervalTimeConfig.getParanValue(Integer.class));
+        result.put("practiceCourseMinutes", practiceCourseMinutesConfig.getParanValue(Integer.class));
+        result.put("practicePayMaxMonth", practicePayMaxMonthConfig.getParanValue(Integer.class));
+        result.put("practicePayDrillTimesOnOneWeek", practicePayDrillTimesOnOneWeekConfig.getParanValue(Integer.class));
+        return result;
+    }
+
+
+    @Override
+    public Map<Integer, List<String>> getEnableApplyDatesWithWeek() {
+        Map<Integer, List<String>> result = new HashMap<>();
+        for (int i = 1; i <= 7; i++) {
+            List<String> tempTimes = new ArrayList<>();
+            for (String applyDayTime : applyDayTimes) {
+                tempTimes.add(applyDayTime);
+            }
+            result.put(i, tempTimes);
+        }
+        return result;
+    }
+
+    @Override
+    public Map getPayPracticeTeacherFreeTimes(Integer userId, Integer teacherId, Integer buyMonths, Date firstClassTime) {
+        if (Objects.isNull(teacherId)) {
+            throw new BizException("请选择教师");
+        }
+        SysUser student = sysUserFeignService.queryUserById(userId);
+        if (Objects.isNull(student)) {
+            throw new BizException("用户不存在");
+        }
+        if (Objects.isNull(student.getOrganId())) {
+            throw new BizException("未找到用户分部属性");
+        }
+        Teacher teacher = teacherDao.get(teacherId);
+        if (Objects.isNull(teacher)) {
+            throw new BizException("教师不存在");
+        }
+        Map result = new HashMap();
+
+        SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
+        Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
+
+        boolean checkTeacherLeaveDate = true;
+        SysConfig allTeacherLeaveDataConfig = sysConfigService.findByParamName(SysConfigService.TEACHER_LEAVE_DATA);
+        JSONObject allTeacherLeaveData = JSONObject.parseObject(allTeacherLeaveDataConfig.getParanValue());
+        if (Objects.isNull(allTeacherLeaveData)) {
+            checkTeacherLeaveDate = false;
+        }
+
+        TeacherFreeTime teacherFreeTime = teacherFreeTimeDao.findTeacherFreeTime(teacherId);
+        JSONObject teacherFreeTimes=new JSONObject();
+        Integer maxTeacherCourses = null;
+        int holiday = 0;
+        if (Objects.nonNull(teacherFreeTime)) {
+            if (Objects.nonNull(teacherFreeTime.getTotalTimes())) {
+                maxTeacherCourses = teacherFreeTime.getTotalTimes();
+            }
+            if (Objects.nonNull(teacherFreeTime.getHoliday())) {
+                holiday = teacherFreeTime.getHoliday();
+            }
+            if (Objects.nonNull(teacherFreeTime.getHoliday())) {
+                holiday = DateUtil.normalWeekNumCalendarWeekNumMap.get(teacherFreeTime.getHoliday());
+            }
+            if(Objects.nonNull(teacherFreeTime.getMonday())){
+                teacherFreeTimes.put(String.valueOf(Calendar.MONDAY), JSON.parseArray(teacherFreeTime.getMonday()));
+            }
+            if(Objects.nonNull(teacherFreeTime.getMonday())){
+                teacherFreeTimes.put(String.valueOf(Calendar.TUESDAY), JSON.parseArray(teacherFreeTime.getTuesday()));
+            }
+            if(Objects.nonNull(teacherFreeTime.getMonday())){
+                teacherFreeTimes.put(String.valueOf(Calendar.WEDNESDAY), JSON.parseArray(teacherFreeTime.getWednesday()));
+            }
+            if(Objects.nonNull(teacherFreeTime.getMonday())){
+                teacherFreeTimes.put(String.valueOf(Calendar.THURSDAY), JSON.parseArray(teacherFreeTime.getThursday()));
+            }
+            if(Objects.nonNull(teacherFreeTime.getMonday())){
+                teacherFreeTimes.put(String.valueOf(Calendar.FRIDAY), JSON.parseArray(teacherFreeTime.getFriday()));
+            }
+            if(Objects.nonNull(teacherFreeTime.getMonday())){
+                teacherFreeTimes.put(String.valueOf(Calendar.SATURDAY), JSON.parseArray(teacherFreeTime.getSaturday()));
+            }
+            if(Objects.nonNull(teacherFreeTime.getMonday())){
+                teacherFreeTimes.put(String.valueOf(Calendar.SUNDAY), JSON.parseArray(teacherFreeTime.getSunday()));
+            }
+        }
+
+        DateTimeFormatter ddtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        DateTimeFormatter ddf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HH:mm:ss");
+        WeekFields weekFields = WeekFields.of(DayOfWeek.MONDAY, 1);
+        ZoneId zoneId = ZoneId.systemDefault();
+
+        LocalDateTime now = LocalDateTime.now();
+        now.plusDays(1);
+        Date applyStartDate = Date.from(now.atZone(zoneId).toInstant());
+        now.plusMonths(buyMonths);
+        Date applyEndDate = Date.from(now.atZone(zoneId).toInstant());
+        Date firstMonday = DateUtil.getWeekDayWithDate(applyStartDate, Calendar.MONDAY);
+        Date secondSunday = DateUtil.getWeekDayWithDate(applyEndDate, Calendar.SUNDAY);
+
+        Map<Integer, List<String>> weekNumApplyTimesMap = getEnableApplyDatesWithWeek();
+        List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeacherCoursesWithDateRange(teacherId, firstMonday, secondSunday);
+        allTeacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
+
+        JSONObject teacherLeaveData = null;
+        if (checkTeacherLeaveDate) {
+            teacherLeaveData = allTeacherLeaveData.getJSONObject(teacherId.toString());
+        }
+
+        if (Objects.isNull(teacherLeaveData)) {
+            checkTeacherLeaveDate = false;
+        }
+
+        if (Objects.nonNull(firstClassTime)) {
+            LocalDateTime localFirstClassTime = LocalDateTime.ofInstant(firstClassTime.toInstant(), zoneId);
+            weekNumApplyTimesMap.remove(localFirstClassTime.getDayOfWeek().getValue());
+        }
+        weekNumApplyTimesMap.remove(holiday);
+
+        if (teacherId == 100473) {
+            List<String> timeStrs = weekNumApplyTimesMap.get(DateUtil.calendarWeekNumNormalWeekNumMap.get(Calendar.MONDAY));
+            LocalTime noonStartTime = LocalTime.parse("11:30:00", dtf);
+            LocalTime noonEndTime = LocalTime.parse("14:30:00", dtf);
+            LocalTime nightStartTime = LocalTime.parse("20:30:00", dtf);
+            LocalTime defaultApplyTime;
+            Iterator<String> iterator = timeStrs.iterator();
+            while (iterator.hasNext()) {
+                defaultApplyTime = LocalTime.parse(iterator.next(), dtf);
+                LocalTime defaultApplyEndTime = defaultApplyTime.plusMinutes(practiceCourseMinutes);
+                if (defaultApplyTime.compareTo(noonStartTime) <= 0
+                        && defaultApplyEndTime.compareTo(noonEndTime) >= 0) {
+                    iterator.remove();
+                    continue;
+                }
+                if (defaultApplyEndTime.compareTo(nightStartTime) < 0) {
+                    iterator.remove();
+                    continue;
+                }
+            }
+            weekNumApplyTimesMap.remove(DateUtil.calendarWeekNumNormalWeekNumMap.get(Calendar.SATURDAY));
+            weekNumApplyTimesMap.put(DateUtil.calendarWeekNumNormalWeekNumMap.get(Calendar.MONDAY), timeStrs);
+            weekNumApplyTimesMap.put(DateUtil.calendarWeekNumNormalWeekNumMap.get(Calendar.SUNDAY), timeStrs);
+        } else if (checkTeacherLeaveDate) {
+            for (String dateStr : teacherLeaveData.keySet()) {
+                LocalDate parse = LocalDate.parse(dateStr, ddf);
+                List<String> applyTimeStrs = weekNumApplyTimesMap.get(parse.getDayOfWeek().getValue());
+                Iterator<String> iterator = applyTimeStrs.iterator();
+                JSONObject leaveDateData = teacherLeaveData.getJSONObject(dateStr);
+                LocalTime leaveStartTime = LocalDateTime.parse(leaveDateData.getString("leave_start_time"), ddtf).toLocalTime();
+                LocalTime leaveEndTime = LocalDateTime.parse(leaveDateData.getString("leave_end_time"), ddtf).toLocalTime();
+                LocalTime defaultApplyTime;
+                while (iterator.hasNext()) {
+                    defaultApplyTime = LocalTime.parse(iterator.next(), dtf);
+                    LocalTime defaultApplyEndTime = defaultApplyTime.plusMinutes(practiceCourseMinutes);
+                    if (defaultApplyTime.compareTo(leaveStartTime) <= 0
+                            && defaultApplyEndTime.compareTo(leaveEndTime) >= 0) {
+                        iterator.remove();
+                        continue;
+                    }
+                }
+                weekNumApplyTimesMap.put(parse.getDayOfWeek().getValue(), applyTimeStrs);
+            }
+        }
+
+        for (Integer weekNum : weekNumApplyTimesMap.keySet()) {
+            JSONArray teacherWeekDayFreeTimes = teacherFreeTimes.getJSONArray(String.valueOf(weekNum));
+            if(Objects.nonNull(teacherWeekDayFreeTimes)){
+                List<String> applyTimeStrs = weekNumApplyTimesMap.get(weekNum);
+                Iterator<String> iterator = applyTimeStrs.iterator();
+                while (iterator.hasNext()) {
+                    LocalTime enableApplyStartTime=LocalTime.parse(iterator.next(), dtf);
+                    LocalTime enableApplyEndTime=enableApplyStartTime.plusMinutes(practiceCourseMinutes);
+                    boolean isInclude=false;
+                    for (Object teacherWeekDayFreeTimeObject : teacherWeekDayFreeTimes) {
+                        JSONObject teacherWeekDayFreeTime=JSONObject.parseObject(teacherWeekDayFreeTimeObject.toString());
+                        LocalTime teacherFreeStartTime=LocalTime.parse(teacherWeekDayFreeTime.getString("startTime"),DateUtil.timeFormatter);
+                        LocalTime teacherFreeEndTime=LocalTime.parse(teacherWeekDayFreeTime.getString("endTime"),DateUtil.timeFormatter);
+                        if(enableApplyStartTime.isBefore(teacherFreeEndTime)
+                                &&enableApplyEndTime.isAfter(teacherFreeStartTime)){
+                            isInclude=true;
+                            break;
+                        }
+                    }
+                    if(!isInclude){
+                        iterator.remove();
+                    }
+                }
+                weekNumApplyTimesMap.put(weekNum,applyTimeStrs);
+            }
+        }
+
+        if (CollectionUtils.isEmpty(allTeacherCourses)) {
+            result.put("teacherFreeDays", weekNumApplyTimesMap);
+            return result;
+        }
+
+        int courseWeekNum = 0;
+        int practiceCourseNum = 0;
+        boolean hasDisableWeek = false;
+        LocalDateTime tempClassDateTime;
+        for (int i = 0; i < allTeacherCourses.size(); i++) {
+            CourseSchedule teacherCourse = allTeacherCourses.get(i);
+            tempClassDateTime = LocalDateTime.ofInstant(teacherCourse.getClassDate().toInstant(), zoneId);
+            if (i == 0 && teacherCourse.getGroupType().equals(GroupType.PRACTICE)) {
+                practiceCourseNum += 1;
+                courseWeekNum = tempClassDateTime.get(weekFields.weekOfYear());
+            }
+            if (Objects.nonNull(maxTeacherCourses) && practiceCourseNum >= maxTeacherCourses) {
+                hasDisableWeek = true;
+                break;
+            }
+            if (tempClassDateTime.get(weekFields.weekOfYear()) != courseWeekNum) {
+                courseWeekNum = tempClassDateTime.get(weekFields.weekOfYear());
+                practiceCourseNum = 0;
+            }
+            if (teacherCourse.getGroupType().equals(GroupType.PRACTICE)) {
+                practiceCourseNum += 1;
+            }
+        }
+
+        if (hasDisableWeek) {
+            result.put("teacherFreeDays", new HashMap<>());
+            return result;
+        }
+
+        for (CourseSchedule teacherCourse : allTeacherCourses) {
+            LocalDateTime courseStartTime = LocalDateTime.ofInstant(teacherCourse.getStartClassTime().toInstant(), zoneId);
+            LocalDateTime courseEndTime = LocalDateTime.ofInstant(teacherCourse.getEndClassTime().toInstant(), zoneId);
+            List<String> applyTimeStrs = weekNumApplyTimesMap.get(courseStartTime.getDayOfWeek().getValue());
+            if (CollectionUtils.isEmpty(applyTimeStrs)) {
+                continue;
+            }
+            Iterator<String> iterator = applyTimeStrs.iterator();
+            LocalTime defaultApplyTime;
+            while (iterator.hasNext()) {
+                defaultApplyTime = LocalTime.parse(iterator.next(), dtf);
+                LocalTime defaultApplyEndTime = defaultApplyTime.plusMinutes(practiceCourseMinutes);
+                if (defaultApplyTime.compareTo(courseEndTime.toLocalTime()) <= 0
+                        && defaultApplyEndTime.compareTo(courseStartTime.toLocalTime()) >= 0) {
+                    iterator.remove();
+                    continue;
+                }
+            }
+            weekNumApplyTimesMap.put(courseStartTime.getDayOfWeek().getValue(), applyTimeStrs);
+        }
+        result.put("teacherFreeDays", weekNumApplyTimesMap);
+        return result;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
+    public HttpResponseResult buyPracticeGroup(PracticeGroupBuyDto practiceGroupBuyParams) {
+        if (Objects.isNull(practiceGroupBuyParams.getUserId())) {
+            return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "请选择教师");
+        }
+        if (Objects.isNull(practiceGroupBuyParams.getSubjectId())) {
+            return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "请选择声部");
+        }
+        if (Objects.isNull(practiceGroupBuyParams.getBuyMonths())) {
+            return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "请选择需要购买的月数");
+        }
+        if (Objects.isNull(practiceGroupBuyParams.getDrillTimesOnWeek())) {
+            return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "请选择单周陪练次数");
+        }
+        if (CollectionUtils.isEmpty(practiceGroupBuyParams.getDrillTimes())) {
+            return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "请选择训练时间");
+        }
+        if (practiceGroupBuyParams.getDrillTimesOnWeek() != practiceGroupBuyParams.getDrillTimes().size()) {
+            return BaseController.failed(HttpStatus.EXPECTATION_FAILED,"训练时间与陪练次数不匹配");
+        }
+
+        SysUser sysUser = sysUserFeignService.queryUserById(practiceGroupBuyParams.getStudentId());
+
+        Subject subject = subjectDao.get(practiceGroupBuyParams.getSubjectId());
+        if (Objects.isNull(subject)) {
+            return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "预约失败,声部选择错误,请重试。");
+        }
+
+        Teacher teacher = teacherService.getDetail(practiceGroupBuyParams.getUserId());
+        if (Objects.isNull(teacher)) {
+            throw new BizException("老师不存在");
+        }
+
+        SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
+        Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
+        SysConfig practiceCourseSalaryConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_SALARY);
+
+        Date now=new Date();
+        PracticeGroup userLatestPracticeGroup = practiceGroupDao.findUserLatestPracticeGroup(practiceGroupBuyParams.getUserId());
+        LocalDate courseStartDay=LocalDate.now();
+        if(Objects.nonNull(userLatestPracticeGroup)){
+            LocalDate lastExpiredDay=LocalDateTime.ofInstant(userLatestPracticeGroup.getCoursesExpireDate().toInstant(),DateUtil.zoneId).toLocalDate();
+            if(Objects.nonNull(lastExpiredDay)&&lastExpiredDay.compareTo(courseStartDay)>=0){
+                courseStartDay=lastExpiredDay;
+            }
+        }
+        courseStartDay=courseStartDay.plusDays(1);
+        Date courseStartDate=Date.from(courseStartDay.atStartOfDay(DateUtil.zoneId).toInstant());
+        practiceGroupBuyParams.setCoursesStartDate(courseStartDate);
+        LocalDate currentExpiredDay = courseStartDay.plusMonths(practiceGroupBuyParams.getBuyMonths());
+        Date courseExpiredDate=Date.from(currentExpiredDay.atStartOfDay(DateUtil.zoneId).toInstant());
+        practiceGroupBuyParams.setCoursesStartDate(courseExpiredDate);
+
+        LocalDate courseStartMonday=courseStartDay.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
+        LocalDate courseExpiredSunday=currentExpiredDay.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.SUNDAY.getValue());
+        Date courseStartMondayDate = Date.from(courseStartMonday.atStartOfDay(DateUtil.zoneId).toInstant());
+        Date courseExpiredSundayDate = Date.from(courseExpiredSunday.atStartOfDay(DateUtil.zoneId).toInstant());
+
+        List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeacherCoursesWithDateRange(practiceGroupBuyParams.getUserId(), courseStartMondayDate, courseExpiredSundayDate);
+
+        TeacherFreeTime teacherFreeTime = teacherFreeTimeDao.findTeacherFreeTime(practiceGroupBuyParams.getUserId());
+        Integer maxTeacherCourses = null;
+        if (Objects.nonNull(teacherFreeTime)) {
+            if (Objects.nonNull(teacherFreeTime.getTotalTimes())) {
+                maxTeacherCourses = teacherFreeTime.getTotalTimes();
+            }
+        }
+        int courseWeekNum = 0;
+        int practiceCourseNum = 0;
+        LocalDateTime tempClassDateTime;
+        for (int i = 0; i < allTeacherCourses.size(); i++) {
+            CourseSchedule teacherCourse = allTeacherCourses.get(i);
+            tempClassDateTime = LocalDateTime.ofInstant(teacherCourse.getClassDate().toInstant(), DateUtil.zoneId);
+            if (i == 0 && teacherCourse.getGroupType().equals(GroupType.PRACTICE)) {
+                practiceCourseNum += 1;
+                courseWeekNum = tempClassDateTime.get(DateUtil.weekFields.weekOfYear());
+            }
+            if (Objects.nonNull(maxTeacherCourses) && practiceCourseNum >= maxTeacherCourses) {
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return BaseController.failed(HttpStatus.MULTIPLE_CHOICES,"抱歉啦,当前所选时段组合,「" + teacher.getRealName() + "」老师已被预约,请重新选择时段或更换老师后重试。");
+            }
+            if (tempClassDateTime.get(DateUtil.weekFields.weekOfYear()) != courseWeekNum) {
+                courseWeekNum = tempClassDateTime.get(DateUtil.weekFields.weekOfYear());
+                practiceCourseNum = 0;
+            }
+            if (teacherCourse.getGroupType().equals(GroupType.PRACTICE)) {
+                practiceCourseNum += 1;
+            }
+        }
+        allTeacherCourses=new ArrayList<>();
+
+        practiceGroupBuyParams.setName(subject.getName() + "•" + sysUser.getUsername());
+
+        List<CourseSchedule> practiceCourses = createPracticeCourses(practiceGroupBuyParams, practiceCourseMinutes);
+
+        try {
+            courseScheduleService.checkNewCourseSchedules(practiceCourses,false);
+        } catch (Exception e) {
+            return BaseController.failed(HttpStatus.FOUND, "课程冲突");
+        }
+
+        practiceGroupBuyParams.setOrganId(sysUser.getOrganId());
+        practiceGroupBuyParams.setSingleClassMinutes(practiceCourseMinutes);
+        practiceGroupDao.insert(practiceGroupBuyParams);
+
+        //创建班级信息
+        ClassGroup classGroup = new ClassGroup();
+        classGroup.setSubjectIdList(practiceGroupBuyParams.getSubjectId().toString());
+        classGroup.setExpectStudentNum(1);
+        classGroup.setStudentNum(1);
+        classGroup.setName(practiceGroupBuyParams.getName());
+        classGroup.setTotalClassTimes(practiceCourses.size());
+        classGroup.setType(ClassGroupTypeEnum.PRACTICE);
+        classGroup.setDelFlag(0);
+        classGroup.setGroupType(GroupType.PRACTICE);
+        classGroup.setMusicGroupId(practiceGroupBuyParams.getId().toString());
+        classGroup.setCreateTime(now);
+        classGroup.setUpdateTime(now);
+        classGroupDao.insert(classGroup);
+
+        //创建班级老师关联记录
+        ClassGroupTeacherMapper classGroupTeacherMapper = new ClassGroupTeacherMapper();
+        classGroupTeacherMapper.setMusicGroupId(practiceGroupBuyParams.getId().toString());
+        classGroupTeacherMapper.setClassGroupId(classGroup.getId());
+        classGroupTeacherMapper.setTeacherRole(TeachTypeEnum.BISHOP);
+        classGroupTeacherMapper.setUserId(practiceGroupBuyParams.getUserId());
+        classGroupTeacherMapper.setGroupType(GroupType.PRACTICE);
+        classGroupTeacherMapper.setCreateTime(now);
+        classGroupTeacherMapper.setUpdateTime(now);
+        classGroupTeacherMapperDao.insert(classGroupTeacherMapper);
+
+        //创建班级与老师课酬记录
+        ClassGroupTeacherSalary classGroupTeacherSalary = new ClassGroupTeacherSalary();
+        classGroupTeacherSalary.setMusicGroupId(practiceGroupBuyParams.getId().toString());
+        classGroupTeacherSalary.setClassGroupId(classGroup.getId());
+        classGroupTeacherSalary.setTeacherRole(TeachTypeEnum.BISHOP);
+        classGroupTeacherSalary.setUserId(practiceGroupBuyParams.getUserId());
+        classGroupTeacherSalary.setSalary(new BigDecimal(practiceCourseSalaryConfig.getParanValue(Integer.class)));
+        classGroupTeacherSalary.setOnlineClassesSalary(new BigDecimal(practiceCourseSalaryConfig.getParanValue(Integer.class)));
+        classGroupTeacherSalary.setGroupType(GroupType.PRACTICE);
+        classGroupTeacherSalary.setCreateTime(now);
+        classGroupTeacherSalary.setUpdateTime(now);
+        classGroupTeacherSalaryDao.insert(classGroupTeacherSalary);
+
+        //班级学生关联表
+        ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
+        classGroupStudentMapper.setMusicGroupId(practiceGroupBuyParams.getId().toString());
+        classGroupStudentMapper.setClassGroupId(classGroup.getId());
+        classGroupStudentMapper.setUserId(practiceGroupBuyParams.getStudentId());
+        classGroupStudentMapper.setCreateTime(now);
+        classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+        classGroupStudentMapper.setGroupType(GroupType.PRACTICE);
+        classGroupStudentMapperDao.insert(classGroupStudentMapper);
+
+        List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaries = new ArrayList<>();
+        List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
+        List<TeacherAttendance> teacherAttendances = new ArrayList<>();
+
+        for (CourseSchedule courseSchedule : practiceCourses) {
+            //课表
+            courseSchedule.setMusicGroupId(practiceGroupBuyParams.getId().toString());
+            courseSchedule.setClassGroupId(classGroup.getId());
+            courseSchedule.setStatus(CourseStatusEnum.NOT_START);
+            courseSchedule.setCreateTime(now);
+            courseSchedule.setUpdateTime(now);
+            courseSchedule.setTeachMode(TeachModeEnum.ONLINE);
+            courseSchedule.setType(CourseSchedule.CourseScheduleType.PRACTICE);
+            courseSchedule.setGroupType(GroupType.PRACTICE);
+            courseSchedule.setIsLock(1);
+        }
+        courseScheduleDao.batchAddCourseSchedules(practiceCourses);
+        for (CourseSchedule courseSchedule : practiceCourses) {
+            //课程与老师薪水表
+            CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();
+            courseScheduleTeacherSalary.setCourseScheduleId(courseSchedule.getId());
+            courseScheduleTeacherSalary.setGroupType(GroupType.PRACTICE);
+            courseScheduleTeacherSalary.setMusicGroupId(practiceGroupBuyParams.getId().toString());
+            courseScheduleTeacherSalary.setTeacherRole(classGroupTeacherMapper.getTeacherRole());
+            courseScheduleTeacherSalary.setUserId(practiceGroupBuyParams.getUserId());
+            courseScheduleTeacherSalary.setExpectSalary(new BigDecimal(practiceCourseSalaryConfig.getParanValue()));
+            courseScheduleTeacherSalary.setCreateTime(now);
+            courseScheduleTeacherSalary.setUpdateTime(now);
+            courseScheduleTeacherSalary.setClassGroupId(classGroup.getId());
+            courseScheduleTeacherSalaries.add(courseScheduleTeacherSalary);
+
+            //学生缴费记录
+            CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
+            courseScheduleStudentPayment.setGroupType(GroupType.PRACTICE);
+            courseScheduleStudentPayment.setMusicGroupId(practiceGroupBuyParams.getId().toString());
+            courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
+            courseScheduleStudentPayment.setUserId(practiceGroupBuyParams.getStudentId());
+            courseScheduleStudentPayment.setExpectPrice(BigDecimal.ZERO);
+            courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
+            courseScheduleStudentPayment.setCreateTime(now);
+            courseScheduleStudentPayment.setUpdateTime(now);
+            courseScheduleStudentPayments.add(courseScheduleStudentPayment);
+
+            //教师签到记录
+            TeacherAttendance teacherAttendance = new TeacherAttendance();
+            teacherAttendance.setMusicGroupId(practiceGroupBuyParams.getId().toString());
+            teacherAttendance.setTeacherId(practiceGroupBuyParams.getUserId());
+            teacherAttendance.setClassGroupId(classGroup.getId());
+            teacherAttendance.setGroupType(GroupType.PRACTICE);
+            teacherAttendance.setCourseScheduleId(courseSchedule.getId());
+            teacherAttendance.setCreateTime(now);
+            teacherAttendances.add(teacherAttendance);
+        }
+        courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaries);
+        teacherAttendanceDao.batchInsert(teacherAttendances);
+
+        StudentPaymentOrder studentPaymentOrder=new StudentPaymentOrder();
+        studentPaymentOrder.setUserId(practiceGroupBuyParams.getStudentId());
+        studentPaymentOrder.setGroupType(GroupType.PRACTICE);
+        String orderNo=idGeneratorService.generatorId("payment") + "";
+        studentPaymentOrder.setOrderNo(orderNo);
+        studentPaymentOrder.setStatus(DealStatusEnum.ING);
+        studentPaymentOrder.setType(OrderTypeEnum.SMALL_CLASS_TO_BUY);
+        studentPaymentOrder.setExpectAmount(new BigDecimal(practiceCourseSalaryConfig.getParanValue(Integer.class)));
+        studentPaymentOrder.setMusicGroupId(practiceGroupBuyParams.getId().toString());
+        studentPaymentOrder.setActualAmount(studentPaymentOrder.getExpectAmount());
+        studentPaymentOrder.setClassGroupId(classGroup.getId());
+        studentPaymentOrder.setVersion(0);
+        studentPaymentOrderService.insert(studentPaymentOrder);
+
+        BigDecimal amount=new BigDecimal(0);
+
+        if(practiceGroupBuyParams.isUseBalancePayment() || studentPaymentOrder.getExpectAmount().doubleValue() == 0){
+            SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(practiceGroupBuyParams.getStudentId());
+            if(userCashAccount == null){
+                throw new BizException("用户账户找不到");
+            }
+            studentPaymentOrder.setPaymentChannel("BALANCE");
+            if(userCashAccount.getBalance().subtract(studentPaymentOrder.getExpectAmount()).doubleValue() >= 0){
+                // 更新订单信息
+                studentPaymentOrder.setActualAmount(new BigDecimal(0));
+                studentPaymentOrder.setBalancePaymentAmount(studentPaymentOrder.getExpectAmount());
+                studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
+                studentPaymentOrder.setUpdateTime(now);
+                studentPaymentOrder.setOrganId(practiceGroupBuyParams.getOrganId());
+
+                sysUserCashAccountService.updateBalance(practiceGroupBuyParams.getStudentId(), studentPaymentOrder.getExpectAmount().negate(),PlatformCashAccountDetailTypeEnum.PAY_FEE,"陪练课购买");
+
+                Map<String,Object> result=new HashMap<>();
+                result.put("orderNo",studentPaymentOrder.getOrderNo());
+
+                return BaseController.succeed();
+            }else{
+                if (userCashAccount.getBalance().doubleValue() > 0) {
+                    sysUserCashAccountService.updateBalance(practiceGroupBuyParams.getStudentId(), userCashAccount.getBalance().negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "陪练课购买");
+                    amount = studentPaymentOrder.getExpectAmount().subtract(userCashAccount.getBalance());
+                    studentPaymentOrder.setActualAmount(amount);
+                    studentPaymentOrder.setBalancePaymentAmount(userCashAccount.getBalance());
+                } else {
+                    studentPaymentOrder.setBalancePaymentAmount(new BigDecimal(0));
+                }
+            }
+        }
+
+        String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
+        Map<String, BigDecimal> classFee = new HashMap<>();
+        classFee.put("course",amount);
+        classFee.put("instrument",BigDecimal.ZERO);
+        classFee.put("accessories",BigDecimal.ZERO);
+        classFee.put("other",BigDecimal.ZERO);
+        try {
+            Map<String,Object> payMap = payService.getPayMap(
+                    amount,
+                    orderNo,
+                    baseApiUrl+"/api-student/studentOrder/notify",
+                    baseApiUrl+"/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
+                    "vip课购买",
+                    practiceGroupBuyParams.getName(),
+                    practiceGroupBuyParams.getStudentId(),
+                    classFee,
+                    practiceGroupBuyParams.getOrganId()
+            );
+
+            Map<String,BigDecimal> routingFee = (Map<String,BigDecimal>)payMap.get("routingFee");
+            studentPaymentOrder.setOrganId(practiceGroupBuyParams.getOrganId());
+            studentPaymentOrder.setComAmount(routingFee.get("COM"));
+            studentPaymentOrder.setPerAmount(routingFee.get("PER"));
+            studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
+            studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
+            studentPaymentOrder.setUpdateTime(now);
+            studentPaymentOrderService.update(studentPaymentOrder);
+
+            return BaseController.succeed(payMap);
+        } catch (Exception e) {
+            throw new BizException("调用支付接口出错", e);
+        }
+    }
+
+    private List<CourseSchedule> createPracticeCourses(PracticeGroupBuyDto practiceGroupBuyParams, Integer practiceCourseMinutes){
+        List<CourseSchedule> courseSchedules=new ArrayList<>();
+        LocalDate courseStartDay=LocalDateTime.ofInstant(practiceGroupBuyParams.getCoursesStartDate().toInstant(),DateUtil.zoneId).toLocalDate();
+        LocalDate courseEndDay=LocalDateTime.ofInstant(practiceGroupBuyParams.getCoursesExpireDate().toInstant(),DateUtil.zoneId).toLocalDate();
+        while (courseStartDay.compareTo(courseEndDay)<0){
+            int dayOfWeek = courseStartDay.get(DateUtil.weekFields.dayOfWeek());
+            for (PracticeDrillTimeDto drillTime : practiceGroupBuyParams.getDrillTimes()) {
+                if(dayOfWeek==drillTime.getWeekNum()){
+                    CourseSchedule courseSchedule=new CourseSchedule();
+                    String courseStartDayStr = DateUtil.dateFormatter.format(courseStartDay);
+                    String courseStartDateTimeStr = courseStartDayStr+" "+drillTime.getTimeStr();
+                    LocalDateTime courseStartDateTime = LocalDateTime.parse(courseStartDateTimeStr,DateUtil.dateTimeFormatter);
+                    LocalDateTime courseEndDateTime = courseStartDateTime.plusMinutes(practiceCourseMinutes);
+                    courseSchedule.setClassDate(Date.from(courseStartDay.atStartOfDay(DateUtil.zoneId).toInstant()));
+                    courseSchedule.setStartClassTime(Date.from(courseStartDateTime.atZone(DateUtil.zoneId).toInstant()));
+                    courseSchedule.setEndClassTime(Date.from(courseEndDateTime.atZone(DateUtil.zoneId).toInstant()));
+                    courseSchedule.setName(practiceGroupBuyParams.getName());
+                    courseSchedule.setTeacherId(practiceGroupBuyParams.getUserId());
+                    courseSchedule.setActualTeacherId(practiceGroupBuyParams.getUserId());
+                    courseSchedule.setTeachMode(TeachModeEnum.ONLINE);
+                    courseSchedule.setType(CourseSchedule.CourseScheduleType.PRACTICE);
+                    courseSchedule.setStatus(CourseStatusEnum.NOT_START);
+                    courseSchedules.add(courseSchedule);
+                }
+            }
+        }
+        return courseSchedules;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
+    public void orderCallback(StudentPaymentOrder order) {
+        StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.get(order.getId());
+        if(studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)){
+            return;
+        }
+        if(order.getStatus().equals(DealStatusEnum.SUCCESS)){
+            courseScheduleDao.updateGroupCourseLock(order.getMusicGroupId(),GroupType.PRACTICE,0);
+        }else{
+            groupService.deleteGroupInfo(order.getMusicGroupId(),GroupType.PRACTICE);
+        }
+        studentPaymentOrderDao.update(order);
+        SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(order.getUserId());
+
+        //插入缴费明细
+        //收入
+        SysUserCashAccountDetail sysUserIncomeCashAccountDetail = new SysUserCashAccountDetail();
+        sysUserIncomeCashAccountDetail.setUserId(order.getUserId());
+        sysUserIncomeCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
+        sysUserIncomeCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
+        sysUserIncomeCashAccountDetail.setAmount(order.getActualAmount());
+        sysUserIncomeCashAccountDetail.setBalance(sysUserCashAccount.getBalance().add(order.getActualAmount()));
+        sysUserIncomeCashAccountDetail.setAttribute(order.getTransNo());
+        sysUserIncomeCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+        sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount());
+        sysUserIncomeCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount());
+
+        //支出
+        SysUserCashAccountDetail sysUserExpendCashAccountDetail = new SysUserCashAccountDetail();
+        sysUserExpendCashAccountDetail.setUserId(order.getUserId());
+        sysUserExpendCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
+        sysUserExpendCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
+        sysUserExpendCashAccountDetail.setAmount(order.getActualAmount().negate());
+        sysUserExpendCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
+        sysUserExpendCashAccountDetail.setAttribute(order.getTransNo());
+        sysUserExpendCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+        if(studentPaymentOrder.getComAmount() != null){
+            sysUserExpendCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
+        }
+        if(studentPaymentOrder.getPerAmount() != null){
+            sysUserExpendCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
+        }
+
+        sysUserCashAccountDetailService.insert(sysUserIncomeCashAccountDetail);
+        sysUserCashAccountDetailService.insert(sysUserExpendCashAccountDetail);
+    }
 }

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/ClassGroupMapper.xml

@@ -79,6 +79,10 @@
         </trim>
     </insert>
 
+    <update id="deleteByGroup">
+        UPDATE class_group SET del_flag_ = 1,update_time_=NOW() WHERE music_group_id_=#{groupId} AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+    </update>
+
     <!-- 根据主键查询一条记录 -->
     <select id="get" resultMap="ClassGroup">
         SELECT * FROM class_group WHERE id_ = #{id}

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

@@ -63,6 +63,9 @@
     <delete id="deleteByClassId">
         UPDATE class_group_student_mapper SET status_='QUIT' WHERE class_group_id_ = #{classGroupId} AND status_='NORMAL'
     </delete>
+    <delete id="deleteByGroup">
+        UPDATE class_group_student_mapper SET status_='QUIT' WHERE music_group_id_=#{groupId} AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+    </delete>
 
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="ClassGroupStudentMapper" parameterType="map">

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

@@ -141,17 +141,17 @@
         </selectKey>
         -->
         INSERT INTO course_schedule
-        (id_,group_type_,music_group_id_,class_group_id_,status_,subsidy_,class_date_,start_class_time_,end_class_time_,teacher_id_,actual_teacher_id_,create_time_,update_time_,type_,name_,teach_mode_,student_num_,leave_student_num_,schoole_id_)
-        VALUES(#{id},#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{classGroupId},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{subsidy},#{classDate},#{startClassTime},#{endClassTime},#{teacherId},#{teacherId},now(),now(),#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{name},#{teachMode,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{studentNum},#{leaveStudentNum},#{schoolId})
+        (id_,group_type_,music_group_id_,class_group_id_,status_,subsidy_,class_date_,start_class_time_,end_class_time_,teacher_id_,actual_teacher_id_,create_time_,update_time_,type_,name_,teach_mode_,student_num_,leave_student_num_,schoole_id_,is_lock_)
+        VALUES(#{id},#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{classGroupId},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{subsidy},#{classDate},#{startClassTime},#{endClassTime},#{teacherId},#{teacherId},now(),now(),#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{name},#{teachMode,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{studentNum},#{leaveStudentNum},#{schoolId},#{isLock})
     </insert>
 
     <insert id="batchAddCourseSchedules" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
             keyProperty="id">
         INSERT INTO course_schedule
-        (group_type_,music_group_id_,class_group_id_,status_,subsidy_,class_date_,start_class_time_,end_class_time_,teacher_id_,actual_teacher_id_,create_time_,update_time_,type_,name_,teach_mode_,student_num_,leave_student_num_,schoole_id_)
+        (group_type_,music_group_id_,class_group_id_,status_,subsidy_,class_date_,start_class_time_,end_class_time_,teacher_id_,actual_teacher_id_,create_time_,update_time_,type_,name_,teach_mode_,student_num_,leave_student_num_,schoole_id_,is_lock_)
         VALUE
         <foreach collection="list" item="course" separator=",">
-            (#{course.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{course.musicGroupId},#{course.classGroupId},#{course.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{course.subsidy},#{course.classDate},#{course.startClassTime},#{course.endClassTime},#{course.teacherId},#{course.teacherId},now(),now(),#{course.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{course.name},#{course.teachMode,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{course.studentNum},#{course.leaveStudentNum},#{course.schoolId})
+            (#{course.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{course.musicGroupId},#{course.classGroupId},#{course.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{course.subsidy},#{course.classDate},#{course.startClassTime},#{course.endClassTime},#{course.teacherId},#{course.teacherId},now(),now(),#{course.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{course.name},#{course.teachMode,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{course.studentNum},#{course.leaveStudentNum},#{course.schoolId},#{isLock})
         </foreach>
     </insert>
 
@@ -207,6 +207,9 @@
             <if test="teachMode != null">
                 teach_mode_ = #{teachMode,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>
+            <if test="isLock != null">
+                is_lock_ = #{isLock},
+            </if>
             update_time_ = NOW()
         </set>
         WHERE id_ = #{id}
@@ -525,7 +528,8 @@
             LEFT JOIN course_schedule_complaints csc ON csc.course_schedule_id_=cssp.course_schedule_id_ AND csc.user_id_=#{studentId}
             LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cs.id_  AND sa.user_id_=#{studentId}
         WHERE
-        (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
+        cs.is_lock_=0
+        AND (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
         AND cs.class_date_ = DATE_FORMAT(#{classDate},'%Y%m%d')
         AND cssp.user_id_ = #{studentId}
         <if test="quitClassGroupIds != null and quitClassGroupIds.size()>0">
@@ -565,7 +569,8 @@
             LEFT JOIN school s ON cs.schoole_id_ = s.id_
             LEFT JOIN teacher_attendance ta ON cs.id_=ta.course_schedule_id_ AND ta.teacher_id_=#{teacherId}
         WHERE
-        (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
+        cs.is_lock_=0
+        AND (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
         AND cs.class_date_ = DATE_FORMAT(#{classDate},'%Y%m%d')
         <if test="type!=null and type!=''">
             AND cs.type_=#{type}
@@ -1100,7 +1105,13 @@
     <update id="updateCourseSchoolByGroup">
         UPDATE course_schedule cs SET cs.schoole_id_ = #{schoolId},update_time_ = NOW()
         WHERE cs.music_group_id_ = #{groupId}
-        AND cs.group_type_ = #{groupType} AND NOW() &lt; CONCAT(cs.class_date_," ",cs.start_class_time_);
+        AND cs.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} AND NOW() &lt; CONCAT(cs.class_date_," ",cs.start_class_time_);
+    </update>
+
+    <update id="updateGroupCourseLock">
+        UPDATE course_schedule SET is_lock_ = #{isLock},update_time_ = NOW()
+        WHERE music_group_id_ = #{groupId}
+        AND group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} AND NOW() &lt; CONCAT(class_date_," ",start_class_time_);
     </update>
 
     <select id="queryNoSignInListByBeforeMinutes" resultMap="CourseSchedule">

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

@@ -431,7 +431,7 @@
 		DELETE cssp FROM course_schedule_teacher_salary cssp left join course_schedule cs on cssp.course_schedule_id_ = cs.id_ WHERE cssp.music_group_id_=#{musicGroupId} AND cssp.group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} and cs.status_ = 'NOT_START'
 	</delete>
 
-	<select id="queryUserNoSettlementListByTypeAndStartClassDate" resultMap="CourseScheduleTeacherSalary">
+    <select id="queryUserNoSettlementListByTypeAndStartClassDate" resultMap="CourseScheduleTeacherSalary">
 		SELECT ts.*,cs.type_,cs.teach_mode_,cs.class_date_,cs.start_class_time_,cs.end_class_time_ FROM course_schedule_teacher_salary ts LEFT JOIN course_schedule cs ON ts.course_schedule_id_ = cs.id_
 		WHERE FIND_IN_SET(cs.type_, #{typeList}) AND ts.user_id_ = #{userId} AND ts.settlement_time_ IS NULL AND cs.class_date_ &gt;= #{startClassDate}
 	</select>

+ 14 - 0
mec-biz/src/main/resources/config/mybatis/GroupMapper.xml

@@ -42,6 +42,20 @@
         </where>
     </sql>
 
+    <delete id="deleteGroup">
+        DELETE FROM
+        <if test="groupType!=null and groupType='MUSIC'">
+            music_group
+        </if>
+        <if test="groupType!=null and groupType='VIP'">
+            vip_group
+        </if>
+        <if test="groupType!=null and groupType='PRACTICE'">
+            practice_group
+        </if>
+        WHERE id_=#{groupId}
+    </delete>
+
     <select id="searchGroups" resultMap="Group">
         ( SELECT o.id_ organ_id_,o.name_ organ_name_,g.id_, g.name_ group_name_, 'MUSIC' group_type_
         FROM music_group g

+ 8 - 2
mec-biz/src/main/resources/config/mybatis/PracticeGroupMapper.xml

@@ -11,6 +11,7 @@
 		<result column="name_" property="name" />
 		<result column="subject_id_" property="subjectId" />
 		<result column="user_id_" property="userId" />
+		<result column="student_id_" property="studentId" />
 		<result column="single_class_minutes_" property="singleClassMinutes" />
 		<result column="organ_id_" property="organId" />
 		<result column="courses_start_date_" property="coursesStartDate" />
@@ -57,7 +58,7 @@
 		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
 		</selectKey>
 		-->
-		INSERT INTO practice_group (id_,name_,subject_id_,user_id_,single_class_minutes_,organ_id_,courses_start_date_,courses_expire_date_,create_time_,update_time_,memo_) VALUES(#{id},#{name},#{subjectId},#{userId},#{singleClassMinutes},#{organId},#{coursesStartDate},#{coursesExpireDate},NOW(),NOW(),#{memo})
+		INSERT INTO practice_group (id_,name_,subject_id_,user_id_,student_id_,single_class_minutes_,organ_id_,courses_start_date_,courses_expire_date_,create_time_,update_time_,memo_) VALUES(#{id},#{name},#{subjectId},#{userId},#{studentId},#{singleClassMinutes},#{organId},#{coursesStartDate},#{coursesExpireDate},NOW(),NOW(),#{memo})
 	</insert>
 	
 	
@@ -94,7 +95,12 @@
 	<select id="countPracticeGroupOverCourse" resultType="java.util.Map">
 
 	</select>
-	<sql id="practiceGroupQueryCondition">
+
+    <select id="findUserLatestPracticeGroup" resultMap="PracticeGroup">
+		SELECT * FROM practice_group WHERE student_id_=#{userId} ORDER BY create_time_ DESC LIMIT 1;
+	</select>
+
+    <sql id="practiceGroupQueryCondition">
 		<where>
 			<if test="search!=null and search!=''">
 				AND (pg.name_ LIKE CONCAT('%',#{search},'%') OR pg.id_= #{search})

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/StudentAttendanceMapper.xml

@@ -169,6 +169,10 @@
             #{userId}
         </foreach>
     </delete>
+    <delete id="deleteByGroup">
+        DELETE sa FROM student_attendance sa LEFT JOIN course_schedule cs ON sa.course_schedule_id_ = cs.id_
+		WHERE sa.music_group_id_=#{musicGroupId} AND sa.group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} and cs.status_ = 'NOT_START'
+    </delete>
 
     <resultMap id="studentAttendanceViewUtilEntity" type="com.ym.mec.biz.dal.dto.StudentAttendanceViewDto">
         <result property="classGroupId" column="class_group_id_"/>

+ 20 - 0
mec-student/src/main/java/com/ym/mec/student/controller/PracticeGroupController.java

@@ -99,4 +99,24 @@ public class PracticeGroupController extends BaseController {
         return succeed(practiceGroupService.practiceApply(practiceGroup));
     }
 
+    @ApiOperation("获取陪练课预约参数——付费")
+    @GetMapping(value = "/getPayPracticeApplyParams")
+    public Object getPayPracticeApplyParams(){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        return succeed(practiceGroupService.getPayPracticeApplyParams(sysUser.getId()));
+    }
+
+    @ApiOperation("获取指定教师的空闲时间——付费")
+    @GetMapping(value = "/getPayPracticeTeacherFreeTimes")
+    public Object getPayPracticeTeacherFreeTimes(Integer teacherId,Integer buyMonths, Date firstClassTime){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        return succeed(practiceGroupService.getPayPracticeTeacherFreeTimes(sysUser.getId(),teacherId, buyMonths,firstClassTime));
+    }
+
 }

+ 19 - 0
mec-util/src/main/java/com/ym/mec/util/date/DateUtil.java

@@ -5,6 +5,10 @@ import org.apache.commons.lang3.StringUtils;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.DayOfWeek;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.WeekFields;
 import java.util.*;
 
 /**
@@ -129,7 +133,14 @@ public class DateUtil {
 
 	public static final long ONE_WEEK = 7 * ONE_DAY;
 
+	public static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+	public static final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+	public static final DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
+	public static final WeekFields weekFields = WeekFields.of(DayOfWeek.MONDAY, 1);
+	public static final ZoneId zoneId = ZoneId.systemDefault();
+
 	public static Map<Object,Integer> normalWeekNumCalendarWeekNumMap=new HashMap<>();
+	public static Map<Object,Integer> calendarWeekNumNormalWeekNumMap=new HashMap<>();
 
 	static {
 		normalWeekNumCalendarWeekNumMap.put(1,Calendar.MONDAY);
@@ -163,6 +174,14 @@ public class DateUtil {
 		normalWeekNumCalendarWeekNumMap.put("星期五",Calendar.FRIDAY);
 		normalWeekNumCalendarWeekNumMap.put("星期六",Calendar.SATURDAY);
 		normalWeekNumCalendarWeekNumMap.put("星期七",Calendar.SUNDAY);
+
+		calendarWeekNumNormalWeekNumMap.put(Calendar.MONDAY,1);
+		calendarWeekNumNormalWeekNumMap.put(Calendar.TUESDAY,2);
+		calendarWeekNumNormalWeekNumMap.put(Calendar.WEDNESDAY,3);
+		calendarWeekNumNormalWeekNumMap.put(Calendar.THURSDAY,4);
+		calendarWeekNumNormalWeekNumMap.put(Calendar.FRIDAY,5);
+		calendarWeekNumNormalWeekNumMap.put(Calendar.SATURDAY,6);
+		calendarWeekNumNormalWeekNumMap.put(Calendar.SUNDAY,7);
 	}
 
 	// ~ 方法 ////////////////////////////////////////////////////////////////