Browse Source

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

zouxuan 4 năm trước cách đây
mục cha
commit
7ace510611
29 tập tin đã thay đổi với 565 bổ sung158 xóa
  1. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java
  2. 21 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java
  3. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderCourseSettingsDao.java
  4. 26 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java
  5. 26 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RemainCourseTypeDurationDto.java
  6. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SporadicPayDto.java
  7. 20 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java
  8. 7 0
      mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java
  9. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupStudentMapperService.java
  10. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderCourseSettingsService.java
  11. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java
  12. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java
  13. 81 7
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java
  14. 67 82
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java
  15. 18 27
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderCourseSettingsServiceImpl.java
  16. 1 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  17. 106 16
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  18. 8 5
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  19. 10 6
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SporadicChargeInfoImpl.java
  20. 22 0
      mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml
  21. 29 0
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  22. 4 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderCourseSettingsMapper.xml
  23. 18 4
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml
  24. 16 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml
  25. 1 1
      mec-biz/src/main/resources/config/mybatis/SporadicChargeInfo.xml
  26. 7 0
      mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupController.java
  27. 21 0
      mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupStudentController.java
  28. 2 5
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java
  29. 1 1
      mec-web/src/main/java/com/ym/mec/web/controller/education/ActivityController.java

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

@@ -14,6 +14,8 @@ import java.util.List;
 import java.util.Map;
 
 public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStudentMapper> {
+
+    int batchUpdate(@Param("classGroupStudentMappers") List<ClassGroupStudentMapper> classGroupStudentMappers);
     /**
      * 批量插入学生
      *
@@ -183,6 +185,15 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
                                                @Param("groupType") GroupType groupType);
 
     /**
+     * @describe 获取指定班级的所有学员
+     * @author Joburgess
+     * @date 2020.11.04
+     * @param classGroupId:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.ClassGroupStudentMapper>
+     */
+    List<ClassGroupStudentMapper> findAllByClassGroup(@Param("classGroupId") Long classGroupId);
+
+    /**
      * @param classGroupId: 班级编号列表
      * @return java.util.List<com.ym.mec.biz.dal.entity.ClassGroupStudentMapper>
      * @describe 根据班级获取学员

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

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 import com.ym.mec.biz.dal.enums.CourseStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.common.dal.BaseDAO;
+
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
@@ -140,6 +141,18 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
     int deleteMusicGroupCourseSchedulesWithStudent(@Param("courseScheduleIds") List<Long> courseScheduleIds,
                                                    @Param("userId") Integer userId);
 
+    int deleteMusicGroupCourseSchedulesWithStudents(@Param("courseScheduleIds") List<Long> courseScheduleIds,
+                                                   @Param("userIds") List<Integer> userIds);
+
+    /**
+     * @describe 获取班级上未开始的课程
+     * @author Joburgess
+     * @date 2020.11.05
+     * @param classGroupId:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.CourseSchedule>
+     */
+    List<CourseSchedule> getClassGroupNotStartCourse(@Param("classGroupId") Long classGroupId);
+
     /**
      * @param teacherId: 教师编号
      * @param classDate: 上课日期
@@ -1575,4 +1588,12 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @return
      */
     List<Map<Integer, Integer>> queryHasReatClass(@Param("classGroupIds") Set<String> classGroupIds, @Param("teacherId") String teacherId);
+
+    
+    /**
+     * 查询班级未上的课程类型对应的时长
+     * @param classGroupIdList
+     * @return
+     */
+    List<RemainCourseTypeDurationDto> queryRemainCourseTypeDuration(String classGroupIdList);
 }

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

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
@@ -17,6 +18,17 @@ public interface MusicGroupPaymentCalenderCourseSettingsDao extends BaseDAO<Inte
 	 */
 	List<MusicGroupPaymentCalenderCourseSettings> getWithPaymentCalender(@Param("calenderId") Long calenderId);
 
+	/**
+	 * @describe 根据缴费日历和课程类型获取课程价格设置
+	 * @author Joburgess
+	 * @date 2020.11.04
+	 * @param calenderId:
+	 * @param courseType:
+	 * @return com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings
+	 */
+	MusicGroupPaymentCalenderCourseSettings getWithPaymentCalenderAndCourseType(@Param("calenderId") Long calenderId,
+																				@Param("courseType")CourseSchedule.CourseScheduleType courseType);
+
 	int deleteByMusicGroupPaymentCalenderId(Long musicGroupPaymentCalenderId);
 
 	/**

+ 26 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java

@@ -1,12 +1,36 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.ym.mec.biz.dal.entity.CourseSchedule;
 import java.util.List;
 
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
 
 public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, MusicGroupPaymentStudentCourseDetail> {
 
+    /**
+     * @describe 获取指定学员,指定课程,指定课程时长下的可用缴费记录
+     * @author Joburgess
+     * @date 2020.11.04
+     * @param studentId:
+     * @param courseType:
+     * @param courseMinutes:
+     * @return com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail
+     */
+    MusicGroupPaymentStudentCourseDetail getUnUseWithStudentAndCourseTypeAndCourseMinutes(@Param("studentId") Integer studentId,
+                                                                                           @Param("courseType")CourseSchedule.CourseScheduleType courseType,
+                                                                                           @Param("courseMinutes") Integer courseMinutes);
+
+    /**
+     * @describe
+     * @author Joburgess
+     * @date 2020.11.04
+     * @param studentIds:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail>
+     */
+    List<MusicGroupPaymentStudentCourseDetail> getUnUseWithStudents(@Param("studentIds") List<Integer> studentIds);
+
 	int batchInsert(List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList);
-	
-}
+
+}

+ 26 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RemainCourseTypeDurationDto.java

@@ -0,0 +1,26 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+
+public class RemainCourseTypeDurationDto {
+
+	private CourseScheduleType courseType;
+	
+	private Integer remainMinutes;
+
+	public CourseScheduleType getCourseType() {
+		return courseType;
+	}
+
+	public void setCourseType(CourseScheduleType courseType) {
+		this.courseType = courseType;
+	}
+
+	public Integer getRemainMinutes() {
+		return remainMinutes;
+	}
+
+	public void setRemainMinutes(Integer remainMinutes) {
+		this.remainMinutes = remainMinutes;
+	}
+}

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SporadicPayDto.java

@@ -14,6 +14,9 @@ public class SporadicPayDto {
     @ApiModelProperty(value = "支付项编号",required = false)
     private Integer sporadicId;
 
+    @ApiModelProperty(value = "购买数量",required = false)
+    private Integer num = 1;
+
     private boolean isRepeatPay;
 
     @ApiModelProperty(value = "是否余额支付",required = false)
@@ -58,4 +61,12 @@ public class SporadicPayDto {
     public void setUseBalancePayment(Boolean useBalancePayment) {
         isUseBalancePayment = useBalancePayment;
     }
+
+    public Integer getNum() {
+        return num;
+    }
+
+    public void setNum(Integer num) {
+        this.num = num;
+    }
 }

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

@@ -128,6 +128,10 @@ public class MusicGroupPaymentCalender {
 	private java.util.Date createTime;
 
 	private java.util.Date updateTime;
+	
+	private String attribute1;
+	
+	private String attribute2;
 
 	private String studentIds;
 
@@ -328,6 +332,22 @@ public class MusicGroupPaymentCalender {
 		this.paymentAmount = paymentAmount;
 	}
 
+	public String getAttribute1() {
+		return attribute1;
+	}
+
+	public void setAttribute1(String attribute1) {
+		this.attribute1 = attribute1;
+	}
+
+	public String getAttribute2() {
+		return attribute2;
+	}
+
+	public void setAttribute2(String attribute2) {
+		this.attribute2 = attribute2;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java

@@ -438,4 +438,11 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
      * @describe 获取班级信息
      */
     TeacherClassHeadInfo findTeacherClassGroupInfoByCourseId(Integer courseId);
+    
+    /**
+     * 查询指定班级剩余未上课程类型的时长
+     * @param classGroupIdList
+     * @return
+     */
+    List<RemainCourseTypeDurationDto> queryRemainCourseTypeDuration(String classGroupIdList);
 }

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

@@ -10,6 +10,7 @@ import com.ym.mec.common.service.BaseService;
 
 import java.io.IOException;
 import java.util.List;
+import java.util.Set;
 
 public interface ClassGroupStudentMapperService extends BaseService<Long, ClassGroupStudentMapper> {
 
@@ -78,4 +79,14 @@ public interface ClassGroupStudentMapperService extends BaseService<Long, ClassG
      */
     List<ClassGroupStudentInfoDto> findStudentByGroupOrClassGroup(String groupId, Integer classGroupId, GroupType groupType);
 
+    /**
+     * @describe 更新班级学员
+     * @author Joburgess
+     * @date 2020.11.04
+     * @param classGroupId:
+     * @param studentIds:
+     * @return void
+     */
+    void updateClassGroupStudents(Long classGroupId, Set<Integer> studentIds);
+
 }

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

@@ -4,6 +4,7 @@ import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.common.service.BaseService;
 
 import java.util.List;
+import java.util.Map;
 
 public interface MusicGroupPaymentCalenderCourseSettingsService extends BaseService<Integer, MusicGroupPaymentCalenderCourseSettings> {
 
@@ -15,6 +16,6 @@ public interface MusicGroupPaymentCalenderCourseSettingsService extends BaseServ
      * @param studentIds:
      * @return java.util.List<com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings>
      */
-    List<MusicGroupPaymentCalenderCourseSettings> getMusicCourseSettingsWithStudents(String musicGroupId, List<Integer> studentIds);
+    Map<String, Integer> getMusicCourseSettingsWithStudents(String musicGroupId, List<Integer> studentIds);
 
 }

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

@@ -18,7 +18,7 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 	 * @return
 	 */
 	Long create(MusicGroupPaymentCalender musicGroupPaymentCalender);
-
+	
 	/**
 	 * 获取明细
 	 * @param id

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

@@ -2894,4 +2894,9 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         }
         return classGroup;
     }
+
+	@Override
+	public List<RemainCourseTypeDurationDto> queryRemainCourseTypeDuration(String classGroupIdList) {
+		return courseScheduleDao.queryRemainCourseTypeDuration(classGroupIdList);
+	}
 }

+ 81 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -2,15 +2,11 @@ package com.ym.mec.biz.service.impl;
 
 import java.io.IOException;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
+import com.ym.mec.biz.dal.dao.CourseScheduleDao;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -49,6 +45,7 @@ import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.im.ImFeignService;
 import com.ym.mec.util.http.HttpUtil;
+import org.springframework.util.CollectionUtils;
 
 @Service
 public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, ClassGroupStudentMapper> implements ClassGroupStudentMapperService {
@@ -78,6 +75,8 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
     private TeacherDefaultMusicGroupSalaryService teacherDefaultMusicGroupSalaryService;
     @Autowired
     private StudentDao studentDao;
+    @Autowired
+    private CourseScheduleDao courseScheduleDao;
 
     private static String holidayUrl = "http://tool.bitefu.net/jiari/?d=";
 
@@ -355,4 +354,79 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
     public List<ClassGroupStudentInfoDto> findStudentByGroupOrClassGroup(String groupId, Integer classGroupId, GroupType groupType) {
         return classGroupStudentMapperDao.findByGroupOrClassGroup(groupId, groupType, classGroupId);
     }
+
+    @Override
+    public void updateClassGroupStudents(Long classGroupId, Set<Integer> studentIds) {
+        ClassGroup classGroup = classGroupService.get(classGroupId.intValue());
+        if(Objects.isNull(classGroup)){
+            throw new BizException("班级信息错误");
+        }
+        List<ClassGroupStudentMapper> classGroupStudents = classGroupStudentMapperDao.findAllByClassGroup(classGroupId);
+
+        Set<Integer> allStudentIds = new HashSet<>();
+        Set<Integer> oldStudentIds = new HashSet<>();
+        Set<Integer> oldNormalStudentIds = new HashSet<>();
+        Set<Integer> addStudentIds;
+        Set<Integer> removeStudentIds;
+
+        if(!CollectionUtils.isEmpty(studentIds)){
+            allStudentIds = studentIds;
+        }
+
+        if(!CollectionUtils.isEmpty(classGroupStudents)){
+            oldStudentIds = classGroupStudents.stream().map(ClassGroupStudentMapper::getUserId).collect(Collectors.toSet());
+            oldNormalStudentIds = classGroupStudents.stream().filter(s -> ClassGroupStudentStatusEnum.NORMAL.equals(s.getStatus())).map(ClassGroupStudentMapper::getUserId).collect(Collectors.toSet());
+        }
+
+        Set<Integer> repeatStudentIds = allStudentIds.stream().filter(oldNormalStudentIds::contains).collect(Collectors.toSet());
+        addStudentIds = allStudentIds.stream().filter(id -> !repeatStudentIds.contains(id)).collect(Collectors.toSet());
+        removeStudentIds = oldNormalStudentIds.stream().filter(id -> !repeatStudentIds.contains(id)).collect(Collectors.toSet());
+
+        for (ClassGroupStudentMapper classGroupStudent : classGroupStudents) {
+            if(addStudentIds.contains(classGroupStudent.getUserId())){
+                classGroupStudent.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+            }else if(removeStudentIds.contains(classGroupStudent.getUserId())){
+                classGroupStudent.setStatus(ClassGroupStudentStatusEnum.QUIT);
+            }
+        }
+
+        classGroupStudentMapperDao.batchUpdate(classGroupStudents);
+
+        Date now = new Date();
+        List<ClassGroupStudentMapper> classGroupStudentMappers = new ArrayList<>();
+        for (Integer addStudentId : addStudentIds) {
+            if(oldStudentIds.contains(addStudentId)){
+                continue;
+            }
+            ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
+            classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
+            classGroupStudentMapper.setClassGroupId(classGroupId.intValue());
+            classGroupStudentMapper.setUserId(addStudentId);
+            classGroupStudentMapper.setCreateTime(now);
+            classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+            classGroupStudentMapper.setGroupType(GroupType.MUSIC);
+            classGroupStudentMappers.add(classGroupStudentMapper);
+        }
+
+        if (classGroupStudentMappers.size() > 0) {
+            classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMappers);
+        }
+
+        classGroupService.updateClassStudentNum(classGroupId.intValue(), allStudentIds.size());
+
+        List<CourseSchedule> classGroupNotStartCourse = courseScheduleDao.getClassGroupNotStartCourse(classGroupId);
+        if(CollectionUtils.isEmpty(classGroupNotStartCourse)){
+            return;
+        }
+
+        List<Long> courseIds = classGroupNotStartCourse.stream().map(CourseSchedule::getId).collect(Collectors.toList());
+
+        if(!CollectionUtils.isEmpty(removeStudentIds)){
+            courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudents(courseIds, new ArrayList<>(removeStudentIds));
+        }
+
+        if(!CollectionUtils.isEmpty(addStudentIds)){
+            courseScheduleStudentPaymentService.createForMusicGroup(classGroup.getMusicGroupId(), classGroupNotStartCourse, new ArrayList<>(addStudentIds));
+        }
+    }
 }

+ 67 - 82
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.VipGroupGiveCourseSortDto;
 import com.ym.mec.biz.dal.entity.*;
@@ -46,6 +47,10 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
 	@Autowired
 	private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
+	@Autowired
+	private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
+	@Autowired
+	private TeacherDao teacherDao;
 
 	@Override
 	public BaseDAO<Long, CourseScheduleStudentPayment> getDAO() {
@@ -282,103 +287,83 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	@Override
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	public void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds) {
-		MusicGroupPaymentCalender musicGroupUnusedFirstPaymentCalender = musicGroupPaymentCalenderDao.getMusicGroupUnusedFirstPaymentCalender(musicGroupId, studentIds);
-		if(Objects.isNull(musicGroupUnusedFirstPaymentCalender)){
-			throw new BizException("当前乐团暂无新缴费设置");
-		}
-
-		List<MusicGroupPaymentCalenderDetail> unusedPaymentCalenderDetail = musicGroupPaymentCalenderDetailDao.getCalenderDetailWithCalender(musicGroupUnusedFirstPaymentCalender.getId());
-		if(CollectionUtils.isEmpty(unusedPaymentCalenderDetail)){
-			throw new BizException("当前乐团无学员缴费信息");
-		}
-		Map<Integer, List<MusicGroupPaymentCalenderDetail>> studentPaymentCalenderMap = unusedPaymentCalenderDetail.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalenderDetail::getUserId));
-
-		List<MusicGroupPaymentCalenderCourseSettings> calenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupUnusedFirstPaymentCalender.getId());
-		if(CollectionUtils.isEmpty(calenderCourseSettings)){
-			throw new BizException("课程收费标准设置异常");
-		}
-
-		Set<Long> paymentOrderIds = unusedPaymentCalenderDetail.stream().map(MusicGroupPaymentCalenderDetail::getPaymentOrderId).collect(Collectors.toSet());
-		List<StudentPaymentOrderDetail> allStudentPaymentOrderDetails = new ArrayList<>();
-		if(!CollectionUtils.isEmpty(paymentOrderIds)){
-			allStudentPaymentOrderDetails = studentPaymentOrderDetailDao.getWithIds(new ArrayList<>(paymentOrderIds));
-		}
-		Map<Long, List<StudentPaymentOrderDetail>> orderIdOrderDetailMap = allStudentPaymentOrderDetails.stream().collect(Collectors.groupingBy(StudentPaymentOrderDetail::getPaymentOrderId));
-
-		Map<CourseSchedule.CourseScheduleType, MusicGroupPaymentCalenderCourseSettings> courseTypeCourseSettingMap = calenderCourseSettings.stream().collect(Collectors.toMap(MusicGroupPaymentCalenderCourseSettings::getCourseType, cs -> cs, (c1, c2) -> c1));
-
 		List<CourseScheduleStudentPayment> baseCourseScheduleStudentPayments = new ArrayList<>();
-
+		Map<CourseSchedule.CourseScheduleType, Integer> courseTypeCourseDurationMap = new HashMap<>();
 		Map<CourseSchedule.CourseScheduleType, List<CourseSchedule>> typeCourseMap = courseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getType));
 		for (Map.Entry<CourseSchedule.CourseScheduleType, List<CourseSchedule>> typeCoursesEntry : typeCourseMap.entrySet()) {
-			MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings = courseTypeCourseSettingMap.get(typeCoursesEntry.getKey());
-			if(musicGroupPaymentCalenderCourseSettings.getIsStudentOptional()){
-				//如果可选,则必须缴费才能排课
-				long paymentStudentNum = allStudentPaymentOrderDetails.stream().filter(spd -> musicGroupPaymentCalenderCourseSettings.getCourseType().getCode().equals(spd.getType().getCode())).count();
-				if(paymentStudentNum<studentIds.size()){
-					throw new BizException("部分学员未完成自选课程缴费");
-				}
-			}
-			List<CourseScheduleStudentPayment> typeCourseStudentPayments = new ArrayList<>();
-			BigDecimal typeCourseTotalOriginalPrice = new BigDecimal("0"), typeCourseTotalCurrentPrice = new BigDecimal("0");
-			typeCoursesEntry.getValue().sort(Comparator.comparing(CourseSchedule::getStartClassTime));
+			int totalCourseDuration = 0;
 			for (CourseSchedule courseSchedule : typeCoursesEntry.getValue()) {
-				//课程每分钟原价
-				BigDecimal unitMinuteOriginalPrice = musicGroupPaymentCalenderCourseSettings.getCourseOriginalPrice().divide(new BigDecimal(musicGroupPaymentCalenderCourseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
-				//课程每分钟现价
-				BigDecimal unitMinuteCurrentPrice = musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice().divide(new BigDecimal(musicGroupPaymentCalenderCourseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
-
 				//课程时长
 				int courseDuration = DateUtil.minutesBetween(courseSchedule.getStartClassTime(), courseSchedule.getEndClassTime());
-
-				//课程原价
-				BigDecimal courseOriginalPrice = unitMinuteOriginalPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
-				typeCourseTotalOriginalPrice = typeCourseTotalOriginalPrice.add(courseOriginalPrice);
-
-				//课程现价
-				BigDecimal courseCurrentPrice = unitMinuteCurrentPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
-				typeCourseTotalCurrentPrice = typeCourseTotalCurrentPrice.add(courseCurrentPrice);
-
-				CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
-				cssp.setGroupType(courseSchedule.getGroupType());
-				cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
-				cssp.setCourseScheduleId(courseSchedule.getId());
-				cssp.setClassGroupId(courseSchedule.getClassGroupId());
-				cssp.setBatchNo(musicGroupUnusedFirstPaymentCalender.getBatchNo());
-				cssp.setOriginalPrice(courseOriginalPrice);
-				cssp.setExpectPrice(courseCurrentPrice);
-				cssp.setActualPrice(BigDecimal.ZERO);
-				typeCourseStudentPayments.add(cssp);
+				totalCourseDuration += courseDuration;
 			}
-			typeCourseStudentPayments.get(0).setOriginalPrice(typeCourseStudentPayments.get(0).getOriginalPrice().add(musicGroupPaymentCalenderCourseSettings.getCourseOriginalPrice().subtract(typeCourseTotalOriginalPrice)));
-			typeCourseStudentPayments.get(0).setExpectPrice(typeCourseStudentPayments.get(0).getExpectPrice().add(musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice().subtract(typeCourseTotalCurrentPrice)));
-			baseCourseScheduleStudentPayments.addAll(typeCourseStudentPayments);
+			courseTypeCourseDurationMap.put(typeCoursesEntry.getKey(), totalCourseDuration);
 		}
 
-		List<MusicGroupPaymentCalenderDetail> needUpdateCalenderDetails = new ArrayList<>();
 		List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
 
 		for (Integer studentId : studentIds) {
-			List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetails = studentPaymentCalenderMap.get(studentId);
-			if(CollectionUtils.isEmpty(musicGroupPaymentCalenderDetails)){
-				throw new BizException("部分学员无缴费信息");
-			}
-			MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = musicGroupPaymentCalenderDetails.stream().min(Comparator.comparing(MusicGroupPaymentCalenderDetail::getCreateTime)).get();
-			if(!musicGroupPaymentCalenderDetail.getMusicGroupPaymentCalenderId().equals(musicGroupUnusedFirstPaymentCalender.getId())){
-				throw new BizException("缴费信息异常");
-			}
-			musicGroupPaymentCalenderDetail.setUseInCourse(1);
-			needUpdateCalenderDetails.add(musicGroupPaymentCalenderDetail);
-
-			for (CourseScheduleStudentPayment baseCourseScheduleStudentPayment : baseCourseScheduleStudentPayments) {
-				CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
-				BeanUtils.copyProperties(baseCourseScheduleStudentPayment, cssp);
-				cssp.setUserId(studentId);
-				courseScheduleStudentPayments.add(cssp);
+			for (Map.Entry<CourseSchedule.CourseScheduleType, List<CourseSchedule>> courseScheduleTypeListEntry : typeCourseMap.entrySet()) {
+				//当前课程类型总课程时长
+				Integer typeCourseDuration = courseTypeCourseDurationMap.get(courseScheduleTypeListEntry.getKey());
+				MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(studentId, courseScheduleTypeListEntry.getKey(), typeCourseDuration);
+				if(Objects.isNull(musicGroupPaymentStudentCourseDetail)){
+					SysUser user = teacherDao.getUser(studentId);
+					throw new BizException("{}在{}课程类型上的课程时长不足", user.getUsername(), courseScheduleTypeListEntry.getKey().getMsg());
+				}
+
+				MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(musicGroupPaymentStudentCourseDetail.getMusicGroupPaymentCalenderId());
+				if(Objects.isNull(musicGroupPaymentCalender)){
+					throw new BizException("缴费设置异常");
+				}
+
+				MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalenderAndCourseType(musicGroupPaymentStudentCourseDetail.getMusicGroupPaymentCalenderId(), courseScheduleTypeListEntry.getKey());
+				if(Objects.isNull(musicGroupPaymentCalenderCourseSettings)){
+					throw new BizException("缴费设置异常");
+				}
+
+				//课程每分钟原价
+				BigDecimal unitMinuteOriginalPrice = musicGroupPaymentCalenderCourseSettings.getCourseOriginalPrice().divide(new BigDecimal(musicGroupPaymentCalenderCourseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+				//课程每分钟现价
+				BigDecimal unitMinuteCurrentPrice = musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice().divide(new BigDecimal(musicGroupPaymentCalenderCourseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+
+				List<CourseScheduleStudentPayment> typeCourseStudentPayments = new ArrayList<>();
+				courseScheduleTypeListEntry.getValue().sort(Comparator.comparing(CourseSchedule::getStartClassTime));
+				BigDecimal typeCourseTotalOriginalPrice = new BigDecimal("0"), typeCourseTotalCurrentPrice = new BigDecimal("0");
+				for (CourseSchedule courseSchedule : courseScheduleTypeListEntry.getValue()) {
+					//课程时长
+					int courseDuration = DateUtil.minutesBetween(courseSchedule.getStartClassTime(), courseSchedule.getEndClassTime());
+
+					//课程原价
+					BigDecimal courseOriginalPrice = unitMinuteOriginalPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
+					typeCourseTotalOriginalPrice = typeCourseTotalOriginalPrice.add(courseOriginalPrice);
+
+					//课程现价
+					BigDecimal courseCurrentPrice = unitMinuteCurrentPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
+					typeCourseTotalCurrentPrice = typeCourseTotalCurrentPrice.add(courseCurrentPrice);
+
+					CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
+					cssp.setGroupType(courseSchedule.getGroupType());
+					cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
+					cssp.setCourseScheduleId(courseSchedule.getId());
+					cssp.setClassGroupId(courseSchedule.getClassGroupId());
+					cssp.setBatchNo(musicGroupPaymentCalender.getBatchNo());
+					cssp.setOriginalPrice(courseOriginalPrice);
+					cssp.setExpectPrice(courseCurrentPrice);
+					cssp.setActualPrice(BigDecimal.ZERO);
+					typeCourseStudentPayments.add(cssp);
+				}
+				if(musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice().compareTo(typeCourseTotalCurrentPrice)<0){
+					throw new BizException("{}课程类型时长不足", courseScheduleTypeListEntry.getKey().getMsg());
+				}
+				typeCourseStudentPayments.get(0).setOriginalPrice(typeCourseStudentPayments.get(0).getOriginalPrice().add(musicGroupPaymentCalenderCourseSettings.getCourseOriginalPrice().subtract(typeCourseTotalOriginalPrice)));
+				typeCourseStudentPayments.get(0).setExpectPrice(typeCourseStudentPayments.get(0).getExpectPrice().add(musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice().subtract(typeCourseTotalCurrentPrice)));
+				baseCourseScheduleStudentPayments.addAll(typeCourseStudentPayments);
+				musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(typeCourseDuration);
+				musicGroupPaymentStudentCourseDetailDao.update(musicGroupPaymentStudentCourseDetail);
 			}
 		}
 		courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
-		musicGroupPaymentCalenderDetailDao.batchUpdate(needUpdateCalenderDetails);
 	}
 
 	@Override

+ 18 - 27
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderCourseSettingsServiceImpl.java

@@ -1,23 +1,17 @@
 package com.ym.mec.biz.service.impl;
 
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
-import com.ym.mec.common.exception.BizException;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
+import com.ym.mec.biz.dal.entity.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderCourseSettingsService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import org.springframework.util.CollectionUtils;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -26,9 +20,7 @@ public class MusicGroupPaymentCalenderCourseSettingsServiceImpl extends BaseServ
 	@Autowired
 	private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
 	@Autowired
-	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
-	@Autowired
-	private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
+	private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
 
 	@Override
 	public BaseDAO<Integer, MusicGroupPaymentCalenderCourseSettings> getDAO() {
@@ -36,22 +28,21 @@ public class MusicGroupPaymentCalenderCourseSettingsServiceImpl extends BaseServ
 	}
 
 	@Override
-	public List<MusicGroupPaymentCalenderCourseSettings> getMusicCourseSettingsWithStudents(String musicGroupId, List<Integer> studentIds) {
-		MusicGroupPaymentCalender musicGroupUnusedFirstPaymentCalender = musicGroupPaymentCalenderDao.getMusicGroupUnusedFirstPaymentCalender(musicGroupId, studentIds);
-		if(Objects.isNull(musicGroupUnusedFirstPaymentCalender)){
-			throw new BizException("当前乐团暂无新缴费设置");
-		}
-
-		List<MusicGroupPaymentCalenderDetail> unusedPaymentCalenderDetail = musicGroupPaymentCalenderDetailDao.getCalenderDetailWithCalender(musicGroupUnusedFirstPaymentCalender.getId());
-		if(CollectionUtils.isEmpty(unusedPaymentCalenderDetail)){
-			throw new BizException("当前乐团无学员缴费信息");
+	public Map<String, Integer> getMusicCourseSettingsWithStudents(String musicGroupId, List<Integer> studentIds) {
+		List<MusicGroupPaymentStudentCourseDetail> mgpscds = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudents(studentIds);
+		if(CollectionUtils.isEmpty(mgpscds)){
+			return Collections.emptyMap();
 		}
-		Map<Integer, List<MusicGroupPaymentCalenderDetail>> studentPaymentCalenderMap = unusedPaymentCalenderDetail.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalenderDetail::getUserId));
-
-		List<MusicGroupPaymentCalenderCourseSettings> calenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupUnusedFirstPaymentCalender.getId());
-		if(CollectionUtils.isEmpty(calenderCourseSettings)){
-			throw new BizException("课程收费标准设置异常");
+		Map<String, Integer> result = new HashMap<>();
+		Map<CourseSchedule.CourseScheduleType, List<MusicGroupPaymentStudentCourseDetail>> courseTypeDetailsMap = mgpscds.stream().collect(Collectors.groupingBy(MusicGroupPaymentStudentCourseDetail::getCourseType));
+		for (Map.Entry<CourseSchedule.CourseScheduleType, List<MusicGroupPaymentStudentCourseDetail>> courseTypeDetailsEntry : courseTypeDetailsMap.entrySet()) {
+			Map<Integer, List<MusicGroupPaymentStudentCourseDetail>> userDetailsMap = courseTypeDetailsEntry.getValue().stream().collect(Collectors.groupingBy(MusicGroupPaymentStudentCourseDetail::getUserId));
+			List<MusicGroupPaymentStudentCourseDetail> details = new ArrayList<>();
+			for (Map.Entry<Integer, List<MusicGroupPaymentStudentCourseDetail>> userDetailsEntry : userDetailsMap.entrySet()) {
+				details.add(userDetailsEntry.getValue().stream().min(Comparator.comparing(MusicGroupPaymentStudentCourseDetail::getId)).get());
+			}
+			result.put(courseTypeDetailsEntry.getKey().getCode(), details.stream().min(Comparator.comparing(MusicGroupPaymentStudentCourseDetail::getTotalCourseMinutes)).get().getTotalCourseMinutes());
 		}
-		return calenderCourseSettings;
+		return result;
 	}
 }

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

@@ -335,6 +335,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 				musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
 				musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
 				musicGroupPaymentStudentCourseDetail.setCreateTime(date);
+				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalenderId);
 				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(userMap.get(studentId).getId());
 				musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
 				musicGroupPaymentStudentCourseDetail.setUpdateTime(date);

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

@@ -1,17 +1,60 @@
 package com.ym.mec.biz.service.impl;
 
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY;
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_RENEW;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Transactional;
+
 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.dao.MusicGroupBuildLogDao;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
+import com.ym.mec.biz.dal.dao.MusicGroupOrganizationCourseSettingsDao;
+import com.ym.mec.biz.dal.dao.MusicGroupOrganizationCourseSettingsDetailDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
+import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
+import com.ym.mec.biz.dal.dao.OrganizationCourseUnitPriceSettingsDao;
+import com.ym.mec.biz.dal.dao.OrganizationDao;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.CalenderPushDto;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDetailDto;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDto;
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
-import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupBuildLog;
+import com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettings;
+import com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettingsDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
+import com.ym.mec.biz.dal.entity.Organization;
+import com.ym.mec.biz.dal.entity.OrganizationCourseUnitPriceSettings;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
 import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
@@ -27,19 +70,6 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Isolation;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.math.BigDecimal;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-
-import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY;
-import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_RENEW;
 
 @Service
 public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalender> implements MusicGroupPaymentCalenderService {
@@ -64,6 +94,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	private OrganizationCourseUnitPriceSettingsDao organizationCourseUnitPriceSettingsDao;
 	
 	@Autowired
+	private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
+	
+	@Autowired
 	private IdGeneratorService idGeneratorService;
 	
 	@Autowired
@@ -178,6 +211,61 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			} else {
 				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
 			}
+			
+			//如果是进行中加学生
+			if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
+				String studentIdStr = musicGroupPaymentCalender.getStudentIds();
+				if (StringUtils.isNoneBlank(studentIdStr)) {
+					//计算总费用
+					BigDecimal totalPrice = new BigDecimal(0);
+					for(MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList){
+						totalPrice = totalPrice.add(musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice());
+					}
+					
+					List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<MusicGroupPaymentStudentCourseDetail>();
+					MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
+					
+					for (String studentId : studentIdStr.split(",")) {
+						// 学生加到calenderDetail
+						MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
+						musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+						musicGroupPaymentCalenderDetail.setCreateTime(date);
+						musicGroupPaymentCalenderDetail.setExpectAmount(totalPrice);
+						musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
+						musicGroupPaymentCalenderDetail.setUpdateTime(date);
+						musicGroupPaymentCalenderDetail.setUserId(Integer.parseInt(studentId));
+						musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupPaymentCalender.getStartPaymentDate());
+						musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
+						
+						musicGroupPaymentCalenderDetailDao.insert(musicGroupPaymentCalenderDetail);
+						
+						// 学生加课程明细
+						for(MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList){
+							if (courseSettings.getIsStudentOptional() == true) {
+								continue;
+							}
+							musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+							musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
+							musicGroupPaymentStudentCourseDetail.setCreateTime(date);
+							musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+							musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
+							musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
+							musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
+							musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
+							musicGroupPaymentStudentCourseDetail.setUserId(Integer.parseInt(studentId));
+							
+							musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
+						}
+						
+						if(musicGroupPaymentStudentCourseDetailList.size() > 0){
+							musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
+						}
+
+						// 学生加到班级
+						String classGroupIdStr = musicGroupPaymentCalender.getAttribute1();
+					}
+				}
+			}
 
 			// 如果是报名,需要修改乐团状态
 			if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
@@ -205,7 +293,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 					.getMusicGroupOrganizationCourseSettingId());
 			for (MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings : musicGroupPaymentCalenderCourseSettingsList) {
 				musicGroupPaymentCalenderCourseSettings.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
-				musicGroupPaymentCalenderCourseSettings.setName(courseSettings.getName());
+				if (courseSettings != null) {
+					musicGroupPaymentCalenderCourseSettings.setName(courseSettings.getName());
+				}
 			}
 			musicGroupPaymentCalenderCourseSettingsDao.batchInsert(musicGroupPaymentCalenderCourseSettingsList);
 		}

+ 8 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -294,20 +294,23 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (chargeInfo.getOpenFlag().equals(1)) {
             throw new BizException("项目已关闭");
         }
-        BigDecimal amount = chargeInfo.getAmount();
+        if(sporadicPayDto.getNum()==null){
+            sporadicPayDto.setNum(1);
+        }
+        BigDecimal amount = chargeInfo.getAmount().multiply(new BigDecimal(sporadicPayDto.getNum()));
         if (chargeInfo.getDiscountAmount() != null && chargeInfo.getDiscountAmount().compareTo(BigDecimal.ZERO) > 0) {
-            amount = amount.subtract(chargeInfo.getDiscountAmount());
+            amount = amount.subtract(chargeInfo.getDiscountAmount().multiply(new BigDecimal(sporadicPayDto.getNum())));
         }
         if (!(amount.compareTo(sporadicPayDto.getAmount()) == 0)) {
             throw new BizException("订单金额异常");
         }
         if (chargeInfo.getMaxAmount() != null) {
-            if (chargeInfo.getOpenMaxTerm().equals(YesOrNoEnum.YES) && chargeInfo.getMaxAmount().compareTo(chargeInfo.getPaidAmount()) <= 0) {
+            if (chargeInfo.getOpenMaxTerm().equals(YesOrNoEnum.YES) && chargeInfo.getMaxAmount().compareTo(chargeInfo.getPaidAmount().add(amount)) < 0) {
                 throw new Exception("活动人数暂时已满,请稍后再试");
             }
             List<SporadicChargeInfo> activeInfos = sporadicChargeInfoDao.getOrganActiveInfo(chargeInfo.getOrganId(), 12);
             for (SporadicChargeInfo activeInfo : activeInfos) {
-                activeInfo.setPaidAmount(activeInfo.getPaidAmount().add(chargeInfo.getAmount()));
+                activeInfo.setPaidAmount(activeInfo.getPaidAmount().add(amount));
                 activeInfo.setUpdateTime(new Date());
                 int update = sporadicChargeInfoDao.update(activeInfo);
                 if (update <= 0) {
@@ -333,6 +336,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentPaymentOrder.setActualAmount(amount);
         studentPaymentOrder.setStatus(DealStatusEnum.ING);
         studentPaymentOrder.setMusicGroupId(sporadicPayDto.getSporadicId().toString());
+        studentPaymentOrder.setClassGroupId(sporadicPayDto.getNum());
         studentPaymentOrderService.insert(studentPaymentOrder);
 
         studentPaymentOrder.setVersion(0);
@@ -587,7 +591,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentPaymentOrder.setVersion(studentPaymentOrder.getVersion() + 1);
 
         if (amount.compareTo(BigDecimal.ZERO) == 0) {
-            //如果赠送网管课
             studentPaymentRouteOrderService.addRouteOrder(orderNo, musicGroup.getOrganId(), balance);
             Map<String, String> notifyMap = new HashMap<>();
             notifyMap.put("tradeState", "1");

+ 10 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SporadicChargeInfoImpl.java

@@ -71,9 +71,9 @@ public class SporadicChargeInfoImpl extends BaseServiceImpl<Integer, SporadicCha
         SysUser sysUser = sysUserFeignService.queryUserById(userId);
         SporadicChargeInfo info = sporadicChargeInfoDao.get(Integer.parseInt(studentPaymentOrder.getMusicGroupId()));
 
-        Map<Integer, String> map = new HashMap();
+        Map<Integer, String> map = new HashMap<>();
         map.put(userId, sysUser.getPhone());
-        Map<Integer, String> yimei = new HashMap();
+        Map<Integer, String> yimei = new HashMap<>();
         map.put(userId, userId.toString());
         if (studentPaymentOrder.getStatus() == DealStatusEnum.SUCCESS) {
             try {
@@ -85,9 +85,13 @@ public class SporadicChargeInfoImpl extends BaseServiceImpl<Integer, SporadicCha
             //福袋活动,增加课程余额
             if (info.getChargeType().getCode() == 6 || info.getChargeType().getCode() == 12) {
                 //第二单起每买一单增加一次抽奖机会
-                int num = studentPaymentOrderDao.getUserOrderNumByType(userId, OrderTypeEnum.DOUBLE_ELEVEN2020);
-                if (num > 1) {
-                    if (!luckDrawCountService.updateTimes(userId.longValue(), 1)) {
+                int times = studentPaymentOrderDao.getUserOrderNumByType(userId, OrderTypeEnum.DOUBLE_ELEVEN2020);
+                int num = studentPaymentOrder.getClassGroupId() == null ? 1 : studentPaymentOrder.getClassGroupId();
+                if (times <= 1) {
+                    num--;
+                }
+                if (num > 0) {
+                    if (!luckDrawCountService.updateTimes(userId.longValue(), num)) {
                         throw new BizException("给用户增加抽奖次数失败");
                     }
                 }
@@ -151,7 +155,7 @@ public class SporadicChargeInfoImpl extends BaseServiceImpl<Integer, SporadicCha
             if (info.getMaxAmount() != null && info.getPaidAmount().compareTo(BigDecimal.ZERO) > 0) {
                 List<SporadicChargeInfo> activeInfos = sporadicChargeInfoDao.getOrganActiveInfo(info.getOrganId(), 12);
                 for (SporadicChargeInfo activeInfo : activeInfos) {
-                    activeInfo.setPaidAmount(activeInfo.getPaidAmount().subtract(info.getAmount()));
+                    activeInfo.setPaidAmount(activeInfo.getPaidAmount().subtract(studentPaymentOrder.getActualAmount()));
                     activeInfo.setUpdateTime(new Date());
                     int update = sporadicChargeInfoDao.update(activeInfo);
                     if (update <= 0) {

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

@@ -61,6 +61,22 @@
         WHERE id_ = #{id}
     </update>
 
+    <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.ClassGroupStudentMapper">
+        <foreach collection="classGroupStudentMappers" item="classGroupStudentMapper" separator=";">
+            UPDATE class_group_student_mapper
+            <set>
+                <if test="classGroupStudentMapper.status != null">
+                    status_ = #{classGroupStudentMapper.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+                </if>
+                <if test="classGroupStudentMapper.groupType != null">
+                    group_type_ = #{classGroupStudentMapper.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+                </if>
+                update_time_ = now(),
+            </set>
+            WHERE id_ = #{classGroupStudentMapper.id}
+        </foreach>
+    </update>
+
     <!-- 根据主键删除一条记录 -->
     <delete id="delete">
 		DELETE FROM class_group_student_mapper WHERE id_ = #{id} 
@@ -258,6 +274,12 @@
         </foreach>
         AND status_ = 'NORMAL'
     </select>
+    <select id="findAllByClassGroup" resultMap="ClassGroupStudentMapper">
+        SELECT
+          cgsm.*
+        FROM class_group_student_mapper cgsm
+        WHERE class_group_id_ = #{classGroupId}
+    </select>
     <select id="findByClassGroup" resultMap="ClassGroupStudentMapper">
         SELECT
           cgsm.*,

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

@@ -41,6 +41,11 @@
         <result column="value_" property="value"/>
     </resultMap>
 
+    <resultMap type="com.ym.mec.biz.dal.dto.RemainCourseTypeDurationDto" id="RemainCourseTypeDurationDto">
+        <result column="course_type_" property="courseType"/>
+        <result column="remain_minutes_" property="remainMinutes"/>
+    </resultMap>
+
     <resultMap id="CourseScheduleEndDto" type="com.ym.mec.biz.dal.dto.CourseScheduleEndDto" extends="CourseSchedule">
         <result column="course_start_time_" property="startClassTime"/>
         <result column="course_end_time_" property="endClassTime"/>
@@ -2001,6 +2006,24 @@
         </foreach>
     </delete>
 
+    <delete id="deleteMusicGroupCourseSchedulesWithStudents">
+        DELETE
+        FROM
+        course_schedule_student_payment
+        WHERE user_id_ IN
+        <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
+            #{userId}
+        </foreach>
+        AND course_schedule_id_ IN
+        <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
+            #{courseScheduleId}
+        </foreach>
+    </delete>
+
+    <select id="getClassGroupNotStartCourse" resultMap="CourseSchedule">
+        SELECT * FROM course_schedule WHERE class_group_id_=#{classGroupId} AND CONCAT(class_date_,' ', start_class_time_) &gt; NOW()
+    </select>
+
     <delete id="deleteCourseSchedulesByClassGroupIds">
         DELETE FROM course_schedule WHERE id_ IN
         <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
@@ -3317,4 +3340,10 @@
         ORDER BY start_class_time_ DESC LIMIT 1;
     </select>
 
+    <select id="queryRemainCourseTypeDuration" resultMap="RemainCourseTypeDurationDto">
+        SELECT cs.type_ course_type_,SUM(TIMESTAMPDIFF(MINUTE,STR_TO_DATE(concat(cs.class_date_,' ',cs.start_class_time_),'%Y-%m-%d %H:%i:%s'), 
+        STR_TO_DATE(concat(cs.class_date_,' ',cs.end_class_time_),'%Y-%m-%d %H:%i:%s'))) remain_minutes_ 
+		from course_schedule cs where cs.class_group_id_ in (#{classgroupId}) and cs.status_ = 'NOT_START' group by cs.type_
+    </select>
+
 </mapper>

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

@@ -109,6 +109,10 @@
 		SELECT * FROM music_group_payment_calender_course_settings WHERE music_group_payment_calender_id_=#{calenderId}
 	</select>
 
+	<select id="getWithPaymentCalenderAndCourseType" resultMap="MusicGroupPaymentCalenderCourseSettings">
+		SELECT * FROM music_group_payment_calender_course_settings WHERE music_group_payment_calender_id_=#{calenderId} AND course_type_=#{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+	</select>
+
 	<delete id="deleteByMusicGroupPaymentCalenderId">
 		DELETE FROM music_group_payment_calender_course_settings WHERE music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId}
 	</delete>

+ 18 - 4
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml

@@ -28,6 +28,8 @@
         <result column="payment_type_" property="paymentType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="batch_no_" property="batchNo"/>
         <result column="payment_amount_" property="paymentAmount"/>
+        <result column="attribute1_" property="attribute1"/>
+        <result column="attribute2_" property="attribute2"/>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -46,12 +48,12 @@
         INSERT INTO music_group_payment_calender
         (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
         actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,
-        payment_pattern_,payment_type_,payment_amount_,batch_no_,audit_memo_,operator_)
+        payment_pattern_,payment_type_,payment_amount_,batch_no_,audit_memo_,operator_,attribute1_,attribute2_)
         VALUES(#{musicGroupId},#{musicGroupOrganizationCourseSettingId},#{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{rejectReason},#{startPaymentDate},#{deadlinePaymentDate},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{expectNum},#{actualNum},#{memo},#{isGiveMusicNetwork},now(),now(),
         #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-        #{paymentAmount},#{batchNo},#{auditMemo},#{operator})
+        #{paymentAmount},#{batchNo},#{auditMemo},#{operator},#{attribute1},#{attribute2})
     </insert>
 
     <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
@@ -59,13 +61,13 @@
         INSERT INTO music_group_payment_calender
         (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
         actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_,payment_amount_,
-        payment_type_,batch_no_,audit_memo_,operator_)
+        payment_type_,batch_no_,audit_memo_,operator_,attribute1_,attribute2_)
         VALUES
         <foreach collection="list" item="item" index="index" separator=",">
         (#{item.musicGroupId},#{item.musicGroupOrganizationCourseSettingId},#{item.payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.rejectReason},#{item.startPaymentDate},#{item.deadlinePaymentDate},#{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{item.expectNum},#{item.actualNum},#{item.memo},#{item.isGiveMusicNetwork},now(),now(),
         #{item.paymentValidStartDate},#{item.paymentValidEndDate},#{item.paymentPattern},#{item.paymentAmount},#{item.paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-        #{item.batchNo},#{item.auditMemo},#{item.operator})
+        #{item.batchNo},#{item.auditMemo},#{item.operator},#{item.attribute1},#{item.attribute2})
         </foreach>
     </insert>
 
@@ -128,6 +130,12 @@
             <if test="paymentAmount != null">
                 payment_amount_ = #{paymentAmount},
             </if>
+            <if test="attribute1 != null">
+                attribute1_ = #{attribute1},
+            </if>
+            <if test="attribute2 != null">
+                attribute2_ = #{attribute2},
+            </if>
         </set>
         WHERE id_ = #{id}
     </update>
@@ -184,6 +192,12 @@
 	            <if test="item.paymentAmount != null">
 	                payment_amount_ = #{item.paymentAmount},
 	            </if>
+	            <if test="item.attribute1 != null">
+	                attribute1_ = #{item.attribute1},
+	            </if>
+	            <if test="item.attribute2 != null">
+	                attribute2_ = #{item.attribute2},
+	            </if>
 	        </set>
 	        WHERE id_ = #{item.id}
 		</foreach>

+ 16 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml

@@ -105,4 +105,20 @@
 		SELECT COUNT(*) FROM
 		music_group_payment_student_course_detail
 	</select>
+    <select id="getUnUseWithStudentAndCourseTypeAndCourseMinutes" resultMap="MusicGroupPaymentStudentCourseDetail">
+		SELECT * FROM music_group_payment_student_course_detail
+		WHERE user_id_=#{studentId}
+		AND course_type_=#{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+		AND total_course_minutes &gt; #{courseMinutes}
+		AND used_course_minutes_ &lt;= 0
+		ORDER BY id_ DESC LIMIT 1;
+	</select>
+    <select id="getUnUseWithStudents" resultMap="MusicGroupPaymentStudentCourseDetail">
+		SELECT * FROM music_group_payment_student_course_detail WHERE
+		used_course_minutes_ &lt;= 0
+		AND user_id_ IN
+		<foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
+			#{studentId}
+		</foreach>
+	</select>
 </mapper>

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

@@ -101,7 +101,7 @@
                 paid_amount_ = #{paidAmount},
             </if>
             <if test="openMaxTerm != null">
-                open_max_term_ = #{openMaxTerm},
+                open_max_term_ = #{openMaxTerm,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>
             <if test="version != null">
                 version_ = version_+1,

+ 7 - 0
mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupController.java

@@ -322,4 +322,11 @@ public class ClassGroupController extends BaseController {
     public HttpResponseResult superFindClassGroups(EndCourseScheduleQueryInfo queryInfo){
         return succeed(classGroupService.endFindClassGroups(queryInfo));
     }
+
+    @ApiOperation(value = "获取班级剩余课程类型对应的时长(分钟)")
+    @GetMapping("/queryRemainCourseTypeDuration")
+    @PreAuthorize("@pcs.hasPermissions('classGroup/queryRemainCourseTypeDuration')")
+    public HttpResponseResult queryRemainCourseTypeDuration(String classGroupIdList){
+        return succeed(classGroupService.queryRemainCourseTypeDuration(classGroupIdList));
+    }
 }

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

@@ -9,6 +9,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -17,6 +18,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 @RequestMapping("classGroupStudent")
 @Api(tags = "班级学生服务")
@@ -79,4 +85,19 @@ public class ClassGroupStudentController extends BaseController {
     public Object queryHoliday(String year) throws IOException {
         return succeed(classGroupStudentMapperService.queryHoliday(year));
     }
+
+    @ApiOperation(value = "修改班级学员")
+    @PostMapping("/updateClassGroupStudents")
+    @PreAuthorize("@pcs.hasPermissions('classGroupStudent/updateClassGroupStudents')")
+    public HttpResponseResult updateClassGroupStudents(Long classGroupId, String studentIds){
+        if(Objects.isNull(classGroupId)){
+            return failed("请指定班级");
+        }
+        Set<Integer> studentIdSet = new HashSet<>();
+        if(StringUtils.isNotBlank(studentIds)){
+            studentIdSet = Arrays.stream(studentIds.split(",")).map(Integer::valueOf).collect(Collectors.toSet());
+        }
+        classGroupStudentMapperService.updateClassGroupStudents(classGroupId, studentIdSet);
+        return succeed();
+    }
 }

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

@@ -27,10 +27,7 @@ import org.springframework.ui.ModelMap;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @RequestMapping("musicGroupPaymentCalender")
@@ -141,7 +138,7 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     @ApiOperation(value = "获取指定学员在指定乐团下本次课排课时长")
     @GetMapping("/getMusicCourseSettingsWithStudents")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/getMusicCourseSettingsWithStudents')")
-    public HttpResponseResult<List<MusicGroupPaymentCalenderCourseSettings>> getMusicCourseSettingsWithStudents(String musicGroupId, String studentIds, Long classGroupId){
+    public HttpResponseResult<Map<String, Integer>> getMusicCourseSettingsWithStudents(String musicGroupId, String studentIds, Long classGroupId){
         List<Integer> studentIdList = new ArrayList<>();
         if(StringUtils.isNotBlank(studentIds)){
             studentIdList = Arrays.stream(studentIds.split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toList());

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

@@ -85,7 +85,7 @@ public class ActivityController extends BaseController {
                 order.setScale(order.getMoney().multiply(new BigDecimal(100)).divide(order.getMaxAmount(), 2, BigDecimal.ROUND_HALF_UP));
             }
         }
-        orders.sort(Comparator.comparing(OrderStatisDto::getMoney).reversed());
+        orders.sort(Comparator.comparing(OrderStatisDto::getScale).reversed());
 
         LuckStatisDto luckStatisDto = new LuckStatisDto();
         luckStatisDto.setOrderStatisDtoList(orders);