package com.xiaoniu.system.datastatistics.controller;

import com.xiaoniu.common.core.resdata.Result;
import com.xiaoniu.common.core.vo.AnalysisLineVO;
import com.xiaoniu.common.core.vo.LabelAndValueNameVO;
import com.xiaoniu.common.core.vo.LabelAndValueVO;
import com.xiaoniu.system.datastatistics.dto.DataStatisticsQueryDTO;
import com.xiaoniu.system.datastatistics.service.IDataStatisticsService;
import com.xiaoniu.system.datastatistics.vo.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author haoxuyang
 * @Date 2024/10/19 16:31
 */

@Tag(name = "数据统计管理")
@RestController
@RequestMapping("/dataStatistics")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class DataStatisticsController {

    private final IDataStatisticsService dataStatisticsService;

    @Operation(summary = "平台订单/积分订单信息")
    @PostMapping("/platformOrder")
    public Result<PlatformOrderVO> platformOrder(@RequestBody DataStatisticsQueryDTO dto) {
        return Result.success("查询成功", dataStatisticsService.platformOrder(dto));
    }

    @Operation(summary = "门店订单")
    @PostMapping("/storeOrder")
    public Result<StoreOrderVO> storeOrder(@RequestBody DataStatisticsQueryDTO dto) {
        return Result.success("查询成功", dataStatisticsService.storeOrder(dto));
    }

    @Operation(summary = "实时数据")
    @PostMapping("/realTimeData")
    public Result<RealTimeDataVO> realTimeData(@RequestBody DataStatisticsQueryDTO dto) {
        return Result.success("查询成功", dataStatisticsService.realTimeData(dto));
    }

    @Operation(summary = "门店数量")
    @PostMapping("/storeNum")
    public Result<Integer> storeNum(@RequestBody DataStatisticsQueryDTO dto) {
        return Result.success("查询成功", dataStatisticsService.storeNum(dto));
    }

    @Operation(summary = "客勤信息")
    @PostMapping("/cusServiceInformation")
    public Result<CUusServiceInformationVO> cusServiceInformation(@RequestBody DataStatisticsQueryDTO dto) {
        return Result.success("查询成功", dataStatisticsService.cusServiceInformation(dto));
    }

    @Operation(summary = "营业数据汇总")
    @PostMapping("/businessDataSummary")
    public Result<BusinessDataSummaryVO> businessDataSummary(@RequestBody DataStatisticsQueryDTO dto) {
        return Result.success("查询成功", dataStatisticsService.businessDataSummary(dto));
    }

    @Operation(summary = "订单统计")
    @PostMapping("/orderStatistics")
    public Result<OrderDataStatisticsVO> orderStatistics(@RequestBody DataStatisticsQueryDTO dto) {
        return Result.success("查询成功", dataStatisticsService.orderStatistics(dto));
    }

    @Operation(summary = "平台用户统计分析")
    @PostMapping("/userStatisticalAnalysis")
    public Result<List<LabelAndValueNameVO>> userStatisticalAnalysis(@RequestBody DataStatisticsQueryDTO dto) {
        return Result.success("查询成功", dataStatisticsService.userStatisticalAnalysis(dto));
    }

    @Operation(summary = "用户行为统计")
    @PostMapping("/userBehaviorStatistics")
    public Result<List<LabelAndValueNameVO>> userBehaviorStatistics(@RequestBody DataStatisticsQueryDTO dto) {
        return Result.success("查询成功", dataStatisticsService.userBehaviorStatistics(dto));
    }
}
