Browse Source

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

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupService.java
zouxuan 5 years ago
parent
commit
70409eb723
26 changed files with 460 additions and 243 deletions
  1. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java
  2. 15 6
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java
  3. 12 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleTeacherSalaryDao.java
  4. 5 5
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java
  5. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/VipGroupDao.java
  6. 1 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ClassGroupStudentMapper.java
  7. 0 12
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ClassGroupTeacherSalary.java
  8. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseSchedule.java
  9. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupStudentMapperService.java
  10. 11 2
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupService.java
  11. 17 9
      mec-biz/src/main/java/com/ym/mec/biz/service/VipGroupService.java
  12. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java
  13. 59 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java
  14. 30 85
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java
  15. 51 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  16. 84 83
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java
  17. 10 6
      mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml
  18. 0 10
      mec-biz/src/main/resources/config/mybatis/ClassGroupTeacherSalaryMapper.xml
  19. 31 1
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  20. 10 0
      mec-biz/src/main/resources/config/mybatis/CourseScheduleTeacherSalaryMapper.xml
  21. 2 2
      mec-biz/src/main/resources/config/mybatis/StudentApplyRefundsMapper.xml
  22. 2 2
      mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml
  23. 10 0
      mec-biz/src/main/resources/config/mybatis/VipGroupMapper.xml
  24. 40 0
      mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupStudentController.java
  25. 16 6
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupQuitController.java
  26. 12 5
      mec-web/src/main/java/com/ym/mec/web/controller/VipGroupManageController.java

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

@@ -88,4 +88,12 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
      * @date 2019/10/19
      */
     List<StudentAttendanceViewDto> findStudentByCourse(Long courseScheduleId);
+
+    /**
+     * 查找班级学生对应关系
+     * @param userId
+     * @param classGroupId
+     * @return
+     */
+    ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(@Param("userId") Integer userId, @Param("classGroupId") Integer classGroupId);
 }

+ 15 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -1,20 +1,20 @@
 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.dto.TeacherClassCourseSchudeleDto;
 import com.ym.mec.biz.dal.entity.ClassGroupTeacherMapper;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+import com.ym.mec.biz.dal.entity.CourseScheduleTeacherSalary;
 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> {
 
@@ -56,6 +56,15 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
     List<CourseSchedule> findByCourseScheduleIds(List<Long> courseScheduleIds);
 
     /**
+     * @describe 根据课程编号列表获取助教列表
+     * @author Joburgess
+     * @date 2019/10/23
+     * @param courseScheduleIds: 课程编号列表
+     * @return java.util.List<java.util.Map<java.lang.Integer,java.lang.Integer>>
+     */
+    List<CourseScheduleTeacherSalary> findTeachingTeachers(List<Long> courseScheduleIds);
+
+    /**
      * @Author: Joburgess
      * @Date: 2019/9/17
      * 根据日期获取当日排课信息

+ 12 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleTeacherSalaryDao.java

@@ -3,13 +3,12 @@ package com.ym.mec.biz.dal.dao;
 import com.ym.mec.biz.dal.dto.VipGroupSalaryDto;
 import com.ym.mec.biz.dal.entity.CourseScheduleTeacherSalary;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.ibatis.annotations.Param;
-
 public interface CourseScheduleTeacherSalaryDao extends BaseDAO<Long, CourseScheduleTeacherSalary> {
 
     /**
@@ -58,4 +57,15 @@ public interface CourseScheduleTeacherSalaryDao extends BaseDAO<Long, CourseSche
 	 */
 	int batchUpdateWages(@Param("classGrpupId") Integer classGrpupId, @Param("userId") Integer userId, @Param("salary") BigDecimal salary,
 			@Param("subsidy") BigDecimal subsidy);
+
+	/**
+	 * @describe 批量更新指定班级关联教师预计薪水
+	 * @author Joburgess
+	 * @date 2019/10/23
+	 * @param courseScheduleId: 课程编号
+	 * @param userIds: 课程关联教师编号
+	 * @return int
+	 */
+	int batchUpdateTeacherExpectSalary(@Param("courseScheduleId") Integer courseScheduleId,
+									   @Param("userIds") List<Integer> userIds);
 }

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

@@ -1,16 +1,15 @@
 package com.ym.mec.biz.dal.dao;
 
-import java.util.List;
-
 import com.ym.mec.biz.dal.dto.UserGoodsDto;
-import org.apache.ibatis.annotations.Param;
-
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
 import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrder> {
 
@@ -28,7 +27,8 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
      * @Date: 2019/10/3
      * 根据学生vip课获取缴费订单
      */
-    StudentPaymentOrder findByStudentVipGroup(@Param("vipGroupId") Long vipGroupId, @Param("userId") Integer userId);
+    StudentPaymentOrder findByStudentVipGroup(@Param("vipGroupId") Long vipGroupId,
+                                              @Param("userId") Integer userId);
 
     /**
      * 查询乐团报名的订单

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

@@ -215,4 +215,13 @@ public interface VipGroupDao extends BaseDAO<Long, VipGroup> {
      * @return
      */
     List<School> querySchoolByUserId(Integer userId);
+
+    /**
+     * @describe 根据课程编号获取vip课
+     * @author Joburgess
+     * @date 2019/10/23
+     * @param courseScheduleId: 课程编号
+     * @return com.ym.mec.biz.dal.entity.VipGroup
+     */
+    VipGroup findByCourseSchedule(Integer courseScheduleId);
 }

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

@@ -1,12 +1,10 @@
 package com.ym.mec.biz.dal.entity;
 
-import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
-
 import io.swagger.annotations.ApiModelProperty;
 
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
-import java.util.Date;
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 
 /**
  * 对应数据库表(class_group_student_mapper):

+ 0 - 12
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ClassGroupTeacherSalary.java

@@ -3,21 +3,9 @@ package com.ym.mec.biz.dal.entity;
 import java.math.BigDecimal;
 
 public class ClassGroupTeacherSalary extends ClassGroupTeacherMapper {
-    /**
-     * 课时长
-     */
-    private Integer duration;
     
     private BigDecimal onlineClassesSalary;
 
-    public Integer getDuration() {
-        return duration;
-    }
-
-    public void setDuration(Integer duration) {
-        this.duration = duration;
-    }
-
 	public BigDecimal getOnlineClassesSalary() {
 		return onlineClassesSalary;
 	}

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

@@ -11,6 +11,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -90,6 +91,9 @@ public class CourseSchedule {
 	@ApiModelProperty(value = "实际上课教师", required = false)
 	private Long actualTeacherId;
 
+	@ApiModelProperty(value = "助教编号列表")
+	private List<Integer> teachingTeacherIdList;
+
 	/**  */
 	private java.util.Date createTime;
 
@@ -110,6 +114,14 @@ public class CourseSchedule {
 	
 	private Integer schoolId;
 
+	public List<Integer> getTeachingTeacherIdList() {
+		return teachingTeacherIdList;
+	}
+
+	public void setTeachingTeacherIdList(List<Integer> teachingTeacherIdList) {
+		this.teachingTeacherIdList = teachingTeacherIdList;
+	}
+
 	public String getStartClassTimeStr() {
 		return startClassTimeStr;
 	}

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

@@ -8,4 +8,12 @@ import org.apache.ibatis.annotations.Param;
 import java.util.List;
 
 public interface ClassGroupStudentMapperService extends BaseService<Long, ClassGroupStudentMapper> {
+
+    /**
+     * 查找班级学生对应关系
+     * @param userId
+     * @param classGroupId
+     * @return
+     */
+    ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(Integer userId, Integer classGroupId);
 }

+ 11 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupService.java

@@ -88,13 +88,22 @@ public interface MusicGroupService extends BaseService<String, MusicGroup> {
 	boolean approveQuitMusicGroup(Long id, ApprovalStatus status, String reason);
 
 	/**
+	 * 一键退团
+	 * @param musicGroupId
+	 * @param userId
+	 * @param reason
+	 * @return
+	 */
+	boolean directQuitMusicGroup(String musicGroupId, Integer userId, String reason);
+
+	/**
 	 *  续费
 	 * @param musicGroupId 乐团编号
 	 * @param userId 用户编号
 	 * @return
 	 */
 	Map renew(String musicGroupId, Integer userId);
-	
+
 	/**
 	 * 学生支付订单
 	 * @param studentPaymentOrder
@@ -124,7 +133,7 @@ public interface MusicGroupService extends BaseService<String, MusicGroup> {
 	 * 修改乐团基本信息
 	 * @param subFeeSettingDto
 	 */
-    void updateBaseInfo(SubFeeSettingDto subFeeSettingDto);
+	void updateBaseInfo(SubFeeSettingDto subFeeSettingDto);
 
 	/**
 	 * 获取修改乐团时的基本信息数据

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

@@ -89,13 +89,21 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
     VipGroupManageDetailDto getVipGroupDetail(Long vipGroupId);
 
     /**
-     * @Author: Joburgess
-     * @Date: 2019/10/10
-     * @params [vipGroup, onlineClassesUnitPrice, offlineClassesUnitPrice]
-     * @return java.math.BigDecimal
-     * @describe 计算课程购买总价
+     * @describe 计算vip课程购买总价,及老师课酬
+     * @author Joburgess
+     * @date 2019/10/23
+     * @param vipGroup: vip课程
+     * @param teacherId: 要计算课酬的老师的编号
+     * @param onlineClassesUnitPrice: 线上课程单价
+     * @param offlineClassesUnitPrice: 线下课程单价
+     * @param computeTotalPrice: 是否计算课程购买总价
+     * @return java.util.Map
      */
-    Map countVipGroupPredictFee(VipGroup vipGroup,BigDecimal onlineClassesUnitPrice,BigDecimal offlineClassesUnitPrice);
+    Map countVipGroupPredictFee(VipGroup vipGroup,
+                                Integer teacherId,
+                                BigDecimal onlineClassesUnitPrice,
+                                BigDecimal offlineClassesUnitPrice,
+                                boolean computeTotalPrice);
 
     /**
      * @Author: Joburgess
@@ -128,8 +136,8 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
      * @describe 更新vip课班级人数及状态
      * @author Joburgess
      * @date 2019/10/20
-     * @param vipGroupId:
-     * @param num:
+     * @param vipGroupId: vip课编号
+     * @param num: 人数
      * @return void
      */
     void updateVipGroupStudentNumAndStatus(Long vipGroupId,Integer num);
@@ -168,7 +176,7 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
      * @return void
      * @describe 退课申请审核
      */
-    void applyRefundAudit(Long id,AuditStatusEnum status,String remark);
+    void applyRefundAudit(Long id,AuditStatusEnum status,String remark,BigDecimal amount);
 
     /**
      * @Author: Joburgess

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -21,4 +21,9 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
 	public BaseDAO<Long, ClassGroupStudentMapper> getDAO() {
 		return classGroupStudentMapperDao;
 	}
+
+    @Override
+    public ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(Integer userId, Integer classGroupId) {
+        return classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId,classGroupId);
+    }
 }

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

@@ -6,14 +6,12 @@ import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.ClassDateAdjustDto;
 import com.ym.mec.biz.dal.dto.CourseScheduleDto;
 import com.ym.mec.biz.dal.dto.TeacherAttendanceDto;
-import com.ym.mec.biz.dal.entity.ClassGroupTeacherMapper;
-import com.ym.mec.biz.dal.entity.CourseSchedule;
-import com.ym.mec.biz.dal.entity.CourseScheduleComplaints;
-import com.ym.mec.biz.dal.entity.SysConfig;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.CourseScheduleQueryInfo;
 import com.ym.mec.biz.dal.page.StudentCourseScheduleRecordQueryInfo;
 import com.ym.mec.biz.service.CourseScheduleService;
+import com.ym.mec.biz.service.CourseScheduleTeacherSalaryService;
 import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.biz.service.SysMessageService;
 import com.ym.mec.common.dal.BaseDAO;
@@ -28,6 +26,7 @@ import org.springframework.beans.BeanUtils;
 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.text.SimpleDateFormat;
 import java.util.*;
@@ -53,6 +52,14 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 	private ClassGroupStudentMapperDao classGroupStudentMapperDao;
 	@Autowired
 	private SysMessageService sysMessageService;
+	@Autowired
+	private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
+	@Autowired
+	private VipGroupDao vipGroupDao;
+	@Autowired
+	private TeacherDefaultVipGroupSalaryDao teacherDefaultVipGroupSalaryDao;
+	@Autowired
+	private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
 
 	@Override
 	public BaseDAO<Long, CourseSchedule> getDAO() {
@@ -315,9 +322,15 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		if(oldCourseScheduleList.size()!=newCourseSchedules.size()){
 			throw new BizException("课程信息错误");
 		}
+
+		//课程对应助教集合
+		List<CourseScheduleTeacherSalary> teachingTeacherSalarys = courseScheduleDao.findTeachingTeachers(newCourseScheduleIds);
+		Map<Long, List<CourseScheduleTeacherSalary>> courseTeachingTeacherMaps = teachingTeacherSalarys.stream().collect(Collectors.groupingBy(CourseScheduleTeacherSalary::getCourseScheduleId));
+
 		Map<Long, CourseSchedule> oldCourseSchedules = oldCourseScheduleList.stream().collect(Collectors.toMap(CourseSchedule::getId,courseSchedule -> courseSchedule));
 		newCourseSchedules.forEach(newCourseSchedule -> {
 			CourseSchedule oldCourseSchedule = oldCourseSchedules.get(newCourseSchedule.getId());
+
 			ArrayList<Date> dates = new ArrayList<>();
 			dates.add(newCourseSchedule.getClassDate());
 			List<CourseSchedule> coursesByDates = courseScheduleDao.findOverLapCoursesInDay(dates,newCourseSchedule.getStartClassTime(),newCourseSchedule.getEndClassTime());
@@ -335,9 +348,51 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 				checkStudentIsRepeat(repeatClassGroupIds);
 				courseScheduleDao.update(newCourseSchedule);
 			}
+
+			//被修改的教师编号列表,需要将预计薪水置零
+			List<Integer> beReplaceTeacherIds=new ArrayList<>();
+
 			if(oldCourseSchedule.getType()== CourseSchedule.CourseScheduleType.VIP){
+				if(Objects.isNull(oldCourseSchedule.getActualTeacherId())||!oldCourseSchedule.getActualTeacherId().equals(newCourseSchedule.getActualTeacherId())){
+					VipGroup byCourseSchedule = vipGroupDao.findByCourseSchedule(newCourseSchedule.getId().intValue());
+					TeacherDefaultVipGroupSalary byTeacherAndCategory = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(newCourseSchedule.getActualTeacherId(), byCourseSchedule.getVipGroupCategoryId());
+					List<CourseSchedule> courseSchedules=new ArrayList<>();
+					coursesByDates.add(newCourseSchedule);
+					courseScheduleTeacherSalaryService.createCourseScheduleTeacherVipSalary(byCourseSchedule,
+							courseSchedules,
+							byTeacherAndCategory.getOnlineClassesSalary(),
+							byTeacherAndCategory.getOfflineClassesSalary());
+					beReplaceTeacherIds.add(oldCourseSchedule.getActualTeacherId().intValue());
+				}
+			}else{
+				if(Objects.isNull(oldCourseSchedule.getActualTeacherId())||!oldCourseSchedule.getActualTeacherId().equals(newCourseSchedule.getActualTeacherId())){
+					//如果主教被修改则调整课酬记录
+
+					beReplaceTeacherIds.add(oldCourseSchedule.getActualTeacherId().intValue());
+				}
+				List<CourseScheduleTeacherSalary> courseTeachingTeacherList=courseTeachingTeacherMaps.get(newCourseSchedule.getId());
+				//当前设置的课程助教编号列表
+				List<Integer> currentCourseTeachingTeacherIds=new ArrayList<>();
+				if(!CollectionUtils.isEmpty(courseTeachingTeacherList)){
+					currentCourseTeachingTeacherIds = courseTeachingTeacherList.stream().map(CourseScheduleTeacherSalary::getUserId).collect(Collectors.toList());
+				}
+				//修改后的课程助教编号列表
+				List<Integer> newTeachingTeacherIdList = newCourseSchedule.getTeachingTeacherIdList();
+				//找出重复的助教编号
+				List<Integer> foundInCurrentCourseTeachingTeacherIds = newTeachingTeacherIdList.stream().filter(currentCourseTeachingTeacherIds::contains).collect(Collectors.toList());
 
+				newTeachingTeacherIdList.forEach(newTeacherId->{
+					//如果不在重复列表中,则需要生成对应的课酬记录
+					if(!foundInCurrentCourseTeachingTeacherIds.contains(newTeacherId)){
+						//计算修改后的助教的课酬
+
+
+						beReplaceTeacherIds.add(oldCourseSchedule.getActualTeacherId().intValue());
+					}
+				});
 			}
+			//将被修改的教师预计薪水置零
+			courseScheduleTeacherSalaryDao.batchUpdateTeacherExpectSalary(newCourseSchedule.getId().intValue(),beReplaceTeacherIds);
 		});
 	}
 

+ 30 - 85
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java

@@ -1,14 +1,14 @@
 package com.ym.mec.biz.service.impl;
 
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
+import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.enums.*;
+import com.ym.mec.biz.service.CourseScheduleTeacherSalaryService;
+import com.ym.mec.biz.service.SysConfigService;
+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.service.impl.BaseServiceImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,38 +16,9 @@ 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.biz.dal.dao.CourseScheduleComplaintsDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleTeacherSalaryDao;
-import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
-import com.ym.mec.biz.dal.dao.SysConfigDao;
-import com.ym.mec.biz.dal.dao.TeacherDefaultVipGroupSalaryDao;
-import com.ym.mec.biz.dal.dao.VipGroupActivityDao;
-import com.ym.mec.biz.dal.dto.VipGroupSalarySettlementDto;
-import com.ym.mec.biz.dal.entity.CourseSchedule;
-import com.ym.mec.biz.dal.entity.CourseScheduleComplaints;
-import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
-import com.ym.mec.biz.dal.entity.CourseScheduleTeacherSalary;
-import com.ym.mec.biz.dal.entity.SysConfig;
-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.enums.AuditStatusEnum;
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
-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.service.CourseScheduleTeacherSalaryService;
-import com.ym.mec.biz.service.SysConfigService;
-import com.ym.mec.biz.service.SysUserCashAccountDetailService;
-import com.ym.mec.biz.service.SysUserCashAccountService;
-import com.ym.mec.common.dal.BaseDAO;
-import com.ym.mec.common.exception.BizException;
-import com.ym.mec.common.service.impl.BaseServiceImpl;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long, CourseScheduleTeacherSalary>  implements CourseScheduleTeacherSalaryService {
@@ -65,9 +36,7 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
 	@Autowired
 	private SysUserCashAccountService sysUserCashAccountService;
 	@Autowired
-	private SysUserCashAccountDetailService sysUserCashAccountDetailService;
-	@Autowired
-	private StudentPaymentOrderDao studentPaymentOrderDao;
+	private VipGroupService vipGroupService;
 	
 	@Autowired
 	private SysConfigDao sysConfigDao;
@@ -85,12 +54,8 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
 													List<CourseSchedule> vipCourseSchedules,
 													BigDecimal onlineTeacherSalary,
 													BigDecimal offlineTeacherSalary) {
-		TeacherDefaultVipGroupSalary teacherDefaultVipGroupSalary = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(vipGroup.getUserId().longValue(),
-				vipGroup.getVipGroupCategoryId());
-
 		//获取活动信息
 		VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId().intValue());
-		VipGroupSalarySettlementDto vipGroupSalarySettlementDto = JSON.parseObject(vipGroupActivity.getSalarySettlementJson(), VipGroupSalarySettlementDto.class);
 
 		List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaries=new ArrayList<>();
 		Map<TeachModeEnum, List<CourseSchedule>> courseScheduleGroupByTeachMode = vipCourseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getTeachMode));
@@ -104,45 +69,25 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
 				CourseScheduleTeacherSalary courseScheduleTeacherSalary=new CourseScheduleTeacherSalary();
 				courseScheduleTeacherSalary.setCourseScheduleId(courseSchedules.get(i).getId());
 				courseScheduleTeacherSalary.setTeacherRole(TeachTypeEnum.BISHOP);
-				courseScheduleTeacherSalary.setUserId(vipGroup.getUserId());
+				courseScheduleTeacherSalary.setUserId(courseSchedules.get(i).getActualTeacherId().intValue());
 				courseScheduleTeacherSalary.setClassGroupId(courseSchedules.get(i).getClassGroupId());
 
-				if(teachModeEnum==TeachModeEnum.ONLINE){
-					if(vipGroupActivity.getType()== VipGroupActivityTypeEnum.GIVE_CLASS
-							&&vipGroup.getGiveTeachMode()==teachModeEnum
-							&&i>=Integer.parseInt(vipGroupActivity.getAttribute1())
-							&&"0".equals(vipGroupActivity.getGiveClassPaySalaryFlag())){
-						courseScheduleTeacherSalary.setExpectSalary(new BigDecimal(0));
-					}else {
-						//教师课酬线上单课酬计算
-						switch (vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSalarySettlementType()){
-							case TEACHER_DEFAULT:
-								courseScheduleTeacherSalary.setExpectSalary(teacherDefaultVipGroupSalary.getOnlineClassesSalary());
-								break;
-							case RATIO_DISCOUNT:
-								courseScheduleTeacherSalary.setExpectSalary(onlineTeacherSalary.multiply(vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue()));
-								break;
-							case FIXED_SALARY:
-								courseScheduleTeacherSalary.setExpectSalary(vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue());
-								break;
-							default:
-								throw new BizException("未指定课酬结算标准!");
-						}
-					}
-				}else{
-					//教师线下单课酬计算
-					switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()){
-						case TEACHER_DEFAULT:
-							courseScheduleTeacherSalary.setExpectSalary(teacherDefaultVipGroupSalary.getOfflineClassesSalary());
-							break;
-						case RATIO_DISCOUNT:
-							courseScheduleTeacherSalary.setExpectSalary(offlineTeacherSalary.multiply(vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue()));
-							break;
-						case FIXED_SALARY:
-							courseScheduleTeacherSalary.setExpectSalary(vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue());
-							break;
-						default:
-							throw new BizException("未指定课酬结算标准!");
+				Map<String,BigDecimal> feeInfo = vipGroupService.countVipGroupPredictFee(vipGroup,
+						courseSchedules.get(i).getActualTeacherId().intValue(),
+						onlineTeacherSalary,
+						offlineTeacherSalary,
+						false);
+
+				if(vipGroupActivity.getType()== VipGroupActivityTypeEnum.GIVE_CLASS
+						&&vipGroup.getGiveTeachMode()==teachModeEnum
+						&&i>=Integer.parseInt(vipGroupActivity.getAttribute1())
+						&&"0".equals(vipGroupActivity.getGiveClassPaySalaryFlag())){
+					courseScheduleTeacherSalary.setExpectSalary(new BigDecimal(0));
+				}else {
+					if(teachModeEnum==TeachModeEnum.ONLINE){
+						courseScheduleTeacherSalary.setExpectSalary(feeInfo.get("onlineTeacherSalary"));
+					}else{
+						courseScheduleTeacherSalary.setExpectSalary(feeInfo.get("offlineTeacherSalary"));
 					}
 				}
 				courseScheduleTeacherSalaries.add(courseScheduleTeacherSalary);

+ 51 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service.impl;
 
+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.BasicUserDto;
@@ -94,6 +95,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 	@Autowired
 	private PayService payService;
 
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
 	@Override
 	public BaseDAO<String, MusicGroup> getDAO() {
 		return musicGroupDao;
@@ -338,6 +342,53 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
 	@Override
 	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+	public boolean directQuitMusicGroup(String musicGroupId, Integer userId, String reason) {
+
+		SysUser sysUser = sysUserFeignService.queryUserById(userId);
+		if (sysUser == null) {
+			throw new BizException("获取用户信息失败");
+		}
+
+		Date date = new Date();
+
+		MusicGroupQuit musicGroupQuit = new MusicGroupQuit();
+		musicGroupQuit.setCreateTime(date);
+		musicGroupQuit.setJoinDate(sysUser.getCreateTime());
+		musicGroupQuit.setMusicGroupId(musicGroupId);
+		musicGroupQuit.setUserId(sysUser.getId());
+		musicGroupQuit.setStatus(ApprovalStatus.APPROVED);
+		musicGroupQuit.setReason(reason);
+		musicGroupQuit.setQuitDate(date);
+
+		musicGroupQuitDao.insert(musicGroupQuit);
+
+		classGroupStudentMapperDao.deleteStudentByMusicGroupId(musicGroupId, userId);
+
+		// 判断乐器是否是租赁
+		StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, musicGroupId);
+		if (studentRegistration == null) {
+			throw new BizException("用户注册信息不存在");
+		}
+		// 退团
+		studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.QUIT);
+		studentRegistration.setUpdateTime(date);
+
+		Integer subjectId = studentRegistration.getActualSubjectId();
+		MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
+		if (musicGroupSubjectPlan == null) {
+			throw new BizException("乐团声部费用设置不存在");
+		}
+		if (musicGroupSubjectPlan.getDepositFee().doubleValue() > 0) {
+			// 增加交易流水
+			sysUserCashAccountDetailService.addCashAccountDetail(userId, musicGroupSubjectPlan.getDepositFee(), SysUserCashAccountDetailService.MUSIC_GROUP
+					+ musicGroupId, "", PlatformCashAccountDetailTypeEnum.REFUNDS, null, DealStatusEnum.SUCCESS, "退出乐团");
+		}
+
+		return true;
+	}
+
+	@Override
+	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 	public Map renew(String musicGroupId, Integer userId) {
 
 		MusicGroup musicGroup = this.get(musicGroupId);

+ 84 - 83
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -141,8 +141,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 		//计算课程相关费用信息
 		Map<String, BigDecimal> costInfo = countVipGroupPredictFee(vipGroupApplyBaseInfoDto,
+				vipGroupApplyBaseInfoDto.getUserId(),
 				vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice(),
-				vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice());
+				vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice(),
+				true);
 
 		//如果默认课酬与实际课酬不匹配则需要审批
 		if(costInfo.get("offlineTeacherSalary").compareTo(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary())!=0||
@@ -441,14 +443,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         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())){
+    public Map<String,BigDecimal> countVipGroupPredictFee(VipGroup vipGroup,
+														  Integer teacherId,
+														  BigDecimal onlineClassesUnitPrice,
+														  BigDecimal offlineClassesUnitPrice,
+														  boolean computeTotalPrice){
+		if(Objects.isNull(teacherId)){
 			throw new BizException("请指定教师");
 		}
 
@@ -461,9 +462,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			throw new BizException("未找到课程形式");
 		}
 
-		TeacherDefaultVipGroupSalary teacherDefaultVipGroupSalary = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(vipGroup.getUserId().longValue(),
+		TeacherDefaultVipGroupSalary teacherDefaultVipGroupSalary = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(teacherId.longValue(),
 				vipGroup.getVipGroupCategoryId());
 
+		if(Objects.isNull(vipGroup.getVipGroupActivityId())){
+			throw new BizException("请指定活动方案");
+		}
+
 		VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId().intValue());
 
 		if(Objects.isNull(vipGroupActivity)){
@@ -486,82 +491,75 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		BigDecimal onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
 		BigDecimal offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
 
-		if(vipGroup.getOnlineClassesNum()>0){
-			//教师课酬线上单课酬计算
-			switch (vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSalarySettlementType()){
-				case TEACHER_DEFAULT:
-					if(Objects.isNull(teacherDefaultVipGroupSalary)){
-						throw new BizException("未设置教师默认课酬");
-					}
-					results.put("onlineTeacherSalary",teacherDefaultVipGroupSalary.getOfflineClassesSalary().multiply(classTimeDuty));
-					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("未指定课酬结算标准!");
-			}
-		}else{
-			results.put("onlineTeacherSalary",new BigDecimal(0));
+		//教师课酬线上单课酬计算
+		switch (vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSalarySettlementType()){
+			case TEACHER_DEFAULT:
+				if(Objects.isNull(teacherDefaultVipGroupSalary)){
+					throw new BizException("未设置教师默认课酬");
+				}
+				results.put("onlineTeacherSalary",teacherDefaultVipGroupSalary.getOfflineClassesSalary().multiply(classTimeDuty));
+				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("未指定课酬结算标准!");
 		}
 
-		if(vipGroup.getOfflineClassesNum()>0){
-			//教师线下单课酬计算
-			switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()){
-				case TEACHER_DEFAULT:
-					if(Objects.isNull(teacherDefaultVipGroupSalary)){
-						throw new BizException("未设置教师默认课酬");
-					}
-					results.put("offlineTeacherSalary",teacherDefaultVipGroupSalary.getOfflineClassesSalary().multiply(classTimeDuty));
+		//教师线下单课酬计算
+		switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()){
+			case TEACHER_DEFAULT:
+				if(Objects.isNull(teacherDefaultVipGroupSalary)){
+					throw new BizException("未设置教师默认课酬");
+				}
+				results.put("offlineTeacherSalary",teacherDefaultVipGroupSalary.getOfflineClassesSalary().multiply(classTimeDuty));
+				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("未指定课酬结算标准!");
+		}
+
+		if(computeTotalPrice){
+			//课程购买费用计算
+			BigDecimal totalPrice;
+			switch (vipGroupActivity.getType()){
+				case BASE_ACTIVITY:
+					totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
 					break;
-				case RATIO_DISCOUNT:
-					results.put("offlineTeacherSalary",offlineClassesUnitPrice.multiply(vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue()));
+				case DISCOUNT:
+					BigDecimal discount=new BigDecimal(vipGroupActivity.getAttribute1());
+					totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
+					totalPrice=totalPrice.multiply(discount);
 					break;
-				case FIXED_SALARY:
-					results.put("offlineTeacherSalary",vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue());
+				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("请指定赠送课程类型!");
+					}
+					totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
 					break;
 				default:
-					throw new BizException("未指定课酬结算标准!");
+					throw new BizException("活动类型错误!");
 			}
-		}else{
-			results.put("offlineTeacherSalary",new BigDecimal(0));
-		}
-
-
-		//课程购买费用计算
-		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("请指定赠送课程类型!");
-				}
-				totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
-				break;
-			default:
-				throw new BizException("活动类型错误!");
+			results.put("totalPrice",totalPrice);
 		}
-		results.put("totalPrice",totalPrice);
         return results;
     }
 
@@ -632,8 +630,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		Map payMap = payService.getPayMap(
 				vipGroup.getTotalPrice(),
 				orderNo,
-				"http://47.99.212.176:8000/api-student/studentOrder/notify",
-				"http://dev.dayaedu.com",
+				"http://103.46.128.45:11805/api-student/studentOrder/notify",
+				"http://103.46.128.45:41818/paymentresult",
 				"vip课购买",
 				vipGroup.getName());
 
@@ -651,6 +649,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		Integer userId = order.getUserId();
 		boolean isOk=order.getStatus().equals(DealStatusEnum.SUCCESS);
 
+		studentPaymentOrderDao.update(order);
+
 		//将学生加入到班级,更新班级报名状态及人数信息
 		if(!isOk){
 			updateVipGroupStudentNumAndStatus(vipGroupId,-1);
@@ -693,8 +693,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		//剩余课时数
 		Map surplusClassTimes=MapUtil.convertMybatisMap(vipGroupDao.countSurplusClassTimes(vipGroupId));
 		studentApplyRefunds.setExpectAmount(countVipGroupPredictFee(vipGroup,
+				vipGroup.getUserId(),
 				new BigDecimal(surplusClassTimes.get(TeachModeEnum.ONLINE.getCode()).toString()),
-				new BigDecimal(surplusClassTimes.get(TeachModeEnum.OFFLINE.getCode()).toString())).get("totalPrice"));
+				new BigDecimal(surplusClassTimes.get(TeachModeEnum.OFFLINE.getCode()).toString()),true).get("totalPrice"));
 		studentApplyRefunds.setStatus(AuditStatusEnum.ING);
 		String orderNo=StringUtils.join(new String[]{studentId.toString(),String.valueOf(System.currentTimeMillis())});
 		studentApplyRefunds.setOrderNo(orderNo);
@@ -705,7 +706,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 	@Transactional(rollbackFor = Exception.class)
 	@Override
-	public void applyRefundAudit(Long id, AuditStatusEnum status, String remark) {
+	public void applyRefundAudit(Long id, AuditStatusEnum status, String remark,BigDecimal amount) {
 
 		StudentApplyRefunds studentApplyRefunds = studentApplyRefundsDao.get(id);
 		if (studentApplyRefunds == null) {
@@ -719,7 +720,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 		studentApplyRefunds.setStatus(status);
 		if (studentApplyRefunds.getStatus() == AuditStatusEnum.PASS) {
-			studentApplyRefunds.setActualAmount(studentApplyRefunds.getExpectAmount());
+			studentApplyRefunds.setActualAmount(amount);
 		} else {
 			studentApplyRefunds.setActualAmount(new BigDecimal(0));
 		}
@@ -733,7 +734,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			sysUserCashAccountDetail.setUserId(studentApplyRefunds.getUserId());
 			sysUserCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.REFUNDS);
 			sysUserCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
-			sysUserCashAccountDetail.setAmount(studentApplyRefunds.getActualAmount());
+			sysUserCashAccountDetail.setAmount(amount);
 			sysUserCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
 			sysUserCashAccountDetail.setAttribute(studentApplyRefunds.getId().toString());
 			sysUserCashAccountDetailDao.insert(sysUserCashAccountDetail);

+ 10 - 6
mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml

@@ -134,11 +134,15 @@
             cssp.course_schedule_id_ =#{courseScheduleId}
     </select>
 
-    <delete id="deleteStudentByMusicGroupId" parameterType="map">
-        DELETE FROM class_group_student_mapper WHERE class_group_id_ in (select id_ from class_group where music_group_id_ = #{musicGroupId}) and user_id_ = #{userId}
-    </delete>
+    <update id="deleteStudentByMusicGroupId" parameterType="map">
+        update class_group_student_mapper set status_ = 'QUIT' where class_group_id_ in (select id_ from class_group where music_group_id_ = #{musicGroupId}) and user_id_ = #{userId}
+    </update>
 
-    <delete id="deleteStudentByClassGroupId">
-        DELETE FROM class_group_student_mapper WHERE class_group_id_=#{classGroupId} AND user_id_=#{userId}
-    </delete>
+    <update id="deleteStudentByClassGroupId">
+        update class_group_student_mapper set status_ = 'QUIT' WHERE class_group_id_=#{classGroupId} AND user_id_=#{userId}
+    </update>
+
+    <select id="findClassStudentMapperByUserIdAndClassGroupId" resultMap="ClassGroupStudentMapper">
+        SELECT * FROM class_group_student_mapper WHERE user_id_=#{userId} AND class_group_id_=#{classGroupId} AND status_ = 'NORMAL'
+    </select>
 </mapper>

+ 0 - 10
mec-biz/src/main/resources/config/mybatis/ClassGroupTeacherSalaryMapper.xml

@@ -7,7 +7,6 @@
     <result column="class_group_id_" jdbcType="INTEGER" property="classGroupId" />
     <result column="teacher_role_" jdbcType="VARCHAR" property="teacherRole" />
     <result column="user_id_" jdbcType="INTEGER" property="userId" />
-    <result column="duration_" jdbcType="INTEGER" property="duration" />
     <result column="salary_" jdbcType="DECIMAL" property="salary" />
     <result column="online_classes_salary_" jdbcType="DECIMAL" property="onlineClassesSalary" />
     <result column="create_time_" jdbcType="TIMESTAMP" property="createTime" />
@@ -36,9 +35,6 @@
       <if test="userId != null">
         user_id_,
       </if>
-      <if test="duration != null">
-        duration_,
-      </if>
       <if test="salary != null">
         salary_,
       </if>
@@ -65,9 +61,6 @@
       <if test="userId != null">
         #{userId,jdbcType=INTEGER},
       </if>
-      <if test="duration != null">
-        #{duration,jdbcType=INTEGER},
-      </if>
       <if test="salary != null">
         #{salary,jdbcType=DECIMAL},
       </if>
@@ -98,9 +91,6 @@
       <if test="userId != null">
         user_id_ = #{userId,jdbcType=INTEGER},
       </if>
-      <if test="duration != null">
-        duration_ = #{duration,jdbcType=INTEGER},
-      </if>
       <if test="salary != null">
         salary_ = #{salary,jdbcType=DECIMAL},
       </if>

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

@@ -286,15 +286,45 @@
 
     <select id="findByCourseScheduleIds" resultMap="CourseSchedule">
         SELECT
-            *
+            cs.id_,
+            cs.class_group_id_,
+            cs.status_,
+            cs.subsidy_,
+            cs.class_date_,
+            cs.start_class_time_,
+            cs.end_class_time_,
+            cs.teacher_id_,
+            csts.user_id_ actual_teacher_id_,
+            cs.create_time_,
+            cs.update_time_,
+            cs.teach_mode_,
+            cs.type_,
+            cs.name_,
+            cs.student_num_,
+            cs.leave_student_num_,
+            cs.schoole_id_
         FROM
             course_schedule
+            LEFT JOIN course_schedule_teacher_salary csts ON cs.id_= csts.course_schedule_id_ AND csts.teacher_role_='BISHOP'
         WHERE id_ IN
         <foreach collection="courseScheduleIds" item="id" open="(" close=")" separator=",">
             #{id}
         </foreach>
     </select>
 
+    <select id="findTeachingTeachers" resultMap="com.ym.mec.biz.dal.dao.CourseScheduleTeacherSalaryDao.CourseScheduleTeacherSalary">
+        SELECT
+          csts.*
+        FROM
+          course_schedule_teacher_salary csts
+        WHERE
+          csts.teacher_role_ = 'BISHOP'
+        AND csts.course_schedule_id_ IN
+        <foreach collection="courseScheduleIds" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+    </select>
+
     <select id="getCourseSchedulesWithDate" resultMap="courseScheduleDto">
         SELECT
         cg.id_ seal_class_id_,

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

@@ -166,4 +166,14 @@
 			update_time_ = now()
 		WHERE user_id_ = #{userId} and class_group_id_ = #{classGroupId}
 	</update>
+    <update id="batchUpdateTeacherExpectSalary">
+		UPDATE course_schedule_teacher_salary
+		SET expect_salary_ = 0
+		WHERE
+			course_schedule_id_ = #{courseScheduleId}
+			AND user_id_ IN
+			<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
+				#{userId}
+			</foreach>
+	</update>
 </mapper>

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

@@ -103,10 +103,10 @@
 		SELECT count(1) FROM student_apply_refunds sar left join student_payment_order spo on sar.orig_payment_order_id_ = spo.id_ 
 		where 1=1 
         <if test="startTime != null">
-            and sar.create_time_ = #{startTime}
+            and sar.create_time_ &gt;= #{startTime}
         </if>
         <if test="endTime != null">
-            and sar.create_time_ = #{endTime}
+            and sar.create_time_ &lt;= #{endTime}
         </if>
 	</select>
 </mapper>

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

@@ -160,10 +160,10 @@
     <sql id="queryPaymentOrder">
         <where>
             <if test="orderStartDate != null">
-                AND spo.pay_time_ &gt;= #{orderStartDate}
+                AND spo.create_time_ &gt;= #{orderStartDate}
             </if>
             <if test="orderEndDate != null">
-                AND spo.pay_time_ &lt;= #{orderEndDate}
+                AND spo.create_time_ &lt;= #{orderEndDate}
             </if>
             <if test="paymentType != null">
                 AND spo.type_ = #{paymentType}

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

@@ -631,4 +631,14 @@
             </foreach>
         GROUP BY vgcgm.vip_group_id_
     </select>
+
+    <select id="findByCourseSchedule" resultMap="VipGroup">
+        SELECT
+            vg.*
+        FROM
+            vip_group vg
+            LEFT JOIN vip_group_class_group_mapper vgcgm ON vg.id_=vgcgm.vip_group_id_
+            LEFT JOIN course_schedule cs ON vgcgm.class_group_id_=cs.class_group_id_
+            WHERE cs.id_=#{courseScheduleId}
+    </select>
 </mapper>

+ 40 - 0
mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupStudentController.java

@@ -0,0 +1,40 @@
+package com.ym.mec.web.controller;
+
+
+import com.ym.mec.biz.dal.entity.ClassGroup;
+import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
+import com.ym.mec.biz.service.ClassGroupStudentMapperService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RequestMapping("classGroupStudent")
+@Api(tags = "班级学生服务")
+@RestController
+public class ClassGroupStudentController extends BaseController {
+
+    @Autowired
+    private ClassGroupStudentMapperService classGroupStudentMapperService;
+
+
+    @ApiOperation(value = "删除班级学生")
+    @PostMapping("/del")
+    @PreAuthorize("@pcs.hasPermissions('classGroupStudent/del')")
+    public HttpResponseResult add(Integer userId, Integer classGroupId) throws Exception {
+        ClassGroupStudentMapper classStudentMapper = classGroupStudentMapperService.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId);
+        if (classStudentMapper == null) {
+            return failed("班级学生不存在");
+        }
+        classStudentMapper.setStatus(ClassGroupStudentStatusEnum.QUIT);
+        return succeed(classGroupStudentMapperService.update(classStudentMapper));
+    }
+
+}

+ 16 - 6
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupQuitController.java

@@ -27,34 +27,44 @@ public class MusicGroupQuitController extends BaseController {
 
 	@Autowired
 	private MusicGroupService musicGroupService;
-	
+
 	@Autowired
 	private MusicGroupQuitService musicGroupQuitService;
-	
+
 	@Autowired
 	private SysUserFeignService sysUserFeignService;
 
 	@ApiOperation(value = "分页查询")
 	@GetMapping("/queryPage")
-    @PreAuthorize("@pcs.hasPermissions('musicGroupQuit/queryPage')")
+	@PreAuthorize("@pcs.hasPermissions('musicGroupQuit/queryPage')")
 	public HttpResponseResult queryPage(QueryInfo queryInfo) throws Exception {
 		return succeed(musicGroupQuitService.queryPage(queryInfo));
 	}
-	
+
 	@ApiOperation(value = "单查询")
 	@GetMapping("/query")
-    @PreAuthorize("@pcs.hasPermissions('musicGroupQuit/query')")
+	@PreAuthorize("@pcs.hasPermissions('musicGroupQuit/query')")
 	public HttpResponseResult query(Long id) throws Exception {
 		return succeed(musicGroupQuitService.get(id));
 	}
 
 	@ApiOperation(value = "退团")
 	@PostMapping("/quitMusicGroup")
-    @PreAuthorize("@pcs.hasPermissions('musicGroupQuit/quitMusicGroup')")
+	@PreAuthorize("@pcs.hasPermissions('musicGroupQuit/quitMusicGroup')")
 	@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "退团申请id", required = true, dataType = "Long"),
 			@ApiImplicitParam(name = "status", value = "审批状态(APPROVED, DENIED, PROCESSING)", required = true, dataType = "String"),
 			@ApiImplicitParam(name = "reason", value = "原因", required = true, dataType = "String") })
 	public HttpResponseResult quitMusicGroup(Long id, ApprovalStatus status, String reason) throws Exception {
 		return succeed(musicGroupService.approveQuitMusicGroup(id, status, reason));
 	}
+
+	@ApiOperation(value = "一键退团")
+	@PostMapping("/directQuitMusicGroup")
+	@PreAuthorize("@pcs.hasPermissions('musicGroupQuit/directQuitMusicGroup')")
+	@ApiImplicitParams({ @ApiImplicitParam(name = "musicGroupId", value = "乐团编号", required = true, dataType = "String"),
+			@ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataType = "Integer"),
+			@ApiImplicitParam(name = "reason", value = "原因", required = true, dataType = "String") })
+	public HttpResponseResult directQuitMusicGroup(String musicGroupId, Integer userId, String reason) throws Exception {
+		return succeed(musicGroupService.directQuitMusicGroup(musicGroupId, userId, reason));
+	}
 }

+ 12 - 5
mec-web/src/main/java/com/ym/mec/web/controller/VipGroupManageController.java

@@ -14,14 +14,17 @@ import com.ym.mec.biz.dal.page.VipGroupTeachingRecordQueryInfo;
 import com.ym.mec.biz.service.CourseScheduleService;
 import com.ym.mec.biz.service.VipGroupService;
 import com.ym.mec.common.controller.BaseController;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -95,10 +98,10 @@ public class VipGroupManageController extends BaseController {
     @ApiOperation(value = "退课申请审核")
     @PostMapping("/applyRefundAudit")
     @PreAuthorize("@pcs.hasPermissions('vipGroupManage/applyRefundAudit')")
-	public Object applyRefundAudit(Long id, AuditStatusEnum status, String remark) {
-		vipGroupService.applyRefundAudit(id, status, remark);
-        return succeed();
-    }
+	public Object applyRefundAudit(Long id, AuditStatusEnum status, String remark, BigDecimal amount) {
+		vipGroupService.applyRefundAudit(id, status, remark, amount);
+		return succeed();
+	}
 
     @ApiOperation(value = "获取VIP课教学记录")
     @GetMapping("/findVipGroupTeachingRecord")
@@ -118,7 +121,11 @@ public class VipGroupManageController extends BaseController {
     @PostMapping("/getVipGroupCostCount")
     @PreAuthorize("@pcs.hasPermissions('vipGroupManage/getVipGroupCostCount')")
     public Object getVipGroupCostCount(VipGroup vipGroup){
-        Map results = vipGroupService.countVipGroupPredictFee(vipGroup, vipGroup.getOnlineClassesUnitPrice(), vipGroup.getOfflineClassesUnitPrice());
+        Map results = vipGroupService.countVipGroupPredictFee(vipGroup,
+                vipGroup.getUserId(),
+                vipGroup.getOnlineClassesUnitPrice(),
+                vipGroup.getOfflineClassesUnitPrice(),
+                true);
         return succeed(results);
     }