package com.fs.api.controller;

import com.fs.statis.cache.IStatisticsCacheService;
import com.fs.statis.dto.*;
import com.fs.statis.service.IStatisticsService;
import com.hc.openapi.tool.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.fs.common.core.domain.R;

import java.util.List;

/**
 * 首页-统计
 */
@RestController
@RequestMapping("/index/statistics")
public class IndexStatisticsController {
    @Autowired
    private IStatisticsCacheService statisticsService;
    @Autowired
    private IStatisticsService statisticsService1;
    /**
     * 分析概览
     */
    @PostMapping("/analysisPreview")
    public R analysisPreview(@RequestBody AnalysisPreviewQueryDTO param){
        AnalysisPreviewDTO analysisPreviewDTO = statisticsService1.analysisPreview(param);
        return R.ok().put("data",analysisPreviewDTO);
    }

    /**
     * 消费余额
     */
    @GetMapping("/rechargeComsumption")
    public R rechargeComsumption(){
        ConsumptionBalanceDataDTO consumptionBalanceDataDTO = statisticsService.rechargeConsumption();
        return R.ok().put("data", consumptionBalanceDataDTO);
    }

    /**
     * 观看趋势
     */
    @PostMapping("/watchEndPlayTrend")
    public R watchEndPlayTrend(@RequestBody AnalysisPreviewQueryDTO param){
        List<WatchEndPlayTrendDTO> watchEndPlayTrendDTOS = statisticsService.watchEndPlayTrend(param);
        return R.ok().put("data", watchEndPlayTrendDTOS);
    }

    /**
     * 经销商会员观看
     */
    @PostMapping("/deaMemberTopTen")
    public R deaMemberTopTen(@RequestBody AnalysisPreviewQueryDTO param){
        List<DeaMemberTopTenDTO> deaMemberTopTenDTOS = statisticsService.deaMemberTopTen(param);
        return R.ok().put("data", deaMemberTopTenDTOS);
    }

    /**
     * 奖励金额top10
     */
    @GetMapping("/rewardMoneyTopTen")
    public R rewardMoneyTopTen(@RequestBody AnalysisPreviewQueryDTO param){
        List<RewardMoneyTopTenDTO> rewardMoneyTopTenDTOS = statisticsService1.rewardMoneyTopTen(param);
        return R.ok().put("data", rewardMoneyTopTenDTOS);
    }

    /**
     * 答题红包金额趋势图
     */
    @GetMapping("/rewardMoneyTrend")
    public R rewardMoneyTrend(@RequestBody AnalysisPreviewQueryDTO param){
        List<RewardMoneyTrendDTO> rewardMoneyTrendDTOS = statisticsService1.rewardMoneyTrendDTO(param);
        return R.ok().put("data", rewardMoneyTrendDTOS);
    }

    /**
     * 课程观看top10
     */
    @PostMapping("/watchCourseTopTen")
    public R watchCourseTopTen(@RequestBody AnalysisPreviewQueryDTO param){
        List<CourseStatsDTO> courseStatsDTOS = statisticsService1.watchCourseTopTen(param);
        return R.ok().put("data", courseStatsDTOS);
    }

    /**
     * 数据概览
     */
    @GetMapping("/dealerAggregated")
    public R dealerAggregated(){
        DealerAggregatedDTO dealerAggregatedDTO = statisticsService.dealerAggregated();
        return R.ok().put("data",dealerAggregatedDTO);
    }

    /**
     * 短信余额
     */
    @GetMapping("/smsBalance")
    public R smsBalance(){
        Long smsBalance = statisticsService1.smsBalance();
        return R.ok().put("data", smsBalance);
    }


    /**
     * 授权信息
     */
    @GetMapping("/authorizationInfo")
    public R authorizationInfo(){
        AuthorizationInfoDTO authorizationInfoDTO = statisticsService1.authorizationInfo();
        return R.ok().put("data", authorizationInfoDTO);
    }
}
