|
@@ -3,26 +3,22 @@ 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.query.LambdaQueryWrapper;
|
|
|
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.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.github.pagehelper.Page;
|
|
|
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.course.vo.LiveListVo;
|
|
|
import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsCourseService;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
@@ -34,7 +30,10 @@ import com.zhongzheng.modules.grade.service.IClassGradeService;
|
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
import com.zhongzheng.modules.grade.vo.ClassGradeVo;
|
|
|
import com.zhongzheng.modules.grade.vo.ClassPeriodVo;
|
|
|
-import com.zhongzheng.modules.order.bo.*;
|
|
|
+import com.zhongzheng.modules.order.bo.OrderGoodsAddBo;
|
|
|
+import com.zhongzheng.modules.order.bo.OrderGoodsEditBo;
|
|
|
+import com.zhongzheng.modules.order.bo.OrderGoodsQueryBo;
|
|
|
+import com.zhongzheng.modules.order.bo.OrderSubjectUserBuyBo;
|
|
|
import com.zhongzheng.modules.order.domain.OrderGoods;
|
|
|
import com.zhongzheng.modules.order.mapper.OrderGoodsMapper;
|
|
|
import com.zhongzheng.modules.order.service.IOrderGoodsService;
|
|
@@ -55,17 +54,15 @@ import com.zhongzheng.modules.user.service.IUserSubscribeService;
|
|
|
import com.zhongzheng.modules.user.vo.SubjectStudyRecordVo;
|
|
|
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;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.github.pagehelper.Page;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -485,88 +482,40 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
|
|
|
return baseMapper.selectBuyUserList(mockMajorSubjectId);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询用户拥有视频+直播商品
|
|
|
+ * @param bo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
- public TableDataInfo<CourseLiveVo> getLiveList(PageDomain pageDomain, Long userId) {
|
|
|
- TableDataInfo<CourseLiveVo> info = new TableDataInfo<>();
|
|
|
- info.setCode(HttpStatus.HTTP_OK);
|
|
|
- info.setMsg("查询成功");
|
|
|
- //获取所有直播课程ID
|
|
|
- List<LiveListVo> liveVos = orderGoodsMapper.getCourseIdByLive(userId);
|
|
|
- if (CollectionUtils.isEmpty(liveVos)){
|
|
|
- return info;
|
|
|
- }
|
|
|
- List<Long> courseIds = liveVos.stream().map(LiveListVo::getCourseId).collect(Collectors.toList());
|
|
|
- //课程目录
|
|
|
- List<CourseMenu> menus = courseMenuService.list(new LambdaQueryWrapper<CourseMenu>()
|
|
|
- .in(CourseMenu::getCourseId, courseIds));
|
|
|
- if (CollectionUtils.isEmpty(menus)){
|
|
|
- return info;
|
|
|
- }
|
|
|
- List<LiveListVo> listVoList = new ArrayList<>();
|
|
|
- menus.forEach(item -> {
|
|
|
- switch (item.getType()){
|
|
|
- case 3://节
|
|
|
- LiveListVo vo = new LiveListVo();
|
|
|
- vo.setCourseId(item.getCourseId());
|
|
|
- vo.setSectionId(item.getMenuId());
|
|
|
- listVoList.add(vo);
|
|
|
- break;
|
|
|
- case 2://章
|
|
|
- List<CourseChapterSection> chapterSections = courseChapterSectionService
|
|
|
- .list(new LambdaQueryWrapper<CourseChapterSection>()
|
|
|
- .eq(CourseChapterSection::getChapterId, item.getMenuId()));
|
|
|
- if (!CollectionUtils.isEmpty(chapterSections)){
|
|
|
- List<LiveListVo> collect = chapterSections.stream().map(chapter -> {
|
|
|
- LiveListVo chapterVo = new LiveListVo();
|
|
|
- chapterVo.setCourseId(item.getCourseId());
|
|
|
- chapterVo.setChapterId(item.getMenuId());
|
|
|
- chapterVo.setSectionId(chapter.getSectionId());
|
|
|
- return chapterVo;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- listVoList.addAll(collect);
|
|
|
- }
|
|
|
- break;
|
|
|
- case 1://模块
|
|
|
- List<LiveListVo> listVos = courseMenuService.getSectionIds(item.getMenuId());
|
|
|
- if (!CollectionUtils.isEmpty(listVos)){
|
|
|
- List<LiveListVo> collect = listVos.stream().map(module -> {
|
|
|
- LiveListVo chapterVo = new LiveListVo();
|
|
|
- chapterVo.setCourseId(item.getCourseId());
|
|
|
- chapterVo.setModuleId(item.getMenuId());
|
|
|
- chapterVo.setChapterId(module.getChapterId());
|
|
|
- chapterVo.setSectionId(module.getSectionId());
|
|
|
- return chapterVo;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- listVoList.addAll(collect);
|
|
|
- }
|
|
|
- break;
|
|
|
+ public List<OrderGoodsVo> listUserVideoLive(GoodsQueryBo bo) {
|
|
|
+ List<OrderGoodsVo> list = this.baseMapper.listUserVideoLive(bo);
|
|
|
+ for(OrderGoodsVo goodsVo : list){
|
|
|
+ Long secLong = 0L;
|
|
|
+ Long studyLong = 0L;
|
|
|
+ SubjectStudyRecordQueryBo subjectStudyRecordQueryBo = new SubjectStudyRecordQueryBo();
|
|
|
+ subjectStudyRecordQueryBo.setGoodsId(goodsVo.getGoodsId());
|
|
|
+ subjectStudyRecordQueryBo.setUserId(bo.getUserId());
|
|
|
+ subjectStudyRecordQueryBo.setOrderGoodsId(goodsVo.getOrderGoodsId());
|
|
|
+ List<SubjectStudyRecordVo> subjectStudyRecordVos = iUserStudyRecordService.listSubject(subjectStudyRecordQueryBo);
|
|
|
+ for (SubjectStudyRecordVo subjectStudyRecordVo : subjectStudyRecordVos) {
|
|
|
+ secLong = new BigDecimal(secLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getSectionNum().toString())).longValue();
|
|
|
+ studyLong = new BigDecimal(studyLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getRecordNum().toString())).longValue();
|
|
|
}
|
|
|
- });
|
|
|
- listVoList.forEach(vo -> {
|
|
|
- liveVos.forEach(item -> {
|
|
|
- if (vo.getCourseId().equals(item.getCourseId())){
|
|
|
- vo.setGoodId(item.getGoodId());
|
|
|
- vo.setOrderGoodId(item.getOrderGoodId());
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- List<Long> sectionIds = listVoList.stream().map(LiveListVo::getSectionId).collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isEmpty(sectionIds)){
|
|
|
- return info;
|
|
|
+ goodsVo.setSecAllNum(secLong);
|
|
|
+ goodsVo.setStuAllNum(studyLong);
|
|
|
}
|
|
|
+ return list;
|
|
|
+ }
|
|
|
|
|
|
- //分页查询节直播信息
|
|
|
- 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)
|
|
|
- .eq(CourseSection::getSectionType,2)//类型为直播
|
|
|
- .orderByAsc(CourseSection::getLiveStartTime));
|
|
|
- if (CollectionUtils.isEmpty(page.getRecords())){
|
|
|
- return info;
|
|
|
+ @Override
|
|
|
+ public List<CourseLiveVo> getLiveList(Long userId) {
|
|
|
+ List<CourseLiveVo> liveVos = orderGoodsMapper.getLiveList(userId);
|
|
|
+ if (CollectionUtils.isEmpty(liveVos)){
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
- 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());
|
|
|
+ Set<String> setUrl = liveVos.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);
|
|
@@ -580,50 +529,14 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
|
|
|
}
|
|
|
return response;
|
|
|
}).collect(Collectors.toList());
|
|
|
- list.forEach(item -> {
|
|
|
- listVoList.forEach(live -> {
|
|
|
- if (item.getSectionId().equals(live.getSectionId())){
|
|
|
- item.setOrderGoodId(live.getOrderGoodId());
|
|
|
- item.setGoodsId(live.getGoodId());
|
|
|
- item.setModuleId(live.getModuleId());
|
|
|
- item.setChapterId(live.getChapterId());
|
|
|
- }
|
|
|
- });
|
|
|
+ liveVos.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;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询用户拥有视频+直播商品
|
|
|
- * @param bo
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- public List<OrderGoodsVo> listUserVideoLive(GoodsQueryBo bo) {
|
|
|
- List<OrderGoodsVo> list = this.baseMapper.listUserVideoLive(bo);
|
|
|
- for(OrderGoodsVo goodsVo : list){
|
|
|
- Long secLong = 0L;
|
|
|
- Long studyLong = 0L;
|
|
|
- SubjectStudyRecordQueryBo subjectStudyRecordQueryBo = new SubjectStudyRecordQueryBo();
|
|
|
- subjectStudyRecordQueryBo.setGoodsId(goodsVo.getGoodsId());
|
|
|
- subjectStudyRecordQueryBo.setUserId(bo.getUserId());
|
|
|
- subjectStudyRecordQueryBo.setOrderGoodsId(goodsVo.getOrderGoodsId());
|
|
|
- List<SubjectStudyRecordVo> subjectStudyRecordVos = iUserStudyRecordService.listSubject(subjectStudyRecordQueryBo);
|
|
|
- for (SubjectStudyRecordVo subjectStudyRecordVo : subjectStudyRecordVos) {
|
|
|
- secLong = new BigDecimal(secLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getSectionNum().toString())).longValue();
|
|
|
- studyLong = new BigDecimal(studyLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getRecordNum().toString())).longValue();
|
|
|
- }
|
|
|
- goodsVo.setSecAllNum(secLong);
|
|
|
- goodsVo.setStuAllNum(studyLong);
|
|
|
- }
|
|
|
- return list;
|
|
|
+ return liveVos;
|
|
|
}
|
|
|
|
|
|
public boolean joinGrade(Long orderGoodsId, Long gradeId, Long userId, Long goodsId) {
|