浏览代码

1、教务端课程交换
2、vip课退课费用及相关逻辑调整

Joburgess 5 年之前
父节点
当前提交
401f14d8c0

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

@@ -979,4 +979,37 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @return java.util.List<java.lang.Integer>
      */
     List<Integer> findCourseIdsByTeacher(String search);
+
+    /**
+     * @describe 统计团体下的总课次
+     * @author Joburgess
+     * @date 2020/1/16
+     * @param groupType:
+     * @param groupId:
+     * @return int
+     */
+    int countGroupAllCourses(@Param("groupType") GroupType groupType,
+                             @Param("groupId") String groupId);
+
+    /**
+     * @describe 获取乐团开课时间
+     * @author Joburgess
+     * @date 2020/1/16
+     * @param groupType:
+     * @param groupId:
+     * @return java.util.Date
+     */
+    Date findGroupCourseStartTime(@Param("groupType") GroupType groupType,
+                                  @Param("groupId") String groupId);
+
+    /**
+     * @describe 获取乐团课程结束时间
+     * @author Joburgess
+     * @date 2020/1/16
+     * @param groupType:
+     * @param groupId:
+     * @return java.util.Date
+     */
+    Date findGroupCourseEndTime(@Param("groupType") GroupType groupType,
+                                  @Param("groupId") String groupId);
 }

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

@@ -64,6 +64,8 @@ public interface SysConfigService extends BaseService<Long, SysConfig> {
 
     String MUSIC_GROUP_SETTLEMENT_CLASS_MINUTES = "music_group_settlement_class_minutes";
 
+    String MUSIC_GROUP_SETTLEMENT_DAY = "music_group_settlement_day";
+
     String MUSIC_GROUP_SETTLEMENT_SINGLE_CLASS_MINUTES = "music_group_settlement_single_class_minutes";
 
     String REFUND_PERIOD = "refund_period";

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

@@ -24,6 +24,15 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
     void createVipGroup(VipGroupApplyDto vipGroup);
 
     /**
+     * @describe 检测vip课程是否超过范围
+     * @author Joburgess
+     * @date 2020/1/16
+     * @param vipGroupId: 小课编号
+     * @return void
+     */
+    void checkVipCourseIsInScore(Long vipGroupId);
+
+    /**
      * @describe 更新vip课程信息
      * @author Joburgess
      * @date 2019/10/30

+ 13 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -1151,6 +1151,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         checkNewCourseSchedules(courseSchedules, false);
         courseScheduleDao.batchUpdate(courseSchedules);
         classGroupService.updateClassGroupInfo(classGroup.getId());
+        vipGroupService.checkVipCourseIsInScore(vipGroupCourseAdjustInfo.getVipGroupId().longValue());
 //        courseScheduleStudentPaymentService.updateVipGiveCourse(vipGroup.getId());
     }
 
@@ -1324,6 +1325,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         vipGroupApplyDto.setSingleClassPrice(vipGroupCourseAdjustInfo.getSingleClassPrice());
         vipGroupService.appendVipGroupCourseSchedules(vipGroupApplyDto);
         classGroupService.updateClassGroupInfo(classGroup.getId());
+        vipGroupService.checkVipCourseIsInScore(vipGroupCourseAdjustInfo.getVipGroupId().longValue());
     }
 
     @Override
@@ -1416,6 +1418,10 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         checkNewCourseSchedules(newCourseSchedules, false);
         //课程调整
         classStartDateAdjust(newCourseSchedules);
+
+        if (!CollectionUtils.isEmpty(oldCourseScheduleIds)&&oldCourseScheduleIds.get(0).getGroupType().equals(GroupType.VIP)){
+            vipGroupService.checkVipCourseIsInScore(Long.valueOf(oldCourseScheduleIds.get(0).getMusicGroupId()));
+        }
     }
 
     @Override
@@ -1466,7 +1472,6 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
             if (!sysUser.getUserType().contains("SYSTEM") && sysUser.getUserType().contains("TEACHER")) {
                 Long normalStudentNum = classGroupStudentNumMap.get(oldCourseSchedule.getClassGroupId());
                 Long courseLeaveStudentNum = courseLeaveStudentNumMap.get(newCourseSchedule.getId());
-                ClassGroup classGroup=idClassGroupMap.get(oldCourseSchedule.getClassGroupId());
                 if(oldCourseSchedule.getGroupType().equals(GroupType.VIP)
                         &&Objects.nonNull(courseLeaveStudentNum)
                         &&Objects.nonNull(normalStudentNum)
@@ -1573,7 +1578,12 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                 }
                 //修改后的课程助教编号列表
                 List<Integer> newTeachingTeacherIdList = newCourseSchedule.getTeachingTeacherIdList();
-                List<Integer> newCreateSalaryTeachingTeacherIds = null;
+
+                if(Objects.isNull(newTeachingTeacherIdList)){
+                    newTeachingTeacherIdList=new ArrayList<>();
+                }
+
+                List<Integer> newCreateSalaryTeachingTeacherIds;
 
                 //找出重复的助教编号
                 List<Integer> foundInCurrentCourseTeachingTeacherIds = newTeachingTeacherIdList.stream().filter(currentCourseTeachingTeacherIds::contains).collect(Collectors.toList());
@@ -1677,7 +1687,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
             throw new BizException("未找到对应课程");
         }
 
-        if(!courseSchedule1.getType().equals(courseSchedule2.getGroupType())
+        if(!courseSchedule1.getGroupType().equals(courseSchedule2.getGroupType())
             ||!courseSchedule1.getMusicGroupId().equals(courseSchedule2.getMusicGroupId())){
             throw new BizException("不能跨乐团进行课时交换");
         }

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

@@ -352,12 +352,12 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
     @Transactional(rollbackFor = Exception.class)
     public void musicGroupTeacherSalarySettlement() {
         Date now = new Date();
-        Date yesterday = DateUtil.addDays1(now, -1);
+        Date settleTime = DateUtil.addDays1(now, -sysConfigDao.findByParamName(SysConfigService.MUSIC_GROUP_SETTLEMENT_DAY).getParanValue(Integer.class));
         Integer settlementClassMinutes = Integer.parseInt(sysConfigDao.findByParamName(SysConfigService.MUSIC_GROUP_SETTLEMENT_CLASS_MINUTES).getParanValue());
         Integer singleClassTime = Integer.parseInt(sysConfigDao.findByParamName(SysConfigService.MUSIC_GROUP_SETTLEMENT_SINGLE_CLASS_MINUTES).getParanValue());
         Date entryDate = DateUtil.stringToDate(sysConfigDao.findByParamName(SysConfigService.TEACHER_ENTRY_DATE).getParanValue(),"yyyy-MM-dd");
         //获取昨天的课程计划
-        List<CourseSchedule> yesterdayCourseSchedules = courseScheduleDao.findCourseScheduleWithDate(yesterday);
+        List<CourseSchedule> yesterdayCourseSchedules = courseScheduleDao.findCourseScheduleWithDate(settleTime);
         //课程编号列表
         List<Long> courseScheduleIds = yesterdayCourseSchedules.stream().map(CourseSchedule::getId).collect(Collectors.toList());
         if (CollectionUtils.isEmpty(courseScheduleIds)) {

+ 105 - 70
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -288,6 +288,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		//课程结束时间为排课的最后一节课的结束时间
 		vipGroupApplyBaseInfoDto.setCoursesExpireDate(latestCourseSchedule.getEndClassTime());
 
+		vipGroupApplyBaseInfoDto.setPaymentExpireDate(DateUtil.getLastSecondWithDay(vipGroupApplyBaseInfoDto.getPaymentExpireDate()));
+
         //获取vip课类型信息
         VipGroupCategory vipGroupCategory = vipGroupCategoryDao.get(vipGroup.getVipGroupApplyBaseInfo().getVipGroupCategoryId().intValue());
 
@@ -387,7 +389,40 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 //		}
 	}
 
-	@Override
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void checkVipCourseIsInScore(Long vipGroupId) {
+	    if(Objects.isNull(vipGroupId)){
+	        return;
+        }
+	    VipGroup vipGroup=vipGroupDao.get(vipGroupId);
+	    if(Objects.isNull(vipGroup)){
+	        throw new BizException("课程不存在");
+        }
+        Date groupCourseStartTime=courseScheduleDao.findGroupCourseStartTime(GroupType.VIP,vipGroupId.toString());
+        Date groupCourseEndTime=courseScheduleDao.findGroupCourseEndTime(GroupType.VIP,vipGroupId.toString());
+
+        //获取活动信息
+        VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId().intValue());
+        if(Objects.nonNull(vipGroupActivity.getCoursesEndTime())||Objects.nonNull(vipGroupActivity.getCoursesStartTime())){
+            if(groupCourseEndTime.after(vipGroupActivity.getCoursesEndTime())
+                    ||groupCourseStartTime.before(vipGroupActivity.getCoursesStartTime())){
+                throw new BizException("课时安排时间超出范围!");
+            }
+        }else{
+            int totalClassTimes = courseScheduleDao.countGroupAllCourses(GroupType.VIP, vipGroupId.toString());
+            VipGroupDefaultClassesCycle vipGroupDefaultClassesCycle = vipGroupDefaultClassesCycleDao.findByOrganAndClassTimes(totalClassTimes);
+
+            if (vipGroupDefaultClassesCycle != null) {
+                int month = DateUtil.monthsBetween(groupCourseStartTime, groupCourseEndTime);
+                if (month > vipGroupDefaultClassesCycle.getMonth()) {
+                    throw new BizException("课时安排时间超出范围!");
+                }
+            }
+        }
+    }
+
+    @Override
 	@Transactional(rollbackFor = Exception.class)
 	public void updateVipGroup(VipGroupApplyDto vipGroupApplyInfo) {
 		VipGroupApplyBaseInfoDto vipGroupUpdateInfo = vipGroupApplyInfo.getVipGroupApplyBaseInfo();
@@ -1661,59 +1696,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		return studentRecoverInfoDto;
     }
 
-//    @Override
-//	@Transactional(rollbackFor = Exception.class)
-//	public Map<String, BigDecimal> getStudentSurplusCourseFee(Long vipGroupId, Integer studentId) {
-//		if(Objects.isNull(vipGroupId)||Objects.isNull(studentId)){
-//			throw new BizException("请指定课程和学生");
-//		}
-//		VipGroup vipGroup = vipGroupDao.get(vipGroupId);
-//		if(Objects.isNull(vipGroup)){
-//			throw new BizException("未找到指定vip课");
-//		}
-//		if(vipGroup.getStatus().equals(VipGroupStatusEnum.CANCEL)){
-//			throw new BizException("不能对已停止的课程进行退课操作");
-//		}
-//		Date now = new Date();
-//        BigDecimal bigDecimal;
-//        List<StudentCourseInfoDto> userCourseInfos = courseScheduleDao.findUserCourseInfos(GroupType.VIP, vipGroupId.toString(), studentId, null);
-//		if(CollectionUtils.isEmpty(userCourseInfos)&&vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)){
-//            StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, studentId, DealStatusEnum.SUCCESS.getCode());
-//            if(Objects.isNull(studentPaymentOrder)){
-//                bigDecimal=new BigDecimal(0);
-//            }else{
-//                bigDecimal=studentPaymentOrder.getActualAmount();
-//            }
-//        }else if(!CollectionUtils.isEmpty(userCourseInfos)){
-//            BigDecimal historyPrice=new BigDecimal(0);
-//            BigDecimal allPrice=new BigDecimal(0);
-//            for (StudentCourseInfoDto userCourseInfo : userCourseInfos) {
-//                allPrice=allPrice.add(userCourseInfo.getExpectPrice());
-//                if(now.after(userCourseInfo.getStartClassTime())){
-//                    historyPrice=historyPrice.add(userCourseInfo.getTeachMode().equals(TeachModeEnum.ONLINE)?vipGroup.getOnlineClassesUnitPrice():vipGroup.getOfflineClassesUnitPrice());
-//                }
-//            }
-//            bigDecimal=allPrice.subtract(historyPrice);
-//            if(bigDecimal.longValue()<0){
-//                bigDecimal=new BigDecimal(0);
-//            }
-//        }else{
-//		    bigDecimal=new BigDecimal(0);
-//        }
-//        Map<String,BigDecimal> result=new HashMap<>();
-//		ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
-//		if(Objects.isNull(classGroup)){
-//			throw new BizException("未找到对应班级");
-//		}
-//		if(Objects.isNull(bigDecimal)){
-//			bigDecimal = new BigDecimal(0);
-//		}
-//		bigDecimal = bigDecimal.multiply(new BigDecimal(0.8)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
-//		result.put("suplusCourseFee", bigDecimal);
-//		return result;
-//	}
-
-	@Override
+    @Override
 	@Transactional(rollbackFor = Exception.class)
 	public Map<String, BigDecimal> getStudentSurplusCourseFee(Long vipGroupId, Integer studentId) {
 		if(Objects.isNull(vipGroupId)||Objects.isNull(studentId)){
@@ -1726,26 +1709,37 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		if(vipGroup.getStatus().equals(VipGroupStatusEnum.CANCEL)){
 			throw new BizException("不能对已停止的课程进行退课操作");
 		}
-		Map<String,BigDecimal> result=new HashMap<>();
-		if(vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)){
-			StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, studentId, DealStatusEnum.SUCCESS.getCode());
-			if(Objects.isNull(studentPaymentOrder)){
-				BigDecimal surplusCourseFee = studentPaymentOrderDao.sumSurplusCourseFee(vipGroupId.toString(), studentId);
-				if(Objects.isNull(surplusCourseFee)){
-					result.put("suplusCourseFee",new BigDecimal(0));
-				}else{
-					result.put("suplusCourseFee",surplusCourseFee);
-				}
-			}else{
-				result.put("suplusCourseFee",studentPaymentOrder.getActualAmount());
-			}
-			return result;
-		}
+		Date now = new Date();
+        BigDecimal bigDecimal;
+        List<StudentCourseInfoDto> userCourseInfos = courseScheduleDao.findUserCourseInfos(GroupType.VIP, vipGroupId.toString(), studentId, null);
+		if(CollectionUtils.isEmpty(userCourseInfos)&&vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)){
+            StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, studentId, DealStatusEnum.SUCCESS.getCode());
+            if(Objects.isNull(studentPaymentOrder)){
+                bigDecimal=new BigDecimal(0);
+            }else{
+                bigDecimal=studentPaymentOrder.getActualAmount();
+            }
+        }else if(!CollectionUtils.isEmpty(userCourseInfos)){
+            BigDecimal historyPrice=new BigDecimal(0);
+            BigDecimal allPrice=new BigDecimal(0);
+            for (StudentCourseInfoDto userCourseInfo : userCourseInfos) {
+                allPrice=allPrice.add(userCourseInfo.getExpectPrice());
+                if(now.after(userCourseInfo.getStartClassTime())){
+                    historyPrice=historyPrice.add(userCourseInfo.getTeachMode().equals(TeachModeEnum.ONLINE)?vipGroup.getOnlineClassesUnitPrice():vipGroup.getOfflineClassesUnitPrice());
+                }
+            }
+            bigDecimal=allPrice.subtract(historyPrice);
+            if(bigDecimal.longValue()<0){
+                bigDecimal=new BigDecimal(0);
+            }
+        }else{
+		    bigDecimal=new BigDecimal(0);
+        }
+        Map<String,BigDecimal> result=new HashMap<>();
 		ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
 		if(Objects.isNull(classGroup)){
 			throw new BizException("未找到对应班级");
 		}
-		BigDecimal bigDecimal = courseScheduleStudentPaymentDao.countSurplusCourseFee(classGroup.getId(), studentId);
 		if(Objects.isNull(bigDecimal)){
 			bigDecimal = new BigDecimal(0);
 		}
@@ -1754,6 +1748,47 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		return result;
 	}
 
+//	@Override
+//	@Transactional(rollbackFor = Exception.class)
+//	public Map<String, BigDecimal> getStudentSurplusCourseFee(Long vipGroupId, Integer studentId) {
+//		if(Objects.isNull(vipGroupId)||Objects.isNull(studentId)){
+//			throw new BizException("请指定课程和学生");
+//		}
+//		VipGroup vipGroup = vipGroupDao.get(vipGroupId);
+//		if(Objects.isNull(vipGroup)){
+//			throw new BizException("未找到指定vip课");
+//		}
+//		if(vipGroup.getStatus().equals(VipGroupStatusEnum.CANCEL)){
+//			throw new BizException("不能对已停止的课程进行退课操作");
+//		}
+//		Map<String,BigDecimal> result=new HashMap<>();
+//		if(vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)){
+//			StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, studentId, DealStatusEnum.SUCCESS.getCode());
+//			if(Objects.isNull(studentPaymentOrder)){
+//				BigDecimal surplusCourseFee = studentPaymentOrderDao.sumSurplusCourseFee(vipGroupId.toString(), studentId);
+//				if(Objects.isNull(surplusCourseFee)){
+//					result.put("suplusCourseFee",new BigDecimal(0));
+//				}else{
+//					result.put("suplusCourseFee",surplusCourseFee);
+//				}
+//			}else{
+//				result.put("suplusCourseFee",studentPaymentOrder.getActualAmount());
+//			}
+//			return result;
+//		}
+//		ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
+//		if(Objects.isNull(classGroup)){
+//			throw new BizException("未找到对应班级");
+//		}
+//		BigDecimal bigDecimal = courseScheduleStudentPaymentDao.countSurplusCourseFee(classGroup.getId(), studentId);
+//		if(Objects.isNull(bigDecimal)){
+//			bigDecimal = new BigDecimal(0);
+//		}
+//		bigDecimal = bigDecimal.multiply(new BigDecimal(0.8)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
+//		result.put("suplusCourseFee", bigDecimal);
+//		return result;
+//	}
+
 	@Transactional(rollbackFor = Exception.class)
 	@Override
 	public void applyRefundAudit(Long id, StudentApplyRefundsStatus status, String remark,BigDecimal amount) {

+ 21 - 4
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -1921,13 +1921,13 @@
         <where>
             <if test="search != null">
                 AND (cs.name_ LIKE CONCAT('%',#{search},'%') OR cs.id_ = #{search}
-                  <if test="groups != null and organIdList==null">
+                  <if test="groups != null and groupId==null">
                       OR cs.music_group_id_ IN
                       <foreach collection="groups" item="group" open="(" close=")" separator=",">
                           #{group.id}
                       </foreach>
                   </if>
-                  <if test="courseIds != null and organIdList==null">
+                  <if test="courseIds != null and groupId==null">
                     OR cs.id_ IN
                     <foreach collection="courseIds" item="courseId" open="(" close=")" separator=",">
                         #{courseId}
@@ -1935,13 +1935,13 @@
                   </if>
                 )
             </if>
-            <if test="groups != null and organIdList!=null">
+            <if test="groups != null and groupId!=null">
                 AND cs.music_group_id_ IN
                 <foreach collection="groups" item="group" open="(" close=")" separator=",">
                     #{group.id}
                 </foreach>
             </if>
-            <if test="courseIds != null and organIdList!=null">
+            <if test="courseIds != null and groupId!=null">
                 AND cs.id_ IN
                 <foreach collection="courseIds" item="courseId" open="(" close=")" separator=",">
                     #{courseId}
@@ -2055,4 +2055,21 @@
         AND cs.class_date_&gt;=DATE_FORMAT(#{fromDate},"%Y-%m-%d")
         AND (cs.del_flag_ IS NULL OR cs.del_flag_=0)
     </select>
+
+    <select id="findGroupCourseStartTime" resultType="java.util.Date">
+        SELECT MIN(CONCAT(class_date_,' ',start_class_time_)) FROM course_schedule
+        WHERE group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+                AND music_group_id_=#{groupId}
+    </select>
+
+    <select id="findGroupCourseEndTime" resultType="java.util.Date">
+        SELECT MAX(CONCAT(class_date_,' ',end_class_time_)) FROM course_schedule
+        WHERE group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+                AND music_group_id_=#{groupId}
+    </select>
+    <select id="countGroupAllCourses" resultType="int">
+        SELECT COUNT(*) FROM course_schedule
+        WHERE group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+                AND music_group_id_=#{groupId}
+    </select>
 </mapper>

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

@@ -916,6 +916,22 @@ public class DateUtil {
 	}
 
 	/**
+	 * @describe 获取指定时间再当天最后一秒的时间
+	 * @author Joburgess
+	 * @date 2020/1/16
+	 * @param date: 时间
+	 * @return java.util.Date
+	 */
+	public static Date getLastSecondWithDay(Date date){
+		Calendar calendar=Calendar.getInstance();
+		calendar.setTime(date);
+		calendar.set(Calendar.HOUR_OF_DAY,23);
+		calendar.set(Calendar.MINUTE, 59);
+		calendar.set(Calendar.SECOND, 59);
+		return calendar.getTime();
+	}
+
+	/**
 	 * @describe 根据日期获取所在周的周一
 	 * @author Joburgess
 	 * @date 2019/10/25