| 
					
				 | 
			
			
				@@ -3,6 +3,7 @@ package com.fs.store.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.RoundingMode; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.function.Function; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -16,6 +17,11 @@ import com.fs.company.cache.ICompanyUserCacheService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.company.domain.CompanyUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.company.service.ICompanyUserService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.company.vo.CompanyQueryVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.course.mapper.FsUserCourseVideoMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.course.param.newfs.UserCourseVideoPageParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.course.vo.newfs.FsCourseAnalysisCountVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.course.vo.newfs.FsCourseAnalysisVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.course.vo.newfs.FsUserCourseVideoPageListVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qw.param.QwFsUserParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qw.vo.QwFsUserVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.store.domain.FsStoreOrder; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -26,8 +32,10 @@ import com.fs.store.dto.FsUserTransferParamDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.store.enums.BillDetailEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.store.mapper.FsStoreOrderMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.store.mapper.FsStoreProductAttrValueMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.store.param.h5.CourseAnalysisParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.store.param.h5.FsUserPageListParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.store.param.SelectCusListPageParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.store.param.h5.UserStatisticsCommonParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.store.service.IFsUserBillService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.store.vo.FSUserVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.store.vo.FsCompanyUserListQueryVO; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -75,6 +83,8 @@ public class FsUserServiceImpl implements IFsUserService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ICompanyUserCacheService companyUserCacheService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ICompanyUserService companyUserService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private FsUserCourseVideoMapper userCourseVideoMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 查询用户 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -480,15 +490,15 @@ public class FsUserServiceImpl implements IFsUserService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public FsUserStatisticsVO userStatistics(Long userId, String startTime, String endTime, String courseId, String videoId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return getUserStatistics(userId, startTime, endTime, courseId, videoId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public FsUserStatisticsVO userStatistics(UserStatisticsCommonParam param) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return getUserStatistics(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private FsUserStatisticsVO getUserStatistics(Long userId, String startTime, String endTime, String courseId, String videoId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private FsUserStatisticsVO getUserStatistics(UserStatisticsCommonParam param) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         FsUserStatisticsVO fsUserStatisticsVO = new FsUserStatisticsVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 获取课程统计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, Long> couserMap = fsUserMapper.countUserCourse(userId, startTime, endTime, courseId, videoId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Long> couserMap = fsUserMapper.countUserCourse(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (couserMap != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             fsUserStatisticsVO.setCourseWatchNum(couserMap.get("courseWatchNum").intValue()).setCourseCompleteNum(couserMap.get("courseCompleteNum").intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -502,7 +512,7 @@ public class FsUserServiceImpl implements IFsUserService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 获取答题统计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, Long> answerMap = fsUserMapper.countUserAnswer(userId, startTime, endTime, courseId, videoId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Long> answerMap = fsUserMapper.countUserAnswer(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (answerMap != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             fsUserStatisticsVO.setAnswerNum(answerMap.get("answerNum").intValue()).setAnswerRightNum(answerMap.get("answerRightNum").intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -516,7 +526,7 @@ public class FsUserServiceImpl implements IFsUserService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 获取红包统计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, Object> redPacketMap = fsUserMapper.countUserRedPacket(userId, startTime, endTime, courseId, videoId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Object> redPacketMap = fsUserMapper.countUserRedPacket(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(redPacketMap != null && redPacketMap.get("redPacketNum") != null && redPacketMap.get("redPacketAmount") != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             fsUserStatisticsVO.setRedPacketNum(Integer.parseInt(redPacketMap.get("redPacketNum").toString())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .setRedPacketAmount(new BigDecimal(redPacketMap.get("redPacketAmount").toString())); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -525,11 +535,11 @@ public class FsUserServiceImpl implements IFsUserService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public FsUserStatisticsVO userStatisticsDetails(Long userId, String courseId, String videoId, Long companyId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        FsUserStatisticsVO userStatisticsVO = getUserStatistics(userId, null, null, courseId, videoId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public FsUserStatisticsVO userStatisticsDetails(UserStatisticsCommonParam param) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FsUserStatisticsVO userStatisticsVO = getUserStatistics(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //统计课程数据详情,在查询统计详情的时候需要显示 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, Long> courseDetailsMap = fsUserMapper.countCourseDetails(userId, courseId, videoId, companyId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Long> courseDetailsMap = fsUserMapper.countCourseDetails(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(courseDetailsMap != null && courseDetailsMap.get("courseNum") != null && courseDetailsMap.get("videoNum") != null && courseDetailsMap.get("courseUserNum") != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             userStatisticsVO.setCourseNum(Integer.parseInt(courseDetailsMap.get("courseNum").toString())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .setVideoNum(Integer.parseInt(courseDetailsMap.get("videoNum").toString())) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -566,8 +576,8 @@ public class FsUserServiceImpl implements IFsUserService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public List<FsUserGraphicStatisticsVO> graphicStatistics(Long userId, String startTime, String endTime, String courseId, String videoId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        FsUserStatisticsVO userStatistics = getUserStatistics(userId, startTime, endTime, courseId, videoId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<FsUserGraphicStatisticsVO> graphicStatistics(UserStatisticsCommonParam param) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FsUserStatisticsVO userStatistics = getUserStatistics(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<FsUserGraphicStatisticsVO> list = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         list.add(new FsUserGraphicStatisticsVO("观看人数",userStatistics.getCourseWatchNum(), userStatistics.getCourseWatchNum())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         list.add(new FsUserGraphicStatisticsVO("完播人数", userStatistics.getCourseCompleteNum(), userStatistics.getCourseCompleteNum())); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -576,4 +586,62 @@ public class FsUserServiceImpl implements IFsUserService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         list.add(new FsUserGraphicStatisticsVO("答题红包数", userStatistics.getRedPacketNum(), userStatistics.getRedPacketNum())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<FsCourseAnalysisVO> courseAnalysis(CourseAnalysisParam param) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //1、查询课程视频信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        UserCourseVideoPageParam userCourseVideoPageParam = new UserCourseVideoPageParam(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BeanUtils.copyProperties(param, userCourseVideoPageParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<FsUserCourseVideoPageListVO> videoList = userCourseVideoMapper.selectFsUserCourseVideoPageList(userCourseVideoPageParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //2、查询统计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<FsCourseAnalysisCountVO> courseCountList = fsUserMapper.courseAnalysisCourseCount(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<FsCourseAnalysisCountVO> redPacketCountList = fsUserMapper.courseAnalysisRedPacketCount(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<FsCourseAnalysisCountVO> answerCountList = fsUserMapper.courseAnalysisAnswerCount(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //3、转化为map 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Long, FsCourseAnalysisCountVO> courseMap = courseCountList.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .collect(Collectors.toMap( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        FsCourseAnalysisCountVO::getVideoId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Function.identity() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                )); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Long, FsCourseAnalysisCountVO> redPacketMap = redPacketCountList.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .collect(Collectors.toMap( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        FsCourseAnalysisCountVO::getVideoId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Function.identity() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                )); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Long, FsCourseAnalysisCountVO> answerMap = answerCountList.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .collect(Collectors.toMap( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        FsCourseAnalysisCountVO::getVideoId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Function.identity() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                )); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //4、处理数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return videoList.stream().map(v -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            FsCourseAnalysisVO allVO = new FsCourseAnalysisVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BeanUtils.copyProperties(v, allVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            FsCourseAnalysisCountVO countVO = new FsCourseAnalysisCountVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            FsCourseAnalysisCountVO courseVO = courseMap.getOrDefault(v.getVideoId(), countVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            FsCourseAnalysisCountVO redPacketVO = redPacketMap.getOrDefault(v.getVideoId(), countVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            FsCourseAnalysisCountVO answerVO = answerMap.getOrDefault(v.getVideoId(), countVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BeanUtils.copyProperties(courseVO, countVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            countVO.setRedPacketNum(redPacketVO.getRedPacketNum()).setRedPacketAmount(redPacketVO.getRedPacketAmount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            countVO.setAnswerNum(answerVO.getAnswerNum()).setAnswerRightNum(answerVO.getAnswerRightNum()).setAnswerRightRate(answerVO.getAnswerRightRate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            allVO.setCountVO(countVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return allVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public CompanyUserSummaryCountVO companyUserSummaryCount(Long userId, String companyUserId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CompanyUserSummaryCountVO companyUserCount = fsUserMapper.companyUserCount(companyUserId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CompanyUserSummaryCountVO newUserRedPacketCount = fsUserMapper.newUserRedPacketCount(companyUserId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CompanyUserSummaryCountVO vo = new CompanyUserSummaryCountVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BeanUtils.copyProperties(companyUserCount, vo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        vo.setUserRedPacketNum(newUserRedPacketCount.getUserRedPacketNum()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        vo.setTodayUserRedPacketAmount(newUserRedPacketCount.getTodayUserRedPacketAmount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return vo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |