package vip.xiaonuo.money.controller;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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 vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.money.entity.MoneyBorrowWarning;
import vip.xiaonuo.money.entity.MoneyOverdue;
import vip.xiaonuo.money.param.MoneyInOutParam;
import vip.xiaonuo.money.param.MoneyOverduePageParam;
import vip.xiaonuo.money.param.MoneyOverdueParam;
import vip.xiaonuo.money.service.IMoneyOverdueService;

import java.util.List;

/**
 * <p>
 * 财务应收逾期表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-21
 */

@Api(tags = "应收逾期分析控制器")
@ApiSupport(author = "wang", order = 1)
@RestController
@Validated
public class MoneyOverdueController {

    @Autowired
    private IMoneyOverdueService overdueService;

    @ApiOperationSupport(order = 1)
    @ApiOperation("逾期一个月以上总金额")
    @PostMapping("/money-overdue/getOverdueCount")
    public CommonResult<JSONObject> getOverdueCount(@RequestBody MoneyOverdueParam overdueParam) {
        return CommonResult.data(overdueService.getOverdueCount(overdueParam));
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation("逾期占比")
    @PostMapping("/money-overdue/overdueRank")
    public CommonResult<JSONObject> overdueRank(@RequestBody MoneyOverdueParam overdueParam) {
        return CommonResult.data(overdueService.overdueRank(overdueParam));
    }

    @ApiOperationSupport(order = 3)
    @ApiOperation("客户应收/逾期分析--客户逾期金额共用")
    @PostMapping("/money-overdue/userRank")
    public CommonResult<JSONArray> userRank(@RequestBody MoneyOverdueParam overdueParam) {
        return CommonResult.data(overdueService.userRank(overdueParam));
    }

    @ApiOperationSupport(order = 4)
    @ApiOperation("逾期明细表")
    @PostMapping("/money-overdue/overdueDetail")
    public CommonResult<Page<MoneyOverdue>> overdueDetail(@RequestBody MoneyOverduePageParam overduePageParam) {
        return CommonResult.data(overdueService.overdueDetail(overduePageParam));
    }
}
