|
|
|
|
@@ -14,9 +14,8 @@ import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service("medicalCourseService")
|
|
|
|
|
@@ -32,6 +31,22 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
|
|
|
|
private CourseCatalogueDao courseCatalogueDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserCourseBuyDao courseBuyDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductDao shopProductDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserVipDao userVipDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserCourseBuyDao userCourseBuyDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private CourseCatalogueChapterDao courseCatalogueChapterDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private CourseCatalogueChapterVideoDao courseCatalogueChapterVideoDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserCourseVideoPositionDao userCourseVideoPositionDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private MyUserDao myUserDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private CourseToSociologyDao courseToSociologyDao;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Page<CourseEntity> getMedicalCourseList(ParamTo param) {
|
|
|
|
|
@@ -168,4 +183,75 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getCourseDetail(Integer id) {
|
|
|
|
|
Map<String, Object> flag = new HashMap<>();
|
|
|
|
|
Integer uId = ShiroUtils.getUId();
|
|
|
|
|
//基础信息
|
|
|
|
|
CourseEntity course = this.getById(id);
|
|
|
|
|
flag.put("course",course);
|
|
|
|
|
//课程相关商品
|
|
|
|
|
if (StringUtils.isNotEmpty(course.getRelationProductIds())){
|
|
|
|
|
String[] ids = course.getRelationProductIds().split(",");
|
|
|
|
|
List<ShopProduct> shopProductList = shopProductDao.selectList(new LambdaQueryWrapper<ShopProduct>()
|
|
|
|
|
.in(ShopProduct::getProductId, ids)
|
|
|
|
|
.orderByAsc(ShopProduct::getSort));
|
|
|
|
|
flag.put("shopProductList",shopProductList);
|
|
|
|
|
}
|
|
|
|
|
//获取用户身份和此课程的关系
|
|
|
|
|
MyUserEntity userEntity = myUserDao.selectById(uId);
|
|
|
|
|
HashMap<String, String> userVip = new HashMap<>();
|
|
|
|
|
userVip.put("vip",userEntity.getVip());
|
|
|
|
|
if (userEntity.getVip().equals("3")){
|
|
|
|
|
Integer integer = courseToSociologyDao.selectCount(new LambdaQueryWrapper<CourseToSociologyEntity>().eq(CourseToSociologyEntity::getCourseId, id));
|
|
|
|
|
userVip.put("vipCan",integer>0?"1":"0");
|
|
|
|
|
}
|
|
|
|
|
flag.put("vip",userVip);
|
|
|
|
|
//目录信息
|
|
|
|
|
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>().eq(CourseCatalogueEntity::getCourseId, id).orderByAsc(CourseCatalogueEntity::getSort));
|
|
|
|
|
|
|
|
|
|
for (CourseCatalogueEntity c :courseCatalogueEntities){
|
|
|
|
|
List<UserCourseBuyEntity> userCourseBuyList = userCourseBuyDao.selectList(new LambdaQueryWrapper<UserCourseBuyEntity>().eq(UserCourseBuyEntity::getUserId, uId).eq(UserCourseBuyEntity::getCatalogueId, c.getId()));
|
|
|
|
|
//完成度、上次学习时间
|
|
|
|
|
catalogueCompletion(c);
|
|
|
|
|
if (userCourseBuyList.size() > 0) {
|
|
|
|
|
c.setIsBuy(1);
|
|
|
|
|
c.setStartTime(userCourseBuyList.get(0).getStartTime());
|
|
|
|
|
c.setEndTime(userCourseBuyList.get(0).getEndTime());
|
|
|
|
|
}else {
|
|
|
|
|
c.setIsBuy(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
flag.put("catalogues",courseCatalogueEntities);
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void catalogueCompletion(CourseCatalogueEntity c){
|
|
|
|
|
List<CourseCatalogueChapterEntity> courseCatalogueChapterEntities = courseCatalogueChapterDao.selectList(new LambdaQueryWrapper<CourseCatalogueChapterEntity>().eq(CourseCatalogueChapterEntity::getCatalogueId, c.getId()));
|
|
|
|
|
Integer act = 0;
|
|
|
|
|
Date date = null;
|
|
|
|
|
for (CourseCatalogueChapterEntity cc : courseCatalogueChapterEntities){
|
|
|
|
|
List<CourseCatalogueChapterVideoEntity> courseCatalogueChapterVideoEntities = courseCatalogueChapterVideoDao.selectList(new LambdaQueryWrapper<CourseCatalogueChapterVideoEntity>().eq(CourseCatalogueChapterVideoEntity::getChapterId, cc.getId()));
|
|
|
|
|
List<Integer> collect = courseCatalogueChapterVideoEntities.stream().map(CourseCatalogueChapterVideoEntity::getId).collect(Collectors.toList());
|
|
|
|
|
if(collect.size()==0){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
List<UserCourseVideoPositionEntity> videoPositionList = userCourseVideoPositionDao.selectList(new LambdaQueryWrapper<UserCourseVideoPositionEntity>().eq(UserCourseVideoPositionEntity::getUserId, ShiroUtils.getUId()).in(UserCourseVideoPositionEntity::getVideoId, collect).orderByDesc(UserCourseVideoPositionEntity::getCreateTime));
|
|
|
|
|
if (videoPositionList.size()>0){
|
|
|
|
|
act++;
|
|
|
|
|
if (date!=null){
|
|
|
|
|
date = date.getTime()>videoPositionList.get(0).getUpdateTime().getTime()?date:videoPositionList.get(0).getUpdateTime();
|
|
|
|
|
}else {
|
|
|
|
|
date = videoPositionList.get(0).getUpdateTime();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int completion = courseCatalogueChapterEntities.size()==0?0:act * 100 / courseCatalogueChapterEntities.size();
|
|
|
|
|
c.setCompletion(completion);
|
|
|
|
|
c.setLastStudyTime(date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|