package com.sckw.order.controller;

import com.sckw.core.web.response.BaseResult;
import com.sckw.core.web.response.HttpResult;
import com.sckw.order.api.model.DailySalesStatisticsDto;
import com.sckw.order.api.model.DailyShipmentStatisticsDto;
import com.sckw.order.api.model.GoodsAmountStatisticsDto;
import com.sckw.order.api.model.GoodsVolumeStatisticsDto;
import com.sckw.order.api.model.SalesReportDataVo;
import com.sckw.order.api.model.SalesReportQueryDto;
import com.sckw.order.model.vo.req.WbTOrderDataStsParam;
import com.sckw.order.model.vo.req.WbTOrderExcelStsParam;
import com.sckw.order.serivce.KwoTradeOrderStatisticsService;
import lombok.AllArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @desc: 订单统计相关接口
 * @author: yzc
 * @date: 2023-09-13 8:34
 */
@AllArgsConstructor
@RestController
@RequestMapping("/kwoTradeOrderStatistics")
public class KwoTradeOrderStatisticsController {

    private final KwoTradeOrderStatisticsService kwoTradeOrderStatisticsService;


    /**
     * @desc: 工作台贸易订单表格统计
     * @author: yzc
     * @date: 2023-09-12 16:38
     * @Param params:
     * @return: com.sckw.core.web.response.HttpResult
     */
    @PostMapping(value = "/workbenchExcel", produces = MediaType.APPLICATION_JSON_VALUE)
    public HttpResult workbenchExcel(@RequestBody @Validated WbTOrderExcelStsParam params) {
        return HttpResult.ok(kwoTradeOrderStatisticsService.workbenchExcel(params));
    }

    /**
     * @desc: 工作台贸易订单数据统计
     * @author: yzc
     * @date: 2023-09-11 14:43
     * @Param params:
     * @return: com.sckw.core.web.response.HttpResult
     */
    @PostMapping(value = "/workbenchData", produces = MediaType.APPLICATION_JSON_VALUE)
    public HttpResult workbenchData(@RequestBody @Validated WbTOrderDataStsParam params) {
        return HttpResult.ok(kwoTradeOrderStatisticsService.workbenchData(params));
    }

    /**
     * @desc: 工作台采购订单列表
     * @author: yzc
     * @date: 2023-09-13 19:13
     * @return: com.sckw.core.web.response.HttpResult
     */
    @GetMapping(value = "/workbenchPurchaseList", produces = MediaType.APPLICATION_JSON_VALUE)
    public HttpResult workbenchPurchaseList() {
        return HttpResult.ok(kwoTradeOrderStatisticsService.workbenchPurchaseList());
    }
    /**
     * 查询销售报表数据
     *
     * @param queryDto 查询参数
     * @return 销售报表数据列表
     */
    @PostMapping("/querySalesReportData")
    public BaseResult<List<SalesReportDataVo>> querySalesReportData(@RequestBody @Validated SalesReportQueryDto queryDto) {
        return BaseResult.success(kwoTradeOrderStatisticsService.querySalesReportData(queryDto));
    }

    @GetMapping("/getDailyShipmentByCategory")
    public BaseResult<List<DailyShipmentStatisticsDto>> getDailyShipmentByCategory(
            @RequestParam("entId") Long entId,
            @RequestParam(value = "days", defaultValue = "7") Integer days) {
        return BaseResult.success(kwoTradeOrderStatisticsService.getDailyShipmentByCategory(entId, days));
    }

    @GetMapping("/getDailySalesByCategory")
    public BaseResult<List<DailySalesStatisticsDto>> getDailySalesByCategory(
            @RequestParam("entId") Long entId,
            @RequestParam(value = "days", defaultValue = "7") Integer days) {
        return BaseResult.success(kwoTradeOrderStatisticsService.getDailySalesByCategory(entId, days));
    }

    @GetMapping("/getGoodsVolumeTop5")
    public BaseResult<List<GoodsVolumeStatisticsDto>> getGoodsVolumeTop5(@RequestParam("entId") Long entId) {
        return BaseResult.success(kwoTradeOrderStatisticsService.getGoodsVolumeTop5(entId));
    }

    @GetMapping("/getGoodsAmountTop5")
    public BaseResult<List<GoodsAmountStatisticsDto>> getGoodsAmountTop5(@RequestParam("entId") Long entId) {
        return BaseResult.success(kwoTradeOrderStatisticsService.getGoodsAmountTop5(entId));
    }
}
