|
|
@@ -20,6 +20,7 @@ import com.fs.company.cache.ICompanyUserCacheService;
|
|
|
import com.fs.company.domain.Company;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyMapper;
|
|
|
+import com.fs.company.mapper.CompanyUserMapper;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
|
import com.fs.course.constant.CourseConstant;
|
|
|
import com.fs.course.domain.*;
|
|
|
@@ -165,6 +166,9 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
@Autowired
|
|
|
private FsUserCourseStudyLogMapper fsUserCourseStudyLogMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CompanyUserMapper companyUserMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询短链课程看课记录
|
|
|
*
|
|
|
@@ -1409,12 +1413,23 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
List<AppCourseReportVO> answerList = fsCourseWatchLogMapper.selectAppAnswerStatistics(param);
|
|
|
List<AppCourseReportVO> redpackList = fsCourseWatchLogMapper.selectAppRedPacketStatistics(param);
|
|
|
|
|
|
+ // 获取公司红包开关状态
|
|
|
+ Map<Long, Integer> companyRedPacketStatus = new HashMap<>();
|
|
|
+ for (Long companyId : companyIds) {
|
|
|
+ Company company = companyCacheService.selectCompanyById(companyId);
|
|
|
+ companyRedPacketStatus.put(companyId, company != null ? company.getOpenRedPacket() : null);
|
|
|
+ }
|
|
|
+
|
|
|
// 5. 转换为 Map 便于查找
|
|
|
Map<Long, AppCourseReportVO> watchStatsMap = watchStatsList.stream()
|
|
|
.collect(Collectors.toMap(AppCourseReportVO::getCompanyId, Function.identity()));
|
|
|
Map<Long, AppCourseReportVO> answerStatsMap = answerList.stream()
|
|
|
.collect(Collectors.toMap(AppCourseReportVO::getCompanyId, Function.identity(), (e, r) -> e));
|
|
|
Map<Long, AppCourseReportVO> redPacketStatsMap = redpackList.stream()
|
|
|
+ .filter(stats -> {
|
|
|
+ Integer status = companyRedPacketStatus.get(stats.getCompanyId());
|
|
|
+ return status != null && status == 1;
|
|
|
+ })
|
|
|
.collect(Collectors.toMap(AppCourseReportVO::getCompanyId, Function.identity(), (e, r) -> e));
|
|
|
|
|
|
// 6. 一次性组装所有数据,减少遍历次数
|
|
|
@@ -1605,18 +1620,39 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
private Map<String, FsCourseReportVO> getRedPacketStatistics(FsCourseWatchLogStatisticsListParam query) {
|
|
|
List<FsCourseReportVO> redPacketStatistics = fsCourseWatchLogMapper.selectRedPacketStatistics(query);
|
|
|
Map<String, FsCourseReportVO> redPacketMap = new HashMap<>();
|
|
|
+
|
|
|
+ Set<Long> companyIds = redPacketStatistics.stream()
|
|
|
+ .map(FsCourseReportVO::getCompanyId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ Map<Long, Integer> companyRedPacketStatus = new HashMap<>();
|
|
|
+ for (Long companyId : companyIds) {
|
|
|
+ Company company = companyCacheService.selectCompanyById(companyId);
|
|
|
+ companyRedPacketStatus.put(companyId, company != null ? company.getOpenRedPacket() : null);
|
|
|
+ }
|
|
|
+
|
|
|
if ("company".equals(query.getDimension())) {
|
|
|
- redPacketMap = redPacketStatistics.stream().collect(Collectors.toMap(
|
|
|
- stats -> String.valueOf(stats.getCompanyId()),
|
|
|
- Function.identity(),
|
|
|
- (existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
- ));
|
|
|
+ redPacketMap = redPacketStatistics.stream()
|
|
|
+ .filter(stats -> {
|
|
|
+ Integer status = companyRedPacketStatus.get(stats.getCompanyId());
|
|
|
+ return status != null && status == 1;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ stats -> String.valueOf(stats.getCompanyId()),
|
|
|
+ Function.identity(),
|
|
|
+ (existing, replacement) -> existing
|
|
|
+ ));
|
|
|
} else if ("camp".equals(query.getDimension())) {
|
|
|
- redPacketMap = redPacketStatistics.stream().collect(Collectors.toMap(
|
|
|
- stats -> stats.getPeriodId() + "_" + stats.getCompanyId(),
|
|
|
- Function.identity(),
|
|
|
- (existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
- ));
|
|
|
+ redPacketMap = redPacketStatistics.stream()
|
|
|
+ .filter(stats -> {
|
|
|
+ Integer status = companyRedPacketStatus.get(stats.getCompanyId());
|
|
|
+ return status != null && status == 1;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ stats -> stats.getPeriodId() + "_" + stats.getCompanyId(),
|
|
|
+ Function.identity(),
|
|
|
+ (existing, replacement) -> existing
|
|
|
+ ));
|
|
|
}
|
|
|
|
|
|
return redPacketMap;
|
|
|
@@ -2642,13 +2678,38 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<AppUserWatchLogVO> selectAppUserWatchLogList(Long userId) {
|
|
|
- return fsCourseWatchLogMapper.selectAppUserWatchLogList(userId);
|
|
|
+ public List<AppUserWatchLogVO> selectAppUserWatchLogList(Long userId,Long projectId,String dateTag,Long companyUserId) {
|
|
|
+ return fsCourseWatchLogMapper.selectAppUserWatchLogList(userId,projectId,dateTag,companyUserId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<TodayUnfinishedCourseVO> selectTodayUnfinishedCourseList(Long userId) {
|
|
|
- return fsCourseWatchLogMapper.selectTodayUnfinishedCourseList(userId);
|
|
|
+ String json = configService.selectConfigByKey("course.config");
|
|
|
+ CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
+ List<TodayUnfinishedCourseVO> todayUnfinishedCourseVOS = fsCourseWatchLogMapper.selectTodayUnfinishedCourseList(userId);
|
|
|
+ todayUnfinishedCourseVOS.forEach(f -> {
|
|
|
+ String domainName = getDomainName(f.getCompanyUserId(), config);
|
|
|
+ FsCourseRealLink courseRealLink = new FsCourseRealLink();
|
|
|
+ courseRealLink.setCompanyUserId(f.getCompanyUserId());
|
|
|
+ courseRealLink.setCourseId(f.getCourseId());
|
|
|
+ courseRealLink.setVideoId(f.getVideoId());
|
|
|
+ courseRealLink.setPeriodId(f.getPeriodId());
|
|
|
+ courseRealLink.setId(f.getPeriodDaysId());
|
|
|
+ courseRealLink.setCompanyId(f.getCompanyId());
|
|
|
+ courseRealLink.setProjectId(f.getProjectId());
|
|
|
+ courseRealLink.setFsUserId(userId);
|
|
|
+ String sortLink = domainName + "/courseH5/pages_course/videovip?course=" + JSON.toJSONString(courseRealLink);
|
|
|
+ f.setUrl(sortLink);
|
|
|
+ });
|
|
|
+ return todayUnfinishedCourseVOS;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getDomainName(Long companyUserId, CourseConfig config){
|
|
|
+ String domainName = companyUserMapper.selectDomainByUserId(companyUserId);
|
|
|
+ if (com.fs.common.utils.StringUtils.isEmpty(domainName)){
|
|
|
+ domainName = config.getRealLinkDomainName();
|
|
|
+ }
|
|
|
+ return domainName;
|
|
|
}
|
|
|
|
|
|
}
|