|
@@ -1154,6 +1154,18 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 批量检查学生课时在数据库是否重复
|
|
|
+ *
|
|
|
+ * @param studentIds 老师id
|
|
|
+ * @param timeList 时间集合
|
|
|
+ */
|
|
|
+ private <T> void batchCheckStudentCourseTime(List<Long> studentIds, List<T> timeList, Function<T, Date> startTimeFun, Function<T, Date> endTimeFun) {
|
|
|
+ for (Long studentId : studentIds) {
|
|
|
+ batchCheckStudentCourseTime(studentId, timeList, startTimeFun, endTimeFun);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* @Description: 趣纠课购买记录
|
|
|
* @Author: cy
|
|
|
* @Date: 2022/5/16
|
|
@@ -1459,9 +1471,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
}
|
|
|
|
|
|
//查询是否有人购买
|
|
|
- CourseScheduleStudentPayment studentPayment = paymentDao.selectOne(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
|
|
|
- .eq(CourseScheduleStudentPayment::getCourseId, courseId));
|
|
|
- if (ObjectUtil.isEmpty(studentPayment)) {
|
|
|
+ List<CourseScheduleStudentPayment> studentPayments = paymentDao.queryByCourseId(courseId.longValue());
|
|
|
+ if (CollectionUtils.isNotEmpty(studentPayments)) {
|
|
|
throw new BizException("课程无人购买");
|
|
|
}
|
|
|
|
|
@@ -1487,21 +1498,21 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
//校验老师课程是否冲突
|
|
|
this.batchCheckTeacherCourseTime(teacherId, timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getFreeEndTime);
|
|
|
//校验学生课程是否冲突
|
|
|
- this.batchCheckStudentCourseTime(studentPayment.getUserId(), timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime);
|
|
|
-
|
|
|
+ List<Long> studentIds = studentPayments.stream().map(CourseScheduleStudentPayment::getUserId).collect(Collectors.toList());
|
|
|
+ this.batchCheckStudentCourseTime(studentIds, timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime);
|
|
|
baseMapper.courseAdjust(adjustVo);
|
|
|
-
|
|
|
// 课程调整后给学生发消息
|
|
|
- sendCourseAdjustMessage(teacherId,studentPayment.getUserId(),adjustVo.getCourseId(),adjustVo.getStartTime(),oldStartTime);
|
|
|
+ sendCourseAdjustMessage(teacherId,studentIds,adjustVo.getCourseId(),adjustVo.getStartTime(),oldStartTime);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//{老师昵称}已将{课程类型趣纠课、琴房课}{课程名称}课调整到{上课时间yyyy-MM-dd HH:mm:ss},请注意查看
|
|
|
- private void sendCourseAdjustMessage(Long teacherId,Long studentId,Integer courseScheduleId,Date date,Date oldStartTime) {
|
|
|
+ private void sendCourseAdjustMessage(Long teacherId,List<Long> studentIds,Integer courseScheduleId,Date date,Date oldStartTime) {
|
|
|
// 趣纠课调整模板
|
|
|
try {
|
|
|
// 发送消息
|
|
|
SysUser teacher = sysUserService.getByUserId(teacherId);
|
|
|
- SysUser student = sysUserService.getByUserId(studentId);
|
|
|
+ List<com.yonge.cooleshow.biz.dal.entity.SysUser> sysUsers = sysUserService.getDao().selectBatchIds(studentIds);
|
|
|
|
|
|
CourseSchedule courseSchedule = this.getById(courseScheduleId);
|
|
|
CourseGroup courseGroup = courseGroupService.getById(courseSchedule.getCourseGroupId());
|
|
@@ -1517,8 +1528,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
}else if(CourseTypeEnum.valueOf(courseGroup.getType()) == CourseTypeEnum.GROUP){
|
|
|
messageType = MessageTypeEnum.GROUP_ADJUST;
|
|
|
}
|
|
|
- Map<Long, String> receivers = new HashMap<>();
|
|
|
- receivers.put(studentId, student.getPhone());
|
|
|
+ Map<Long, String> receivers = sysUsers.stream()
|
|
|
+ .collect(Collectors.toMap(com.yonge.cooleshow.biz.dal.entity.SysUser::getId, com.yonge.cooleshow.biz.dal.entity.SysUser::getPhone));
|
|
|
// String url = sysMessageService.selectConfigUrl(MessageTypeEnum.PRACTICE_ADJUST.getCode(),courseSchedule.getId());
|
|
|
sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG,
|
|
|
messageType,
|