package com.ruoyi.web.controller.mall;


import com.ruoyi.mall.domain.query.GoodsStatisticsQuery;
import com.ruoyi.mall.domain.query.OrderStatisticsQuery;
import com.ruoyi.mall.domain.vo.OrderAndAftersaleStatisticsVO;
import com.ruoyi.mall.domain.vo.OrderStatisticsVO;
import com.ruoyi.mall.domain.vo.ProductTopVO;
import com.ruoyi.mall.service.IndexStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(tags = "管理端,首页统计数据接口")
@RestController
@RequestMapping("/dev/statistics/index")
public class IndexStatisticsManagerController {

    /**
     * 首页统计
     */
    @Autowired
    private IndexStatisticsService indexStatisticsService;

    @ApiOperation(value = "获取首页查询热卖商品TOP10")
    @GetMapping("/goodsStatistics")
    public ResponseEntity<List<ProductTopVO>> goodsStatistics(@Validated GoodsStatisticsQuery goodsStatisticsQuery) {

        return ResponseEntity.ok(indexStatisticsService.goodsStatistics(goodsStatisticsQuery));
    }

    @ApiOperation(value = "订单与售后单统计")
    @GetMapping("/order/aftersale/statistics")
    public ResponseEntity<OrderAndAftersaleStatisticsVO> orderAndAftersaleStatistics(){
        return ResponseEntity.ok(indexStatisticsService.orderAndAftersaleStatistics());
    }

    @ApiOperation(value = "订单信息")
    @PostMapping("/orderStatistics")
    public ResponseEntity<List<OrderStatisticsVO>> orderStatistics(@RequestBody OrderStatisticsQuery param) {
        return ResponseEntity.ok(indexStatisticsService.orderStatistics(param));
    }

}
