package com.bonus.canteen.core.screening.controller;

import com.bonus.canteen.core.screening.dto.DataScreenDTO;
import com.bonus.canteen.core.screening.service.DataScreeningService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 设备绑定多档口子Controller
 * 
 * @author xsheng
 * @date 2025-05-13
 */
@Api(tags = "数据总览")
@RestController
@RequestMapping("/dataScreening")
public class DataScreeningController extends BaseController {
    @Resource
    private DataScreeningService service;

    @ApiOperation(value = "获取数据总览（今日营业额、订单等）")
    @PostMapping("/getDataScreeningModel")
    public AjaxResult getDataScreeningModel() {
        try {
            return success(service.getDataScreeningModel());
        } catch (Exception e) {
            return error("获取数据总览错误");
        }
    }

    @ApiOperation(value = "获取食堂订单及销量趋势")
    @PostMapping("/getCanteenOrdersAndSalesTrends")
    public AjaxResult getCanteenOrdersAndSalesTrends(@RequestBody DataScreenDTO dataScreenDTO) {
        try {
            return service.getCanteenOrdersAndSalesTrends(dataScreenDTO);
        } catch (Exception e) {
            return error("获取食堂订单及销量趋势错误");
        }
    }
    @ApiOperation(value = "获取商超订单及销量趋势")
    @PostMapping("/getSupermarketOrderAndSalesTrend")
    public AjaxResult getSupermarketOrderAndSalesTrend(@RequestBody DataScreenDTO dataScreenDTO) {
        try {
            return service.getSupermarketOrderAndSalesTrend(dataScreenDTO);
        } catch (Exception e) {
            return error("获取商超订单及销量趋势错误");
        }
    }
    @ApiOperation(value = "获取本月菜品销量排名")
    @PostMapping("/getThisMonthSDishSalesRanking")
    public AjaxResult getThisMonthDishSalesRanking() {
        try {
            return service.getThisMonthDishSalesRanking();
        } catch (Exception e) {
            return error("获取本月菜品销量排名错误");
        }
    }
    @ApiOperation(value = "订单类型占比")
    @PostMapping("/getProportionOfOrderTypes")
    public AjaxResult getProportionOfOrderTypes(@RequestBody DataScreenDTO dataScreenDTO) {
        try {
            return service.getProportionOfOrderTypes(dataScreenDTO);
        } catch (Exception e) {
            return error("获取订单类型占比错误");
        }
    }
}
