package org.jeecg.modules.system.app.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.system.app.service.IStatisticsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Tag(name="管理端统计")
@RestController
@RequestMapping("/statisticsInfo")
@Slf4j
public class StatisticsController {
    @Resource
    private IStatisticsService statisticsService;

    /**
     * <p>管理端首页获取商品销量排行</p>
     * @author SheepHy
     * @param type，参数为类则包含{@link Object}
     *
     */
    @GetMapping("/findByShopSum")
    @Operation(summary = "管理端首页获取商品销量排行")
    public Result<List<Map<String, Object>>> findByShopSum(int type){
        return Result.ok(statisticsService.findByShopSum(type));
    }

    /**
     * <p>管理端首页获取部门售额排行</p>
     * @author SheepHy
     * @param type，参数为类则包含{@link Object}
     *
     */
    @GetMapping("/findByDeptSum")
    @Operation(summary = "管理端首页获取部门售额排行")
    public Result<List<Map<String, Object>>> findByDeptSum(int type){
        return Result.ok(statisticsService.findByDeptSum(type));
    }

    /**
     * <p>首页统计</p>
     * @author SheepHy
     * @param 参数描述，参数为类则包含{@link Object}
     * @return 返回值描述，如无返回值则为void 返回值为类则包含{@link object}
     *
     */
    @GetMapping("/findIndexStatistics")
    @Operation(summary = "首页统计")
    public Result<Map<String, Object>> findIndexStatistics(){
        return Result.ok(statisticsService.findIndexStatistics());
    }

    /**
     * <p>本月销售额趋势图</p>
     * @author SheepHy
     * @param 参数描述，参数为类则包含{@link Object}
     * @return 返回值描述，如无返回值则为void 返回值为类则包含{@link object}
     *
     */
    @GetMapping("/findMonthSaleTrend")
    @Operation(summary = "本月销售额趋势图")
    public Result<List<Map<String, Object>>> findMonthSaleTrend(){
        return Result.ok(statisticsService.findMonthSaleTrend());
    }

    /**
     * <p>分页查询店铺资金总览</p>
     * @author SheepHy
     * @param 参数描述，参数为类则包含{@link Object}
     * @return 返回值描述，如无返回值则为void 返回值为类则包含{@link object}
     *
     */
    @GetMapping("/findShopAccountOverview")
    @Operation(summary = "分页查询店铺资金总览-平台")
    public Result<List<Map<String, Object>>> findShopAccountOverview(@RequestParam(name="pageNo",required=false) Integer pageNo,
                                                                     @RequestParam(name="pageSize",required=false) Integer pageSize,
                                                                     @RequestParam(name="name",required=false) String name){
        Page<Map<String, Object>> page = new Page<>(pageNo, pageSize);
        return Result.ok(statisticsService.findShopAccountOverview(page,name));
    }

    /**
     * <p>查询店铺资金总览-门店统计</p>
     * @author SheepHy
     * @param 参数描述，参数为类则包含{@link Object}
     * @return 返回值描述，如无返回值则为void 返回值为类则包含{@link object}
     *
     */
    @GetMapping("/findShopAccountOverviewDept")
    @Operation(summary = "查询店铺资金总览-门店统计")
    public Result<List<Map<String, Object>>> findShopAccountOverviewDept(){
        return Result.ok(statisticsService.findShopAccountOverviewDept());
    }

    /**
     * <p>分页查询店铺资金总览-门店</p>
     * @author SheepHy
     * @param 参数描述，参数为类则包含{@link Object}
     * @return 返回值描述，如无返回值则为void 返回值为类则包含{@link object}
     *
     */
    @GetMapping("/selectFundChanges")
    @Operation(summary = "分页查询店铺资金总览-门店")
    public Result<List<Map<String, Object>>> selectFundChanges(@RequestParam(name="pageNo",required=false) Integer pageNo,
                                                               @RequestParam(name="pageSize",required=false) Integer pageSize,
                                                               @RequestParam(name="incomeExpenseType",required=false)String incomeExpenseType,
                                                               @RequestParam(name="changeReason",required=false)String changeReason,
                                                               @RequestParam(name="amountType",required=false)String amountType){
        Page<Map<String, Object>> page = new Page<>(pageNo, pageSize);
        return Result.ok(statisticsService.selectFundChanges(page,incomeExpenseType,changeReason,amountType));
    }
}
