package com.ruoyi.homepage.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.homepage.model.param.ChartReq;
import com.ruoyi.homepage.model.param.RankingListReq;
import com.ruoyi.homepage.model.result.ChartResult;
import com.ruoyi.homepage.model.result.RankingResult;
import com.ruoyi.homepage.model.result.StatisticsResult;
import com.ruoyi.homepage.service.HomePageService;
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;

/**
 * 后台——首页数据统计
 *
 * @author: liwenlong
 * @date: 2023-02-21
 */
@RestController
@RequestMapping("/homePage")
public class HomePageController {


    @Autowired
    private HomePageService homePageService;

    /**
     * 后台首页统计
     * @return
     */
    @PostMapping("/statistics")
    public AjaxResult<StatisticsResult> statistics() {
        return homePageService.statistics();
    }

    /**
     * 订单金额统计
     * @return
     */
    @PostMapping("/orderAmountChart")
    public AjaxResult<ChartResult> orderAmountChart(@RequestBody ChartReq req) {
        return homePageService.orderAmountChart(req);
    }

    /**
     * 订单金额统计2
     * @return
     */
    @PostMapping("/orderAmountChartNear")
    public AjaxResult<ChartResult> orderAmountChartNear(@RequestBody ChartReq req) {
        return homePageService.orderAmountChartNear(req);
    }


    /**
     * 分类占比统计
     * @return
     */
    @PostMapping("/classificationProportion")
    public AjaxResult classificationProportion(@RequestBody ChartReq req) {
        return homePageService.classificationProportion(req);
    }


    /**
     * 新老客户数量占比
     * @return
     */
    @PostMapping("/newOldCustomers")
    public AjaxResult newOldCustomers(@RequestBody ChartReq req) {
        return homePageService.newOldCustomers(req);
    }


    /**
     * 消费排行榜
     * @return
     */
    @PostMapping("/rankingList")
    public AjaxResult<RankingResult> rankingList(@RequestBody RankingListReq req) {
        return homePageService.rankingList(req);
    }


}
