package com.bizzan.bitrade.controller.index;


import com.bizzan.bitrade.annotation.AccessLog;
import com.bizzan.bitrade.constant.AdminModule;
import com.bizzan.bitrade.service.*;
import com.bizzan.bitrade.util.MessageResult;
import com.fasterxml.jackson.annotation.JsonFormat;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RestController("index")
@RequestMapping("index/statistics")
public class IndexController {

    private static final Logger logger = LoggerFactory.getLogger(IndexController.class);

    @Autowired
    private ExchangeCoinService exchangeCoinService ;

    @Autowired
    private MemberApplicationService memberApplicationService ;

    @Autowired
    private BusinessAuthApplyService businessAuthApplyService ;

    @Autowired
    private BusinessCancelApplyService businessCancelApplyService ;

    @Autowired
    private AppealService appealService ;

    @Autowired
    private WithdrawRecordService withdrawRecordService ;

    @PostMapping("member-statistics-info")
    @AccessLog(module = AdminModule.INDEX,operation = "首页会员信息统计")
    public MessageResult getYestodayStatisticsInfo(
            @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")Date startDate,
            @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")Date endDate){
        return MessageResult.getSuccessInstance("", Collections.emptyList());
    }

    @PostMapping("member-statistics-chart")
    @AccessLog(module = AdminModule.INDEX,operation = "首页会员信息统计图")
    public MessageResult getMemberStatisticsChart(
            @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")Date startDate,
            @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")Date endDate){
        return MessageResult.getSuccessInstance("", Collections.emptyList());
    }

    @PostMapping("otc-statistics-turnover")
    @AccessLog(module = AdminModule.INDEX,operation = "法币成交信息统计")
    public MessageResult otcStatistics(
            @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")Date startDate,
            @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")Date endDate,
            String unit){
        return MessageResult.getSuccessInstance("", Collections.emptyMap());
    }

    @PostMapping("exchange-statistics-turnover")
    @AccessLog(module = AdminModule.INDEX,operation = "首页币币成交量/成交额/手续费 总计")
    public MessageResult exchangeStatistics(
            @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")Date startDate,
            @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")Date endDate,
            String unit) {
        return MessageResult.getSuccessInstance("", Collections.emptyMap());
    }

    @PostMapping("/otc-statistics-num-chart")
    @AccessLog(module = AdminModule.INDEX,operation = "法币成交量统计图")
    public MessageResult otcNumChart(
            @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")Date startDate,
            @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")Date endDate,
            String[] units){
        return MessageResult.getSuccessInstance("", Collections.emptyList());
    }

    @PostMapping("exchange-statistics-turnover-chart")
    @AccessLog(module = AdminModule.INDEX,operation = "币币成交 统计图 （按照交易对区分）")
    public MessageResult exchangeNumStatistics(
            @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")Date startDate,
            @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")Date endDate,
            String baseSymbol,
            String[] coinSymbols){
        return MessageResult.getSuccessInstance("", Collections.emptyList());
    }

    @GetMapping("affairs")
    public MessageResult affairs(){
        long applicationNum = memberApplicationService.countAuditing();
        long businessAuthNum = businessAuthApplyService.countAuditing();
        long appealNum = appealService.countAuditing();
        long businessCancelNum = businessCancelApplyService.countAuditing();
        long withdrawRecordNum = withdrawRecordService.countAuditing();
        Map<String,Object> map = new HashMap<>();
        map.put("applicationNum",applicationNum);
        map.put("businessAuthNum",businessAuthNum);
        map.put("appealNum",appealNum);
        map.put("businessCancelNum",businessCancelNum);
        map.put("withdrawRecordNum",withdrawRecordNum);
        return MessageResult.getSuccessInstance("",map);
    }

    @PostMapping("all-exchange-coin")
    public MessageResult getAllExchangeCoin(){
        return MessageResult.getSuccessInstance("",new ArrayList<>());
    }
}
