|
@@ -1603,13 +1603,32 @@ public class MyController {
|
|
|
throw new ParameterException("课程类型错误");
|
|
|
}
|
|
|
List<UserCourseDetailDto> pr = Transform.convert(p, UserCourseDetailDto.class);
|
|
|
+ Map<Integer, UserOrderRecord> map = new HashMap<>();
|
|
|
+ for(UserOrderRecord record : p){
|
|
|
+ map.put(record.getId(), record);
|
|
|
+ }
|
|
|
|
|
|
Collection recordIds = Transform.getIds(p, UserOrderRecord.class,"id");
|
|
|
|
|
|
// 绑定课程
|
|
|
Collection courseIds = Transform.getIds(p, UserOrderRecord.class, "productId");
|
|
|
List<Course> courseList = courseService.select(courseIds);
|
|
|
+ Map courseMap = Transform.getMap(courseList, Course.class, "id");
|
|
|
Transform.combine(pr, courseList, UserCourseDetailDto.class, "productId", "course", Course.class, "id", CourseExtendDto.class);
|
|
|
+ for(UserCourseDetailDto dto : pr){
|
|
|
+ Course course = (Course)courseMap.get(dto.getProductId());
|
|
|
+ CourseExtendDto courseExtendDto = dto.getCourse();
|
|
|
+ if (course.getCourseModule().equals(CourseModule.VS.key)){
|
|
|
+ // 根据课时数进行计算
|
|
|
+ courseExtendDto.setExpireDays(courseExtendService.computeExpire(dto.getNumber(), course));
|
|
|
+ }else if(course.getCourseModule().equals(CourseModule.VIDEO.key)){
|
|
|
+ // 根据设置进行计算
|
|
|
+ courseExtendDto.setExpireDays(courseExtendService.computeExpire(course));
|
|
|
+ }else if(course.getCourseModule().equals(CourseModule.ONLINE.key)){
|
|
|
+ // 根据使用时长计算
|
|
|
+ courseExtendDto.setExpireDays((int)(dto.getUseEndTime().getTime() - dto.getUseStartTime().getTime() / 86400000));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// 绑定课时、预约、进度
|
|
|
Map<Object, Collection<CourseNo>> courseNoMap = courseNoService.groupByCourseId(courseIds);
|
|
@@ -1625,12 +1644,14 @@ public class MyController {
|
|
|
if (list == null || list.size() == 0) continue;
|
|
|
Collection<CourseNo> courseNos = courseNoMap.get(dto.getProductId());
|
|
|
dto.setCurrentNo(courseExtendService.computeCourseNoCurrent(courseNos, list));
|
|
|
- dto.setTotalDays(courseExtendService.computeCourseDay(recordMap.get(dto.getId())));
|
|
|
+ Collection<UserCourseRecord> userCourseRecords = recordMap.get(dto.getId());
|
|
|
+ dto.setTotalTime(courseExtendService.computeCourseTime(userCourseRecords));
|
|
|
+ dto.setTotalDays(courseExtendService.computeCourseDay(map.get(dto.getId()), userCourseRecords));
|
|
|
}
|
|
|
|
|
|
// 获取每个科目的所有作业
|
|
|
Map<Object, Collection<UserPreviewPaperRelation>> previewMap = previewService.groupByCourseId(user.getId(), recordIds, 1000);
|
|
|
- Transform.combine(pr, previewMap, UserCourseDetailDto.class, "productId", "papers", UserPaperBaseExtendDto.class);
|
|
|
+ Transform.combine(pr, previewMap, UserCourseDetailDto.class, "productId", "papers", BasePaperExtendDto.class);
|
|
|
for(UserCourseDetailDto dto : pr){
|
|
|
Collection<UserPreviewPaperRelation> list = previewMap.get(dto.getId());
|
|
|
if (list == null || list.size() == 0) continue;
|
|
@@ -1650,6 +1671,39 @@ public class MyController {
|
|
|
List<CourseTeacher> teacherList = courseTeacherService.select(teacherIds);
|
|
|
Transform.combine(pr, teacherList, UserCourseDetailDto.class, "teacherId", "teacher", CourseTeacher.class, "id", CourseTeacherExtendDto.class);
|
|
|
|
|
|
+ // 提问数、笔记数
|
|
|
+ Map<Object, Collection<UserAskCourse>> askMap = userAskCourseService.groupByRecordId(recordIds);
|
|
|
+ Transform.combine(pr, appointmentMap, UserCourseDetailDto.class, "productId", "appointments", UserCourseAppointmentExtendDto.class);
|
|
|
+
|
|
|
+ Map<Object, Collection<UserNoteCourse>> noteMap = userNoteCourseService.groupByCourse(courseIds);
|
|
|
+ Transform.combine(pr, appointmentMap, UserCourseDetailDto.class, "productId", "notes", UserNoteCourseExtendDto.class);
|
|
|
+ for(UserCourseDetailDto dto : pr){
|
|
|
+ Collection<CourseNoExtendDto> courseNos = dto.getCourseNos();
|
|
|
+ if (courseNos == null) continue;
|
|
|
+ Collection<UserAskCourse> askList = askMap.get(dto.getId());
|
|
|
+ Map<Object, List<UserAskCourse>> askListMap = Transform.getMapList(askList, UserAskCourse.class, "courseNoId");
|
|
|
+ Collection<UserNoteCourse> noteList = noteMap.get(dto.getProductId());
|
|
|
+ Map notes = Transform.getMap(noteList, UserNoteCourse.class, "courseNoId");
|
|
|
+ int noteNumber = 0;
|
|
|
+ int askNumber = askList.size();
|
|
|
+ int answerNumber = (int)askList.stream().filter(r->r.getAnswerStatus()==AskStatus.ANSWER.index).count();
|
|
|
+ for(CourseNoExtendDto courseNo : courseNos){
|
|
|
+ if (notes.get(courseNo.getId()) != null){
|
|
|
+ courseNo.setNote(true);
|
|
|
+ noteNumber += 1;
|
|
|
+ }
|
|
|
+ List<UserAskCourse> askListNo = askListMap.get(courseNo.getId());
|
|
|
+ if (askListNo != null){
|
|
|
+ courseNo.setAskNumber(askListNo.size());
|
|
|
+ courseNo.setAnswerNumber((int)askListNo.stream().filter(r->r.getAnswerStatus()==AskStatus.ANSWER.index).count());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dto.setNoteNumber(noteNumber);
|
|
|
+ dto.setAskNumber(askNumber);
|
|
|
+ dto.setAnswerNumber(answerNumber);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
}
|
|
|
|
|
@@ -1742,4 +1796,37 @@ public class MyController {
|
|
|
|
|
|
return ResponseHelp.success(dtos);
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping(value = "/export/question/error", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "关闭提示", notes = "关闭提示", httpMethod = "POST")
|
|
|
+ public Response<List<UserQuestionDetailDto>> exportQuestionError() {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+
|
|
|
+ return ResponseHelp.success(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/export/tips", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "关闭提示", notes = "关闭提示", httpMethod = "POST")
|
|
|
+ public Response<Boolean> exportTips() {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+
|
|
|
+ User in = usersService.get(user.getId());
|
|
|
+ usersService.edit(User.builder()
|
|
|
+ .id(user.getId())
|
|
|
+ .exportTips(1)
|
|
|
+ .build());
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/course/comment/tips", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "关闭评论提示提示", notes = "关闭评论提示提示", httpMethod = "POST")
|
|
|
+ public Response<Boolean> exportTips(@RequestBody @Validated RecordCommentTipsDto dto) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ UserOrderRecord record = userOrderRecordService.get(dto.getRecordId());
|
|
|
+ userOrderRecordService.edit(UserOrderRecord.builder()
|
|
|
+ .id(dto.getRecordId())
|
|
|
+ .commentTips(1)
|
|
|
+ .build());
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
}
|