package com.sckw.report.controller;

import com.sckw.core.web.response.BaseResult;
import com.sckw.report.model.vo.DailySalesAmountVo;
import com.sckw.report.model.vo.DailyShipmentAmountVo;
import com.sckw.report.model.vo.GoodsSalesAmountRatioVo;
import com.sckw.report.model.vo.GoodsSalesVolumeRatioVo;
import com.sckw.report.service.KwBiReportService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/kwBiReport")
@Tag(name = "BI报表统计", description = "BI报表统计接口")
@RequiredArgsConstructor
public class KwBiReportController {

    private final KwBiReportService kwBiReportService;

    @GetMapping("/dailyShipmentAmount")
    @Operation(summary = "近7日出货量", description = "折线图展示近7个自然日，每个一级分类下所有商品的已完成运单的净重汇总")
    public BaseResult<DailyShipmentAmountVo> getDailyShipmentAmount() {
        return BaseResult.success(kwBiReportService.getDailyShipmentAmount());
    }

    @GetMapping("/dailySalesAmount")
    @Operation(summary = "近7日销售额", description = "折线图展示近7个自然日，每个一级分类下所有商品的销售额汇总")
    public BaseResult<DailySalesAmountVo> getDailySalesAmount() {
        return BaseResult.success(kwBiReportService.getDailySalesAmount());
    }

    @GetMapping("/goodsSalesVolumeRatio")
    @Operation(summary = "主要商品销量占比", description = "饼状图展示，按最低级分类统计历史完成订单的净重总和，取前5名")
    public BaseResult<GoodsSalesVolumeRatioVo> getGoodsSalesVolumeRatio() {
        return BaseResult.success(kwBiReportService.getGoodsSalesVolumeRatio());
    }

    @GetMapping("/goodsSalesAmountRatio")
    @Operation(summary = "主要商品销售金额占比", description = "饼状图展示，按最低级分类统计历史完成订单的销售金额总和，取前5名")
    public BaseResult<GoodsSalesAmountRatioVo> getGoodsSalesAmountRatio() {
        return BaseResult.success(kwBiReportService.getGoodsSalesAmountRatio());
    }
}