|
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.CourseScheduleDao;
|
|
@@ -43,8 +44,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.text.DateFormat;
|
|
|
-import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
@@ -269,6 +268,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 +346,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 +462,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 +487,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 +499,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
times.add(courseTimeEntity);
|
|
|
});
|
|
|
entity.setCourseTime(times);
|
|
|
+ return entity;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -510,13 +511,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);
|
|
@@ -535,9 +533,12 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
* @param studentId 学员id
|
|
|
*/
|
|
|
private Map<String, List<CourseTimeEntity>> getAllPracticeCourseTime(Long teacherId, Long studentId, String startDate, String endDate) {
|
|
|
+ //未开始、进行中的课程
|
|
|
+ List<String> statusList = Lists.newArrayList(CourseScheduleEnum.NOT_START.getCode(), CourseScheduleEnum.ING.getCode());
|
|
|
//查询该老师指定时间段的课程
|
|
|
List<CourseSchedule> courseList = this.list(Wrappers.<CourseSchedule>lambdaQuery()
|
|
|
.eq(CourseSchedule::getTeacherId, teacherId)
|
|
|
+ .in(CourseSchedule::getStatus, statusList)
|
|
|
.ge(CourseSchedule::getClassDate, startDate)
|
|
|
.le(CourseSchedule::getClassDate, endDate)
|
|
|
);
|
|
@@ -549,6 +550,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
param.put("studentId", studentId);
|
|
|
param.put("startClassDate", startDate);
|
|
|
param.put("endClassDate", endDate);
|
|
|
+ param.put("statusList", statusList);
|
|
|
List<CourseSchedule> studentCourse = baseMapper.queryStudentCourse(param);
|
|
|
//将数据合并
|
|
|
if (CollectionUtils.isNotEmpty(studentCourse)) {
|
|
@@ -647,7 +649,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 +910,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 +949,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 +963,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 +991,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 +1037,110 @@ 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) {
|
|
|
+ Map<Long, String> teacherReceivers = new HashMap<>();
|
|
|
+ teacherReceivers.put(sysUser.getId(), sysUser.getPhone());
|
|
|
+ Map<Long, String> teacherSms = new HashMap<>();
|
|
|
+ teacherSms.put(sysUser.getId(), sysUser.getPhone());
|
|
|
+
|
|
|
+ Integer liveCount=0;
|
|
|
+ Integer practiceCount=0;
|
|
|
+ List<CountVo> typeCount=baseMapper.selectTypeCount(sysUser.getId(),tomorrow);
|
|
|
+ for (CountVo countVo : typeCount) {
|
|
|
+ if (countVo.getType().equals(CourseScheduleEnum.LIVE.getCode())) {
|
|
|
+ liveCount=countVo.getCount();
|
|
|
+ }
|
|
|
+ if (countVo.getType().equals(CourseScheduleEnum.PRACTICE.getCode())) {
|
|
|
+ practiceCount=countVo.getCount();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //老师端-明日课程提醒
|
|
|
+ String teacherUrl = sysMessageService.selectConfigUrl(MessageTypeEnum.SMS_TOMORROW_COURSE_REMINDER.getCode());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.TOMORROW_COURSE_REMINDER,
|
|
|
+ teacherReceivers, null, 0, null, ClientEnum.TEACHER.getCode(),
|
|
|
+ practiceCount.toString(),liveCount.toString(),teacherUrl);
|
|
|
+ log.info("send success {}",MessageTypeEnum.TOMORROW_COURSE_REMINDER);
|
|
|
+
|
|
|
+ //老师端-明日课程提醒(短信)
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.SMS_TOMORROW_COURSE_REMINDER,
|
|
|
+ teacherSms, null, 0, null, null,
|
|
|
+ practiceCount, liveCount);
|
|
|
+ log.info("send success {}",MessageTypeEnum.SMS_STUDENT_BUY_PRACTICE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|