package com.fjhx.controller.contract;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.base.Condition;
import com.fjhx.params.contract.ContractPayVo;
import com.fjhx.params.contract.DateStatisticsResult;
import com.fjhx.params.contract.SupplierStatisticsResult;
import com.fjhx.service.contract.ContractPayService;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
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;
import java.util.Map;

/**
 * <p>
 * 合同付款 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-09-29
 */
@RestController
@RequestMapping("/contractPay")
public class ContractPayController {

    @Autowired
    private ContractPayService contractPayService;

    @PostMapping("/add")
    public R add(@RequestBody ContractPayVo contractPayVo) {
        contractPayService.add(contractPayVo);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody ContractPayVo contractPayVo) {
        contractPayService.edit(contractPayVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody ContractPayVo contractPayVo) {
        contractPayService.delete(contractPayVo);
        return R.success();
    }

    /**
     * 合同付款日期统计
     */
    @PostMapping("/dateStatistics")
    public R dateStatistics() {
        Map<Integer, DateStatisticsResult> result = contractPayService.dateStatistics();
        return R.success(result);
    }

    /**
     * 合同付款供应商统计
     */
    @PostMapping("/supplierStatistics")
    public R supplierStatistics(@RequestBody Condition condition) {
        List<SupplierStatisticsResult> result = contractPayService.supplierStatistics(condition);
        return R.success(result);
    }

    /**
     * 可发起、待补齐状态统计
     */
    @PostMapping("/statusStatistics")
    public R statusStatistics(@RequestBody Condition condition) {
        Map<String, Object> result = contractPayService.statusStatistics(condition);
        return R.success(result);
    }

    /**
     * 本周期、上周期顺延、其他
     */
    @PostMapping("/cycleStatistics")
    public R cycleStatistics(@RequestBody Condition condition) {
        Map<String, Object> result = contractPayService.cycleStatistics(condition);
        return R.success(result);
    }

    /**
     * 分页
     */
    @PostMapping("/page")
    public R page(@RequestBody Condition condition) {
        Page<Map<String, Object>> result = contractPayService.getPage(condition);
        return R.success(result);
    }




}

