package cn.ysk.cashier.controller.shop;

import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.dto.ShopSummaryDto;
import cn.ysk.cashier.service.SummaryService;
import cn.ysk.cashier.vo.TbOrderPayCountVo;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.List;

/**
 * @author lyf
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/summary/day")
public class SummaryByDayController {
    @Autowired
    private SummaryService summaryService;

    @ApiOperation("导出数据")
    @PostMapping(value = "download")
    public void exportTbOrderInfo(HttpServletResponse response, @RequestBody ShopSummaryDto exportRequest) throws IOException {
        summaryService.download(exportRequest,response);
    }


    @GetMapping
    public Page<T> shopSummary(ShopSummaryDto summaryDto,
                                @RequestParam(required = false, defaultValue = "0") Integer page,
                                @RequestParam(required = false, defaultValue = "10") Integer size) {
        return summaryService.selectSummaryByDay(summaryDto, page, size);
    }

    @GetMapping(value = "count")
    public List<TbOrderPayCountVo> summaryCount(ShopSummaryDto summaryDto) {
        return summaryService.summaryCount(summaryDto);
    }

}
