|
@@ -1,18 +1,31 @@
|
|
package com.fs.statis.service.impl;
|
|
package com.fs.statis.service.impl;
|
|
|
|
|
|
|
|
+import com.fs.company.cache.ICompanyCacheService;
|
|
import com.fs.statis.dto.*;
|
|
import com.fs.statis.dto.*;
|
|
import com.fs.statis.mapper.ConsumptionBalanceMapper;
|
|
import com.fs.statis.mapper.ConsumptionBalanceMapper;
|
|
import com.fs.statis.service.IStatisticsService;
|
|
import com.fs.statis.service.IStatisticsService;
|
|
|
|
+import com.fs.statis.service.utils.TrendDataFiller;
|
|
|
|
+import com.fs.store.service.cache.IFsUserCourseCacheService;
|
|
import com.hc.openapi.tool.util.ObjectUtils;
|
|
import com.hc.openapi.tool.util.ObjectUtils;
|
|
|
|
+import com.hc.openapi.tool.util.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
|
|
+import java.util.Collections;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class StatisticsServiceImpl implements IStatisticsService {
|
|
public class StatisticsServiceImpl implements IStatisticsService {
|
|
@Autowired
|
|
@Autowired
|
|
private ConsumptionBalanceMapper consumptionBalanceMapper;
|
|
private ConsumptionBalanceMapper consumptionBalanceMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IFsUserCourseCacheService fsUserCourseCacheService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICompanyCacheService companyCacheService;
|
|
@Override
|
|
@Override
|
|
public DealerAggregatedDTO dealerAggregated() {
|
|
public DealerAggregatedDTO dealerAggregated() {
|
|
return consumptionBalanceMapper.dealerAggregated();
|
|
return consumptionBalanceMapper.dealerAggregated();
|
|
@@ -43,8 +56,10 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
dto.setCompletedUserCount(completedUserCount);
|
|
dto.setCompletedUserCount(completedUserCount);
|
|
|
|
|
|
// 完播率
|
|
// 完播率
|
|
- if(!ObjectUtils.equals(completedUserCount,0L)){
|
|
|
|
- dto.setCompletedRate((completedUserCount / watchUserCount) * 100 +"%");
|
|
|
|
|
|
+ if(!ObjectUtils.equals(watchUserCount,0L)){
|
|
|
|
+ BigDecimal multiply = (BigDecimal.valueOf(completedUserCount).divide(BigDecimal.valueOf(watchUserCount))).multiply(BigDecimal.valueOf(100));
|
|
|
|
+
|
|
|
|
+ dto.setCompletedRate(multiply.setScale(2,BigDecimal.ROUND_HALF_UP).toPlainString());
|
|
} else {
|
|
} else {
|
|
dto.setCompletedRate("0");
|
|
dto.setCompletedRate("0");
|
|
}
|
|
}
|
|
@@ -64,8 +79,12 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
// 完播次数
|
|
// 完播次数
|
|
dto.setCompletedCount(completedCount);
|
|
dto.setCompletedCount(completedCount);
|
|
// 视频完播率
|
|
// 视频完播率
|
|
- if(!ObjectUtils.equals(completedCount, 0L)){
|
|
|
|
- dto.setCompletedRate((completedCount / watchCount) * 100 +"%");
|
|
|
|
|
|
+ if(!ObjectUtils.equals(watchCount, 0L)){
|
|
|
|
+ BigDecimal multiply = BigDecimal.valueOf(completedCount)
|
|
|
|
+ .divide(BigDecimal.valueOf(watchCount))
|
|
|
|
+ .multiply(BigDecimal.valueOf(100));
|
|
|
|
+
|
|
|
|
+ dto.setCompletedRate(multiply.setScale(2,BigDecimal.ROUND_HALF_UP).toPlainString());
|
|
} else {
|
|
} else {
|
|
dto.setCompletedRate("0");
|
|
dto.setCompletedRate("0");
|
|
}
|
|
}
|
|
@@ -85,12 +104,20 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
dto.setCorrectUserCount(correctUserCount);
|
|
dto.setCorrectUserCount(correctUserCount);
|
|
// 正确比例
|
|
// 正确比例
|
|
if(!ObjectUtils.equals(answerMemberCount, 0L)){
|
|
if(!ObjectUtils.equals(answerMemberCount, 0L)){
|
|
- dto.setCorrectRate((correctUserCount / answerMemberCount) * 100 +"%");
|
|
|
|
|
|
+ BigDecimal multiply = BigDecimal.valueOf(correctUserCount).divide(BigDecimal.valueOf(answerMemberCount)).multiply(BigDecimal.valueOf(100));
|
|
|
|
+
|
|
|
|
+ dto.setCorrectRate(multiply.setScale(2, RoundingMode.HALF_UP).toPlainString());
|
|
} else {
|
|
} else {
|
|
dto.setCorrectRate("0");
|
|
dto.setCorrectRate("0");
|
|
}
|
|
}
|
|
Long rewardCount = consumptionBalanceMapper.queryRewardCount(param);
|
|
Long rewardCount = consumptionBalanceMapper.queryRewardCount(param);
|
|
|
|
+ if(rewardCount == null) {
|
|
|
|
+ rewardCount = 0L;
|
|
|
|
+ }
|
|
BigDecimal rewardMoney = consumptionBalanceMapper.queryRewardMoney(param);
|
|
BigDecimal rewardMoney = consumptionBalanceMapper.queryRewardMoney(param);
|
|
|
|
+ if(rewardMoney == null) {
|
|
|
|
+ rewardMoney = BigDecimal.ZERO;
|
|
|
|
+ }
|
|
// 答题红包个数
|
|
// 答题红包个数
|
|
dto.setRewardCount(rewardCount);
|
|
dto.setRewardCount(rewardCount);
|
|
// 答题红包金额
|
|
// 答题红包金额
|
|
@@ -108,4 +135,43 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
public AuthorizationInfoDTO authorizationInfo() {
|
|
public AuthorizationInfoDTO authorizationInfo() {
|
|
return consumptionBalanceMapper.authorizationInfo();
|
|
return consumptionBalanceMapper.authorizationInfo();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<WatchEndPlayTrendDTO> watchEndPlayTrend(AnalysisPreviewQueryDTO param) {
|
|
|
|
+ List<WatchEndPlayTrendDTO> watchEndPlayTrendDTOS = consumptionBalanceMapper.watchEndPlayTrend(param);
|
|
|
|
+ // 今日,昨日 格式为24小时
|
|
|
|
+ if(ObjectUtils.equals(param.getType(),0) || ObjectUtils.equals(param.getType(),1)){
|
|
|
|
+ watchEndPlayTrendDTOS = TrendDataFiller.fillHourData(watchEndPlayTrendDTOS);
|
|
|
|
+ // 否则都是按天为维度的时间范围
|
|
|
|
+ } else {
|
|
|
|
+ watchEndPlayTrendDTOS = TrendDataFiller.fillDateSegmentData(watchEndPlayTrendDTOS, param.getStartTime(), param.getEndTime());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return watchEndPlayTrendDTOS;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<DeaMemberTopTenDTO> deaMemberTopTen(AnalysisPreviewQueryDTO param) {
|
|
|
|
+ List<DeaMemberTopTenDTO> deaMemberTopTenDTOS = consumptionBalanceMapper.deaMemberTopTen(param);
|
|
|
|
+ for (DeaMemberTopTenDTO dto : deaMemberTopTenDTOS) {
|
|
|
|
+ Long companyId = dto.getCompanyId();
|
|
|
|
+ String companyName = companyCacheService.selectCompanyNameById(companyId);
|
|
|
|
+ if(StringUtils.isNotBlank(companyName)){
|
|
|
|
+ dto.setCompanyName(companyName);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return deaMemberTopTenDTOS;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<CourseStatsDTO> watchCourseTopTen(AnalysisPreviewQueryDTO param) {
|
|
|
|
+ List<CourseStatsDTO> courseStatsDTOS = consumptionBalanceMapper.watchCourseTopTen(param);
|
|
|
|
+ for (CourseStatsDTO courseStatsDTO : courseStatsDTOS) {
|
|
|
|
+ String courseName = fsUserCourseCacheService.selectCourseNameByCourseId(courseStatsDTO.getCourseId());
|
|
|
|
+ if(StringUtils.isNotBlank(courseName)){
|
|
|
|
+ courseStatsDTO.setCourseName(courseName);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return courseStatsDTOS;
|
|
|
|
+ }
|
|
}
|
|
}
|