package com.jeesharp.business.modules.food.controller;

import com.jeesharp.business.modules.food.application.FoodStatisticsApplicationService;
import com.jeesharp.business.modules.food.vo.FoodCompanyMealStatisticsVO;
import com.jeesharp.business.modules.food.vo.FoodDishSalesStatisticsVO;
import com.jeesharp.business.modules.food.vo.FoodOrderStatisticsVO;
import com.jeesharp.business.modules.food.vo.FoodPaymentStatisticsVO;
import com.jeesharp.business.modules.food.vo.FoodStatisticsQueryVO;
import com.jeesharp.framework.pojo.AjaxResult;
import com.jeesharp.framework.web.controller.BaseController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
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;

import java.util.List;

@RestController
@RequestMapping(value = "${jeesharp.web.adminPath}/food/statistics/v1")
@Tag(name = "订餐统计管理")
@AllArgsConstructor
public class FoodStatisticsController extends BaseController {

    private final FoodStatisticsApplicationService foodStatisticsApplicationService;

    @Operation(summary = "订餐统计")
    @PreAuthorize("@ss.hasPermission('manager:business:food:statistics:list')")
    @PostMapping("order")
    public AjaxResult<List<FoodOrderStatisticsVO>> order(@RequestBody FoodStatisticsQueryVO query) {
        return AjaxResult.okData(foodStatisticsApplicationService.orderStatistics(query));
    }

    @Operation(summary = "支付统计")
    @PreAuthorize("@ss.hasPermission('manager:business:food:statistics:list')")
    @PostMapping("payment")
    public AjaxResult<List<FoodPaymentStatisticsVO>> payment(@RequestBody FoodStatisticsQueryVO query) {
        return AjaxResult.okData(foodStatisticsApplicationService.paymentStatistics(query));
    }

    @Operation(summary = "企业团餐统计")
    @PreAuthorize("@ss.hasPermission('manager:business:food:statistics:list')")
    @PostMapping("companyMeal")
    public AjaxResult<List<FoodCompanyMealStatisticsVO>> companyMeal(@RequestBody FoodStatisticsQueryVO query) {
        return AjaxResult.okData(foodStatisticsApplicationService.companyMealStatistics(query));
    }

    @Operation(summary = "菜品销量和备餐统计")
    @PreAuthorize("@ss.hasPermission('manager:business:food:statistics:list')")
    @PostMapping("dishSales")
    public AjaxResult<List<FoodDishSalesStatisticsVO>> dishSales(@RequestBody FoodStatisticsQueryVO query) {
        return AjaxResult.okData(foodStatisticsApplicationService.dishSalesStatistics(query));
    }
}
