|
@@ -1,46 +1,42 @@
|
|
package com.zhongzheng.modules.user.service.impl;
|
|
package com.zhongzheng.modules.user.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
-import cn.hutool.core.convert.Convert;
|
|
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.lang.Validator;
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
-import com.microsoft.schemas.office.visio.x2012.main.SectionType;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.github.pagehelper.Page;
|
|
import com.zhongzheng.common.core.page.TableDataInfo;
|
|
import com.zhongzheng.common.core.page.TableDataInfo;
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
-import com.zhongzheng.modules.bank.domain.Exam;
|
|
|
|
import com.zhongzheng.modules.course.bo.*;
|
|
import com.zhongzheng.modules.course.bo.*;
|
|
|
|
+import com.zhongzheng.modules.course.domain.CourseBusiness;
|
|
import com.zhongzheng.modules.course.domain.CoursePhotoLog;
|
|
import com.zhongzheng.modules.course.domain.CoursePhotoLog;
|
|
import com.zhongzheng.modules.course.domain.CourseSection;
|
|
import com.zhongzheng.modules.course.domain.CourseSection;
|
|
|
|
+import com.zhongzheng.modules.course.service.ICourseBusinessService;
|
|
import com.zhongzheng.modules.course.service.ICourseChapterSectionService;
|
|
import com.zhongzheng.modules.course.service.ICourseChapterSectionService;
|
|
import com.zhongzheng.modules.course.service.ICoursePhotoLogService;
|
|
import com.zhongzheng.modules.course.service.ICoursePhotoLogService;
|
|
import com.zhongzheng.modules.course.service.ICourseSectionService;
|
|
import com.zhongzheng.modules.course.service.ICourseSectionService;
|
|
import com.zhongzheng.modules.course.vo.CourseChapterSectionVo;
|
|
import com.zhongzheng.modules.course.vo.CourseChapterSectionVo;
|
|
import com.zhongzheng.modules.course.vo.CourseSectionVo;
|
|
import com.zhongzheng.modules.course.vo.CourseSectionVo;
|
|
|
|
+import com.zhongzheng.modules.goods.domain.Goods;
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
-import com.zhongzheng.modules.goods.vo.GoodsUserVo;
|
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
|
|
-import com.zhongzheng.modules.grade.bo.UserPeriodAddBo;
|
|
|
|
-import com.zhongzheng.modules.grade.bo.UserPeriodStatusAddBo;
|
|
|
|
|
|
+import com.zhongzheng.modules.grade.bo.UserPeriodEditBo;
|
|
import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
import com.zhongzheng.modules.grade.domain.UserPeriod;
|
|
import com.zhongzheng.modules.grade.domain.UserPeriod;
|
|
import com.zhongzheng.modules.grade.domain.UserPeriodStatus;
|
|
import com.zhongzheng.modules.grade.domain.UserPeriodStatus;
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
import com.zhongzheng.modules.grade.service.IUserPeriodService;
|
|
import com.zhongzheng.modules.grade.service.IUserPeriodService;
|
|
import com.zhongzheng.modules.grade.service.IUserPeriodStatusService;
|
|
import com.zhongzheng.modules.grade.service.IUserPeriodStatusService;
|
|
-
|
|
|
|
import com.zhongzheng.modules.grade.vo.ClassPeriodStudentVo;
|
|
import com.zhongzheng.modules.grade.vo.ClassPeriodStudentVo;
|
|
-
|
|
|
|
import com.zhongzheng.modules.grade.vo.ClassPeriodVo;
|
|
import com.zhongzheng.modules.grade.vo.ClassPeriodVo;
|
|
-import com.zhongzheng.modules.grade.vo.UserPeriodStatusVo;
|
|
|
|
import com.zhongzheng.modules.inform.bo.InformRemindQueryBo;
|
|
import com.zhongzheng.modules.inform.bo.InformRemindQueryBo;
|
|
import com.zhongzheng.modules.inform.bo.InformUserAddBo;
|
|
import com.zhongzheng.modules.inform.bo.InformUserAddBo;
|
|
import com.zhongzheng.modules.inform.service.IInformRemindService;
|
|
import com.zhongzheng.modules.inform.service.IInformRemindService;
|
|
@@ -59,10 +55,6 @@ import net.polyv.live.v1.entity.channel.viewdata.LiveListChannelViewlogResponse;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
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 org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
@@ -138,6 +130,8 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
private IUserExamGoodsService iUserExamGoodsService;
|
|
private IUserExamGoodsService iUserExamGoodsService;
|
|
@Autowired
|
|
@Autowired
|
|
private IPolyvLiveService ployvLiveService;
|
|
private IPolyvLiveService ployvLiveService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseBusinessService iCourseBusinessService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private RedisCache redisCache;
|
|
private RedisCache redisCache;
|
|
@@ -264,7 +258,7 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<UserStudyRecordVo> selectList(UserStudyRecordQueryBo bo) {
|
|
public List<UserStudyRecordVo> selectList(UserStudyRecordQueryBo bo) {
|
|
- return userStudyRecordMapper.selectList(bo);
|
|
|
|
|
|
+ return userStudyRecordMapper.getListByBo(bo);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -341,7 +335,7 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
//获取节类型
|
|
//获取节类型
|
|
CourseSection section = iCourseSectionService.getById(bo.getSectionId());
|
|
CourseSection section = iCourseSectionService.getById(bo.getSectionId());
|
|
add.setSectionType(section.getSectionType());
|
|
add.setSectionType(section.getSectionType());
|
|
- add.setFirstEntry(ObjectUtils.isNull(bo.getFirstEntry())?0:bo.getFirstEntry());
|
|
|
|
|
|
+ add.setIdentification(bo.getIdentification());
|
|
this.save(add);
|
|
this.save(add);
|
|
if (ObjectUtils.isNull(bo.getOrderGoodsId())){
|
|
if (ObjectUtils.isNull(bo.getOrderGoodsId())){
|
|
//没有购买商品,通过分享观看
|
|
//没有购买商品,通过分享观看
|
|
@@ -432,6 +426,19 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
classGradeUser1.setUpdateTime(DateUtils.getNowTime());
|
|
classGradeUser1.setUpdateTime(DateUtils.getNowTime());
|
|
List<ClassGradeUser> list1 = iClassGradeUserService.list(classGradeUser);
|
|
List<ClassGradeUser> list1 = iClassGradeUserService.list(classGradeUser);
|
|
iClassGradeUserService.update(classGradeUser1, classGradeUser);
|
|
iClassGradeUserService.update(classGradeUser1, classGradeUser);
|
|
|
|
+ //查询商品业务学时审核类型
|
|
|
|
+ Goods goods = iGoodsService.getById(bo.getGoodsId());
|
|
|
|
+ CourseBusiness business = iCourseBusinessService.getById(goods.getBusinessId());
|
|
|
|
+ if (ObjectUtils.isNotNull(business) && ObjectUtils.isNotNull(business.getPeriodType()) && business.getPeriodType() == 2){
|
|
|
|
+ //自动审核
|
|
|
|
+ UserPeriodEditBo editBo = new UserPeriodEditBo();
|
|
|
|
+ editBo.setGoodsId(bo.getGoodsId());
|
|
|
|
+ editBo.setGradeId(bo.getGradeId());
|
|
|
|
+ editBo.setUserId(bo.getUserId());
|
|
|
|
+ iUserPeriodService.updateByEditBo(editBo);
|
|
|
|
+ iUserPeriodService.confirmPeriod(editBo);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
InformRemindQueryBo informRemindQueryBo = new InformRemindQueryBo();
|
|
InformRemindQueryBo informRemindQueryBo = new InformRemindQueryBo();
|
|
informRemindQueryBo.setSort(8L);
|
|
informRemindQueryBo.setSort(8L);
|
|
@@ -639,32 +646,19 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public TableDataInfo<CourseStatementVo> getCourseStatement(CourseStatementBo bo) {
|
|
|
|
- com.baomidou.mybatisplus.extension.plugins.pagination.Page<UserStudyRecord> page =
|
|
|
|
- page(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<UserStudyRecord>(bo.getPageNum(), bo.getPageSize()),
|
|
|
|
- new LambdaQueryWrapper<UserStudyRecord>()
|
|
|
|
- .eq(UserStudyRecord::getGoodsId, bo.getGoodsId())
|
|
|
|
- .groupBy(UserStudyRecord::getSectionId));
|
|
|
|
- if (CollectionUtils.isEmpty(page.getRecords())){
|
|
|
|
- return new TableDataInfo<>();
|
|
|
|
|
|
+ public List<CourseStatementVo> getCourseStatement(CourseStatementBo bo) {
|
|
|
|
+ List<CourseStatementVo> voList = baseMapper.getCourseStatement(bo);
|
|
|
|
+ if (CollectionUtils.isEmpty(voList)){
|
|
|
|
+ return new ArrayList<>();
|
|
}
|
|
}
|
|
- List<CourseStatementVo> statementVos = page.getRecords().stream().map(item -> {
|
|
|
|
- CourseStatementVo vo = new CourseStatementVo();
|
|
|
|
- //课程节信息
|
|
|
|
- CourseSection section = iCourseSectionService.getById(item.getSectionId());
|
|
|
|
- if (ObjectUtils.isNotNull(section)) {
|
|
|
|
- vo.setSectionName(section.getName());
|
|
|
|
- vo.setLiveStartTime(section.getLiveStartTime());
|
|
|
|
- vo.setLiveEndTime(section.getLiveEndTime());
|
|
|
|
- vo.setLiveUrl(section.getLiveUrl());
|
|
|
|
- }
|
|
|
|
|
|
+ voList.forEach(item -> {
|
|
//统计观看人数
|
|
//统计观看人数
|
|
List<UserStudyRecord> recordList = list(new LambdaQueryWrapper<UserStudyRecord>()
|
|
List<UserStudyRecord> recordList = list(new LambdaQueryWrapper<UserStudyRecord>()
|
|
.eq(UserStudyRecord::getGoodsId, item.getGoodsId())
|
|
.eq(UserStudyRecord::getGoodsId, item.getGoodsId())
|
|
.eq(UserStudyRecord::getSectionId, item.getSectionId()));
|
|
.eq(UserStudyRecord::getSectionId, item.getSectionId()));
|
|
if (CollectionUtils.isNotEmpty(recordList)) {
|
|
if (CollectionUtils.isNotEmpty(recordList)) {
|
|
Map<Long, List<UserStudyRecord>> map = recordList.stream().collect(Collectors.groupingBy(UserStudyRecord::getUserId));
|
|
Map<Long, List<UserStudyRecord>> map = recordList.stream().collect(Collectors.groupingBy(UserStudyRecord::getUserId));
|
|
- vo.setWatchNumber(map.keySet().size());
|
|
|
|
|
|
+ item.setWatchNumber(map.keySet().size());
|
|
Integer unBuyCourse = 0;
|
|
Integer unBuyCourse = 0;
|
|
Integer buyCourse = 0;
|
|
Integer buyCourse = 0;
|
|
for (UserStudyRecord record : recordList) {
|
|
for (UserStudyRecord record : recordList) {
|
|
@@ -675,25 +669,24 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
buyCourse++;
|
|
buyCourse++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- vo.setBuyCourseNumber(buyCourse);
|
|
|
|
- vo.setUnBuyCourseNumber(unBuyCourse);
|
|
|
|
|
|
+ item.setBuyCourseNumber(buyCourse);
|
|
|
|
+ item.setUnBuyCourseNumber(unBuyCourse);
|
|
Map<String, List<UserStudyRecord>> collect = recordList.stream().filter(x -> ObjectUtils.isNotNull(x.getFromPlat())).collect(Collectors.groupingBy(UserStudyRecord::getFromPlat));
|
|
Map<String, List<UserStudyRecord>> collect = recordList.stream().filter(x -> ObjectUtils.isNotNull(x.getFromPlat())).collect(Collectors.groupingBy(UserStudyRecord::getFromPlat));
|
|
if (CollectionUtils.isNotEmpty(collect)) {
|
|
if (CollectionUtils.isNotEmpty(collect)) {
|
|
collect.forEach((k, v) -> {
|
|
collect.forEach((k, v) -> {
|
|
if (k.equals("1")) {
|
|
if (k.equals("1")) {
|
|
//小程序
|
|
//小程序
|
|
- vo.setAppWatchNumber(collect.get(k).size());
|
|
|
|
|
|
+ item.setAppWatchNumber(collect.get(k).size());
|
|
} else {
|
|
} else {
|
|
//PC
|
|
//PC
|
|
- vo.setAdminWatchNumber(collect.get(k).size());
|
|
|
|
|
|
+ item.setAdminWatchNumber(collect.get(k).size());
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return vo;
|
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
|
|
+ });
|
|
//查询保利威直播状态
|
|
//查询保利威直播状态
|
|
- Set<String> setUrl = statementVos.stream().map(CourseStatementVo::getLiveUrl).collect(Collectors.toSet());
|
|
|
|
|
|
+ Set<String> setUrl = voList.stream().map(CourseStatementVo::getLiveUrl).collect(Collectors.toSet());
|
|
List<LiveChannelBasicInfoResponse> result = setUrl.stream().map(url -> {
|
|
List<LiveChannelBasicInfoResponse> result = setUrl.stream().map(url -> {
|
|
PolyvLiveQueryBo queryBo = new PolyvLiveQueryBo();
|
|
PolyvLiveQueryBo queryBo = new PolyvLiveQueryBo();
|
|
queryBo.setChannelId(url);
|
|
queryBo.setChannelId(url);
|
|
@@ -707,17 +700,14 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
}
|
|
}
|
|
return response;
|
|
return response;
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
- statementVos.forEach(item -> {
|
|
|
|
|
|
+ voList.forEach(item -> {
|
|
for (LiveChannelBasicInfoResponse response : result) {
|
|
for (LiveChannelBasicInfoResponse response : result) {
|
|
if (net.polyv.common.v1.util.StringUtils.isNotBlank(item.getLiveUrl()) && item.getLiveUrl().equals(response.getChannelId())){
|
|
if (net.polyv.common.v1.util.StringUtils.isNotBlank(item.getLiveUrl()) && item.getLiveUrl().equals(response.getChannelId())){
|
|
item.setWatchStatus(response.getWatchStatus());
|
|
item.setWatchStatus(response.getWatchStatus());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- TableDataInfo<CourseStatementVo> info = new TableDataInfo<CourseStatementVo>();
|
|
|
|
- info.setRows(statementVos);
|
|
|
|
- info.setTotal(page.getTotal());
|
|
|
|
- return info;
|
|
|
|
|
|
+ return voList;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -737,7 +727,6 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
List<UserStudyRecord> list = list(new LambdaQueryWrapper<UserStudyRecord>()
|
|
List<UserStudyRecord> list = list(new LambdaQueryWrapper<UserStudyRecord>()
|
|
.eq(UserStudyRecord::getUserId, item.getUserId())
|
|
.eq(UserStudyRecord::getUserId, item.getUserId())
|
|
.eq(UserStudyRecord::getGoodsId, bo.getGoodsId())
|
|
.eq(UserStudyRecord::getGoodsId, bo.getGoodsId())
|
|
- .eq(UserStudyRecord::getCourseId, bo.getCourseId())
|
|
|
|
.eq(UserStudyRecord::getSectionId, bo.getSectionId()));
|
|
.eq(UserStudyRecord::getSectionId, bo.getSectionId()));
|
|
item.setLiveDuration(liveStartTime);
|
|
item.setLiveDuration(liveStartTime);
|
|
if (list.stream().anyMatch(x -> x.getBuyCourse() == 1)){
|
|
if (list.stream().anyMatch(x -> x.getBuyCourse() == 1)){
|
|
@@ -746,12 +735,39 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
}
|
|
}
|
|
Long sum = list.stream().filter(x -> ObjectUtils.isNotNull(x.getStudyDuration())).mapToLong(UserStudyRecord::getStudyDuration).sum();
|
|
Long sum = list.stream().filter(x -> ObjectUtils.isNotNull(x.getStudyDuration())).mapToLong(UserStudyRecord::getStudyDuration).sum();
|
|
item.setWatchLiveDuration(sum);
|
|
item.setWatchLiveDuration(sum);
|
|
- Integer size = list.stream().filter(x -> ObjectUtils.isNotNull(x.getFirstEntry()) && x.getFirstEntry() == 1).collect(Collectors.toList()).size();
|
|
|
|
- item.setWatchNumber(size);
|
|
|
|
|
|
+ Map<String, List<UserStudyRecord>> collect = list.stream().filter(x -> StringUtils.isNotBlank(x.getIdentification())).collect(Collectors.groupingBy(UserStudyRecord::getIdentification));
|
|
|
|
+ item.setWatchNumber(collect.keySet().size());
|
|
}
|
|
}
|
|
return detailVos;
|
|
return detailVos;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<UserWatchStatisticsVo> getUserWatchStatistics(CourseSectionDetailBo bo) {
|
|
|
|
+ //学员的观看记录
|
|
|
|
+ List<UserStudyRecord> list = list(new LambdaQueryWrapper<UserStudyRecord>()
|
|
|
|
+ .eq(UserStudyRecord::getUserId, bo.getUserId())
|
|
|
|
+ .eq(UserStudyRecord::getGoodsId, bo.getGoodsId())
|
|
|
|
+ .eq(UserStudyRecord::getSectionId, bo.getSectionId()));
|
|
|
|
+ if (CollectionUtils.isEmpty(list)){
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ List<UserWatchStatisticsVo> result = new ArrayList<>();
|
|
|
|
+ Map<String, List<UserStudyRecord>> map = list.stream().filter(x -> StringUtils.isNotBlank(x.getIdentification())).collect(Collectors.groupingBy(UserStudyRecord::getIdentification));
|
|
|
|
+ map.forEach((k,v) -> {
|
|
|
|
+ UserWatchStatisticsVo vo = new UserWatchStatisticsVo();
|
|
|
|
+ List<UserStudyRecord> records = map.get(k).stream().sorted(Comparator.comparing(UserStudyRecord::getCreateTime)).collect(Collectors.toList());
|
|
|
|
+ UserStudyRecord user = records.get(0);
|
|
|
|
+ vo.setStartTime(user.getStartTime());
|
|
|
|
+ vo.setEndTime(records.get(records.size() - 1).getEndTime());
|
|
|
|
+ vo.setFromPlat(user.getFromPlat());
|
|
|
|
+ vo.setSectionType(user.getSectionType());
|
|
|
|
+ Long sum = records.stream().filter(x -> ObjectUtils.isNotNull(x.getStudyDuration())).mapToLong(UserStudyRecord::getStudyDuration).sum();
|
|
|
|
+ vo.setWatchLiveDuration(sum);
|
|
|
|
+ result.add(vo);
|
|
|
|
+ });
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取最后一次看完的节
|
|
* 获取最后一次看完的节
|