|
@@ -4,8 +4,11 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.dayaedu.cbs.openfeign.client.CoursewareFeignService;
|
|
|
import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsMaterialWrapper;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
import com.microsvc.toolkit.common.response.paging.PageInfo;
|
|
|
import com.microsvc.toolkit.common.response.template.R;
|
|
|
+import com.ym.mec.biz.dal.dao.CloudTeacherOrderDao;
|
|
|
import com.ym.mec.biz.dal.dao.CourseHomeworkDao;
|
|
|
import com.ym.mec.biz.dal.dao.StudentLessonTrainingDetailMapper;
|
|
|
import com.ym.mec.biz.dal.dao.SubjectDao;
|
|
@@ -17,12 +20,14 @@ import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.ELessonTrainingType;
|
|
|
import com.ym.mec.biz.dal.enums.StandardEnum;
|
|
|
import com.ym.mec.biz.service.ExtracurricularExercisesService;
|
|
|
+import com.ym.mec.biz.service.MemberRankCategoryMapperService;
|
|
|
import com.ym.mec.biz.service.StudentLessonTrainingDetailService;
|
|
|
import com.ym.mec.biz.service.SubjectService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -51,6 +56,12 @@ public class StudentLessonTrainingDetailServiceImpl extends ServiceImpl<StudentL
|
|
|
@Resource
|
|
|
private CoursewareFeignService coursewareFeignService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CloudTeacherOrderDao cloudTeacherOrderDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MemberRankCategoryMapperService memberRankCategoryMapperService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询详情
|
|
|
* @param id 详情ID
|
|
@@ -205,6 +216,30 @@ public class StudentLessonTrainingDetailServiceImpl extends ServiceImpl<StudentL
|
|
|
.distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
if(CollectionUtils.isNotEmpty(musicScoreIdList)){
|
|
|
+
|
|
|
+ // 按用户分组,查询用户VIP信息
|
|
|
+ List<Long> collect = studentLessonTrainingDetails.stream()
|
|
|
+ .filter(x -> "MUSIC_SCORE".equals(x.getHomeworkType()))
|
|
|
+ .map(StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail::getUserId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<Integer, List<Integer>> userVipMap = Maps.newConcurrentMap();
|
|
|
+ collect.parallelStream().forEach(userId -> {
|
|
|
+ // 查询有效的会员
|
|
|
+ List<Integer> activationVipIds = cloudTeacherOrderDao.getActivationVipIds(userId.intValue());
|
|
|
+
|
|
|
+ // 获取会员的曲目分类
|
|
|
+ List<MemberRankCategoryMapper> categoryMapperList = memberRankCategoryMapperService.getByMemberRankId(activationVipIds);
|
|
|
+ if (CollectionUtils.isEmpty(categoryMapperList)) {
|
|
|
+ categoryMapperList = Lists.newArrayList();
|
|
|
+ }
|
|
|
+ List<Integer> categoryIds = categoryMapperList.stream().map(MemberRankCategoryMapper::getCategoryId).distinct().collect(Collectors.toList());
|
|
|
+ // 设置用户VIP可查看曲目分类
|
|
|
+ userVipMap.put(userId.intValue(), categoryIds);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 查询曲目信息
|
|
|
List<SysMusicScore> scoreList = sysMusicScoreDao.findByIds(musicScoreIdList.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
|
|
if(CollectionUtils.isNotEmpty(scoreList)){
|
|
|
Map<Integer, SysMusicScore> musicScoreMap = scoreList.stream().collect(Collectors.toMap(SysMusicScore::getId, Function.identity()));
|
|
@@ -215,12 +250,33 @@ public class StudentLessonTrainingDetailServiceImpl extends ServiceImpl<StudentL
|
|
|
if(sysMusicScore.getShowFlag() == 1 && sysMusicScore.getDelFlag() == 0){
|
|
|
studentLessonTrainingDetail.setValidFlag(true);
|
|
|
}
|
|
|
+
|
|
|
+ // 免费曲目也可以直接访问
|
|
|
+ if (StringUtils.isBlank(sysMusicScore.getRankIds())) {
|
|
|
+ studentLessonTrainingDetail.setValidFlag(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 用户VIP可查看曲目分类
|
|
|
+ if (Objects.nonNull(studentLessonTrainingDetail.getUserId())
|
|
|
+ && userVipMap.containsKey(studentLessonTrainingDetail.getUserId().intValue())) {
|
|
|
+
|
|
|
+ // 设置默认不可以查看
|
|
|
+ boolean validFlag = false;
|
|
|
+ List<Integer> categoryIds = userVipMap.get(studentLessonTrainingDetail.getUserId().intValue());
|
|
|
+ if (categoryIds.contains(sysMusicScore.getCbsMusicCategoriesId())
|
|
|
+ || StringUtils.isBlank(sysMusicScore.getRankIds())) {
|
|
|
+ // 免费曲目,已购买曲目可直接查看
|
|
|
+ validFlag = true;
|
|
|
+ }
|
|
|
+ studentLessonTrainingDetail.setValidFlag(validFlag);
|
|
|
+ }
|
|
|
studentLessonTrainingDetail.setMusicScoreName(sysMusicScore.getName());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//课件素材编号列表
|
|
|
List<Long> materialList = studentLessonTrainingDetails.stream()
|
|
|
.filter(o->"VIDEO".equals(o.getHomeworkType()))
|