|
@@ -269,6 +269,9 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
calendarEntity.setFullCourse(0);// 0:未满 1满
|
|
|
} else {
|
|
|
//将日历时间与课程时间进行对比,如果有交集则将日历的时间数据删除
|
|
|
+ if (CollectionUtils.isEmpty(calendarEntity.getCourseTime())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
Iterator<CourseTimeEntity> iterator = calendarEntity.getCourseTime().iterator();
|
|
|
while (iterator.hasNext()) {
|
|
|
CourseTimeEntity next = iterator.next();
|
|
@@ -344,12 +347,10 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
int addDay = 0;
|
|
|
//获取每日日期数据
|
|
|
while (firstDay.isBefore(lastDay) || firstDay.isEqual(lastDay)) {
|
|
|
- CourseCalendarEntity entity = new CourseCalendarEntity();
|
|
|
- List<CourseTimeEntity> times = new ArrayList<>();
|
|
|
+ //将每日上课时间时间添加到日历中
|
|
|
+ CourseCalendarEntity entity = opsCourseDayTime(addDay, dayTime);
|
|
|
//获取当前日期
|
|
|
entity.setDate(firstDay.toString());
|
|
|
- //将每日上课时间时间添加到日历中
|
|
|
- opsCourseDayTime(addDay, entity, times, dayTime);
|
|
|
list.add(entity);
|
|
|
firstDay = firstDay.plusDays(1L);
|
|
|
addDay++;
|
|
@@ -462,7 +463,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
//获取当前日期周几
|
|
|
int weekNum = firstDay.getDayOfWeek().getValue();
|
|
|
JSONArray jsonArray = teacherPracticeTime.get(weekNum);
|
|
|
- if (Objects.nonNull(jsonArray)){
|
|
|
+ if (Objects.nonNull(jsonArray)) {
|
|
|
List<CourseTimeEntity> timeEntities = jsonArray.stream()
|
|
|
.map(t -> getCourseTimeEntity(entity, (JSONObject) t))
|
|
|
.collect(Collectors.toList());
|
|
@@ -487,11 +488,11 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
* 将每日上课时间时间添加到日历中
|
|
|
*
|
|
|
* @param addDay 添加的天数
|
|
|
- * @param entity 实体数据
|
|
|
- * @param times 课程数据集合
|
|
|
* @param timeEntities 每日上课时间集合
|
|
|
*/
|
|
|
- private void opsCourseDayTime(int addDay, CourseCalendarEntity entity, List<CourseTimeEntity> times, List<CourseTimeEntity> timeEntities) {
|
|
|
+ private CourseCalendarEntity opsCourseDayTime(int addDay, List<CourseTimeEntity> timeEntities) {
|
|
|
+ CourseCalendarEntity entity = new CourseCalendarEntity();
|
|
|
+ List<CourseTimeEntity> times = new ArrayList<>();
|
|
|
timeEntities.forEach(time -> {
|
|
|
CourseTimeEntity courseTimeEntity = new CourseTimeEntity();
|
|
|
courseTimeEntity.setStartTime(DateUtil.addDays(time.getStartTime(), addDay));
|
|
@@ -499,6 +500,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
times.add(courseTimeEntity);
|
|
|
});
|
|
|
entity.setCourseTime(times);
|
|
|
+ return entity;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -510,13 +512,10 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
Map<Integer, JSONArray> teacherPracticeTime = new HashMap<>();
|
|
|
//将老师设置的陪练课时间放入map中
|
|
|
BiConsumer<String, Integer> timeCon = (timeStr, weekNum) -> {
|
|
|
- if (StringUtils.isBlank(timeStr)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- JSONArray objects = JSONObject.parseArray(timeStr);
|
|
|
- if (CollectionUtils.isNotEmpty(objects)) {
|
|
|
- teacherPracticeTime.put(weekNum, objects);
|
|
|
- }
|
|
|
+ Optional.ofNullable(timeStr)
|
|
|
+ .map(JSONObject::parseArray)
|
|
|
+ .filter(CollectionUtils::isNotEmpty)
|
|
|
+ .ifPresent(objects -> teacherPracticeTime.put(weekNum, objects));
|
|
|
};
|
|
|
timeCon.accept(teacherTime.getMonday(), 1);
|
|
|
timeCon.accept(teacherTime.getTuesday(), 2);
|
|
@@ -647,7 +646,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
List<Long> userList = paymentDao.selectAll();
|
|
|
//取差集
|
|
|
userList.removeAll(studentList);
|
|
|
- if (userList.isEmpty()) {
|
|
|
+ if (CollectionUtils.isEmpty(userList)) {
|
|
|
return page.setRecords(new ArrayList<>());
|
|
|
}
|
|
|
search.setRepliedIds(userList);
|
|
@@ -908,7 +907,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
log.info("buyPracticeCourseSuccess param:{}", JSON.toJSONString(orderParam));
|
|
|
String orderNo = orderParam.getOrderNo();
|
|
|
List<CourseScheduleStudentPaymentVo> paymentList = paymentDao.selectPaymentList(orderNo);
|
|
|
- if (paymentList.isEmpty()) {
|
|
|
+ if (CollectionUtils.isEmpty(paymentList)) {
|
|
|
throw new BizException("订单不存在!");
|
|
|
}
|
|
|
|
|
@@ -947,47 +946,12 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
|
|
|
//消息推送
|
|
|
try {
|
|
|
- practiceSend(paymentList.get(0).getTeacherId(), orderParam.getUserId(),paymentList.size() + "",orderNo);
|
|
|
- }catch (Exception e){
|
|
|
+ practiceSend(paymentList.get(0).getTeacherId(), orderParam.getUserId(), paymentList.size() + "", orderNo);
|
|
|
+ } catch (Exception e) {
|
|
|
log.error("陪练课消息推送失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void practiceSend(Long teacherId, Long studentId,String courseNum,String orderNo) {
|
|
|
- //查询老师&学生信息
|
|
|
- SysUser teacher = sysUserFeignService.queryUserById(teacherId);
|
|
|
- SysUser student = sysUserFeignService.queryUserById(studentId);
|
|
|
-
|
|
|
- //消息接收者(Key:用户编号 value:消息接收对象)
|
|
|
- Map<Long, String> teacherReceivers = new HashMap<>();
|
|
|
- teacherReceivers.put(teacherId, teacher.getPhone());
|
|
|
- Map<Long, String> studentReceivers = new HashMap<>();
|
|
|
- studentReceivers.put(studentId, student.getPhone());
|
|
|
-
|
|
|
- //老师端-学生买陪练课
|
|
|
- String teacherUrl = sysMessageService.selectConfigUrl(MessageTypeEnum.STUDENT_BUY_PRACTICE.getCode());
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_BUY_PRACTICE,
|
|
|
- teacherReceivers, null, 0, null, ClientEnum.TEACHER.getCode(),
|
|
|
- student.getUsername(),courseNum, teacherUrl);
|
|
|
-
|
|
|
- //学生端-买陪练课
|
|
|
- String studentUrl = sysMessageService.selectConfigUrl(MessageTypeEnum.PRACTICE_BUY.getCode());
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PRACTICE_BUY,
|
|
|
- studentReceivers, null, 0, null, ClientEnum.STUDENT.getCode(),
|
|
|
- teacher.getUsername(), courseNum, studentUrl);
|
|
|
-
|
|
|
- //陪练课开课提醒
|
|
|
- List<String> startTimeList = baseMapper.selectStartTime(orderNo);
|
|
|
- for (String startTime : startTimeList) {
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PRACTICE_REMINDER,
|
|
|
- teacherReceivers, DateUtil.offsetMinute(startTime, -20), 0, null, ClientEnum.TEACHER.getCode(),
|
|
|
- student.getUsername());
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PRACTICE_REMIND,
|
|
|
- studentReceivers, DateUtil.offsetMinute(startTime, -20), 0, null, ClientEnum.STUDENT.getCode(),
|
|
|
- teacher.getUsername());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 学生购买陪练课-失败-回调
|
|
|
*/
|
|
@@ -996,7 +960,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
String orderNo = orderParam.getOrderNo();
|
|
|
List<CourseScheduleStudentPayment> paymentList = paymentDao.selectList(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
|
|
|
.eq(CourseScheduleStudentPayment::getOrderNo, orderNo));
|
|
|
- if (paymentList.isEmpty()) {
|
|
|
+ if (CollectionUtils.isEmpty(paymentList)) {
|
|
|
throw new BizException("订单不存在!");
|
|
|
}
|
|
|
|
|
@@ -1024,16 +988,21 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @Description: 学生-首页-直播课&视频课
|
|
|
+ * @Description: 首页-直播课&视频课
|
|
|
* @Author: cy
|
|
|
* @Date: 2022/4/22
|
|
|
*/
|
|
|
@Override
|
|
|
- public StudentHomePage queryLiveAndVideo(Long studentId) {
|
|
|
+ public StudentHomePage queryLiveAndVideo(Long studentId, Long teacherId) {
|
|
|
StudentHomePage homePage = new StudentHomePage();
|
|
|
- homePage.setLiveList(baseMapper.selectLive());
|
|
|
- homePage.setVideoList(baseMapper.selectVideo());
|
|
|
- homePage.setRecentCourses(baseMapper.selectRecentCourses(studentId));
|
|
|
+ if (teacherId == null) {
|
|
|
+ homePage.setLiveList(baseMapper.selectLive());
|
|
|
+ homePage.setVideoList(baseMapper.selectVideo());
|
|
|
+ homePage.setRecentCourses(baseMapper.selectRecentCourses(studentId));
|
|
|
+ }
|
|
|
+ if (studentId == null) {
|
|
|
+ homePage.setRecentCourses(baseMapper.selectRecentCoursesTeacher(teacherId));
|
|
|
+ }
|
|
|
return homePage;
|
|
|
}
|
|
|
|
|
@@ -1065,4 +1034,82 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
public Integer getWeekStudentRepliedCourseSchedule(Long userId) {
|
|
|
return baseMapper.selectWeekStudentRepliedCourseSchedule(userId);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description: 购买陪练课消息推送
|
|
|
+ * @Author: cy
|
|
|
+ * @Date: 2022/5/6
|
|
|
+ */
|
|
|
+ public void practiceSend(Long teacherId, Long studentId, String courseNum, String orderNo) {
|
|
|
+ //查询老师&学生信息
|
|
|
+ SysUser teacher = sysUserFeignService.queryUserById(teacherId);
|
|
|
+ SysUser student = sysUserFeignService.queryUserById(studentId);
|
|
|
+
|
|
|
+ //消息接收者(Key:用户编号 value:消息接收对象)
|
|
|
+ Map<Long, String> teacherReceivers = new HashMap<>();
|
|
|
+ teacherReceivers.put(teacherId, teacher.getPhone());
|
|
|
+ Map<Long, String> studentReceivers = new HashMap<>();
|
|
|
+ studentReceivers.put(studentId, student.getPhone());
|
|
|
+ Map<Long, String> teacherSms = new HashMap<>();
|
|
|
+ teacherSms.put(teacherId, teacher.getPhone());
|
|
|
+ Map<Long, String> studentSms = new HashMap<>();
|
|
|
+ studentSms.put(studentId, student.getPhone());
|
|
|
+
|
|
|
+ //老师端-学生买陪练课
|
|
|
+ String teacherUrl = sysMessageService.selectConfigUrl(MessageTypeEnum.STUDENT_BUY_PRACTICE.getCode());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_BUY_PRACTICE,
|
|
|
+ teacherReceivers, null, 0, null, ClientEnum.TEACHER.getCode(),
|
|
|
+ student.getUsername(), courseNum, teacherUrl);
|
|
|
+ log.info("send success {}", MessageTypeEnum.STUDENT_BUY_PRACTICE);
|
|
|
+
|
|
|
+ //老师端-学生买陪练课(短信)
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.SMS_STUDENT_BUY_PRACTICE,
|
|
|
+ teacherSms, null, 0, null, null,
|
|
|
+ student.getUsername(), courseNum);
|
|
|
+ log.info("send success {}", MessageTypeEnum.SMS_STUDENT_BUY_PRACTICE);
|
|
|
+
|
|
|
+ //学生端-买陪练课
|
|
|
+ String studentUrl = sysMessageService.selectConfigUrl(MessageTypeEnum.PRACTICE_BUY.getCode());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PRACTICE_BUY,
|
|
|
+ studentReceivers, null, 0, null, ClientEnum.STUDENT.getCode(),
|
|
|
+ teacher.getUsername(), courseNum, studentUrl);
|
|
|
+ log.info("send success {}", MessageTypeEnum.PRACTICE_BUY);
|
|
|
+
|
|
|
+ //学生端-买陪练课(短信)
|
|
|
+ String studentSmsUrl = sysMessageService.selectConfigUrl(MessageTypeEnum.SMS_PRACTICE_BUY.getCode());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.SMS_PRACTICE_BUY,
|
|
|
+ studentSms, null, 0, null, null,
|
|
|
+ teacher.getUsername(), courseNum, studentSmsUrl);
|
|
|
+ log.info("send success {}", MessageTypeEnum.SMS_PRACTICE_BUY);
|
|
|
+
|
|
|
+ List<String> startTimeList = baseMapper.selectStartTime(orderNo);
|
|
|
+ for (String startTime : startTimeList) {
|
|
|
+ //老师端-陪练课开课提醒
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PRACTICE_REMINDER,
|
|
|
+ teacherReceivers, DateUtil.offsetMinute(startTime, -20), 0, null, ClientEnum.TEACHER.getCode(),
|
|
|
+ student.getUsername());
|
|
|
+
|
|
|
+ //学生端-陪练课开课提醒
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PRACTICE_REMIND,
|
|
|
+ studentReceivers, DateUtil.offsetMinute(startTime, -20), 0, null, ClientEnum.STUDENT.getCode(),
|
|
|
+ teacher.getUsername());
|
|
|
+ }
|
|
|
+ log.info("send success {}", MessageTypeEnum.PRACTICE_REMIND);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description: 明日课程提醒(每晚9点)
|
|
|
+ * @Author: cy
|
|
|
+ * @Date: 2022/5/6
|
|
|
+ */
|
|
|
+ public void courseRemind() {
|
|
|
+ String tomorrow = new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.addDays1(new Date(), 1));
|
|
|
+ //查询明天有课的老师
|
|
|
+ List<SysUser> userList = baseMapper.selectTeacher(tomorrow);
|
|
|
+ if (CollectionUtils.isNotEmpty(userList)) {
|
|
|
+ for (SysUser sysUser : userList) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|