浏览代码

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

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java
yonge 4 年之前
父节点
当前提交
9c787e263c
共有 18 个文件被更改,包括 220 次插入126 次删除
  1. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java
  2. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderCourseSettingsDao.java
  3. 26 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java
  4. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SporadicPayDto.java
  5. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupStudentMapperService.java
  6. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderCourseSettingsService.java
  7. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java
  8. 67 82
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java
  9. 18 27
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderCourseSettingsServiceImpl.java
  10. 7 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  11. 8 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SporadicChargeInfoImpl.java
  12. 6 0
      mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml
  13. 4 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderCourseSettingsMapper.xml
  14. 16 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml
  15. 1 1
      mec-biz/src/main/resources/config/mybatis/SporadicChargeInfo.xml
  16. 11 0
      mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupStudentController.java
  17. 2 5
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java
  18. 1 1
      mec-web/src/main/java/com/ym/mec/web/controller/education/ActivityController.java

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

@@ -183,6 +183,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 根据班级获取学员

+ 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);
-	
-}
+
+}

+ 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;
+    }
 }

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

@@ -78,4 +78,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, String 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);
 
 }

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

@@ -355,4 +355,13 @@ 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, String studentIds) {
+        List<ClassGroupStudentMapper> classGroupStudents = classGroupStudentMapperDao.findAllByClassGroup(classGroupId);
+
+        List<Integer> allStudentIds = new ArrayList<>();
+        List<Integer> addStudentIds = new ArrayList<>();
+        List<Integer> removeStudentIds = new ArrayList<>();
+    }
 }

+ 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;
 	}
 }

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

@@ -294,9 +294,12 @@ 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("订单金额异常");
@@ -307,7 +310,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             }
             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);

+ 8 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SporadicChargeInfoImpl.java

@@ -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);
+                Integer 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) {

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

@@ -258,6 +258,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.*,

+ 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>

+ 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,

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

@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.io.IOException;
+import java.util.Objects;
 
 @RequestMapping("classGroupStudent")
 @Api(tags = "班级学生服务")
@@ -79,4 +80,14 @@ 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("请指定班级");
+        }
+        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);