yonge 5 years ago
parent
commit
191f9b9848

+ 232 - 236
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -1,248 +1,244 @@
 package com.ym.mec.biz.dal.dao;
 
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ibatis.annotations.Param;
+
 import com.ym.mec.biz.dal.dto.CourseScheduleDto;
 import com.ym.mec.biz.dal.dto.TeacherAttendanceDto;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.StudentCourseScheduleRecordDto;
+import com.ym.mec.biz.dal.enums.CourseStatusEnum;
 import com.ym.mec.common.dal.BaseDAO;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
 
 public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
 
-    /**
-     * 根据教师ID获取当前课程信息
-     *
-     * @param teacherID
-     * @return
-     */
-    TeacherAttendanceDto getCurrentCourseDetail(@Param("courseID") Long courseID);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/10/16
-     * @params [startTime, endTime, teacherId]
-     * @return com.ym.mec.biz.dal.dto.TeacherAttendanceDto
-     * @describe 根据时间区间获取教师上课的课程
-     */
-    TeacherAttendanceDto getTeacherCourseByDateSpeed(@Param("startTime") Date startTime,
-                                                     @Param("endTime") Date endTime,
-                                                     @Param("teacherId") Long teacherId);
-
-    int batchAddCourseSchedules(List<CourseSchedule> courseSchedules);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/17
-     * 统计学生所属班级数量
-     */
-    Integer[] countStudentInClass(List<Integer> classGroupIDs);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/17
-     * 根据日期获取当日排课信息
-     */
-    List<CourseScheduleDto> getCourseSchedulesWithDate(@Param("classDate") Date classDate);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/10/14
-     * @params [classDates, classGroupId]
-     * @return java.util.List<com.ym.mec.biz.dal.entity.CourseSchedule>
-     * @describe 根据班级和上课日期获取课程计划
-     */
-    List<CourseSchedule> findByClassGroupAndDate(@Param("classDates") List<Date> classDates,
-                                                 @Param("classGroupId") Long classGroupId);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/17
-     * 根据日期获取学生当日排课信息
-     */
-    List<CourseScheduleDto> getStudentCourseSchedulesWithDate(@Param("classDate") Date classDate,
-                                                              @Param("studentId") Long studentId);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/10/11
-     * @params [courseScheduleId]
-     * @return java.util.List<java.lang.String>
-     * @describe 获取课程签到学生姓名
-     */
-    List<String> findStudentNamesByCourseSchedule(Long courseScheduleId);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/17
-     * 根据日期获取老师当日排课信息
-     */
-    List<CourseScheduleDto> getTeacherCourseSchedulesWithDate(@Param("classDate") Date classDate,
-                                                              @Param("teacherId") Long teacherId);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/10/11
-     * @params [params]
-     * @return java.util.List<com.ym.mec.biz.dal.dto.CourseScheduleDto>
-     * @describe 根据
-     */
-    List<CourseScheduleDto> getCourseSchedulesWithDate(Map<String,Object> params);
-    int countCourseSchedulesWithDate(Map<String,Object> params);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/17
-     * 根据乐团ID删除排课
-     */
-    int deleteCourseSchedulesByMusicGroupID(@Param("musicGroupID") Long musicGroupID);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/17
-     * 根据月份获取乐团在该月有课的日期
-     */
-    List<Date> getCourseScheduleDateByMonth(@Param("musicGroupID") Long musicGroupID,
-                                            @Param("month") Date month);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/27
-     * 获取学生有课日期
-     */
-    List<Date> getStudentCourseScheduleDate(@Param("studentId") Long studentId,
-                                            @Param("month") Date month,
-                                            @Param("isAttend") Integer isAttend);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/27
-     * 获取教师有课日期
-     */
-    List<Date> getTeacherCourseScheduleDate(@Param("teacherId") Long teacherId,
-                                            @Param("month") Date month);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/10/11
-     * @params [month, organId]
-     * @return java.util.List<java.util.Date>
-     * @describe 获取当月有课的日期
-     */
-    List<Date> getCourseScheduleDate(@Param("month") Date month,
-                                     @Param("organId") Long organId);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/23
-     * 统计教师在一天内有时间重复的课数
-     */
-    int countTeacherCourseInOnDayRepeats(CourseSchedule courseSchedule);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/24
-     * 根据日期获取对应老师的课程
-     */
-    List<CourseSchedule> findTeacherCoursesInDates(@Param("dates") List<Date> dates,
-                                                   @Param("teacherId") Long teacherId);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/24
-     * 根据日期获取课程
-     */
-    List<CourseSchedule> findCoursesByDates(@Param("dates") List<Date> dates);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/24
-     * 获取在指定时间段内存在重复的课程
-     */
-    List<CourseSchedule> findOverLapCoursesInDay(@Param("dates") List<Date> dates,
-                                                 @Param("startClassTime") Date startClassTime,
-                                                 @Param("endClassTime") Date endClassTime);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/29
-     * 获取班级的声部
-     */
-    String[] findClassSubjects(List<Integer> ids);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/24
-     * 根据id批量获取课程
-     */
-    List<CourseSchedule> findCourseSchedulesByIds(@Param("ids") Long[] ids);
-
-    /**
-     * 获取班级的课程计划
-     * @param classGroupList
-     * @return
-     */
-    List<CourseSchedule> findClassGroupCourseSchedules(@Param("classGroupList") List classGroupList);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/30
-     * 获取学生上课记录
-     */
-    List<StudentCourseScheduleRecordDto> findStudentCourseScheduleRecords(Map<String,Object> params);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/30
-     * 统计学生上课记录
-     */
-    int countStudentCourseScheduleRecords(Map<String,Object> params);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/30
-     * 获取学生未上课记录
-     */
-    List<StudentCourseScheduleRecordDto> findStudentCourseScheduleNotStartRecords(@Param("userId") Long userId,
-                                                                                  @Param("date") Date date);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/10/8
-     * @params [classGroupId]
-     * @return int
-     * @describe 统计已上课次
-     */
-    int countClassTimes(Long classGroupId);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/9/17
-     * 获取课程信息
-     */
-    CourseScheduleDto getCourseSchedules(@Param("courseScheduleId") Long courseScheduleId);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/10/14
-     * @params [vipGroupId]
-     * @return java.util.List<com.ym.mec.biz.dal.entity.CourseSchedule>
-     * @describe 获取vip课排课计划
-     */
-    List<CourseSchedule> findVipGroupCourseSchedules(@Param("vipGroupId") Long vipGroupId);
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/10/16
-     * @params [courseScheduleId]
-     * @return java.lang.String
-     * @describe 获取课程关联班级类型
-     */
-    String findClassTypeByCourse(@Param("courseScheduleId") Long courseScheduleId);
-
-
+	/**
+	 * 根据教师ID获取当前课程信息
+	 *
+	 * @param teacherID
+	 * @return
+	 */
+	TeacherAttendanceDto getCurrentCourseDetail(@Param("courseID") Long courseID);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/10/16
+	 * @params [startTime, endTime, teacherId]
+	 * @return com.ym.mec.biz.dal.dto.TeacherAttendanceDto
+	 * @describe 根据时间区间获取教师上课的课程
+	 */
+	TeacherAttendanceDto getTeacherCourseByDateSpeed(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("teacherId") Long teacherId);
+
+	int batchAddCourseSchedules(List<CourseSchedule> courseSchedules);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/17
+	 * 统计学生所属班级数量
+	 */
+	Integer[] countStudentInClass(List<Integer> classGroupIDs);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/17
+	 * 根据日期获取当日排课信息
+	 */
+	List<CourseScheduleDto> getCourseSchedulesWithDate(@Param("classDate") Date classDate);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/10/14
+	 * @params [classDates, classGroupId]
+	 * @return java.util.List<com.ym.mec.biz.dal.entity.CourseSchedule>
+	 * @describe 根据班级和上课日期获取课程计划
+	 */
+	List<CourseSchedule> findByClassGroupAndDate(@Param("classDates") List<Date> classDates, @Param("classGroupId") Long classGroupId);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/17
+	 * 根据日期获取学生当日排课信息
+	 */
+	List<CourseScheduleDto> getStudentCourseSchedulesWithDate(@Param("classDate") Date classDate, @Param("studentId") Long studentId);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/10/11
+	 * @params [courseScheduleId]
+	 * @return java.util.List<java.lang.String>
+	 * @describe 获取课程签到学生姓名
+	 */
+	List<String> findStudentNamesByCourseSchedule(Long courseScheduleId);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/17
+	 * 根据日期获取老师当日排课信息
+	 */
+	List<CourseScheduleDto> getTeacherCourseSchedulesWithDate(@Param("classDate") Date classDate, @Param("teacherId") Long teacherId);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/10/11
+	 * @params [params]
+	 * @return java.util.List<com.ym.mec.biz.dal.dto.CourseScheduleDto>
+	 * @describe 根据
+	 */
+	List<CourseScheduleDto> getCourseSchedulesWithDate(Map<String, Object> params);
+
+	int countCourseSchedulesWithDate(Map<String, Object> params);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/17
+	 * 根据乐团ID删除排课
+	 */
+	int deleteCourseSchedulesByMusicGroupID(@Param("musicGroupID") Long musicGroupID);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/17
+	 * 根据月份获取乐团在该月有课的日期
+	 */
+	List<Date> getCourseScheduleDateByMonth(@Param("musicGroupID") Long musicGroupID, @Param("month") Date month);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/27
+	 * 获取学生有课日期
+	 */
+	List<Date> getStudentCourseScheduleDate(@Param("studentId") Long studentId, @Param("month") Date month, @Param("isAttend") Integer isAttend);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/27
+	 * 获取教师有课日期
+	 */
+	List<Date> getTeacherCourseScheduleDate(@Param("teacherId") Long teacherId, @Param("month") Date month);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/10/11
+	 * @params [month, organId]
+	 * @return java.util.List<java.util.Date>
+	 * @describe 获取当月有课的日期
+	 */
+	List<Date> getCourseScheduleDate(@Param("month") Date month, @Param("organId") Long organId);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/23
+	 * 统计教师在一天内有时间重复的课数
+	 */
+	int countTeacherCourseInOnDayRepeats(CourseSchedule courseSchedule);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/24
+	 * 根据日期获取对应老师的课程
+	 */
+	List<CourseSchedule> findTeacherCoursesInDates(@Param("dates") List<Date> dates, @Param("teacherId") Long teacherId);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/24
+	 * 根据日期获取课程
+	 */
+	List<CourseSchedule> findCoursesByDates(@Param("dates") List<Date> dates);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/24
+	 * 获取在指定时间段内存在重复的课程
+	 */
+	List<CourseSchedule> findOverLapCoursesInDay(@Param("dates") List<Date> dates, @Param("startClassTime") Date startClassTime,
+			@Param("endClassTime") Date endClassTime);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/29
+	 * 获取班级的声部
+	 */
+	String[] findClassSubjects(List<Integer> ids);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/24
+	 * 根据id批量获取课程
+	 */
+	List<CourseSchedule> findCourseSchedulesByIds(@Param("ids") Long[] ids);
+
+	/**
+	 * 获取班级的课程计划
+	 * @param classGroupList
+	 * @return
+	 */
+	List<CourseSchedule> findClassGroupCourseSchedules(@Param("classGroupList") List classGroupList);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/30
+	 * 获取学生上课记录
+	 */
+	List<StudentCourseScheduleRecordDto> findStudentCourseScheduleRecords(Map<String, Object> params);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/30
+	 * 统计学生上课记录
+	 */
+	int countStudentCourseScheduleRecords(Map<String, Object> params);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/30
+	 * 获取学生未上课记录
+	 */
+	List<StudentCourseScheduleRecordDto> findStudentCourseScheduleNotStartRecords(@Param("userId") Long userId, @Param("date") Date date);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/10/8
+	 * @params [classGroupId]
+	 * @return int
+	 * @describe 统计已上课次
+	 */
+	int countClassTimes(Long classGroupId);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/9/17
+	 * 获取课程信息
+	 */
+	CourseScheduleDto getCourseSchedules(@Param("courseScheduleId") Long courseScheduleId);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/10/14
+	 * @params [vipGroupId]
+	 * @return java.util.List<com.ym.mec.biz.dal.entity.CourseSchedule>
+	 * @describe 获取vip课排课计划
+	 */
+	List<CourseSchedule> findVipGroupCourseSchedules(@Param("vipGroupId") Long vipGroupId);
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/10/16
+	 * @params [courseScheduleId]
+	 * @return java.lang.String
+	 * @describe 获取课程关联班级类型
+	 */
+	String findClassTypeByCourse(@Param("courseScheduleId") Long courseScheduleId);
+
+	/**
+	 * 根据课程状态查询老师指定月份的VIP课程记录数
+	 * @param monthDate 指定月份
+	 * @param status 课程状态
+	 * @return
+	 */
+	List<Map<Integer, Integer>> queryVipGroupTeachereClassTimesByMonth(@Param("monthDate") Date monthDate,@Param("status") CourseStatusEnum status);
 
 }

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

@@ -98,6 +98,10 @@ public class VipGroup {
 
 	@ApiModelProperty(value = "赠送课时类型")
 	private TeachModeEnum giveTeachMode;
+	
+	private Integer organId;
+	
+	private Integer schoolId;
 
 	public String getVipGroupActivityName() {
 		return vipGroupActivityName;
@@ -307,6 +311,22 @@ public class VipGroup {
 		this.giveTeachMode = giveTeachMode;
 	}
 
+	public Integer getOrganId() {
+		return organId;
+	}
+
+	public void setOrganId(Integer organId) {
+		this.organId = organId;
+	}
+
+	public Integer getSchoolId() {
+		return schoolId;
+	}
+
+	public void setSchoolId(Integer schoolId) {
+		this.schoolId = schoolId;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 2 - 5
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/PlatformCashAccountDetailTypeEnum.java

@@ -6,11 +6,8 @@ import com.ym.mec.common.enums.BaseEnum;
  * 交易类型 (RECHARGE 充值,WITHDRAW 提现,PAY_FEE 缴费,REFUNDS 退费,FILL_ACCOUNT 人工补账)
  */
 public enum PlatformCashAccountDetailTypeEnum implements BaseEnum<String, PlatformCashAccountDetailTypeEnum> {
-	RECHARGE("RECHARGE", "充值"),
-	WITHDRAW("WITHDRAW", "提现"),
-	PAY_FEE("PAY_FEE", "缴费"),
-	FILL_ACCOUNT("FILL_ACCOUNT", "人工补账"),
-	REFUNDS("REFUNDS", "退费");
+	RECHARGE("RECHARGE", "充值"), WITHDRAW("WITHDRAW", "提现"), PAY_FEE("PAY_FEE", "缴费"), FILL_ACCOUNT("FILL_ACCOUNT", "人工补账"), REFUNDS("REFUNDS", "退费"), REWARDS(
+			"REWARDS", "奖励");
 
 	private String code;
 

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysUserCashAccountDetailService.java

@@ -9,6 +9,12 @@ import com.ym.mec.biz.dal.enums.TransTypeEnum;
 import com.ym.mec.common.service.BaseService;
 
 public interface SysUserCashAccountDetailService extends BaseService<Long, SysUserCashAccountDetail> {
+	
+	final static String MUSIC_GROUP = "group";
+	
+	final static String ORGAN = "organ";
+	
+	final static String COURSE_SCHEDULE = "cs";
 
 	SysUserCashAccountDetail queryDetailByTransNo(String transNo);
 

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

@@ -33,7 +33,7 @@ public class CourseScheduleRewardsRulesServiceImpl extends BaseServiceImpl<Integ
 		List<CourseScheduleRewardsRules> CourseScheduleRewardsRulesList = courseScheduleRewardsDao.query(organId, courseScheduleType);
 
 		if (CourseScheduleRewardsRulesList == null || CourseScheduleRewardsRulesList.size() == 0) {
-			return null;
+			return new BigDecimal(0);
 		}
 
 		CourseScheduleRewardsRules courseScheduleRewardsRules = CourseScheduleRewardsRulesList.get(0);

+ 7 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -179,8 +179,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 	@Override
 	public List<MusicCardDto> queryUserMusicGroups(Integer userId) {
 		List<MusicCardDto> musicCardDtos = musicGroupDao.queryUserMusicGroups(userId);
-		//获取学员在该乐团续费状态
-		musicCardDtos.forEach(e->{
+		// 获取学员在该乐团续费状态
+		musicCardDtos.forEach(e -> {
 			e.setPaymentStatus(musicGroupStudentFeeDao.findByUser(userId, e.getMusicGroupId()).getPaymentStatus());
 		});
 		return musicCardDtos;
@@ -229,8 +229,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 		for (StudentPaymentOrder order : studentPaymentOrders) {
 			sysUserCashAccountService.updateBalance(order.getUserId(), order.getActualAmount());
 			// 增加交易流水
-			sysUserCashAccountDetailService.addCashAccountDetail(order.getUserId(), order.getActualAmount(), "", "", PlatformCashAccountDetailTypeEnum.REFUNDS,
-					null, DealStatusEnum.SUCCESS, "取消乐团");
+			sysUserCashAccountDetailService.addCashAccountDetail(order.getUserId(), order.getActualAmount(), SysUserCashAccountDetailService.MUSIC_GROUP
+					+ musicGroupId, "", PlatformCashAccountDetailTypeEnum.REFUNDS, null, DealStatusEnum.SUCCESS, "取消乐团");
 		}
 
 		return true;
@@ -377,8 +377,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 				}
 				if (musicGroupSubjectPlan.getDepositFee().doubleValue() > 0) {
 					// 增加交易流水
-					sysUserCashAccountDetailService.addCashAccountDetail(userId, musicGroupSubjectPlan.getDepositFee(), "", "",
-							PlatformCashAccountDetailTypeEnum.REFUNDS, null, DealStatusEnum.SUCCESS, "退出乐团");
+					sysUserCashAccountDetailService.addCashAccountDetail(userId, musicGroupSubjectPlan.getDepositFee(),
+							SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "", PlatformCashAccountDetailTypeEnum.REFUNDS, null,
+							DealStatusEnum.SUCCESS, "退出乐团");
 				}
 			}
 		}

+ 401 - 308
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -1,14 +1,91 @@
 package com.ym.mec.biz.service.impl;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
 import com.alibaba.fastjson.JSON;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.dto.*;
-import com.ym.mec.biz.dal.entity.*;
-import com.ym.mec.biz.dal.enums.*;
-import com.ym.mec.biz.dal.page.*;
-import com.ym.mec.biz.service.*;
+import com.ym.mec.biz.dal.dao.ClassGroupDao;
+import com.ym.mec.biz.dal.dao.ClassGroupTeacherMapperDao;
+import com.ym.mec.biz.dal.dao.ClassGroupTeacherSalaryDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleTeacherSalaryDao;
+import com.ym.mec.biz.dal.dao.StudentApplyRefundsDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
+import com.ym.mec.biz.dal.dao.StudentVipGroupPaymentDao;
+import com.ym.mec.biz.dal.dao.SubjectDao;
+import com.ym.mec.biz.dal.dao.SysUserCashAccountDetailDao;
+import com.ym.mec.biz.dal.dao.TeacherDefaultVipGroupSalaryDao;
+import com.ym.mec.biz.dal.dao.VipGroupActivityDao;
+import com.ym.mec.biz.dal.dao.VipGroupCategoryDao;
+import com.ym.mec.biz.dal.dao.VipGroupClassGroupMapperDao;
+import com.ym.mec.biz.dal.dao.VipGroupDao;
+import com.ym.mec.biz.dal.dao.VipGroupDefaultClassesUnitPriceDao;
+import com.ym.mec.biz.dal.dto.StudentVipGroupDetailDto;
+import com.ym.mec.biz.dal.dto.TeachingRecordBaseInfo;
+import com.ym.mec.biz.dal.dto.VipGroupApplyBaseInfoDto;
+import com.ym.mec.biz.dal.dto.VipGroupApplyDto;
+import com.ym.mec.biz.dal.dto.VipGroupBuyParamsDto;
+import com.ym.mec.biz.dal.dto.VipGroupCostCountDto;
+import com.ym.mec.biz.dal.dto.VipGroupCostCountParamsDto;
+import com.ym.mec.biz.dal.dto.VipGroupManageDetailDto;
+import com.ym.mec.biz.dal.dto.VipGroupSalaryBaseInfo;
+import com.ym.mec.biz.dal.dto.VipGroupSalaryDto;
+import com.ym.mec.biz.dal.dto.VipGroupSalarySettlementDto;
+import com.ym.mec.biz.dal.entity.ClassGroup;
+import com.ym.mec.biz.dal.entity.ClassGroupTeacherMapper;
+import com.ym.mec.biz.dal.entity.ClassGroupTeacherSalary;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+import com.ym.mec.biz.dal.entity.StudentApplyRefunds;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.entity.StudentVipGroupPayment;
+import com.ym.mec.biz.dal.entity.SysUserCashAccount;
+import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
+import com.ym.mec.biz.dal.entity.TeacherDefaultVipGroupSalary;
+import com.ym.mec.biz.dal.entity.VipGroup;
+import com.ym.mec.biz.dal.entity.VipGroupActivity;
+import com.ym.mec.biz.dal.entity.VipGroupCategory;
+import com.ym.mec.biz.dal.entity.VipGroupClassGroupMapper;
+import com.ym.mec.biz.dal.entity.VipGroupDefaultClassesUnitPrice;
+import com.ym.mec.biz.dal.enums.AuditStatusEnum;
+import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
+import com.ym.mec.biz.dal.enums.CourseStatusEnum;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.TeachModeEnum;
+import com.ym.mec.biz.dal.enums.TeachTypeEnum;
+import com.ym.mec.biz.dal.enums.VipGroupActivityTypeEnum;
+import com.ym.mec.biz.dal.enums.VipGroupStatusEnum;
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
+import com.ym.mec.biz.dal.page.StudentVipGroupQueryInfo;
+import com.ym.mec.biz.dal.page.VipGroupAttendanceQueryInfo;
+import com.ym.mec.biz.dal.page.VipGroupQueryInfo;
+import com.ym.mec.biz.dal.page.VipGroupSalaryQueryInfo;
+import com.ym.mec.biz.dal.page.VipGroupTeachingRecordQueryInfo;
+import com.ym.mec.biz.service.ClassGroupService;
+import com.ym.mec.biz.service.CourseScheduleRewardsRulesService;
+import com.ym.mec.biz.service.CourseScheduleService;
+import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
+import com.ym.mec.biz.service.CourseScheduleTeacherSalaryService;
+import com.ym.mec.biz.service.PayService;
+import com.ym.mec.biz.service.SysUserCashAccountDetailService;
+import com.ym.mec.biz.service.SysUserCashAccountService;
+import com.ym.mec.biz.service.VipGroupService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.ImGroupMember;
 import com.ym.mec.common.entity.ImGroupModel;
@@ -17,19 +94,10 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.im.ImFeignService;
 import com.ym.mec.util.collection.MapUtil;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.CollectionUtils;
-
-import java.math.BigDecimal;
-import java.util.*;
-import java.util.stream.Collectors;
 
 @Service
 public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> implements VipGroupService {
-	
+
 	@Autowired
 	private VipGroupDao vipGroupDao;
 	@Autowired
@@ -50,38 +118,43 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 	private VipGroupActivityDao vipGroupActivityDao;
 	@Autowired
 	private VipGroupCategoryDao vipGroupCategoryDao;
-    @Autowired
-    private SysUserFeignService sysUserFeignService;
-    @Autowired
-    private TeacherDefaultVipGroupSalaryDao teacherDefaultVipGroupSalaryDao;
-    @Autowired
-    private StudentPaymentOrderDao studentPaymentOrderDao;
-    @Autowired
-    private StudentVipGroupPaymentDao studentVipGroupPaymentDao;
-    @Autowired
+	@Autowired
+	private SysUserFeignService sysUserFeignService;
+	@Autowired
+	private TeacherDefaultVipGroupSalaryDao teacherDefaultVipGroupSalaryDao;
+	@Autowired
+	private StudentPaymentOrderDao studentPaymentOrderDao;
+	@Autowired
+	private StudentVipGroupPaymentDao studentVipGroupPaymentDao;
+	@Autowired
 	private StudentApplyRefundsDao studentApplyRefundsDao;
-	
+
 	@Autowired
 	private SysUserCashAccountService sysUserCashAccountService;
 
-    @Autowired
+	@Autowired
 	private SysUserCashAccountDetailDao sysUserCashAccountDetailDao;
-    @Autowired
+	@Autowired
 	private ClassGroupTeacherSalaryDao classGroupTeacherSalaryDao;
 
-    @Autowired
+	@Autowired
 	private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
-    @Autowired
+	@Autowired
 	private ImFeignService imFeignService;
-    @Autowired
+	@Autowired
 	private SubjectDao subjectDao;
-    @Autowired
+	@Autowired
 	private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
-    @Autowired
+	@Autowired
 	private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
 	@Autowired
 	private PayService payService;
 
+	@Autowired
+	private CourseScheduleRewardsRulesService courseScheduleRewardsRulesService;
+
+	private SysUserCashAccountDetailService sysUserCashAccountDetailService;
+
 	@Override
 	public BaseDAO<Long, VipGroup> getDAO() {
 		return vipGroupDao;
@@ -91,99 +164,101 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 	@Override
 	public void createVipGroup(VipGroupApplyDto vipGroup) {
 
-		if (Objects.isNull(vipGroup.getVipGroupApplyBaseInfo().getUserId())){
+		if (Objects.isNull(vipGroup.getVipGroupApplyBaseInfo().getUserId())) {
 			throw new BizException("请选择指导老师");
 		}
 
-	    if(vipGroup.getCourseSchedules().size()!=(vipGroup.getVipGroupApplyBaseInfo().getOfflineClassesNum()+vipGroup.getVipGroupApplyBaseInfo().getOnlineClassesNum())){
-	        throw new BizException("课时总数不匹配!");
-        }
+		if (vipGroup.getCourseSchedules().size() != (vipGroup.getVipGroupApplyBaseInfo().getOfflineClassesNum() + vipGroup.getVipGroupApplyBaseInfo()
+				.getOnlineClassesNum())) {
+			throw new BizException("课时总数不匹配!");
+		}
 
-        Map<TeachModeEnum, List<CourseSchedule>> courseScheduleGroup = vipGroup.getCourseSchedules().stream().collect(Collectors.groupingBy(CourseSchedule::getTeachMode));
+		Map<TeachModeEnum, List<CourseSchedule>> courseScheduleGroup = vipGroup.getCourseSchedules().stream()
+				.collect(Collectors.groupingBy(CourseSchedule::getTeachMode));
 
-	    if((Objects.isNull(courseScheduleGroup.get(TeachModeEnum.OFFLINE))&&vipGroup.getVipGroupApplyBaseInfo().getOfflineClassesNum()!=0)
-				||(!Objects.isNull(courseScheduleGroup.get(TeachModeEnum.OFFLINE))&&(courseScheduleGroup.get(TeachModeEnum.OFFLINE).size()<vipGroup.getVipGroupApplyBaseInfo().getOfflineClassesNum()))){
-	        throw new BizException("线下课课时数量安排有误!");
-        }
-        if((Objects.isNull(courseScheduleGroup.get(TeachModeEnum.ONLINE))&&vipGroup.getVipGroupApplyBaseInfo().getOnlineClassesNum()!=0)
-				||(!Objects.isNull(courseScheduleGroup.get(TeachModeEnum.ONLINE))&&(courseScheduleGroup.get(TeachModeEnum.ONLINE).size()<vipGroup.getVipGroupApplyBaseInfo().getOnlineClassesNum()))){
-            throw new BizException("线上课课时数量安排有误!");
-        }
+		if ((Objects.isNull(courseScheduleGroup.get(TeachModeEnum.OFFLINE)) && vipGroup.getVipGroupApplyBaseInfo().getOfflineClassesNum() != 0)
+				|| (!Objects.isNull(courseScheduleGroup.get(TeachModeEnum.OFFLINE)) && (courseScheduleGroup.get(TeachModeEnum.OFFLINE).size() < vipGroup
+						.getVipGroupApplyBaseInfo().getOfflineClassesNum()))) {
+			throw new BizException("线下课课时数量安排有误!");
+		}
+		if ((Objects.isNull(courseScheduleGroup.get(TeachModeEnum.ONLINE)) && vipGroup.getVipGroupApplyBaseInfo().getOnlineClassesNum() != 0)
+				|| (!Objects.isNull(courseScheduleGroup.get(TeachModeEnum.ONLINE)) && (courseScheduleGroup.get(TeachModeEnum.ONLINE).size() < vipGroup
+						.getVipGroupApplyBaseInfo().getOnlineClassesNum()))) {
+			throw new BizException("线上课课时数量安排有误!");
+		}
 
-        //获取活动信息
-        VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupApplyBaseInfo().getVipGroupActivityId().intValue());
+		// 获取活动信息
+		VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupApplyBaseInfo().getVipGroupActivityId().intValue());
 
-		//生成vip课信息
-		VipGroupApplyBaseInfoDto vipGroupApplyBaseInfoDto=vipGroup.getVipGroupApplyBaseInfo();
+		// 生成vip课信息
+		VipGroupApplyBaseInfoDto vipGroupApplyBaseInfoDto = vipGroup.getVipGroupApplyBaseInfo();
 		List<String> bySubIds = subjectDao.findBySubIds(vipGroupApplyBaseInfoDto.getSubjectIdList());
-		StringBuffer className=new StringBuffer(StringUtils.join(bySubIds,","));
+		StringBuffer className = new StringBuffer(StringUtils.join(bySubIds, ","));
 		className.append("•");
 		className.append(vipGroupApplyBaseInfoDto.getName());
 		vipGroupApplyBaseInfoDto.setName(className.toString());
-		vipGroupApplyBaseInfoDto.setTotalPrice(countVipGroupPredictFee(vipGroupApplyBaseInfoDto,
-				vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice(),
+		vipGroupApplyBaseInfoDto.setTotalPrice(countVipGroupPredictFee(vipGroupApplyBaseInfoDto, vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice(),
 				vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice()).get("totalPrice"));
 		vipGroupApplyBaseInfoDto.setStatus(VipGroupStatusEnum.APPLYING);
 		vipGroupDao.insert(vipGroupApplyBaseInfoDto);
 
-		//获取vip课类型信息
+		// 获取vip课类型信息
 		VipGroupCategory vipGroupCategory = vipGroupCategoryDao.get(vipGroup.getVipGroupApplyBaseInfo().getVipGroupCategoryId().intValue());
 
-		//创建班级信息
-		ClassGroup classGroup=new ClassGroup();
+		// 创建班级信息
+		ClassGroup classGroup = new ClassGroup();
 		classGroup.setSubjectIdList(vipGroupApplyBaseInfoDto.getSubjectIdList());
 		classGroup.setExpectStudentNum(vipGroupCategory.getStudentNum());
 		classGroup.setName(vipGroupApplyBaseInfoDto.getName());
 		classGroup.setExpectStudentNum(vipGroupApplyBaseInfoDto.getExpectStudentNum());
-		classGroup.setTotalClassTimes(vipGroupApplyBaseInfoDto.getOnlineClassesNum()+vipGroupApplyBaseInfoDto.getOfflineClassesNum());
+		classGroup.setTotalClassTimes(vipGroupApplyBaseInfoDto.getOnlineClassesNum() + vipGroupApplyBaseInfoDto.getOfflineClassesNum());
 		classGroup.setType(ClassGroupTypeEnum.VIP);
 		classGroup.setDelFlag(YesOrNoEnum.NO);
 		classGroupDao.insert(classGroup);
 
-		//创建vip课班级关联记录
-		VipGroupClassGroupMapper vipGroupClassGroupMapper=new VipGroupClassGroupMapper();
+		// 创建vip课班级关联记录
+		VipGroupClassGroupMapper vipGroupClassGroupMapper = new VipGroupClassGroupMapper();
 		vipGroupClassGroupMapper.setVipGroupId(vipGroupApplyBaseInfoDto.getId());
 		vipGroupClassGroupMapper.setClassGroupId(classGroup.getId());
 		vipGroupClassGroupMapperDao.insert(vipGroupClassGroupMapper);
 
-		//创建融云班级群
+		// 创建融云班级群
 		// 指导老师加入群组
-		ImGroupMember[] imGroupMembers = { new ImGroupMember(vipGroup.getVipGroupApplyBaseInfo().getUserId().toString())};
+		ImGroupMember[] imGroupMembers = { new ImGroupMember(vipGroup.getVipGroupApplyBaseInfo().getUserId().toString()) };
 		// 创建群组
 		imFeignService.groupCreate(new ImGroupModel(classGroup.getId().toString(), imGroupMembers, classGroup.getName()));
 
-		//创建班级老师关联记录
-		ClassGroupTeacherMapper classGroupTeacherMapper=new ClassGroupTeacherMapper();
+		// 创建班级老师关联记录
+		ClassGroupTeacherMapper classGroupTeacherMapper = new ClassGroupTeacherMapper();
 		classGroupTeacherMapper.setTeacherRole(TeachTypeEnum.BISHOP);
 		classGroupTeacherMapper.setUserId(vipGroupApplyBaseInfoDto.getUserId());
 		classGroupTeacherMapperDao.insert(classGroupTeacherMapper);
 
-		//创建班级与老师课酬记录
-		ClassGroupTeacherSalary classGroupTeacherSalary=new ClassGroupTeacherSalary();
+		// 创建班级与老师课酬记录
+		ClassGroupTeacherSalary classGroupTeacherSalary = new ClassGroupTeacherSalary();
 		classGroupTeacherSalary.setTeacherRole(TeachTypeEnum.BISHOP);
 		classGroupTeacherSalary.setUserId(vipGroupApplyBaseInfoDto.getUserId());
 		classGroupTeacherSalary.setSalary(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary());
 		classGroupTeacherSalary.setOnlineClassesSalary(vipGroupApplyBaseInfoDto.getOnlineTeacherSalary());
 		classGroupTeacherSalaryDao.insert(classGroupTeacherSalary);
 
-		//课程信息调整
-		vipGroup.getCourseSchedules().forEach(courseSchedule -> {
-		    if(courseSchedule.getEndClassTime().after(vipGroupActivity.getCoursesEndTime())
-                &&courseSchedule.getStartClassTime().before(vipGroupActivity.getCoursesStartTime())){
-		        throw new BizException("课时安排时间超出范围!");
-            }
-		    courseSchedule.setTeacherId(vipGroupApplyBaseInfoDto.getUserId().longValue());
-			courseSchedule.setStatus(CourseStatusEnum.NOT_START);
-		    courseSchedule.setType(CourseSchedule.CourseScheduleType.VIP);
-			courseSchedule.setClassGroupId(classGroup.getId());
-		});
+		// 课程信息调整
+		vipGroup.getCourseSchedules().forEach(
+				courseSchedule -> {
+					if (courseSchedule.getEndClassTime().after(vipGroupActivity.getCoursesEndTime())
+							&& courseSchedule.getStartClassTime().before(vipGroupActivity.getCoursesStartTime())) {
+						throw new BizException("课时安排时间超出范围!");
+					}
+					courseSchedule.setTeacherId(vipGroupApplyBaseInfoDto.getUserId().longValue());
+					courseSchedule.setStatus(CourseStatusEnum.NOT_START);
+					courseSchedule.setType(CourseSchedule.CourseScheduleType.VIP);
+					courseSchedule.setClassGroupId(classGroup.getId());
+				});
 		courseScheduleService.batchAddCourseSchedule(vipGroup.getCourseSchedules());
 
-		//创建老师单节课课酬信息
-		courseScheduleTeacherSalaryService.createCourseScheduleTeacherVipSalary(vipGroupApplyBaseInfoDto,
-				vipGroup.getCourseSchedules(),
-				vipGroupApplyBaseInfoDto.getOnlineTeacherSalary(),
-				vipGroupApplyBaseInfoDto.getOfflineTeacherSalary());
+		// 创建老师单节课课酬信息
+		courseScheduleTeacherSalaryService.createCourseScheduleTeacherVipSalary(vipGroupApplyBaseInfoDto, vipGroup.getCourseSchedules(),
+				vipGroupApplyBaseInfoDto.getOnlineTeacherSalary(), vipGroupApplyBaseInfoDto.getOfflineTeacherSalary());
 	}
 
 	@Override
@@ -230,7 +305,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 	@Override
 	public Map<String, Object> findVipGroupTeachingRecord(VipGroupTeachingRecordQueryInfo queryInfo) {
-		if(Objects.isNull(queryInfo.getVipGroupId())){
+		if (Objects.isNull(queryInfo.getVipGroupId())) {
 			throw new BizException("请指定vip课程!");
 		}
 		PageInfo pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
@@ -251,18 +326,18 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		TeachingRecordBaseInfo classTimes = vipGroupDao.getClassTimes(queryInfo.getVipGroupId());
 		classTimes.setIsSalaryNum(vipGroupDao.countIsSalaryNum(queryInfo.getVipGroupId()));
 		classTimes.setComplaintsNum(vipGroupDao.countComplaintsNum(queryInfo.getVipGroupId()));
-		Map<String,Object> result=new HashMap<>();
-		result.put("pageInfo",pageInfo);
-		result.put("baseInfo",classTimes);
+		Map<String, Object> result = new HashMap<>();
+		result.put("pageInfo", pageInfo);
+		result.put("baseInfo", classTimes);
 		return result;
 	}
 
 	@Override
 	public TeachingRecordBaseInfo findTeachingRecordBaseInfo(Long vipGroupId) {
-        TeachingRecordBaseInfo classTimes = vipGroupDao.getClassTimes(vipGroupId);
-        classTimes.setIsSalaryNum(vipGroupDao.countIsSalaryNum(vipGroupId));
-        classTimes.setComplaintsNum(vipGroupDao.countComplaintsNum(vipGroupId));
-        return classTimes;
+		TeachingRecordBaseInfo classTimes = vipGroupDao.getClassTimes(vipGroupId);
+		classTimes.setIsSalaryNum(vipGroupDao.countIsSalaryNum(vipGroupId));
+		classTimes.setComplaintsNum(vipGroupDao.countComplaintsNum(vipGroupId));
+		return classTimes;
 	}
 
 	@Override
@@ -287,11 +362,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 	@Override
 	public VipGroupManageDetailDto getVipGroupDetail(Long vipGroupId) {
-		if(Objects.isNull(vipGroupId)){
+		if (Objects.isNull(vipGroupId)) {
 			throw new BizException("请指定vip课程");
 		}
 		VipGroupManageDetailDto vipGroupBaseInfo = vipGroupDao.getVipGroupBaseInfo(vipGroupId);
-		vipGroupBaseInfo.setSubjectName(StringUtils.join(subjectDao.findBySubIds(vipGroupBaseInfo.getSubjectIdList()),","));
+		vipGroupBaseInfo.setSubjectName(StringUtils.join(subjectDao.findBySubIds(vipGroupBaseInfo.getSubjectIdList()), ","));
 		return vipGroupBaseInfo;
 	}
 
@@ -317,162 +392,167 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 	@Override
 	public StudentVipGroupDetailDto getVipGroupShowDetail(Long vipGroupId) {
-		if(Objects.isNull(vipGroupId)){
+		if (Objects.isNull(vipGroupId)) {
 			throw new BizException("请指定vip课程");
 		}
-        StudentVipGroupDetailDto vipGroupDetail = vipGroupDao.getVipGroupDetail(vipGroupId);
-        vipGroupDetail.setNumberOfClasses(vipGroupDao.countTeacherVipGroups(vipGroupDetail.getTeacherId().longValue()));
-        return vipGroupDetail;
+		StudentVipGroupDetailDto vipGroupDetail = vipGroupDao.getVipGroupDetail(vipGroupId);
+		vipGroupDetail.setNumberOfClasses(vipGroupDao.countTeacherVipGroups(vipGroupDetail.getTeacherId().longValue()));
+		return vipGroupDetail;
 	}
 
 	@Override
 	public VipGroupCostCountDto vipGroupCostCount(VipGroupCostCountParamsDto vipGroupCostCountParamsDto) {
-        SysUser user = sysUserFeignService.queryUserInfo();
-        TeacherDefaultVipGroupSalary teacherDefaultVipGroupSalary = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(user.getId().longValue(), vipGroupCostCountParamsDto.getVipGroupCategoryId());
-        VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = vipGroupDefaultClassesUnitPriceDao.get(vipGroupCostCountParamsDto.getVipGroupDefaultClassesUnitPriceId().intValue());
+		SysUser user = sysUserFeignService.queryUserInfo();
+		TeacherDefaultVipGroupSalary teacherDefaultVipGroupSalary = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(user.getId().longValue(),
+				vipGroupCostCountParamsDto.getVipGroupCategoryId());
+		VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = vipGroupDefaultClassesUnitPriceDao.get(vipGroupCostCountParamsDto
+				.getVipGroupDefaultClassesUnitPriceId().intValue());
 		VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroupCostCountParamsDto.getVipGroupActivityId().intValue());
-        VipGroupSalarySettlementDto vipGroupSalarySettlementDto = JSON.parseObject(vipGroupActivity.getSalarySettlementJson(), VipGroupSalarySettlementDto.class);
-        BigDecimal offlineClassNum=new BigDecimal(vipGroupCostCountParamsDto.getOfflineClassesNum());
-        BigDecimal onlineClassNum=new BigDecimal(vipGroupCostCountParamsDto.getOnlineClassesNum());
-
-
-        //教师课酬
-        BigDecimal teacherOnlineSalary,teacherOfflineSalary,teacherSalary;
-        switch (vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSalarySettlementType()){
-            case TEACHER_DEFAULT:
-                teacherOnlineSalary=teacherDefaultVipGroupSalary.getOnlineClassesSalary().multiply(onlineClassNum);
-                break;
-            case RATIO_DISCOUNT:
-                teacherOnlineSalary=vipGroupDefaultClassesUnitPrice.getOnlineClassesUnitPrice().multiply(vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue()).multiply(onlineClassNum);
-                break;
-            case FIXED_SALARY:
-                teacherOnlineSalary=vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue().multiply(onlineClassNum);
-                break;
-             default:
-                 throw new BizException("未指定课酬结算标准!");
-        }
-        switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()){
-            case TEACHER_DEFAULT:
-                teacherOfflineSalary=teacherDefaultVipGroupSalary.getOfflineClassesSalary().multiply(offlineClassNum);
-                break;
-            case RATIO_DISCOUNT:
-                teacherOfflineSalary=vipGroupDefaultClassesUnitPrice.getOfflineClassesUnitPrice().multiply(vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue()).multiply(offlineClassNum);
-                break;
-            case FIXED_SALARY:
-                teacherOfflineSalary=vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue().multiply(offlineClassNum);
-                break;
-            default:
-                throw new BizException("未指定课酬结算标准!");
-        }
-        teacherSalary=teacherOnlineSalary.add(teacherOfflineSalary);
-        return new VipGroupCostCountDto(null,teacherSalary);
-    }
-
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/10/2
-     * 计算VIP课程预计收费
-     */
-    @Override
-    public Map<String,BigDecimal> countVipGroupPredictFee(VipGroup vipGroup,BigDecimal onlineClassesUnitPrice,BigDecimal offlineClassesUnitPrice){
-		if(Objects.isNull(vipGroup.getUserId())){
+		VipGroupSalarySettlementDto vipGroupSalarySettlementDto = JSON.parseObject(vipGroupActivity.getSalarySettlementJson(),
+				VipGroupSalarySettlementDto.class);
+		BigDecimal offlineClassNum = new BigDecimal(vipGroupCostCountParamsDto.getOfflineClassesNum());
+		BigDecimal onlineClassNum = new BigDecimal(vipGroupCostCountParamsDto.getOnlineClassesNum());
+
+		// 教师课酬
+		BigDecimal teacherOnlineSalary, teacherOfflineSalary, teacherSalary;
+		switch (vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSalarySettlementType()) {
+		case TEACHER_DEFAULT:
+			teacherOnlineSalary = teacherDefaultVipGroupSalary.getOnlineClassesSalary().multiply(onlineClassNum);
+			break;
+		case RATIO_DISCOUNT:
+			teacherOnlineSalary = vipGroupDefaultClassesUnitPrice.getOnlineClassesUnitPrice()
+					.multiply(vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue()).multiply(onlineClassNum);
+			break;
+		case FIXED_SALARY:
+			teacherOnlineSalary = vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue().multiply(onlineClassNum);
+			break;
+		default:
+			throw new BizException("未指定课酬结算标准!");
+		}
+		switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()) {
+		case TEACHER_DEFAULT:
+			teacherOfflineSalary = teacherDefaultVipGroupSalary.getOfflineClassesSalary().multiply(offlineClassNum);
+			break;
+		case RATIO_DISCOUNT:
+			teacherOfflineSalary = vipGroupDefaultClassesUnitPrice.getOfflineClassesUnitPrice()
+					.multiply(vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue()).multiply(offlineClassNum);
+			break;
+		case FIXED_SALARY:
+			teacherOfflineSalary = vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue().multiply(offlineClassNum);
+			break;
+		default:
+			throw new BizException("未指定课酬结算标准!");
+		}
+		teacherSalary = teacherOnlineSalary.add(teacherOfflineSalary);
+		return new VipGroupCostCountDto(null, teacherSalary);
+	}
+
+	/**
+	 * @Author: Joburgess
+	 * @Date: 2019/10/2
+	 * 计算VIP课程预计收费
+	 */
+	@Override
+	public Map<String, BigDecimal> countVipGroupPredictFee(VipGroup vipGroup, BigDecimal onlineClassesUnitPrice, BigDecimal offlineClassesUnitPrice) {
+		if (Objects.isNull(vipGroup.getUserId())) {
 			throw new BizException("请指定教师");
 		}
 
-		if(Objects.isNull(vipGroup.getVipGroupCategoryId())){
+		if (Objects.isNull(vipGroup.getVipGroupCategoryId())) {
 			throw new BizException("请指定课程形式");
 		}
 
-    	TeacherDefaultVipGroupSalary teacherDefaultVipGroupSalary = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(vipGroup.getUserId().longValue(),
+		TeacherDefaultVipGroupSalary teacherDefaultVipGroupSalary = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(vipGroup.getUserId().longValue(),
 				vipGroup.getVipGroupCategoryId());
 
 		VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId().intValue());
 
-		if(Objects.isNull(vipGroupActivity)){
+		if (Objects.isNull(vipGroupActivity)) {
 			throw new BizException("指定的活动方案不存在");
 		}
 
-		VipGroupSalarySettlementDto vipGroupSalarySettlementDto = JSON.parseObject(vipGroupActivity.getSalarySettlementJson(), VipGroupSalarySettlementDto.class);
+		VipGroupSalarySettlementDto vipGroupSalarySettlementDto = JSON.parseObject(vipGroupActivity.getSalarySettlementJson(),
+				VipGroupSalarySettlementDto.class);
 
-		if(Objects.isNull(vipGroupSalarySettlementDto)){
+		if (Objects.isNull(vipGroupSalarySettlementDto)) {
 			throw new BizException("课酬结算方案错误");
 		}
 
-		Map<String,BigDecimal> results=new HashMap<>(1);
+		Map<String, BigDecimal> results = new HashMap<>(1);
 
-		BigDecimal offlineClassNum=new BigDecimal(vipGroup.getOfflineClassesNum());
-		BigDecimal onlineClassNum=new BigDecimal(vipGroup.getOnlineClassesNum());
+		BigDecimal offlineClassNum = new BigDecimal(vipGroup.getOfflineClassesNum());
+		BigDecimal onlineClassNum = new BigDecimal(vipGroup.getOnlineClassesNum());
 		BigDecimal onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
 		BigDecimal offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
 
-		//教师课酬线上单课酬计算
-		switch (vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSalarySettlementType()){
-			case TEACHER_DEFAULT:
-				if(Objects.isNull(teacherDefaultVipGroupSalary)){
-					throw new BizException("未设置教师默认课酬");
-				}
-				results.put("onlineTeacherSalary",teacherDefaultVipGroupSalary.getOfflineClassesSalary());
-				break;
-			case RATIO_DISCOUNT:
-				results.put("onlineTeacherSalary",onlineClassesUnitPrice.multiply((vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue())));
-				break;
-			case FIXED_SALARY:
-				results.put("onlineTeacherSalary",vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue());
-				break;
-			default:
-				throw new BizException("未指定课酬结算标准!");
-		}
-		//教师线下单课酬计算
-		switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()){
-			case TEACHER_DEFAULT:
-				if(Objects.isNull(teacherDefaultVipGroupSalary)){
-					throw new BizException("未设置教师默认课酬");
-				}
-				results.put("offlineTeacherSalary",teacherDefaultVipGroupSalary.getOfflineClassesSalary());
-				break;
-			case RATIO_DISCOUNT:
-				results.put("offlineTeacherSalary",offlineClassesUnitPrice.multiply(vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue()));
-				break;
-			case FIXED_SALARY:
-				results.put("offlineTeacherSalary",vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue());
-				break;
-			default:
-				throw new BizException("未指定课酬结算标准!");
-		}
-
-		//课程购买费用计算
+		// 教师课酬线上单课酬计算
+		switch (vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSalarySettlementType()) {
+		case TEACHER_DEFAULT:
+			if (Objects.isNull(teacherDefaultVipGroupSalary)) {
+				throw new BizException("未设置教师默认课酬");
+			}
+			results.put("onlineTeacherSalary", teacherDefaultVipGroupSalary.getOfflineClassesSalary());
+			break;
+		case RATIO_DISCOUNT:
+			results.put("onlineTeacherSalary", onlineClassesUnitPrice.multiply((vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue())));
+			break;
+		case FIXED_SALARY:
+			results.put("onlineTeacherSalary", vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue());
+			break;
+		default:
+			throw new BizException("未指定课酬结算标准!");
+		}
+		// 教师线下单课酬计算
+		switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()) {
+		case TEACHER_DEFAULT:
+			if (Objects.isNull(teacherDefaultVipGroupSalary)) {
+				throw new BizException("未设置教师默认课酬");
+			}
+			results.put("offlineTeacherSalary", teacherDefaultVipGroupSalary.getOfflineClassesSalary());
+			break;
+		case RATIO_DISCOUNT:
+			results.put("offlineTeacherSalary", offlineClassesUnitPrice.multiply(vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue()));
+			break;
+		case FIXED_SALARY:
+			results.put("offlineTeacherSalary", vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue());
+			break;
+		default:
+			throw new BizException("未指定课酬结算标准!");
+		}
+
+		// 课程购买费用计算
 		BigDecimal totalPrice;
-		switch (vipGroupActivity.getType()){
-			case BASE_ACTIVITY:
-				totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
-				break;
-			case DISCOUNT:
-				BigDecimal discount=new BigDecimal(vipGroupActivity.getAttribute1());
-				totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
-				totalPrice=totalPrice.multiply(discount);
-				break;
-			case GIVE_CLASS:
-				if(vipGroup.getGiveTeachMode()==TeachModeEnum.OFFLINE){
-					if(offlineClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))>-1){
-						offlineClassNum=offlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
-					}
-					offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
-				}else if(vipGroup.getGiveTeachMode()==TeachModeEnum.ONLINE){
-					if(onlineClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))>-1){
-						onlineClassNum=onlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
-					}
-					onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
-				}else{
-					throw new BizException("请指定赠送课程类型!");
+		switch (vipGroupActivity.getType()) {
+		case BASE_ACTIVITY:
+			totalPrice = onlineVipGroupCharge.add(offlineVipGroupCharge);
+			break;
+		case DISCOUNT:
+			BigDecimal discount = new BigDecimal(vipGroupActivity.getAttribute1());
+			totalPrice = onlineVipGroupCharge.add(offlineVipGroupCharge);
+			totalPrice = totalPrice.multiply(discount);
+			break;
+		case GIVE_CLASS:
+			if (vipGroup.getGiveTeachMode() == TeachModeEnum.OFFLINE) {
+				if (offlineClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1())) > -1) {
+					offlineClassNum = offlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
+				}
+				offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
+			} else if (vipGroup.getGiveTeachMode() == TeachModeEnum.ONLINE) {
+				if (onlineClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1())) > -1) {
+					onlineClassNum = onlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
 				}
-				totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
-				break;
-			default:
-				throw new BizException("活动类型错误!");
+				onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
+			} else {
+				throw new BizException("请指定赠送课程类型!");
+			}
+			totalPrice = onlineVipGroupCharge.add(offlineVipGroupCharge);
+			break;
+		default:
+			throw new BizException("活动类型错误!");
 		}
-		results.put("totalPrice",totalPrice);
-        return results;
-    }
+		results.put("totalPrice", totalPrice);
+		return results;
+	}
 
 	@Transactional(rollbackFor = Exception.class)
 	@Override
@@ -481,51 +561,46 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 		StudentPaymentOrder byStudentVipGroup = studentPaymentOrderDao.findByStudentVipGroup(vipGroupBuyParams.getVipGroupId(), user.getId().longValue());
 
-		if(Objects.nonNull(byStudentVipGroup)){
+		if (Objects.nonNull(byStudentVipGroup)) {
 			throw new BizException("订单已存在!");
 		}
 
 		VipGroup vipGroup = vipGroupDao.get(vipGroupBuyParams.getVipGroupId());
 
-		if(vipGroup.getStatus()!=VipGroupStatusEnum.APPLYING){
+		if (vipGroup.getStatus() != VipGroupStatusEnum.APPLYING) {
 			throw new BizException("该课程已结束报名!");
 		}
 
 		VipGroupClassGroupMapper vipGroupClassGroupMapper = vipGroupClassGroupMapperDao.findByVipGroupId(vipGroup.getId());
 
 		VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId().intValue());
-		StudentPaymentOrder studentPaymentOrder=new StudentPaymentOrder();
+		StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
 		studentPaymentOrder.setUserId(user.getId());
-		String orderNo=StringUtils.join(new String[]{user.getId().toString(),String.valueOf(System.currentTimeMillis())});
+		String orderNo = StringUtils.join(new String[] { user.getId().toString(), String.valueOf(System.currentTimeMillis()) });
 		studentPaymentOrder.setOrderNo(orderNo);
 		studentPaymentOrder.setType(OrderTypeEnum.SMALL_CLASS_TO_BUY);
 		studentPaymentOrder.setExpectAmount(vipGroup.getTotalPrice());
-		if(vipGroupActivity.getType()==VipGroupActivityTypeEnum.DISCOUNT){
+		if (vipGroupActivity.getType() == VipGroupActivityTypeEnum.DISCOUNT) {
 			studentPaymentOrder.setActualAmount(studentPaymentOrder.getExpectAmount().multiply(new BigDecimal(vipGroupActivity.getAttribute1())));
-		}else{
+		} else {
 			studentPaymentOrder.setActualAmount(studentPaymentOrder.getExpectAmount());
 		}
 		studentPaymentOrder.setMusicGroupId(vipGroup.getId().toString());
 		studentPaymentOrder.setClassGroupId(vipGroupClassGroupMapper.getClassGroupId());
 		studentPaymentOrderDao.insert(studentPaymentOrder);
 
-		StudentVipGroupPayment studentVipGroupPayment=new StudentVipGroupPayment();
+		StudentVipGroupPayment studentVipGroupPayment = new StudentVipGroupPayment();
 		studentVipGroupPayment.setUserId(user.getId());
 		studentVipGroupPayment.setVipGroupId(vipGroup.getId());
 		studentVipGroupPayment.setClassGroupId(vipGroupClassGroupMapper.getClassGroupId());
 		studentVipGroupPayment.setStudentPaymentOrderId(studentPaymentOrder.getId());
 		studentVipGroupPaymentDao.insert(studentVipGroupPayment);
 
-		//更新班级人数,如果订单支付失败则减少
-		classGroupService.updateClassStudentNum(vipGroupClassGroupMapper.getClassGroupId().longValue(),1);
+		// 更新班级人数,如果订单支付失败则减少
+		classGroupService.updateClassStudentNum(vipGroupClassGroupMapper.getClassGroupId().longValue(), 1);
 
-		//生成回调地址
-		Map payMap = payService.getPayMap(
-				vipGroup.getTotalPrice(),
-				orderNo,
-				"https://pay.dayaedu.com/api/yqpay/notify",
-				"http://dev.dayaedu.com",
-				"vip课购买",
+		// 生成回调地址
+		Map payMap = payService.getPayMap(vipGroup.getTotalPrice(), orderNo, "https://pay.dayaedu.com/api/yqpay/notify", "http://dev.dayaedu.com", "vip课购买",
 				vipGroup.getName());
 
 		return payMap;
@@ -536,54 +611,53 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 	@Transactional(rollbackFor = Exception.class)
 	public void orderCallback(String callbackParams) {
 		/*
-		根据回调信息调整订单状态及vip课程状态等相关信息
+		 * 根据回调信息调整订单状态及vip课程状态等相关信息
 		 */
-		Long vipGroupId=1L,userId=1L;
+		Long vipGroupId = 1L, userId = 1L;
 
 		VipGroup vipGroup = vipGroupDao.get(vipGroupId);
 
-		//生成学生单课缴费信息
-		courseScheduleStudentPaymentService.createCourseScheduleStudentPaymentForVipGroup(vipGroupId,userId);
+		// 生成学生单课缴费信息
+		courseScheduleStudentPaymentService.createCourseScheduleStudentPaymentForVipGroup(vipGroupId, userId);
 
 		VipGroupClassGroupMapper vipGroupClassGroupMapper = vipGroupClassGroupMapperDao.findByVipGroupId(vipGroupId);
 
-		//更新订单状态
-		StudentPaymentOrder studentPaymentOrder=studentPaymentOrderDao.findByStudentVipGroup(vipGroupId,userId);
+		// 更新订单状态
+		StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, userId);
 		studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
 		studentPaymentOrderDao.update(studentPaymentOrder);
 
-		//将学生加入到班级,更新班级报名状态及人数信息
+		// 将学生加入到班级,更新班级报名状态及人数信息
 		ClassGroup classGroup = classGroupDao.get(vipGroupClassGroupMapper.getClassGroupId());
 		int classStudents = classGroupDao.countClassStudent(vipGroupClassGroupMapper.getClassGroupId().longValue());
-		if(classGroup.getExpectStudentNum()==classStudents){
+		if (classGroup.getExpectStudentNum() == classStudents) {
 			vipGroup.setStatus(VipGroupStatusEnum.FINISH);
 			vipGroupDao.update(vipGroup);
 		}
-		classGroup.setStudentNum(classGroup.getStudentNum()+1);
+		classGroup.setStudentNum(classGroup.getStudentNum() + 1);
 		classGroupDao.update(classGroup);
 
 	}
 
 	@Transactional(rollbackFor = Exception.class)
 	@Override
-	public void applyRefund(Long vipGroupId,Long studentId) {
-		SysUser sysUser=sysUserFeignService.queryUserInfo();
-    	if(null==studentId){
-    		studentId=sysUser.getId().longValue();
-		}
-		StudentApplyRefunds studentApplyRefunds=new StudentApplyRefunds();
-		StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId,studentId);
-		if(null==studentPaymentOrder){
+	public void applyRefund(Long vipGroupId, Long studentId) {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (null == studentId) {
+			studentId = sysUser.getId().longValue();
+		}
+		StudentApplyRefunds studentApplyRefunds = new StudentApplyRefunds();
+		StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, studentId);
+		if (null == studentPaymentOrder) {
 			throw new BizException("未找到相关订单信息!");
 		}
-		VipGroup vipGroup=vipGroupDao.get(vipGroupId);
-		//剩余课时数
-		Map surplusClassTimes=MapUtil.convertMybatisMap(vipGroupDao.countSurplusClassTimes(vipGroupId));
-		studentApplyRefunds.setExpectAmount(countVipGroupPredictFee(vipGroup,
-				new BigDecimal(surplusClassTimes.get(TeachModeEnum.ONLINE.getCode()).toString()),
+		VipGroup vipGroup = vipGroupDao.get(vipGroupId);
+		// 剩余课时数
+		Map surplusClassTimes = MapUtil.convertMybatisMap(vipGroupDao.countSurplusClassTimes(vipGroupId));
+		studentApplyRefunds.setExpectAmount(countVipGroupPredictFee(vipGroup, new BigDecimal(surplusClassTimes.get(TeachModeEnum.ONLINE.getCode()).toString()),
 				new BigDecimal(surplusClassTimes.get(TeachModeEnum.OFFLINE.getCode()).toString())).get("totalPrice"));
 		studentApplyRefunds.setStatus(AuditStatusEnum.ING);
-		String orderNo=StringUtils.join(new String[]{studentId.toString(),String.valueOf(System.currentTimeMillis())});
+		String orderNo = StringUtils.join(new String[] { studentId.toString(), String.valueOf(System.currentTimeMillis()) });
 		studentApplyRefunds.setOrderNo(orderNo);
 		studentApplyRefunds.setOrigPaymentOrderId(studentPaymentOrder.getId());
 		studentApplyRefunds.setUserId(studentId.intValue());
@@ -593,44 +667,44 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 	@Transactional(rollbackFor = Exception.class)
 	@Override
 	public void applyRefundAudit(StudentApplyRefunds studentApplyRefunds) {
-    	if(Objects.isNull(studentApplyRefunds.getId())){
-    		throw new BizException("请指定退费订单!");
+		if (Objects.isNull(studentApplyRefunds.getId())) {
+			throw new BizException("请指定退费订单!");
 		}
-		StudentApplyRefunds oldStudentApplyRefunds=studentApplyRefundsDao.get(studentApplyRefunds.getId());
+		StudentApplyRefunds oldStudentApplyRefunds = studentApplyRefundsDao.get(studentApplyRefunds.getId());
 		oldStudentApplyRefunds.setStatus(studentApplyRefunds.getStatus());
-		if(null==studentApplyRefunds.getActualAmount()){
+		if (null == studentApplyRefunds.getActualAmount()) {
 			oldStudentApplyRefunds.setActualAmount(oldStudentApplyRefunds.getExpectAmount());
-		}else{
+		} else {
 			oldStudentApplyRefunds.setActualAmount(studentApplyRefunds.getActualAmount());
 		}
 		oldStudentApplyRefunds.setRemark(studentApplyRefunds.getRemark());
 		studentApplyRefundsDao.update(oldStudentApplyRefunds);
-		switch (studentApplyRefunds.getStatus()){
-			case PASS:
-				sysUserCashAccountService.updateBalance(oldStudentApplyRefunds.getUserId(),oldStudentApplyRefunds.getActualAmount());
-				SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(studentApplyRefunds.getUserId().intValue());
-				SysUserCashAccountDetail sysUserCashAccountDetail=new SysUserCashAccountDetail();
-				sysUserCashAccountDetail.setUserId(studentApplyRefunds.getUserId());
-				sysUserCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.REFUNDS);
-				sysUserCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
-				sysUserCashAccountDetail.setAmount(oldStudentApplyRefunds.getActualAmount());
-				sysUserCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
-				sysUserCashAccountDetail.setAttribute(oldStudentApplyRefunds.getId().toString());
-				sysUserCashAccountDetailDao.insert(sysUserCashAccountDetail);
-				break;
-			case REJECT:
-
-				break;
-			default:
-				throw new BizException("审核状态错误!");
+		switch (studentApplyRefunds.getStatus()) {
+		case PASS:
+			sysUserCashAccountService.updateBalance(oldStudentApplyRefunds.getUserId(), oldStudentApplyRefunds.getActualAmount());
+			SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(studentApplyRefunds.getUserId().intValue());
+			SysUserCashAccountDetail sysUserCashAccountDetail = new SysUserCashAccountDetail();
+			sysUserCashAccountDetail.setUserId(studentApplyRefunds.getUserId());
+			sysUserCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.REFUNDS);
+			sysUserCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
+			sysUserCashAccountDetail.setAmount(oldStudentApplyRefunds.getActualAmount());
+			sysUserCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
+			sysUserCashAccountDetail.setAttribute(oldStudentApplyRefunds.getId().toString());
+			sysUserCashAccountDetailDao.insert(sysUserCashAccountDetail);
+			break;
+		case REJECT:
+
+			break;
+		default:
+			throw new BizException("审核状态错误!");
 		}
 	}
 
 	@Override
 	public Map<String, Object> findVipGroupSalarys(VipGroupSalaryQueryInfo queryInfo) {
 
-    	if(Objects.isNull(queryInfo.getVipGroupId())){
-    		throw new BizException("请指定vip课程!");
+		if (Objects.isNull(queryInfo.getVipGroupId())) {
+			throw new BizException("请指定vip课程!");
 		}
 
 		PageInfo pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
@@ -644,13 +718,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			params.put("offset", pageInfo.getOffset());
 			dataList = courseScheduleTeacherSalaryDao.findVipGroupSalarys(params);
 			dataList.forEach(vipGroupSalaryDto -> {
-				if(Objects.isNull(vipGroupSalaryDto.getExpectSalary())){
+				if (Objects.isNull(vipGroupSalaryDto.getExpectSalary())) {
 					vipGroupSalaryDto.setExpectSalary(new BigDecimal(0));
 				}
-				if(Objects.isNull(vipGroupSalaryDto.getActualSalary())){
+				if (Objects.isNull(vipGroupSalaryDto.getActualSalary())) {
 					vipGroupSalaryDto.setActualSalary(new BigDecimal(0));
 					vipGroupSalaryDto.setIsSalary(YesOrNoEnum.NO);
-				}else{
+				} else {
 					vipGroupSalaryDto.setIsSalary(YesOrNoEnum.YES);
 				}
 				vipGroupSalaryDto.setDeductionFee(vipGroupSalaryDto.getExpectSalary().subtract(vipGroupSalaryDto.getActualSalary()));
@@ -662,28 +736,28 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		pageInfo.setRows(dataList);
 
 		VipGroupSalaryBaseInfo vipGroupSalaryBaseInfo = vipGroupDao.getVipGroupSalaryInfo(queryInfo.getVipGroupId());
-		if(Objects.isNull(vipGroupSalaryBaseInfo)){
-			vipGroupSalaryBaseInfo=new VipGroupSalaryBaseInfo();
+		if (Objects.isNull(vipGroupSalaryBaseInfo)) {
+			vipGroupSalaryBaseInfo = new VipGroupSalaryBaseInfo();
 		}
-		if(Objects.isNull(vipGroupSalaryBaseInfo.getExpectTotalSalary())){
+		if (Objects.isNull(vipGroupSalaryBaseInfo.getExpectTotalSalary())) {
 			vipGroupSalaryBaseInfo.setExpectTotalSalary(new BigDecimal(0));
 		}
-		if(Objects.isNull(vipGroupSalaryBaseInfo.getTotalSalary())){
+		if (Objects.isNull(vipGroupSalaryBaseInfo.getTotalSalary())) {
 			vipGroupSalaryBaseInfo.setTotalSalary(new BigDecimal(0));
 		}
 		vipGroupSalaryBaseInfo.setTotalFeeDeduction(vipGroupSalaryBaseInfo.getExpectTotalSalary().subtract(vipGroupSalaryBaseInfo.getTotalSalary()));
 		vipGroupSalaryBaseInfo.setFeeDeductionNum(vipGroupDao.countVipGroupDeductionNum(queryInfo.getVipGroupId()));
 
-		Map<String,Object> result=new HashMap<>();
-		result.put("pageInfo",pageInfo);
-		result.put("baseInfo",vipGroupSalaryBaseInfo);
+		Map<String, Object> result = new HashMap<>();
+		result.put("pageInfo", pageInfo);
+		result.put("baseInfo", vipGroupSalaryBaseInfo);
 		return result;
 	}
 
 	@Override
 	public List<String> findVipGroupAttendanceStudents(Long courseScheduleId) {
-    	if(Objects.isNull(courseScheduleId)){
-    		throw new BizException("请指定课程");
+		if (Objects.isNull(courseScheduleId)) {
+			throw new BizException("请指定课程");
 		}
 		return courseScheduleDao.findStudentNamesByCourseSchedule(courseScheduleId);
 	}
@@ -691,36 +765,36 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void stopGroup(Long vipGroupId) {
-    	if(Objects.isNull(vipGroupId)){
-    		throw new BizException("请指定vip课");
+		if (Objects.isNull(vipGroupId)) {
+			throw new BizException("请指定vip课");
 		}
 		VipGroup vipGroup = vipGroupDao.get(vipGroupId);
-    	if(Objects.isNull(vipGroup)){
-    		throw new BizException("该课程不存在");
+		if (Objects.isNull(vipGroup)) {
+			throw new BizException("该课程不存在");
 		}
-    	if(vipGroup.getStatus()==VipGroupStatusEnum.FINISH||vipGroup.getStatus()==VipGroupStatusEnum.CANCEL){
-    		throw new BizException("该课程已结束或者已被停止,无法进行此操作");
+		if (vipGroup.getStatus() == VipGroupStatusEnum.FINISH || vipGroup.getStatus() == VipGroupStatusEnum.CANCEL) {
+			throw new BizException("该课程已结束或者已被停止,无法进行此操作");
 		}
-    	if(vipGroup.getStatus()==VipGroupStatusEnum.NOT_START){
+		if (vipGroup.getStatus() == VipGroupStatusEnum.NOT_START) {
 			vipGroup.setStatus(VipGroupStatusEnum.CANCEL);
-    		vipGroupDao.update(vipGroup);
-    		return;
+			vipGroupDao.update(vipGroup);
+			return;
 		}
 		List<Map<Long, BigDecimal>> maps = vipGroupDao.countSurplusCourseFee(vipGroupId);
-    	if(CollectionUtils.isEmpty(maps)||(maps.size()==1&&Objects.isNull(maps.get(0)))){
+		if (CollectionUtils.isEmpty(maps) || (maps.size() == 1 && Objects.isNull(maps.get(0)))) {
 			vipGroup.setStatus(VipGroupStatusEnum.CANCEL);
 			vipGroupDao.update(vipGroup);
 			return;
 		}
 		Map<Long, BigDecimal> studentSurplusClassFees = MapUtil.convertMybatisMap(maps);
-    	for(Long userId:studentSurplusClassFees.keySet()){
-			StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId,userId);
-			if(null==studentPaymentOrder){
+		for (Long userId : studentSurplusClassFees.keySet()) {
+			StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, userId);
+			if (null == studentPaymentOrder) {
 				throw new BizException("未找到相关订单信息!");
 			}
-			sysUserCashAccountService.updateBalance(userId.intValue(),studentSurplusClassFees.get(userId));
+			sysUserCashAccountService.updateBalance(userId.intValue(), studentSurplusClassFees.get(userId));
 			SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(userId.intValue());
-			SysUserCashAccountDetail sysUserCashAccountDetail=new SysUserCashAccountDetail();
+			SysUserCashAccountDetail sysUserCashAccountDetail = new SysUserCashAccountDetail();
 			sysUserCashAccountDetail.setUserId(userId.intValue());
 			sysUserCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.REFUNDS);
 			sysUserCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
@@ -735,6 +809,25 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 	@Override
 	public boolean awardedMonthlyRewards() {
-		return false;
+		List<Map<Integer, Integer>> list = courseScheduleDao.queryVipGroupTeachereClassTimesByMonth(new Date(), CourseStatusEnum.OVER);
+
+		if (list != null && list.size() > 0) {
+
+			Integer organId = null, teacherId = null, coursesTimes = 0;
+
+			for (Map<Integer, Integer> map : list) {
+				organId = map.get("organ_id_");
+				teacherId = map.get("teacher_id_");
+				coursesTimes = map.get("times");
+
+				BigDecimal decimal = courseScheduleRewardsRulesService.queryRewardsAmount(organId, CourseScheduleType.VIP, coursesTimes);
+				if (decimal.doubleValue() > 0) {
+					sysUserCashAccountDetailService.addCashAccountDetail(teacherId, decimal, "", SysUserCashAccountDetailService.ORGAN,
+							PlatformCashAccountDetailTypeEnum.REWARDS, null, DealStatusEnum.SUCCESS, "分部奖励");
+				}
+			}
+		}
+
+		return true;
 	}
 }

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

@@ -665,6 +665,7 @@
             </if>
         </where>
     </select>
+    
     <select id="findClassTypeByCourse" resultType="string">
         SELECT
             cg.type_
@@ -673,4 +674,8 @@
             LEFT JOIN class_group cg ON cs.class_group_id_=cg.id_
             WHERE cs.id_=#{courseScheduleId}
     </select>
+    
+    <select id="queryVipGroupTeachereClassTimesByMonth" resultType="map" parameterType="map">
+        SELECT vp.organ_id_ organ_id_,cs.actual_teacher_id_ teacher_id_,count(cs.id_) times FROM course_schedule cs left join vip_group_class_group_mapper vgm on cs.class_group_id_ = vgm.class_group_id_ left join vip_group vp on vgm.vip_group_id_ = vp.id_ where cs.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} and date_format(#{monthDate} , '%Y%m' ) = date_format(cs.class_date_, '%Y%m' ) group by vp.organ_id_,cs.actual_teacher_id_
+    </select>
 </mapper>

+ 10 - 2
mec-biz/src/main/resources/config/mybatis/VipGroupMapper.xml

@@ -33,6 +33,8 @@
         <result column="current_class_times_" property="currentClassTimes"/>
         <result column="vip_group_category_id_" property="vipGroupCategoryId"/>
         <result column="give_teach_mode_" property="giveTeachMode" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result column="organ_id_" property="organId"/>
+        <result column="schoole_id_" property="schoolId"/>
     </resultMap>
 
     <resultMap id="studentManageVipGroup" type="com.ym.mec.biz.dal.dto.StudentManageVipGroupDto" extends="VipGroup">
@@ -144,8 +146,8 @@
         </selectKey>
         -->
         INSERT INTO vip_group
-        (id_,user_id_,single_class_minutes_,payment_expire_date_,courses_expire_date_,create_time_,update_time_,teacher_school_id_,online_classes_num_,offline_classes_num_,registration_start_time_,name_,organ_id_list_,vip_group_activity_id_,status_,online_classes_unit_price_,offline_classes_unit_price_,total_price_,give_teach_mode_,vip_group_category_id_)
-        VALUES(#{id},#{userId},#{singleClassMinutes},#{paymentExpireDate},#{coursesExpireDate},now(),now(),#{teacherSchoolId},#{onlineClassesNum},#{offlineClassesNum},#{registrationStartTime},#{name},#{organIdList},#{vipGroupActivityId},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{onlineClassesUnitPrice},#{offlineClassesUnitPrice},#{totalPrice},#{giveTeachMode},#{vipGroupCategoryId})
+        (id_,user_id_,single_class_minutes_,payment_expire_date_,courses_expire_date_,create_time_,update_time_,teacher_school_id_,online_classes_num_,offline_classes_num_,registration_start_time_,name_,organ_id_list_,vip_group_activity_id_,status_,online_classes_unit_price_,offline_classes_unit_price_,total_price_,give_teach_mode_,vip_group_category_id_,schoole_id_,organ_id_)
+        VALUES(#{id},#{userId},#{singleClassMinutes},#{paymentExpireDate},#{coursesExpireDate},now(),now(),#{teacherSchoolId},#{onlineClassesNum},#{offlineClassesNum},#{registrationStartTime},#{name},#{organIdList},#{vipGroupActivityId},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{onlineClassesUnitPrice},#{offlineClassesUnitPrice},#{totalPrice},#{giveTeachMode},#{vipGroupCategoryId},#{schoolId},#{organId})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -206,6 +208,12 @@
             <if test="giveTeachMode!=null">
                 give_teach_mode_=#{giveTeachMode}
             </if>
+            <if test="organId!=null">
+                organ_id_=#{organId}
+            </if>
+            <if test="schoolId!=null">
+                schoole_id_=#{schoolId}
+            </if>
         </set>
         WHERE id_ = #{id}
     </update>