package com.sunxung.factoring.web.financing;

import com.sunxung.factoring.entity.ResponseJson;
import com.sunxung.factoring.entity.financing.review.ReviewFinancingInfo;
import com.sunxung.factoring.entity.financing.review.ReviewQuotaDisburse;
import com.sunxung.factoring.service.financing.review.ReviewQuotaDisburseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description : 额度支用控制层
 * @Author : L.Jia
 * @Date: 2024-01-02 09:41
 */

@RestController
@RequestMapping("/reviewQuotaDisburse")
public class ReviewQuotaDisburseController {

    @Autowired
    private ReviewQuotaDisburseService reviewQuotaDisburseService;

    /**
     * 根据融资信息生成收支计划
     *
     * @param reviewFinancingInfo 融资信息
     * @return
     */
    @PostMapping(value = "/doGenerateIncomeExpenditurePlan")
    public Object doGenerateIncomeExpenditurePlan(@RequestBody ReviewFinancingInfo reviewFinancingInfo) {
        return reviewQuotaDisburseService.generateIncomeExpenditurePlan(reviewFinancingInfo);
    }

    /**
     * 根据收支计划信息：计算irr
     */
    @PostMapping("/doCalculateIrr")
    public Object doCalculateIrr(@RequestBody ReviewQuotaDisburse quotaDisburse) {
        return reviewQuotaDisburseService.calculateIrr(quotaDisburse);
    }

    /**
     * 获取相关还款责任人-还款责任人类型
     *
     * @param code 参数code
     * @return
     */
    @GetMapping(value = "/doFindArlpType")
    @ResponseBody
    public Object doFindArlpType(String code) {
        return reviewQuotaDisburseService.findArlpType(code);
    }

    /**
     * 新增额度支用信息
     */
    @PostMapping("/doEdit")
    public Object doEdit(@RequestBody ReviewQuotaDisburse reviewQuotaDisburse) throws Exception {
        reviewQuotaDisburseService.editReviewQuotaDisburse(reviewQuotaDisburse);
        return new ResponseJson("提交成功");
    }
}
