package com.yonge.cooleshow.admin.controller;

import com.yonge.cooleshow.admin.dto.HomeOrderStatistical;
import com.yonge.cooleshow.admin.dto.HomeStatistical;
import com.yonge.cooleshow.admin.dto.search.OrderStatisticalSearch;
import com.yonge.cooleshow.admin.service.OmsOrderService;
import com.yonge.cooleshow.mall.common.api.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Description
 *
 * @author liujunchi
 * @date 2022-04-26
 */
@Controller
@Api(tags = "首页商城统计")
@RequestMapping("/statistical")
public class AdminStatisticalController {

    @Autowired
    private OmsOrderService orderService;


    @ApiOperation("商城首页统计")
    @RequestMapping(value = "/home", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<HomeStatistical> count() {

        HomeStatistical statistical = orderService.countStatistical();

        return CommonResult.success(statistical);

    }


    @ApiOperation("商城首页统计")
    @PostMapping(value = "/orderStatistical")
    @ResponseBody
    public CommonResult<HomeOrderStatistical> orderStatistical(@RequestBody OrderStatisticalSearch search) {

        HomeOrderStatistical homeOrderStatistical = orderService.orderStatistical(search);

        return CommonResult.success(homeOrderStatistical);

    }
}
