|
@@ -3,12 +3,24 @@ package com.zhongzheng.modules.order.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.http.HttpStatus;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.zhongzheng.common.core.page.PageDomain;
|
|
|
+import com.zhongzheng.common.core.page.TableDataInfo;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
|
|
|
+import com.zhongzheng.modules.course.domain.CourseChapterSection;
|
|
|
+import com.zhongzheng.modules.course.domain.CourseMenu;
|
|
|
+import com.zhongzheng.modules.course.domain.CourseSection;
|
|
|
+import com.zhongzheng.modules.course.service.ICourseChapterSectionService;
|
|
|
+import com.zhongzheng.modules.course.service.ICourseChapterService;
|
|
|
+import com.zhongzheng.modules.course.service.ICourseMenuService;
|
|
|
+import com.zhongzheng.modules.course.service.ICourseSectionService;
|
|
|
+import com.zhongzheng.modules.course.vo.CourseLiveVo;
|
|
|
import com.zhongzheng.modules.course.vo.CourseVo;
|
|
|
import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsCourseService;
|
|
@@ -29,6 +41,8 @@ import com.zhongzheng.modules.order.service.IOrderService;
|
|
|
import com.zhongzheng.modules.order.vo.OrderGoodsVo;
|
|
|
import com.zhongzheng.modules.order.vo.OrderListVo;
|
|
|
import com.zhongzheng.modules.order.vo.OrderUserGoodsVo;
|
|
|
+import com.zhongzheng.modules.polyv.bo.PolyvLiveQueryBo;
|
|
|
+import com.zhongzheng.modules.polyv.service.IPolyvLiveService;
|
|
|
import com.zhongzheng.modules.user.bo.UserExamGoodsQueryBo;
|
|
|
import com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo;
|
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
@@ -36,6 +50,9 @@ import com.zhongzheng.modules.user.service.IUserExamGoodsService;
|
|
|
import com.zhongzheng.modules.user.service.IUserService;
|
|
|
import com.zhongzheng.modules.user.service.IUserStudyRecordService;
|
|
|
import com.zhongzheng.modules.user.service.IUserSubscribeService;
|
|
|
+import net.polyv.common.v1.util.StringUtils;
|
|
|
+import net.polyv.live.v1.entity.channel.operate.LiveChannelBasicInfoResponse;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -90,6 +107,17 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
|
|
|
@Autowired
|
|
|
private IUserSubscribeService iUserSubscribeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICourseMenuService courseMenuService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICourseChapterSectionService courseChapterSectionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICourseSectionService courseSectionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IPolyvLiveService ployvLiveService;
|
|
|
|
|
|
@Override
|
|
|
public OrderGoodsVo queryById(Long orderGoodsId) {
|
|
@@ -453,6 +481,83 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
|
|
|
return baseMapper.selectBuyUserList(mockMajorSubjectId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<CourseLiveVo> getLiveList(PageDomain pageDomain, Long userId) {
|
|
|
+ TableDataInfo<CourseLiveVo> info = new TableDataInfo<>();
|
|
|
+ info.setCode(HttpStatus.HTTP_OK);
|
|
|
+ info.setMsg("查询成功");
|
|
|
+ //获取所有直播课程ID
|
|
|
+ List<Long> courseIds = orderGoodsMapper.getCourseIdByLive(userId);
|
|
|
+ if (CollectionUtils.isEmpty(courseIds)){
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+ //课程目录
|
|
|
+ List<CourseMenu> menus = courseMenuService.list(new LambdaQueryWrapper<CourseMenu>()
|
|
|
+ .in(CourseMenu::getCourseId, courseIds));
|
|
|
+ if (CollectionUtils.isEmpty(menus)){
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+
|
|
|
+ //节ID
|
|
|
+ List<Long> sectionIds = menus.stream().filter(x -> x.getType() == 3).map(CourseMenu::getMenuId).collect(Collectors.toList());
|
|
|
+ //章ID
|
|
|
+ List<Long> chapterIds = menus.stream().filter(x -> x.getType() == 2).map(CourseMenu::getMenuId).collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(chapterIds)){
|
|
|
+ List<CourseChapterSection> chapterSections = courseChapterSectionService.list(new LambdaQueryWrapper<CourseChapterSection>()
|
|
|
+ .in(CourseChapterSection::getChapterId, chapterIds));
|
|
|
+ if (!CollectionUtils.isEmpty(chapterSections)){
|
|
|
+ List<Long> ids = chapterSections.stream().map(CourseChapterSection::getSectionId).collect(Collectors.toList());
|
|
|
+ sectionIds.addAll(ids);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //模块ID
|
|
|
+ List<Long> moduleIds = menus.stream().filter(x -> x.getType() == 1).map(CourseMenu::getMenuId).collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(moduleIds)){
|
|
|
+ List<Long> ids = courseMenuService.getSectionIds(moduleIds);
|
|
|
+ if (!CollectionUtils.isEmpty(ids)){
|
|
|
+ sectionIds.addAll(ids);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isEmpty(sectionIds)){
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+
|
|
|
+ //分页查询节直播信息
|
|
|
+ com.baomidou.mybatisplus.extension.plugins.pagination.Page<CourseSection> page = courseSectionService.page(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageDomain.getPageNum(), pageDomain.getPageSize()),
|
|
|
+ new LambdaQueryWrapper<CourseSection>()
|
|
|
+ .in(CourseSection::getSectionId, sectionIds)
|
|
|
+ .orderByAsc(CourseSection::getLiveStartTime));
|
|
|
+ if (CollectionUtils.isEmpty(page.getRecords())){
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+ List<CourseLiveVo> list = page.getRecords().stream().map(item -> BeanUtil.copyProperties(item, CourseLiveVo.class)).collect(Collectors.toList());
|
|
|
+ //获取保利威直播状态
|
|
|
+ Set<String> setUrl = list.stream().filter(x -> StringUtils.isNotBlank(x.getLiveUrl())).map(CourseLiveVo::getLiveUrl).collect(Collectors.toSet());
|
|
|
+ List<LiveChannelBasicInfoResponse> result = setUrl.stream().map(url -> {
|
|
|
+ PolyvLiveQueryBo bo = new PolyvLiveQueryBo();
|
|
|
+ bo.setChannelId(url);
|
|
|
+ LiveChannelBasicInfoResponse response = new LiveChannelBasicInfoResponse();
|
|
|
+ try {
|
|
|
+ response = ployvLiveService.GetChannelBasicInfo(bo);
|
|
|
+ } catch (Exception e) {
|
|
|
+// throw new CustomException("获取保利威直播状态失败");
|
|
|
+ response.setChannelId(url);
|
|
|
+ response.setWatchStatus("waiting");
|
|
|
+ }
|
|
|
+ return response;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ list.forEach(item -> {
|
|
|
+ for (LiveChannelBasicInfoResponse response : result) {
|
|
|
+ if (StringUtils.isNotBlank(item.getLiveUrl()) && item.getLiveUrl().equals(response.getChannelId())){
|
|
|
+ item.setWatchStatus(response.getWatchStatus());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ info.setTotal(page.getTotal());
|
|
|
+ info.setRows(list);
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+
|
|
|
public boolean joinGrade(Long orderGoodsId, Long gradeId, Long userId, Long goodsId) {
|
|
|
ClassGradeVo classGradeVo = iClassGradeService.queryById(gradeId);
|
|
|
if (classGradeVo == null) {
|