Pārlūkot izejas kodu

feat: 销售端首页

xdd 1 mēnesi atpakaļ
vecāks
revīzija
e4c3289f81

+ 220 - 0
fs-company/src/main/java/com/fs/company/controller/IndexStatisticsController.java

@@ -0,0 +1,220 @@
+package com.fs.company.controller;
+
+import com.fs.common.core.domain.R;
+import com.fs.common.core.redis.RedisCache;
+import com.fs.statis.StatisticsRedisConstant;
+import com.fs.statis.dto.*;
+import io.jsonwebtoken.lang.Assert;
+import org.apache.http.util.Asserts;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.fs.statis.StatisticsRedisConstant.*;
+
+/**
+ * 首页-统计
+ */
+@RestController
+@RequestMapping("/index/statistics")
+public class IndexStatisticsController {
+    @Autowired
+    private RedisCache redisCache;
+    /**
+     * 分析概览
+     */
+    @PostMapping("/analysisPreview")
+    public R analysisPreview(@RequestBody AnalysisPreviewQueryDTO param){
+        AnalysisPreviewDTO analysisPreviewDTO = null;
+        Integer type = param.getType();
+        Integer userType = param.getUserType();
+
+        if(type == null) {
+            type = 0;
+        }
+
+        if(userType == null) {
+            userType = 0;
+        }
+        Asserts.notNull(param.getCompanyId(),"公司id不能为空!");
+
+        analysisPreviewDTO = redisCache.getCacheObject(String.format("%s:%d:%d:%d",DATA_OVERVIEW_DEALER_ANALYSISPREVIEW,type,userType,param.getCompanyId()));
+
+        return R.ok().put("data",analysisPreviewDTO);
+    }
+
+
+    /**
+     * 消费余额
+     */
+    @GetMapping("/rechargeComsumption")
+    public R rechargeComsumption(@RequestParam("companyId") Long companyId){
+        Assert.notNull(companyId,"公司id不能为空!");
+
+        ConsumptionBalanceDataDTO consumptionBalanceDataDTO = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.DATA_OVERVIEW_DEALER_BALANCE,companyId));
+        return R.ok().put("data", consumptionBalanceDataDTO);
+    }
+
+    /**
+     * 获取统计流量
+     * @return
+     */
+    @GetMapping("/trafficLog")
+    public R getTrafficLog(@RequestParam("companyId") Long companyId){
+        Assert.notNull(companyId,"公司id不能为空!");
+
+        TrafficLogDTO trafficLogDTO = redisCache.getCacheObject(String.format("%s:%d",DATA_OVERVIEW_TRAFFIC_LOG,companyId));
+        return R.ok().put("data",trafficLogDTO);
+    }
+
+    /**
+     * 观看趋势
+     */
+    @PostMapping("/watchEndPlayTrend")
+    public R watchEndPlayTrend(@RequestBody AnalysisPreviewQueryDTO param){
+        Integer type = param.getType();
+        Integer userType = param.getUserType();
+
+        if(type == null) {
+            type = 0;
+        }
+        if(userType == null){
+            userType = 0;
+        }
+        Assert.notNull(param.getCompanyId(),"公司id不能为空!");
+
+        String key = String.format("%s:%d:%d:%d", DATA_OVERVIEW_DEALER_CHARTS, type,userType,param.getCompanyId());
+        List<DeaMemberTopTenDTO> deaMemberTopTenDTOS = redisCache.getCacheObject(key);
+        return R.ok().put("data", deaMemberTopTenDTOS);
+    }
+
+    /**
+     * 经销商会员观看
+     */
+    @PostMapping("/deaMemberTopTen")
+    public R deaMemberTopTen(@RequestBody AnalysisPreviewQueryDTO param){
+        Integer type = param.getType();
+        Integer statisticalType = param.getStatisticalType();
+        Integer userType = param.getUserType();
+
+        if(type == null) {
+            type = 0;
+        }
+        if(userType == null){
+            userType = 0;
+        }
+        Assert.notNull(param.getCompanyId(),"公司id不能为空!");
+
+        List<DeaMemberTopTenDTO> deaMemberTopTenDTOS = redisCache.getCacheObject(String.format("%s:%d:%d:%d:%d", CHARTS_MEMBER_TOP_TEN_WATCH, type, statisticalType,userType,param.getCompanyId()));
+        if(deaMemberTopTenDTOS == null){
+            deaMemberTopTenDTOS = new ArrayList<>();
+        }
+        return R.ok().put("data", deaMemberTopTenDTOS);
+    }
+
+    /**
+     * 奖励金额top10
+     */
+    @PostMapping("/rewardMoneyTopTen")
+    public R rewardMoneyTopTen(@RequestBody AnalysisPreviewQueryDTO param){
+        Integer type = param.getType();
+        Integer dataType = param.getDataType();
+        Integer userType = param.getUserType();
+        Assert.notNull(param.getCompanyId(),"公司id不能为空!");
+
+        List<RewardMoneyTopTenDTO> rewardMoneyTopTenDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TOP_TEN, type,dataType,userType,param.getCompanyId()));
+        return R.ok().put("data", rewardMoneyTopTenDTOS);
+    }
+
+    /**
+     * 答题红包金额趋势图
+     */
+    @PostMapping("/rewardMoneyTrend")
+    public R rewardMoneyTrend(@RequestBody AnalysisPreviewQueryDTO param){
+        Integer type = param.getType();
+        Integer userType = param.getUserType();
+        Assert.notNull(param.getCompanyId(),"公司id不能为空!");
+
+        List<RewardMoneyTrendDTO> rewardMoneyTrendDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d", CHARTS_REWARD_MONEY_TREND, type,userType,param.getCompanyId()));
+        return R.ok().put("data", rewardMoneyTrendDTOS);
+    }
+
+    /**
+     * 课程观看top10
+     */
+    @PostMapping("/watchCourseTopTen")
+    public R watchCourseTopTen(@RequestBody AnalysisPreviewQueryDTO param){
+        Integer type = param.getType();
+        String sort = param.getSort();
+        Integer statisticalType = param.getStatisticalType();
+        Integer userType = param.getUserType();
+        Assert.notNull(param.getCompanyId(),"公司id不能为空!");
+
+        List<CourseStatsDTO> courseStatsDTOS = redisCache.getCacheObject(String.format("%s:%d:%d:%d:%s:%d", CHARTS_WATCH_TOP_TEN, type,statisticalType,userType,sort,param.getCompanyId()));
+        return R.ok().put("data", courseStatsDTOS);
+    }
+
+    /**
+     * 数据概览
+     */
+    @GetMapping("/dealerAggregated")
+    public R dealerAggregated(@RequestParam("companyId") Long companyId){
+        Assert.notNull(companyId,"公司id不能为空!");
+
+        DealerAggregatedDTO dealerAggregatedDTO = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AGGREGATED,companyId));
+
+        return R.ok().put("data",dealerAggregatedDTO);
+    }
+
+    /**
+     * 短信余额
+     */
+    @GetMapping("/smsBalance")
+    public R smsBalance(@RequestParam("companyId") Long companyId){
+        Assert.notNull(companyId, "公司id不能为空!");
+
+        Long smsBalance = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.DATA_OVERVIEW_DEALER_SMS_BALANCE,companyId));
+
+        return R.ok().put("data", smsBalance);
+    }
+
+
+    /**
+     * 授权信息
+     */
+    @GetMapping("/authorizationInfo")
+    public R authorizationInfo(@RequestParam("companyId") Long companyId){
+        Assert.notNull(companyId, "公司id不能为空!");
+
+        AuthorizationInfoDTO authorizationInfoDTO = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AUTHORIZATION_INFO,companyId));
+
+        return R.ok().put("data", authorizationInfoDTO);
+    }
+
+
+    /**
+     * 当月订单数统计
+     * @return
+     */
+    @GetMapping("/thisMonthOrderCount")
+    public R thisMonthOrderCount(@RequestParam("companyId") Long companyId){
+        Assert.notNull(companyId, "公司id不能为空!");
+
+        R result = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.THIS_MONTH_ORDER_COUNT,companyId));
+        return result;
+    }
+
+    /**
+     * 当月收益统计
+     * @return
+     */
+
+    @GetMapping("/thisMonthRecvCount")
+    public R thisMonthRecvCount(@RequestParam("companyId") Long companyId){
+        Assert.notNull(companyId, "公司id不能为空!");
+        R result = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.THIS_MONTH_RECV_COUNT,companyId));
+        return result;
+    }
+}

+ 3 - 0
fs-service-system/src/main/java/com/fs/course/mapper/FsCourseTrafficLogMapper.java

@@ -80,17 +80,20 @@ public interface FsCourseTrafficLogMapper
      * @return Long
      */
     Long getTodayTrafficLog();
+    Long getTodayTrafficLogCompanyId(@Param("companyId") Long companyId);
 
     /**
      * 获取当月统计流量
      * @return Long
      */
     Long getMonthTrafficLog();
+    Long getMonthTrafficLogCompanyId(@Param("companyId") Long companyId);
 
     /**
      * 昨天
      * @return Long
      */
     Long getYesterdayTrafficLog();
+    Long getYesterdayTrafficLogCompanyId(@Param("companyId") Long companyId);
 
 }

+ 5 - 0
fs-service-system/src/main/java/com/fs/statis/dto/AnalysisPreviewQueryDTO.java

@@ -42,4 +42,9 @@ public class AnalysisPreviewQueryDTO implements Serializable {
      */
     private Integer userType;
 
+    /**
+     * 公司id
+     */
+    private Long companyId;
+
 }

+ 4 - 0
fs-service-system/src/main/java/com/fs/statis/mapper/ConsumptionBalanceMapper.java

@@ -1,6 +1,7 @@
 package com.fs.statis.mapper;
 
 import com.fs.statis.dto.*;
+import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -17,6 +18,7 @@ public interface ConsumptionBalanceMapper {
     ConsumptionBalanceDataDTO rechargeConsumption();
 
     DealerAggregatedDTO dealerAggregated();
+    DealerAggregatedDTO dealerAggregatedCompanyId(@Param("companyId") Long companyId);
 
     /**
      * 观看人数
@@ -120,5 +122,7 @@ public interface ConsumptionBalanceMapper {
     List<RewardMoneyTrendDTO> rewardMoneyTrendDTO(AnalysisPreviewQueryDTO param);
 
     BigDecimal getCurrentBalance();
+    BigDecimal getCurrentBalanceCompanyId(@Param("companyId") Long companyId);
 
+    Long smsBalanceCompany(@Param("companyId") Long companyId);
 }

+ 108 - 0
fs-service-system/src/main/java/com/fs/statis/service/IStatisticsCompanyService.java

@@ -0,0 +1,108 @@
+package com.fs.statis.service;
+
+import com.fs.statis.dto.*;
+
+import java.util.List;
+
+/**
+ * 公司统计接口
+ */
+public interface IStatisticsCompanyService {
+
+    /**
+     * 数据概览定时任务
+     */
+    void dataOverviewTask();
+
+    /**
+     * 分析概览定时任务
+     */
+    void analysisPreviewTask(Integer type,Integer userType,Long companyId);
+
+
+    /**
+     * 会员观看、完播人数趋势图
+     */
+    void watchEndPlayTrendTask(Integer type,Integer userType,Long companyId);
+
+
+    /**
+     * 经销商会员观看TOP10
+     */
+    void companyWatchCourseTopTenTask(Integer type,Integer statisticalType,Integer userType,Long companyId);
+
+    /**
+     * 课程观看TOP10
+     */
+    void watchCourseTopTenTask(Integer type,Integer statisticalType,Integer userType,String sort,Long companyId);
+
+    /**
+     * 答题红包金额TOP10
+     */
+    void rewardMoneyTopTenTask(Integer type,Integer dataType,Integer userType,Long companyId);
+    void rewardMoneyTradeTask(Integer type,Integer userType,Long companyId);
+
+
+
+    DealerAggregatedDTO dealerAggregated(Long companyId);
+
+    /**
+     * 消费余额
+     */
+
+    ConsumptionBalanceDataDTO rechargeConsumption(Long companyId);
+
+    /**
+     * 分析概览
+     */
+    AnalysisPreviewDTO analysisPreview(AnalysisPreviewQueryDTO param);
+
+    Long smsBalance(Long companyId);
+
+    /**
+     * 授权信息
+     * @return
+     */
+    AuthorizationInfoDTO authorizationInfo();
+
+    /**
+     * 会员观看、完播人数趋势图
+     * @param param 请求参数
+     * @return 观看完播趋势
+     */
+    List<WatchEndPlayTrendDTO> watchEndPlayTrend(AnalysisPreviewQueryDTO param);
+
+    /**
+     * 经销商会员观看TOP10
+     * @param param
+     * @return
+     */
+    List<DeaMemberTopTenDTO> deaMemberTopTen(AnalysisPreviewQueryDTO param);
+
+    /**
+     * 课程观看TOP10
+     * @param param
+     * @return
+     */
+    List<CourseStatsDTO> watchCourseTopTen(AnalysisPreviewQueryDTO param);
+
+    List<RewardMoneyTopTenDTO> rewardMoneyTopTen(AnalysisPreviewQueryDTO param);
+
+    List<RewardMoneyTrendDTO> rewardMoneyTrendDTO(AnalysisPreviewQueryDTO param);
+
+    /**
+     * 获取统计流量
+     * @return TrafficLogDTO
+     */
+    TrafficLogDTO getTrafficLog(Long companyId);
+
+    /**
+     * 本月订单数
+     */
+    void thisMonthOrderCount(Long companyId);
+
+    /**
+     * 本月收款数
+     */
+    void thisMonthRecvCount(Long companyId);
+}

+ 1077 - 0
fs-service-system/src/main/java/com/fs/statis/service/impl/StatisticsCompanyServiceImpl.java

@@ -0,0 +1,1077 @@
+package com.fs.statis.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fs.common.core.domain.R;
+import com.fs.common.core.redis.RedisCache;
+import com.fs.common.utils.TimeUtils;
+import com.fs.company.cache.ICompanyCacheService;
+import com.fs.company.service.ICompanyService;
+import com.fs.course.mapper.FsCourseTrafficLogMapper;
+import com.fs.his.vo.OptionsVO;
+import com.fs.statis.StatisticsRedisConstant;
+import com.fs.statis.dto.*;
+import com.fs.statis.mapper.ConsumptionBalanceMapper;
+import com.fs.statis.service.IStatisticsCompanyService;
+import com.fs.statis.service.utils.TrendDataFiller;
+import com.fs.store.service.IFsStoreOrderService;
+import com.fs.store.service.IFsStorePaymentService;
+import com.fs.store.service.IFsStoreProductService;
+import com.fs.store.service.IFsUserService;
+import com.fs.store.service.cache.IFsUserCourseCacheService;
+import com.fs.system.domain.SysConfig;
+import com.fs.system.service.ISysConfigService;
+import com.hc.openapi.tool.util.ObjectUtils;
+import com.hc.openapi.tool.util.StringUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.util.Asserts;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.DayOfWeek;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAdjusters;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static com.fs.statis.StatisticsRedisConstant.*;
+
+@Slf4j
+@Service("statisticsCompanyService")
+public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
+    @Autowired
+    private ConsumptionBalanceMapper consumptionBalanceMapper;
+
+    @Autowired
+    private IFsUserCourseCacheService fsUserCourseCacheService;
+
+    @Autowired
+    private ICompanyCacheService companyCacheService;
+
+    @Autowired
+    private RedisCache redisCache;
+
+    @Autowired
+    private FsCourseTrafficLogMapper fsCourseTrafficLogMapper;
+    @Autowired
+    private IFsUserService userService;
+
+    @Autowired
+    private IFsStoreOrderService storeOrderService;
+
+    @Autowired
+    private IFsStorePaymentService paymentService;
+
+    @Autowired
+    private IFsStoreProductService productService;
+
+    @Autowired
+    private ISysConfigService configService;
+
+    @Autowired
+    private ICompanyService companyService;
+    @Override
+    public void dataOverviewTask() {
+        List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
+        for (OptionsVO optionsVO : optionsVOS) {
+            Long companyId = optionsVO.getDictValue();
+            if(companyId == null){
+                continue;
+            }
+            dataOverviewTaskCompany(companyId);
+        }
+    }
+
+    private void dataOverviewTaskCompany(Long companyId){
+        DealerAggregatedDTO dealerAggregatedDTO = this.dealerAggregated(companyId);
+        ConsumptionBalanceDataDTO consumptionBalanceDataDTO = this.rechargeConsumption(companyId);
+        AuthorizationInfoDTO authorizationInfoDTO = authorizationInfo();
+        Long smsBalance = this.smsBalance(companyId);
+        TrafficLogDTO trafficLog = this.getTrafficLog(companyId);
+
+        redisCache.setCacheObject(String.format(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AGGREGATED+":%d",companyId), dealerAggregatedDTO);
+        redisCache.setCacheObject(String.format(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_BALANCE+":%d",companyId), consumptionBalanceDataDTO);
+        redisCache.setCacheObject(String.format(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AUTHORIZATION_INFO+":%d",companyId), authorizationInfoDTO);
+        redisCache.setCacheObject(String.format(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_SMS_BALANCE+":%d",companyId), smsBalance);
+        redisCache.setCacheObject(String.format(StatisticsRedisConstant.DATA_OVERVIEW_TRAFFIC_LOG+":%d",companyId),trafficLog);
+    }
+    public void analysisPreviewTask0(){
+        List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
+        for (OptionsVO optionsVO : optionsVOS) {
+            Long companyId = optionsVO.getDictValue();
+            if (companyId == null) {
+                continue;
+            }
+            analysisPreviewTask(0,1,companyId);
+            analysisPreviewTask(0,2,companyId);
+        }
+
+    }
+
+    public void analysisPreviewTask1(){
+        List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
+        for (OptionsVO optionsVO : optionsVOS) {
+            Long companyId = optionsVO.getDictValue();
+            if (companyId == null) {
+                continue;
+            }
+
+            analysisPreviewTask(0,1,companyId);
+            analysisPreviewTask(1,1,companyId);
+            analysisPreviewTask(2,1,companyId);
+            analysisPreviewTask(3,1,companyId);
+            analysisPreviewTask(4,1,companyId);
+
+            analysisPreviewTask(0,2,companyId);
+            analysisPreviewTask(1,2,companyId);
+            analysisPreviewTask(2,2,companyId);
+            analysisPreviewTask(3,2,companyId);
+            analysisPreviewTask(4,2,companyId);
+        }
+    }
+    @Override
+    public void analysisPreviewTask(Integer type, Integer userType,Long companyId) {
+        // 根据type计算出时间范围
+        String startDate = "";
+        String endDate = "";
+
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
+
+        if(0 == type){
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
+        } else if(1 == type){
+            LocalDateTime yesterday = now.minusDays(1);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
+        } else if(2 == type) {
+            LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(3 == type) {
+            LocalDateTime startOfMonth = now.withDayOfMonth(1);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(4 == type) {
+            LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
+            LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
+        }
+
+        AnalysisPreviewQueryDTO param = new AnalysisPreviewQueryDTO();
+        param.setStartTime(startDate);
+        param.setEndTime(endDate);
+        param.setType(type);
+        param.setUserType(userType);
+        param.setCompanyId(companyId);
+
+        AnalysisPreviewDTO analysisPreviewDTO = this.analysisPreview(param);
+
+        redisCache.setCacheObject(String.format("%s:%d:%d:%d",DATA_OVERVIEW_DEALER_ANALYSISPREVIEW,type,userType,companyId), analysisPreviewDTO);
+    }
+
+
+    public void watchEndPlayTrendTask0(){
+        List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
+        for (OptionsVO optionsVO : optionsVOS) {
+            Long companyId = optionsVO.getDictValue();
+            if(companyId == null){
+                continue;
+            }
+            this.watchEndPlayTrendTask(0,1,companyId);
+            this.watchEndPlayTrendTask(0,2,companyId);
+        }
+
+    }
+
+    public void watchEndPlayTrendTask1(){
+        List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
+        for (OptionsVO optionsVO : optionsVOS) {
+            Long companyId = optionsVO.getDictValue();
+            if(companyId == null){
+                continue;
+            }
+            this.watchEndPlayTrendTask(1,1,companyId);
+            this.watchEndPlayTrendTask(2,1,companyId);
+            this.watchEndPlayTrendTask(3,1,companyId);
+            this.watchEndPlayTrendTask(4,1,companyId);
+
+            this.watchEndPlayTrendTask(1,2,companyId);
+            this.watchEndPlayTrendTask(2,2,companyId);
+            this.watchEndPlayTrendTask(3,2,companyId);
+            this.watchEndPlayTrendTask(4,2,companyId);
+        }
+
+    }
+    @Override
+    public void watchEndPlayTrendTask(Integer type, Integer userType,Long companyId) {
+        // 根据type计算出时间范围
+        String startDate = "";
+        String endDate = "";
+
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
+
+        if(0 == type){
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
+        } else if(1 == type){
+            LocalDateTime yesterday = now.minusDays(1);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
+        } else if(2 == type) {
+            LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(3 == type) {
+            LocalDateTime startOfMonth = now.withDayOfMonth(1);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(4 == type) {
+            LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
+            LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
+        }
+
+        AnalysisPreviewQueryDTO param = new AnalysisPreviewQueryDTO();
+        param.setStartTime(startDate);
+        param.setEndTime(endDate);
+        param.setType(type);
+        param.setCompanyId(companyId);
+
+        param.setUserType(userType);
+        List<WatchEndPlayTrendDTO> watchEndPlayTrendDTOS = this.watchEndPlayTrend(param);
+
+        redisCache.setCacheObject(String.format("%s:%d:%d",DATA_OVERVIEW_DEALER_CHARTS,type,userType),watchEndPlayTrendDTOS);
+    }
+
+    @Override
+    public void companyWatchCourseTopTenTask(Integer type, Integer statisticalType, Integer userType,Long companyId) {
+
+        AnalysisPreviewQueryDTO dto = new AnalysisPreviewQueryDTO();
+        dto.setType(type);
+        dto.setStatisticalType(statisticalType);
+
+        String startDate = "";
+        String endDate = "";
+
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
+
+        if(0 == type){
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
+        } else if(1 == type){
+            LocalDateTime yesterday = now.minusDays(1);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
+        } else if(2 == type) {
+            LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(3 == type) {
+            LocalDateTime startOfMonth = now.withDayOfMonth(1);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(4 == type) {
+            LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
+            LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
+        }
+
+        dto.setStartTime(startDate);
+        dto.setEndTime(endDate);
+        dto.setUserType(userType);
+        dto.setCompanyId(companyId);
+
+        List<DeaMemberTopTenDTO> deaMemberTopTenDTOS = deaMemberTopTen(dto);
+        redisCache.setCacheObject(String.format("%s:%d:%d:%d:%d", CHARTS_MEMBER_TOP_TEN_WATCH, type,statisticalType,userType,companyId), deaMemberTopTenDTOS);
+    }
+
+    public void companyWatchCourseTopTenTask0(){
+        List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
+        for (OptionsVO optionsVO : optionsVOS) {
+            Long companyId = optionsVO.getDictValue();
+            if (companyId == null) {
+                continue;
+            }
+            companyWatchCourseTopTenTask(0,0,1,companyId);
+            companyWatchCourseTopTenTask(0,1,1,companyId);
+
+
+            companyWatchCourseTopTenTask(0,0,2,companyId);
+            companyWatchCourseTopTenTask(0,1,2,companyId);
+        }
+
+    }
+
+    public void companyWatchCourseTopTenTask1(){
+        List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
+        for (OptionsVO optionsVO : optionsVOS) {
+            Long companyId = optionsVO.getDictValue();
+            if (companyId == null) {
+                continue;
+            }
+            companyWatchCourseTopTenTask(1,0,1,companyId);
+            companyWatchCourseTopTenTask(1,1,1,companyId);
+            companyWatchCourseTopTenTask(2,0,1,companyId);
+            companyWatchCourseTopTenTask(2,1,1,companyId);
+            companyWatchCourseTopTenTask(3,0,1,companyId);
+            companyWatchCourseTopTenTask(3,1,1,companyId);
+            companyWatchCourseTopTenTask(4,0,1,companyId);
+            companyWatchCourseTopTenTask(4,1,1,companyId);
+
+            companyWatchCourseTopTenTask(1,0,2,companyId);
+            companyWatchCourseTopTenTask(1,1,2,companyId);
+            companyWatchCourseTopTenTask(2,0,2,companyId);
+            companyWatchCourseTopTenTask(2,1,2,companyId);
+            companyWatchCourseTopTenTask(3,0,2,companyId);
+            companyWatchCourseTopTenTask(3,1,2,companyId);
+            companyWatchCourseTopTenTask(4,0,2,companyId);
+            companyWatchCourseTopTenTask(4,1,2,companyId);
+        }
+
+
+
+    }
+
+    @Override
+    public void watchCourseTopTenTask(Integer type, Integer statisticalType, Integer userType, String sort,Long companyId) {
+        AnalysisPreviewQueryDTO dto = new AnalysisPreviewQueryDTO();
+        dto.setType(type);
+        dto.setStatisticalType(statisticalType);
+        dto.setSort(sort);
+
+        String startDate = "";
+        String endDate = "";
+
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
+
+        if(0 == type){
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
+        } else if(1 == type){
+            LocalDateTime yesterday = now.minusDays(1);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
+        } else if(2 == type) {
+            LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(3 == type) {
+            LocalDateTime startOfMonth = now.withDayOfMonth(1);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(4 == type) {
+            LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
+            LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
+        }
+        dto.setStartTime(startDate);
+        dto.setEndTime(endDate);
+        dto.setUserType(userType);
+        dto.setCompanyId(companyId);
+        List<CourseStatsDTO> courseStatsDTOS = watchCourseTopTen(dto);
+
+        redisCache.setCacheObject( String.format("%s:%d:%d:%d:%s:%d", CHARTS_WATCH_TOP_TEN, type,statisticalType,userType,sort,companyId), courseStatsDTOS);
+
+    }
+
+
+    public void watchCourseTopTenTask0(){
+        List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
+        for (OptionsVO optionsVO : optionsVOS) {
+            Long companyId = optionsVO.getDictValue();
+            if (companyId == null) {
+                continue;
+            }
+
+            watchCourseTopTenTask(0,0,1,"DESC",companyId);
+            watchCourseTopTenTask(0,0,1,"ASC",companyId);
+            watchCourseTopTenTask(0,1,1,"DESC",companyId);
+            watchCourseTopTenTask(0,1,1,"ASC",companyId);
+            watchCourseTopTenTask(0,2,1,"DESC",companyId);
+            watchCourseTopTenTask(0,2,1,"ASC",companyId);
+            watchCourseTopTenTask(0,3,1,"DESC",companyId);
+            watchCourseTopTenTask(0,3,1,"ASC",companyId);
+
+            watchCourseTopTenTask(0,0,1,"DESC",companyId);
+            watchCourseTopTenTask(0,0,1,"ASC",companyId);
+            watchCourseTopTenTask(0,1,1,"DESC",companyId);
+            watchCourseTopTenTask(0,1,1,"ASC",companyId);
+            watchCourseTopTenTask(0,2,1,"DESC",companyId);
+            watchCourseTopTenTask(0,2,1,"ASC",companyId);
+            watchCourseTopTenTask(0,3,1,"DESC",companyId);
+            watchCourseTopTenTask(0,3,1,"ASC",companyId);
+
+        }
+
+    }
+
+    public void watchCourseTopTenTask1(){
+        List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
+        for (OptionsVO optionsVO : optionsVOS) {
+            Long companyId = optionsVO.getDictValue();
+            if (companyId == null) {
+                continue;
+            }
+
+            watchCourseTopTenTask(1,0,1,"DESC",companyId);
+            watchCourseTopTenTask(1,0,1,"ASC",companyId);
+
+            watchCourseTopTenTask(1,0,2,"DESC",companyId);
+            watchCourseTopTenTask(1,0,2,"ASC",companyId);
+
+
+            watchCourseTopTenTask(1,1,1,"DESC",companyId);
+            watchCourseTopTenTask(1,1,1,"ASC",companyId);
+
+            watchCourseTopTenTask(1,1,2,"DESC",companyId);
+            watchCourseTopTenTask(1,1,2,"ASC",companyId);
+
+            watchCourseTopTenTask(1,2,1,"DESC",companyId);
+            watchCourseTopTenTask(1,2,1,"ASC",companyId);
+
+            watchCourseTopTenTask(1,2,2,"DESC",companyId);
+            watchCourseTopTenTask(1,2,2,"ASC",companyId);
+
+
+            watchCourseTopTenTask(1,3,1,"DESC",companyId);
+            watchCourseTopTenTask(1,3,1,"ASC",companyId);
+
+            watchCourseTopTenTask(1,3,2,"DESC",companyId);
+            watchCourseTopTenTask(1,3,2,"ASC",companyId);
+
+            watchCourseTopTenTask(2,0,1,"DESC",companyId);
+            watchCourseTopTenTask(2,0,1,"ASC",companyId);
+
+            watchCourseTopTenTask(2,0,2,"DESC",companyId);
+            watchCourseTopTenTask(2,0,2,"ASC",companyId);
+
+            watchCourseTopTenTask(2,1,1,"DESC",companyId);
+            watchCourseTopTenTask(2,1,1,"ASC",companyId);
+
+            watchCourseTopTenTask(2,1,2,"DESC",companyId);
+            watchCourseTopTenTask(2,1,2,"ASC",companyId);
+
+            watchCourseTopTenTask(2,2,1,"DESC",companyId);
+            watchCourseTopTenTask(2,2,1,"ASC",companyId);
+
+            watchCourseTopTenTask(2,2,2,"DESC",companyId);
+            watchCourseTopTenTask(2,2,2,"ASC",companyId);
+
+
+            watchCourseTopTenTask(2,3,1,"DESC",companyId);
+            watchCourseTopTenTask(2,3,1,"ASC",companyId);
+
+            watchCourseTopTenTask(2,3,2,"DESC",companyId);
+            watchCourseTopTenTask(2,3,2,"ASC",companyId);
+
+            watchCourseTopTenTask(3,0,1,"DESC",companyId);
+            watchCourseTopTenTask(3,0,1,"ASC",companyId);
+
+            watchCourseTopTenTask(3,0,2,"DESC",companyId);
+            watchCourseTopTenTask(3,0,2,"ASC",companyId);
+
+            watchCourseTopTenTask(3,1,1,"DESC",companyId);
+            watchCourseTopTenTask(3,1,1,"ASC",companyId);
+
+            watchCourseTopTenTask(3,1,2,"DESC",companyId);
+            watchCourseTopTenTask(3,1,2,"ASC",companyId);
+
+            watchCourseTopTenTask(3,2,1,"DESC",companyId);
+            watchCourseTopTenTask(3,2,1,"ASC",companyId);
+
+            watchCourseTopTenTask(3,2,2,"DESC",companyId);
+            watchCourseTopTenTask(3,2,2,"ASC",companyId);
+
+            watchCourseTopTenTask(3,3,1,"DESC",companyId);
+            watchCourseTopTenTask(3,3,1,"ASC",companyId);
+
+            watchCourseTopTenTask(3,3,2,"DESC",companyId);
+            watchCourseTopTenTask(3,3,2,"ASC",companyId);
+
+            watchCourseTopTenTask(4,0,1,"DESC",companyId);
+            watchCourseTopTenTask(4,0,1,"ASC",companyId);
+
+            watchCourseTopTenTask(4,0,2,"DESC",companyId);
+            watchCourseTopTenTask(4,0,2,"ASC",companyId);
+
+            watchCourseTopTenTask(4,1,1,"DESC",companyId);
+            watchCourseTopTenTask(4,1,1,"ASC",companyId);
+            watchCourseTopTenTask(4,2,1,"DESC",companyId);
+            watchCourseTopTenTask(4,2,1,"ASC",companyId);
+            watchCourseTopTenTask(4,3,1,"DESC",companyId);
+            watchCourseTopTenTask(4,3,1,"ASC",companyId);
+
+            watchCourseTopTenTask(4,1,2,"DESC",companyId);
+            watchCourseTopTenTask(4,1,2,"ASC",companyId);
+            watchCourseTopTenTask(4,2,2,"DESC",companyId);
+            watchCourseTopTenTask(4,2,2,"ASC",companyId);
+            watchCourseTopTenTask(4,3,2,"DESC",companyId);
+            watchCourseTopTenTask(4,3,2,"ASC",companyId);
+        }
+
+    }
+
+
+    @Override
+    public void rewardMoneyTopTenTask(Integer type, Integer dataType, Integer userType,Long companyId) {
+        AnalysisPreviewQueryDTO dto = new AnalysisPreviewQueryDTO();
+        dto.setType(type);
+        dto.setDataType(dataType);
+
+        String startDate = "";
+        String endDate = "";
+
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
+
+        if(0 == type){
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
+        } else if(1 == type){
+            LocalDateTime yesterday = now.minusDays(1);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
+        } else if(2 == type) {
+            LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(3 == type) {
+            LocalDateTime startOfMonth = now.withDayOfMonth(1);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(4 == type) {
+            LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
+            LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
+        }
+
+        dto.setStartTime(startDate);
+        dto.setEndTime(endDate);
+        dto.setUserType(userType);
+        dto.setCompanyId(companyId);
+
+        List<RewardMoneyTopTenDTO> rewardMoneyTopTenDTOS = rewardMoneyTopTen(dto);
+
+        redisCache.setCacheObject( String.format("%s:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TOP_TEN, type,dataType,userType,companyId), rewardMoneyTopTenDTOS);
+
+    }
+
+    @Override
+    public void rewardMoneyTradeTask(Integer type, Integer userType,Long companyId) {
+        AnalysisPreviewQueryDTO dto = new AnalysisPreviewQueryDTO();
+        dto.setType(type);
+
+        String startDate = "";
+        String endDate = "";
+
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
+
+        if(0 == type){
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
+        } else if(1 == type){
+            LocalDateTime yesterday = now.minusDays(1);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
+        } else if(2 == type) {
+            LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(3 == type) {
+            LocalDateTime startOfMonth = now.withDayOfMonth(1);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(4 == type) {
+            LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
+            LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
+        }
+
+        dto.setStartTime(startDate);
+        dto.setEndTime(endDate);
+        dto.setUserType(userType);
+        dto.setCompanyId(companyId);
+        List<RewardMoneyTrendDTO> rewardMoneyTrendDTOS = rewardMoneyTrendDTO(dto);
+        redisCache.setCacheObject( String.format("%s:%d:%d", CHARTS_REWARD_MONEY_TREND, type,userType), rewardMoneyTrendDTOS);
+
+    }
+
+
+    public void rewardMoneyTask15Minutes(){
+        List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
+        for (OptionsVO optionsVO : optionsVOS) {
+            Long companyId = optionsVO.getDictValue();
+            if (companyId == null) {
+                continue;
+            }
+            rewardMoneyTopTenTask(0,0,1,companyId);
+            rewardMoneyTopTenTask(0,1,1,companyId);
+
+            rewardMoneyTradeTask(0,1,companyId);
+
+            rewardMoneyTopTenTask(0,0,2,companyId);
+            rewardMoneyTopTenTask(0,1,2,companyId);
+
+            rewardMoneyTradeTask(0,2,companyId);
+        }
+
+    }
+
+
+    public void rewardMoneyTaskEveryday(){
+        List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
+        for (OptionsVO optionsVO : optionsVOS) {
+            Long companyId = optionsVO.getDictValue();
+            if (companyId == null) {
+                continue;
+            }
+
+            rewardMoneyTopTenTask(1,0,1,companyId);
+            rewardMoneyTopTenTask(1,1,1,companyId);
+
+
+            rewardMoneyTopTenTask(2,0,1,companyId);
+            rewardMoneyTopTenTask(2,1,1,companyId);
+
+            rewardMoneyTopTenTask(3,0,1,companyId);
+            rewardMoneyTopTenTask(3,1,1,companyId);
+
+            rewardMoneyTopTenTask(4,0,1,companyId);
+            rewardMoneyTopTenTask(4,1,1,companyId);
+
+
+            rewardMoneyTradeTask(1,1,companyId);
+            rewardMoneyTradeTask(2,1,companyId);
+            rewardMoneyTradeTask(3,1,companyId);
+            rewardMoneyTradeTask(4,1,companyId);
+
+
+            rewardMoneyTopTenTask(1,0,2,companyId);
+            rewardMoneyTopTenTask(1,1,2,companyId);
+            rewardMoneyTopTenTask(2,0,2,companyId);
+            rewardMoneyTopTenTask(2,1,2,companyId);
+            rewardMoneyTopTenTask(3,0,2,companyId);
+            rewardMoneyTopTenTask(3,1,2,companyId);
+            rewardMoneyTopTenTask(4,0,2,companyId);
+            rewardMoneyTopTenTask(4,1,2,companyId);
+
+            rewardMoneyTradeTask(1,2,companyId);
+            rewardMoneyTradeTask(2,2,companyId);
+            rewardMoneyTradeTask(3,2,companyId);
+            rewardMoneyTradeTask(4,2,companyId);
+        }
+
+    }
+
+    @Override
+    public DealerAggregatedDTO dealerAggregated(Long companyId) {
+        Long dayUserCount=userService.selectFsUserCount(1,companyId);
+        Long storeOrderCount=storeOrderService.selectFsStoreOrderTotalCount(0,companyId);
+        Long dayStoreOrderCount=storeOrderService.selectFsStoreOrderTotalCount(1,companyId);
+        Long paymentCount=paymentService.selectFsStorePaymentCount(0,companyId);
+        Long dayPaymentCount=paymentService.selectFsStorePaymentCount(1,companyId);
+        Long productCount=productService.selectFsStoreProductCount(0,companyId);
+        Long dayProductCount=productService.selectFsStoreProductCount(1,companyId);
+        DealerAggregatedDTO dealerAggregatedDTO = consumptionBalanceMapper.dealerAggregatedCompanyId(companyId);
+        dealerAggregatedDTO.setTodayIncreaseUserNum(dayUserCount);
+        dealerAggregatedDTO.setOrderTotalNum(storeOrderCount);
+        dealerAggregatedDTO.setTodayOrderNum(dayStoreOrderCount);
+        dealerAggregatedDTO.setRecvTodayNum(paymentCount);
+        dealerAggregatedDTO.setRecvTodayNum(dayPaymentCount);
+        dealerAggregatedDTO.setGoodsTotalNum(productCount);
+        dealerAggregatedDTO.setTodayGoodsNum(dayProductCount);
+        return dealerAggregatedDTO;
+    }
+
+    @Override
+    public ConsumptionBalanceDataDTO rechargeConsumption(Long companyId) {
+        // 获取流量统计数据
+        TrafficLogDTO trafficLog = this.getTrafficLog(companyId);
+
+        // 获取流量价格配置
+        SysConfig config = configService.selectConfigByConfigKey("statis.config");
+        Asserts.notNull(config, "流量价格配置不能为空!");
+        JSONObject jsonObject = JSONObject.parseObject(config.getConfigValue());
+        float trafficPrice = jsonObject.getFloatValue("trafficPrice");
+
+        // 创建消费余额数据对象
+        ConsumptionBalanceDataDTO consumptionBalanceData = new ConsumptionBalanceDataDTO();
+
+        // 计算消费金额(将流量从字节转换为GB,然后乘以每GB价格)
+        BigDecimal todayConsumption = calculateTrafficCost(trafficLog.getToday(), trafficPrice);
+        BigDecimal yesterdayConsumption = calculateTrafficCost(trafficLog.getYesterday(), trafficPrice);
+
+        // 设置消费数据
+        consumptionBalanceData.setTodayComsumption(todayConsumption);
+        consumptionBalanceData.setYesterdayComsumption(yesterdayConsumption);
+
+        // 从数据库获取当前余额
+        BigDecimal currentBalance = consumptionBalanceMapper.getCurrentBalanceCompanyId(companyId);
+        consumptionBalanceData.setBalance(currentBalance);
+
+        return consumptionBalanceData;
+    }
+    /**
+     * 计算流量消费金额
+     * @param trafficBytes 流量字节数
+     * @param pricePerGB 每GB价格
+     * @return 消费金额
+     */
+    private BigDecimal calculateTrafficCost(Long trafficBytes, float pricePerGB) {
+        if (trafficBytes == null || trafficBytes <= 0) {
+            return BigDecimal.ZERO;
+        }
+
+        // 将字节转换为GB (1GB = 1024^3 bytes)
+        BigDecimal trafficGB = new BigDecimal(trafficBytes)
+                .divide(new BigDecimal(1024 * 1024 * 1024), 6, BigDecimal.ROUND_HALF_UP);
+
+        // 计算消费金额
+        return trafficGB.multiply(new BigDecimal(pricePerGB)).setScale(2, BigDecimal.ROUND_HALF_UP);
+    }
+
+
+    @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(watchUserCount,0L)){
+            BigDecimal multiply = (BigDecimal.valueOf(completedUserCount)
+                    .divide(BigDecimal.valueOf(watchUserCount),4,BigDecimal.ROUND_HALF_UP))
+                    .multiply(BigDecimal.valueOf(100));
+
+            dto.setCompletedRate(multiply.setScale(2,BigDecimal.ROUND_HALF_UP).toPlainString());
+        } else {
+            dto.setCompletedRate("0");
+        }
+
+        Long watchCount = consumptionBalanceMapper.queryWatchCount(param);
+        Long completedCount = consumptionBalanceMapper.queryCompletedCount(param);
+
+        if(watchCount == null){
+            watchCount = 0L;
+        }
+        if(completedCount == null){
+            completedCount = 0L;
+        }
+
+        // 观看次数
+        dto.setWatchCount(watchCount);
+        // 完播次数
+        dto.setCompletedCount(completedCount);
+        // 视频完播率
+        if(!ObjectUtils.equals(watchCount, 0L)){
+            BigDecimal multiply = BigDecimal.valueOf(completedCount)
+                    .divide(BigDecimal.valueOf(watchCount),4,BigDecimal.ROUND_HALF_UP)
+                    .multiply(BigDecimal.valueOf(100));
+
+            dto.setWatchRate(multiply.setScale(2,BigDecimal.ROUND_HALF_UP).toPlainString());
+        } else {
+            dto.setWatchRate("0");
+        }
+
+        Long answerMemberCount = consumptionBalanceMapper.queryAnswerMemberCount(param);
+        Long correctUserCount = consumptionBalanceMapper.queryCorrectUserCount(param);
+
+        if(answerMemberCount == null){
+            answerMemberCount = 0L;
+        }
+        if(correctUserCount == null){
+            correctUserCount = 0L;
+        }
+        // 答题人数
+        dto.setAnswerMemberCount(answerMemberCount);
+        // 正确人数
+        dto.setCorrectUserCount(correctUserCount);
+        // 正确比例
+        if(!ObjectUtils.equals(answerMemberCount, 0L)){
+            BigDecimal multiply = BigDecimal.valueOf(correctUserCount)
+                    .divide(BigDecimal.valueOf(answerMemberCount),4,BigDecimal.ROUND_HALF_UP)
+                    .multiply(BigDecimal.valueOf(100));
+
+            dto.setCorrectRate(multiply.setScale(2, RoundingMode.HALF_UP).toPlainString());
+        } else {
+            dto.setCorrectRate("0");
+        }
+        Long rewardCount = consumptionBalanceMapper.queryRewardCount(param);
+        if(rewardCount == null) {
+            rewardCount = 0L;
+        }
+        BigDecimal rewardMoney = consumptionBalanceMapper.queryRewardMoney(param);
+        if(rewardMoney == null) {
+            rewardMoney = BigDecimal.ZERO;
+        }
+        // 答题红包个数
+        dto.setRewardCount(rewardCount);
+        // 答题红包金额
+        dto.setRewardMoney(rewardMoney);
+
+        return dto;
+    }
+
+
+    @Override
+    public Long smsBalance(Long companyId) {
+        Long smsBalance = consumptionBalanceMapper.smsBalanceCompany(companyId);
+        if(smsBalance != null) {
+            smsBalance = 0L;
+        }
+        return smsBalance;
+    }
+
+    @Override
+    public AuthorizationInfoDTO authorizationInfo() {
+        return consumptionBalanceMapper.authorizationInfo();
+    }
+
+    @Override
+    public List<WatchEndPlayTrendDTO> watchEndPlayTrend(AnalysisPreviewQueryDTO param) {
+        return Collections.emptyList();
+    }
+
+    @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;
+    }
+
+    @Override
+    public List<RewardMoneyTopTenDTO> rewardMoneyTopTen(AnalysisPreviewQueryDTO param) {
+        List<RewardMoneyTopTenDTO> rewardMoneyTopTenDTOS = consumptionBalanceMapper.rewardMoneyTopTen(param);
+        for (RewardMoneyTopTenDTO dto : rewardMoneyTopTenDTOS) {
+            if(dto.getCompanyId() != null) {
+                String companyName = companyCacheService.selectCompanyNameById(dto.getCompanyId());
+                dto.setCompanyName(companyName);
+            }
+            if(dto.getCourseId() != null){
+                String courseName = fsUserCourseCacheService.selectCourseNameByCourseId(dto.getCourseId());
+                dto.setCourseName(courseName);
+            }
+
+        }
+        return rewardMoneyTopTenDTOS;
+    }
+
+    @Override
+    public List<RewardMoneyTrendDTO> rewardMoneyTrendDTO(AnalysisPreviewQueryDTO param) {
+        List<RewardMoneyTrendDTO> rewardMoneyTrendDTOS = consumptionBalanceMapper.rewardMoneyTrendDTO(param);
+
+        // 今日,昨日 格式为24小时
+        if(ObjectUtils.equals(param.getType(),0) || ObjectUtils.equals(param.getType(),1)){
+            rewardMoneyTrendDTOS = TrendDataFiller.fillRewardHourData(rewardMoneyTrendDTOS);
+            // 否则都是按天为维度的时间范围
+        } else {
+            rewardMoneyTrendDTOS = TrendDataFiller.fillRewardDateSegmentData(rewardMoneyTrendDTOS, param.getStartTime(), param.getEndTime());
+        }
+
+
+        return rewardMoneyTrendDTOS;
+    }
+
+    @Override
+    public TrafficLogDTO getTrafficLog(Long companyId) {
+        TrafficLogDTO trafficLogDTO = new TrafficLogDTO();
+        Long todayTrafficLog = fsCourseTrafficLogMapper.getTodayTrafficLogCompanyId(companyId);
+        Long yesterdayTrafficLog = fsCourseTrafficLogMapper.getYesterdayTrafficLogCompanyId(companyId);
+        Long monthTrafficLog = fsCourseTrafficLogMapper.getMonthTrafficLogCompanyId(companyId);
+        trafficLogDTO.setToday(todayTrafficLog);
+        trafficLogDTO.setThisMonth(monthTrafficLog);
+        trafficLogDTO.setYesterday(yesterdayTrafficLog);
+        return trafficLogDTO;
+    }
+
+    public void companyThisMonthOrderCount(){
+        List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
+        for (OptionsVO optionsVO : optionsVOS) {
+            Long companyId = optionsVO.getDictValue();
+            if (companyId == null) {
+                continue;
+            }
+            this.thisMonthOrderCount(companyId);
+            this.thisMonthRecvCount(companyId);
+        }
+    }
+    @Override
+    public void thisMonthOrderCount(Long companyId) {
+        Long[] users=new Long[0];
+        TimeUtils.TimeEntity timeEntity=TimeUtils.parseTime("5",null,null);
+        timeEntity.setUserIds(users);
+        timeEntity.setCompanyId(companyId);
+        Integer cycleNum = timeEntity.getCycleNum();
+        Integer beginTime = timeEntity.getBeginTime();
+        List<Integer> timeList = new ArrayList<>();
+        for (int i = 1; i <= cycleNum; i++) {
+            timeList.add(beginTime);
+            beginTime = TimeUtils.formatTime(beginTime);
+        }
+        List<JSONObject> jsonObjectList = storeOrderService.selectFsStoreOrderCounts(timeEntity.toMap());
+        List<String> dates = jsonObjectList.stream().map(jsonObject -> jsonObject.getString("type")).collect(Collectors.toList());
+        List<Integer> orderCount = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("orderCount")).collect(Collectors.toList());
+        List<Integer> payPrice = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("payPrice")).collect(Collectors.toList());
+        R result = R.ok().put("dates", dates).put("orderCount", orderCount).put("payPrice", payPrice);
+        redisCache.setCacheObject(String.format(THIS_MONTH_ORDER_COUNT+":%d",companyId),result);
+    }
+
+    @Override
+    public void thisMonthRecvCount(Long companyId) {
+        Long[] users=new Long[0];
+        TimeUtils.TimeEntity timeEntity=TimeUtils.parseTime("5",null,null);
+        timeEntity.setUserIds(users);
+        timeEntity.setCompanyId(companyId);
+        Integer cycleNum = timeEntity.getCycleNum();
+        Integer beginTime = timeEntity.getBeginTime();
+        List<Integer> timeList = new ArrayList<>();
+        for (int i = 1; i <= cycleNum; i++) {
+            timeList.add(beginTime);
+            beginTime = TimeUtils.formatTime(beginTime);
+        }
+        List<JSONObject> jsonObjectList = paymentService.selectFsStorePaymentCounts(timeEntity.toMap());
+        List<String> dates = jsonObjectList.stream().map(jsonObject -> jsonObject.getString("type")).collect(Collectors.toList());
+        List<Integer> orderCount = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("orderCount")).collect(Collectors.toList());
+        List<Float> payMoney = jsonObjectList.stream().map(jsonObject -> jsonObject.getFloatValue("payMoney")).collect(Collectors.toList());
+        R result = R.ok().put("dates", dates).put("orderCount", orderCount).put("payMoney", payMoney);
+        redisCache.setCacheObject(String.format(THIS_MONTH_RECV_COUNT+":%d",companyId),result);
+    }
+}

+ 12 - 0
fs-service-system/src/main/java/com/fs/store/mapper/FsStoreProductMapper.java

@@ -182,6 +182,18 @@ public interface FsStoreProductMapper
             "</if>" +
             "</script>"})
     Long selectFsStoreProductCount(@Param("type") int type );
+    @Select({"<script> " +
+            "select count(1) from fs_store_product  " +
+            "where 1=1 " +
+            "<if test = 'type != null and  type ==1  '> " +
+            "and  DATE_FORMAT(create_time, '%Y-%m-%d')  = DATE_FORMAT(NOW(), '%Y-%m-%d') " +
+            "</if>" +
+            "<if test = 'companyIds != null and companyIds != \"\" '> " +
+            "and find_in_set(#{companyIds}, company_ids) " +
+            "</if>" +
+            "</script>"})
+    Long selectFsStoreProductCount(@Param("type") int type,@Param("companyIds") Long companyIds);
+
     @Select({"<script> " +
             "select * from fs_store_product where find_in_set(product_id,#{ids})  " +
             "</script>"})

+ 1 - 0
fs-service-system/src/main/java/com/fs/store/service/IFsStoreProductService.java

@@ -98,6 +98,7 @@ public interface IFsStoreProductService
     List<FsStoreProductListQueryVO> selectFsStoreProductGoodListQuery();
 
     Long selectFsStoreProductCount(int type);
+    Long selectFsStoreProductCount(int type,Long companyId);
 
     List<FsStoreProductActivityListVO> selectFsStoreProductByIds(String productIds);
 

+ 5 - 0
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreProductServiceImpl.java

@@ -654,6 +654,11 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
         return fsStoreProductMapper.selectFsStoreProductCount(type);
     }
 
+    @Override
+    public Long selectFsStoreProductCount(int type, Long companyId) {
+        return fsStoreProductMapper.selectFsStoreProductCount(type,companyId);
+    }
+
     @Override
     public List<FsStoreProductActivityListVO> selectFsStoreProductByIds(String productIds) {
         return fsStoreProductMapper.selectFsStoreProductByIds(productIds);

+ 40 - 1
fs-service-system/src/main/resources/mapper/course/FsCourseTrafficLogMapper.xml

@@ -82,7 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM
             fs_course_traffic_log
         WHERE
-            DATE(create_time) = CURDATE()
+        DATE(create_time) = CURDATE()
     </select>
     <select id="getMonthTrafficLog" resultType="java.lang.Long">
         SELECT
@@ -101,6 +101,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         WHERE
             DATE(create_time) = CURDATE() - INTERVAL 1 DAY
     </select>
+    <select id="getTodayTrafficLogCompanyId" resultType="java.lang.Long">
+        SELECT
+            COALESCE(SUM(internet_traffic), 0) AS today_traffic_bytes
+        FROM
+            fs_course_traffic_log
+        <where>
+            DATE(create_time) = CURDATE()
+            <if test="companyId != null">
+                AND company_id = ${companyId}
+            </if>
+        </where>
+
+    </select>
+    <select id="getMonthTrafficLogCompanyId" resultType="java.lang.Long">
+        SELECT
+            COALESCE(SUM(internet_traffic), 0) AS month_traffic_bytes
+        FROM
+            fs_course_traffic_log
+        <where>
+            YEAR(create_time) = YEAR(CURDATE())
+            AND MONTH(create_time) = MONTH(CURDATE())
+            <if test="companyId != null">
+                AND company_id = ${companyId}
+            </if>
+        </where>
+    </select>
+    <select id="getYesterdayTrafficLogCompanyId" resultType="java.lang.Long">
+        SELECT
+            COALESCE(SUM(internet_traffic), 0) AS yesterday_traffic_bytes
+        FROM
+            fs_course_traffic_log
+        <where>
+            DATE(create_time) = CURDATE() - INTERVAL 1 DAY
+            <if test="companyId != null">
+                AND company_id = ${companyId}
+            </if>
+        </where>
+
+    </select>
 
     <insert id="insertFsCourseTrafficLog" parameterType="FsCourseTrafficLog" useGeneratedKeys="true" keyProperty="logId">
         insert into fs_course_traffic_log

+ 88 - 0
fs-service-system/src/main/resources/mapper/statis/ConsumptionBalanceMapper.xml

@@ -4,6 +4,7 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.statis.mapper.ConsumptionBalanceMapper">
 
+
     <select id="rechargeConsumption" resultType="com.fs.statis.dto.ConsumptionBalanceDataDTO">
         select
             14371277 AS balance,
@@ -46,6 +47,9 @@
             <if test="startTime != null and endTime != null">
                 and create_time between #{startTime} and #{endTime}
             </if>
+            <if test="companyId != null">
+                and company_id = #{companyId}
+            </if>
         </where>
     </select>
     <select id="queryCompletedUserCount" resultType="java.lang.Long">
@@ -58,6 +62,9 @@
             <if test="startTime != null and endTime != null">
                 and create_time between #{startTime} and #{endTime}
             </if>
+            <if test="companyId != null">
+                and company_id = #{companyId}
+            </if>
         </where>
     </select>
     <select id="queryWatchUserCount" resultType="java.lang.Long">
@@ -69,6 +76,9 @@
             <if test="startTime != null and endTime != null">
                 and create_time between #{startTime} and #{endTime}
             </if>
+            <if test="companyId != null">
+                and company_id = #{companyId}
+            </if>
 
         </where>
     </select>
@@ -82,6 +92,9 @@
              <if test="userType != null">
                  and send_type=${userType}
              </if>
+             <if test="companyId != null">
+                 and company_id = #{companyId}
+             </if>
          </where>
     </select>
     <select id="queryAnswerMemberCount" resultType="java.lang.Long">
@@ -90,6 +103,9 @@
            <if test="startTime != null and endTime != null">
                create_time BETWEEN #{startTime} AND #{endTime}
            </if>
+           <if test="companyId != null">
+               and company_id = #{companyId}
+           </if>
        </where>
     </select>
     <select id="queryCorrectUserCount" resultType="java.lang.Long">
@@ -99,6 +115,9 @@
             <if test="startTime != null and endTime != null">
                 and create_time BETWEEN #{startTime} AND #{endTime}
             </if>
+            <if test="companyId != null">
+                and company_id = #{companyId}
+            </if>
         </where>
     </select>
     <select id="queryRewardCount" resultType="java.lang.Long">
@@ -113,6 +132,9 @@
             <if test="userType != null">
                 and log.send_type = ${userType}
             </if>
+            <if test="companyId != null">
+                and log.company_id = #{companyId}
+            </if>
         </where>
     </select>
     <select id="queryRewardMoney" resultType="java.math.BigDecimal">
@@ -127,11 +149,22 @@
             <if test="userType != null">
                 and log.send_type = ${userType}
             </if>
+            <if test="companyId != null">
+                and log.company_id = #{companyId}
+            </if>
         </where>
     </select>
     <select id="smsBalance" resultType="java.lang.Long">
         select sum(remain_sms_count) from company_sms
     </select>
+    <select id="smsBalanceCompany" resultType="java.lang.Long">
+        select sum(remain_sms_count) from company_sms
+        <where>
+            <if test="companyId != null">
+                company_id = #{companyId}
+            </if>
+        </where>
+    </select>
     <select id="authorizationInfo" resultType="com.fs.statis.dto.AuthorizationInfoDTO">
         select version_limit,today_watch_user_count from fs_statistics_index limit 1
     </select>
@@ -186,6 +219,9 @@
             <if test="userType != null">
                 AND send_type = ${userType}
             </if>
+            <if test="companyId != null">
+                AND company_id = ${companyId}
+            </if>
         </where>
         GROUP BY company_id
         limit 10
@@ -211,6 +247,9 @@
             <if test="userType != null">
                 AND send_type = ${userType}
             </if>
+            <if test="companyId != null">
+                AND w.company_id = ${companyId}
+            </if>
         </where>
         GROUP BY
         w.course_id
@@ -258,6 +297,9 @@
             <if test="userType != null">
                 and log.send_type = ${userType}
             </if>
+            <if test="companyId != null">
+                and log.company_id = ${companyId}
+            </if>
         </where>
         GROUP BY
             <if test="dataType == 0">
@@ -294,6 +336,9 @@
             <if test="userType != null">
                 and log.send_type = ${userType}
             </if>
+            <if test="companyId != null">
+                and log.company_id = ${companyId}
+            </if>
             AND rpl.operate_type = 1
             AND rpl.status = 1
         </where>
@@ -302,5 +347,48 @@
     <select id="getCurrentBalance" resultType="java.math.BigDecimal">
         select sum(money) from company
     </select>
+    <select id="dealerAggregatedCompanyId" resultType="com.fs.statis.dto.DealerAggregatedDTO">
+        SELECT
+                1 AS dealder_count,
+                (SELECT COUNT(*) FROM COMPANY_USER
+                                 <where>
+                                     <if test="companyId != null">
+                                         company_id = #{companyId}
+                                     </if>
+                                 </where>
+                                 ) AS group_mgr_count,
+                (SELECT COUNT(*) FROM FS_USER
+                                <where>
+                                    <if test="companyId != null">
+                                        company_id = #{companyId}
+                                    </if>
+                                </where>
+                                ) AS member_count,
+                (SELECT COUNT(*) FROM FS_USER
+                                <where>
+                                    STATUS=1
+                                    <if test="companyId != null">
+                                        company_id = #{companyId}
+                                    </if>
+                                </where>
+                                ) AS normal_num,
+                (SELECT COUNT(*) FROM FS_USER
+                                <where>
+                                    STATUS=0
+                                    <if test="companyId != null">
+                                        company_id = #{companyId}
+                                    </if>
+                                </where>
+                ) AS black_num,
+                (select COUNT(*) FROM qw_user) AS qw_member_num
+    </select>
+    <select id="getCurrentBalanceCompanyId" resultType="java.math.BigDecimal">
+        select sum(money) from company
+        <where>
+            <if test="companyId != null">
+                company_id = #{companyId}
+            </if>
+        </where>
+    </select>
 
 </mapper>

+ 13 - 12
fs-service-system/src/main/resources/mapper/store/FsStoreOrderMapper.xml

@@ -432,18 +432,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT DATE_FORMAT( o.create_time, #{sqlDateFormat} ) AS type,  o.id,o.pay_price
         FROM
         fs_store_order  AS o
-        WHERE
-        o.status  &gt; 0 and
-        (DATE_FORMAT(o.create_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
-        <if test="userIds != null and userIds.length>0">
-            AND o.company_user_id IN
-            <foreach item="item" collection="userIds" open="(" separator="," close=")">
-                #{item}
-            </foreach>
-        </if>
-        <if test="companyId != null  ">
-            AND o.company_id = #{companyId}
-        </if>
+        <where>
+            o.status  &gt; 0 and
+            (DATE_FORMAT(o.create_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
+            <if test="userIds != null and userIds.length>0">
+                AND o.company_user_id IN
+                <foreach item="item" collection="userIds" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="companyId != null  ">
+                AND o.company_id = #{companyId}
+            </if>
+        </where>
 
         ) t
         GROUP BY t.type

+ 13 - 13
fs-service-system/src/main/resources/mapper/store/FsStorePaymentMapper.xml

@@ -162,19 +162,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT DATE_FORMAT( o.create_time, #{sqlDateFormat} ) AS type,  o.payment_id,o.pay_money
         FROM
         fs_store_payment  AS o
-        WHERE
-        o.status=1 and o.business_type=1 and
-        (DATE_FORMAT(o.create_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
-        <if test="userIds != null and userIds.length>0">
-            AND o.company_user_id IN
-            <foreach item="item" collection="userIds" open="(" separator="," close=")">
-                #{item}
-            </foreach>
-        </if>
-        <if test="companyId != null  ">
-            AND o.company_id = #{companyId}
-        </if>
-
+        <where>
+            o.status=1 and o.business_type=1 and
+            (DATE_FORMAT(o.create_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
+            <if test="userIds != null and userIds.length>0">
+                AND o.company_user_id IN
+                <foreach item="item" collection="userIds" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="companyId != null  ">
+                AND o.company_id = #{companyId}
+            </if>
+        </where>
         ) t
         GROUP BY t.type
     </select>