|
@@ -0,0 +1,111 @@
|
|
|
|
+package com.fs.statis.service.impl;
|
|
|
|
+
|
|
|
|
+import com.fs.statis.dto.*;
|
|
|
|
+import com.fs.statis.mapper.ConsumptionBalanceMapper;
|
|
|
|
+import com.fs.statis.service.IStatisticsService;
|
|
|
|
+import com.hc.openapi.tool.util.ObjectUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
|
+ @Autowired
|
|
|
|
+ private ConsumptionBalanceMapper consumptionBalanceMapper;
|
|
|
|
+ @Override
|
|
|
|
+ public DealerAggregatedDTO dealerAggregated() {
|
|
|
|
+ return consumptionBalanceMapper.dealerAggregated();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ConsumptionBalanceDataDTO rechargeConsumption() {
|
|
|
|
+ return consumptionBalanceMapper.rechargeConsumption();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public AnalysisPreviewDTO analysisPreview(AnalysisPreviewQueryDTO param) {
|
|
|
|
+ AnalysisPreviewDTO dto = new AnalysisPreviewDTO();
|
|
|
|
+
|
|
|
|
+ Long watchUserCount = consumptionBalanceMapper.queryWatchUserCount(param);
|
|
|
|
+ Long completedUserCount = consumptionBalanceMapper.queryCompletedUserCount(param);
|
|
|
|
+
|
|
|
|
+ if(watchUserCount == null){
|
|
|
|
+ watchUserCount = 0L;
|
|
|
|
+ }
|
|
|
|
+ if(completedUserCount == null){
|
|
|
|
+ completedUserCount = 0L;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 观看人数
|
|
|
|
+ dto.setWatchUserCount(watchUserCount);
|
|
|
|
+ // 完播人数
|
|
|
|
+ dto.setCompletedUserCount(completedUserCount);
|
|
|
|
+
|
|
|
|
+ // 完播率
|
|
|
|
+ if(!ObjectUtils.equals(completedUserCount,0L)){
|
|
|
|
+ dto.setCompletedRate((completedUserCount / watchUserCount) * 100 +"%");
|
|
|
|
+ } else {
|
|
|
|
+ dto.setCompletedRate("0");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Long watchCount = consumptionBalanceMapper.queryWatchCount(param);
|
|
|
|
+ Long completedCount = consumptionBalanceMapper.queryCompletedCount(param);
|
|
|
|
+
|
|
|
|
+ if(watchCount == 0){
|
|
|
|
+ watchCount = 0L;
|
|
|
|
+ }
|
|
|
|
+ if(completedCount == 0){
|
|
|
|
+ completedCount = 0L;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 观看次数
|
|
|
|
+ dto.setWatchCount(watchCount);
|
|
|
|
+ // 完播次数
|
|
|
|
+ dto.setCompletedCount(completedCount);
|
|
|
|
+ // 视频完播率
|
|
|
|
+ if(!ObjectUtils.equals(completedCount, 0L)){
|
|
|
|
+ dto.setCompletedRate((completedCount / watchCount) * 100 +"%");
|
|
|
|
+ } else {
|
|
|
|
+ dto.setCompletedRate("0");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Long answerMemberCount = consumptionBalanceMapper.queryAnswerMemberCount(param);
|
|
|
|
+ Long correctUserCount = consumptionBalanceMapper.queryCorrectUserCount(param);
|
|
|
|
+
|
|
|
|
+ if(answerMemberCount == 0){
|
|
|
|
+ answerMemberCount = 0L;
|
|
|
|
+ }
|
|
|
|
+ if(correctUserCount == 0){
|
|
|
|
+ correctUserCount = 0L;
|
|
|
|
+ }
|
|
|
|
+ // 答题人数
|
|
|
|
+ dto.setAnswerMemberCount(answerMemberCount);
|
|
|
|
+ // 正确人数
|
|
|
|
+ dto.setCorrectUserCount(correctUserCount);
|
|
|
|
+ // 正确比例
|
|
|
|
+ if(!ObjectUtils.equals(answerMemberCount, 0L)){
|
|
|
|
+ dto.setCorrectRate((correctUserCount / answerMemberCount) * 100 +"%");
|
|
|
|
+ } else {
|
|
|
|
+ dto.setCorrectRate("0");
|
|
|
|
+ }
|
|
|
|
+ Long rewardCount = consumptionBalanceMapper.queryRewardCount(param);
|
|
|
|
+ BigDecimal rewardMoney = consumptionBalanceMapper.queryRewardMoney(param);
|
|
|
|
+ // 答题红包个数
|
|
|
|
+ dto.setRewardCount(rewardCount);
|
|
|
|
+ // 答题红包金额
|
|
|
|
+ dto.setRewardMoney(rewardMoney);
|
|
|
|
+
|
|
|
|
+ return dto;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Long smsBalance() {
|
|
|
|
+ return consumptionBalanceMapper.smsBalance();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public AuthorizationInfoDTO authorizationInfo() {
|
|
|
|
+ return consumptionBalanceMapper.authorizationInfo();
|
|
|
|
+ }
|
|
|
|
+}
|