|
@@ -121,7 +121,16 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
result.setPlanList(coursePlanService.queryCoursePlanByGroupId(groupId));
|
|
|
//课程组学员信息
|
|
|
result.setStudentList(courseScheduleStudentPaymentService.queryStudentInfoByGroupId(groupId));
|
|
|
-
|
|
|
+ //查询是否购买过该课程组
|
|
|
+ Long id = getSysUser().getId();
|
|
|
+ List<CourseScheduleStudentPayment> paymentList = courseScheduleStudentPaymentService.list(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
|
|
|
+ .eq(CourseScheduleStudentPayment::getUserId, id)
|
|
|
+ .eq(CourseScheduleStudentPayment::getCourseGroupId, groupId)
|
|
|
+ );
|
|
|
+ result.setExistBuy(0);
|
|
|
+ if (CollectionUtils.isNotEmpty(paymentList)) {
|
|
|
+ result.setExistBuy(1);
|
|
|
+ }
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -141,6 +150,27 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
Page<CourseGroupVo> pageInfo = PageUtil.getPageInfo(param);
|
|
|
pageInfo.setAsc("b.created_time_");
|
|
|
IPage<CourseGroupVo> page = baseMapper.queryTeacherCourseGroup(pageInfo, param);
|
|
|
+ //学生端查询报名中的课程组需要标明该学生是否已经购买过该课程组
|
|
|
+ String os = WrapperUtil.toStr(param, "os");
|
|
|
+ if ("student".equals(os) && CollectionUtils.isNotEmpty(page.getRecords())) {
|
|
|
+ //获取当前课程组Id
|
|
|
+ List<CourseGroupVo> records = page.getRecords();
|
|
|
+ List<Long> groupId = records.stream().map(CourseGroupVo::getCourseGroupId).collect(Collectors.toList());
|
|
|
+ //根据学生id 及 课程组id集合查询购买记录
|
|
|
+ List<CourseScheduleStudentPayment> paymentList = courseScheduleStudentPaymentService.list(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
|
|
|
+ .eq(CourseScheduleStudentPayment::getUserId, getSysUser().getId())
|
|
|
+ .in(CourseScheduleStudentPayment::getCourseGroupId, groupId)
|
|
|
+ );
|
|
|
+ if (CollectionUtils.isNotEmpty(paymentList)) {
|
|
|
+ Map<Long, List<CourseScheduleStudentPayment>> payMap = WrapperUtil.groupList(paymentList, CourseScheduleStudentPayment::getCourseGroupId);
|
|
|
+ records.forEach(o -> {
|
|
|
+ o.setExistBuy(0);
|
|
|
+ if (payMap.containsKey(o.getCourseGroupId())) {
|
|
|
+ o.setExistBuy(1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
return PageUtil.pageInfo(page);
|
|
|
}
|
|
|
|
|
@@ -253,9 +283,10 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
/**
|
|
|
* 创建课时写到缓存锁定时间
|
|
|
*/
|
|
|
+ @Override
|
|
|
public List<CourseTimeEntity> lockCourseToCache(CheckCourseTimeDto dto) {
|
|
|
- //获取课程类型
|
|
|
- CourseScheduleEnum courseType = CourseScheduleEnum.existCourseType(dto.getCourseType(), "课程类型不正确!");
|
|
|
+ // true:陪练课PRACTICE false:LIVE直播课
|
|
|
+ boolean courseTypeFlag = CourseScheduleEnum.existCourseType(dto.getCourseType(), "课程类型不正确!").equals(CourseScheduleEnum.PRACTICE);
|
|
|
//先自校验传入时间是否交集
|
|
|
List<CourseTimeEntity> timeList = dto.getTimeList();
|
|
|
if (timeList.size() > 1) {
|
|
@@ -273,21 +304,21 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
}
|
|
|
//批量检查老师课时在数据库是否重复
|
|
|
batchCheckTeacherCourseTime(dto.getTeacherId(), timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime);
|
|
|
- //获取老师锁课缓存并添加课时数据
|
|
|
- RMap<Long, List<CourseTimeEntity>> map = getExpireLiveLockTimeCache(dto.getTeacherId());
|
|
|
- map.fastPut(dto.getTeacherId(), timeList);
|
|
|
|
|
|
//需要自动补全课时
|
|
|
if (dto.getLoop() == 1) {
|
|
|
//自动排课,获取排课后所有的课程时间
|
|
|
- List<CourseTimeEntity> allCourseTime = autoPlanningLiveCourseTime(dto.getTeacherId(), dto.getCourseNum(), timeList, courseType);
|
|
|
- allCourseTime.sort(Comparator.comparing(CourseTimeEntity::getStartTime));
|
|
|
- //替换掉原有的课时
|
|
|
- dto.setTimeList(allCourseTime);
|
|
|
- //将自动排课后的课时写入缓存覆盖原有的
|
|
|
- map.fastPut(dto.getTeacherId(), dto.getTimeList());
|
|
|
+ timeList = autoPlanningLiveCourseTime(dto.getTeacherId(), dto.getCourseNum(), timeList, courseTypeFlag);
|
|
|
+ timeList.sort(Comparator.comparing(CourseTimeEntity::getStartTime));
|
|
|
+ }
|
|
|
+ //获取老师锁课缓存
|
|
|
+ RMap<Long, List<CourseTimeEntity>> map = getExpireLiveLockTimeCache(dto.getTeacherId());
|
|
|
+ //陪练课无需锁定时间
|
|
|
+ if (!courseTypeFlag) {
|
|
|
+ //直播课添加课时数据
|
|
|
+ map.fastPut(dto.getTeacherId(), timeList);
|
|
|
}
|
|
|
- return dto.getTimeList();
|
|
|
+ return timeList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -331,14 +362,12 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
* @param teacherId 老师id
|
|
|
* @param totalCourseNum 总课程数量
|
|
|
* @param paramTimeList 当前课程的时间段
|
|
|
- * @param courseType PRACTICE陪练课 LIVE直播课
|
|
|
+ * @param courseTypeFlag true:陪练课PRACTICE false:LIVE直播课
|
|
|
* @return 自动排课后的全部课时
|
|
|
*/
|
|
|
- private List<CourseTimeEntity> autoPlanningLiveCourseTime(Long teacherId, int totalCourseNum, List<CourseTimeEntity> paramTimeList, CourseScheduleEnum courseType) {
|
|
|
+ private List<CourseTimeEntity> autoPlanningLiveCourseTime(Long teacherId, int totalCourseNum, List<CourseTimeEntity> paramTimeList, boolean courseTypeFlag) {
|
|
|
//是否跳过节假日
|
|
|
boolean skipHoliday = false;
|
|
|
- //true 陪练课
|
|
|
- boolean courseTypeFlag = courseType.equals(CourseScheduleEnum.PRACTICE);
|
|
|
if (courseTypeFlag) {
|
|
|
//查询老师陪练课设置
|
|
|
TeacherFreeTime teacherTime = teacherFreeTimeService.getOne(Wrappers.<TeacherFreeTime>lambdaQuery()
|