123
This commit is contained in:
@@ -57,7 +57,7 @@ public class AppSettingController {
|
||||
|
||||
@GetMapping("/loans")
|
||||
@ApiOperation(value = "贷款信息")
|
||||
public AjaxResult<LoansSetting> loans() {
|
||||
public AjaxResult<LoansSettingVO> loans() {
|
||||
LoansSetting setting = loansSettingService.getLoansSetting();
|
||||
LoansSettingVO vo = BeanConvertUtil.convertTo(setting, LoansSettingVO::new);
|
||||
Double minDayServiceRate = Arrays.stream(setting.getServiceRate().split(","))
|
||||
@@ -68,7 +68,7 @@ public class AppSettingController {
|
||||
minDayServiceRate = 0D;
|
||||
}
|
||||
vo.setMinDayServiceRate(minDayServiceRate);
|
||||
return AjaxResult.success(setting);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,11 @@ public class CalLoanResp {
|
||||
@ApiModelProperty("还款月份")
|
||||
private int totalMonth; //
|
||||
@ApiModelProperty("贷款年利率")
|
||||
private double loanRate; //
|
||||
private double loanRateYear; //
|
||||
@ApiModelProperty("贷款日利率")
|
||||
private double loanRateDay; //
|
||||
@ApiModelProperty("贷款日利率")
|
||||
private double loanRateMonth; //
|
||||
|
||||
@ApiModelProperty("总利息数")
|
||||
private BigDecimal totalInterest; //
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.bashi.dk.kit;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.bashi.dk.domain.LoansSetting;
|
||||
import com.bashi.dk.dto.app.req.CalLoanReq;
|
||||
import com.bashi.dk.service.LoansSettingService;
|
||||
@@ -18,9 +19,7 @@ public class CalLoanManager {
|
||||
|
||||
public Loan calLoan(BigDecimal totalLoanMoney,Integer totalMonth, Double loanRate){
|
||||
ACPIMLoanCalculator calculator = new ACPIMLoanCalculator();
|
||||
Loan loan = calculator.calLoan(totalLoanMoney, totalMonth, loanRate, LoanUtil.RATE_TYPE_MONTH);
|
||||
loan.setLoanRateMonth(loanRate);
|
||||
return loan;
|
||||
return calculator.calLoan(totalLoanMoney, totalMonth, loanRate, LoanUtil.RATE_TYPE_MONTH);
|
||||
}
|
||||
|
||||
public Loan calLoan(CalLoanReq calLoanReq){
|
||||
@@ -39,4 +38,10 @@ public class CalLoanManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ACPIMLoanCalculator calculator = new ACPIMLoanCalculator();
|
||||
Loan loan = calculator.calLoan(BigDecimal.valueOf(20000), 3, 0.5, LoanUtil.RATE_TYPE_MONTH);
|
||||
System.out.println(loan);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class BorrowServiceImpl extends ServiceImpl<BorrowMapper, Borrow> impleme
|
||||
borrow.setTotalLoanMoney(loan.getTotalLoanMoney());
|
||||
borrow.setTotalMonth(loan.getTotalMonth());
|
||||
borrow.setLoanMonthRate(loan.getLoanRateMonth());
|
||||
borrow.setLoanYearRate(loan.getLoanRate());
|
||||
borrow.setLoanYearRate(loan.getLoanRateYear());
|
||||
borrow.setTotalInterest(loan.getTotalInterest());
|
||||
borrow.setTotalRepayment(loan.getTotalRepayment());
|
||||
borrow.setFirstRepayment(loan.getFirstRepayment());
|
||||
@@ -135,7 +135,7 @@ public class BorrowServiceImpl extends ServiceImpl<BorrowMapper, Borrow> impleme
|
||||
update.setTotalLoanMoney(loan.getTotalLoanMoney());
|
||||
update.setTotalMonth(loan.getTotalMonth());
|
||||
update.setLoanMonthRate(loan.getLoanRateMonth());
|
||||
update.setLoanYearRate(loan.getLoanRate());
|
||||
update.setLoanYearRate(loan.getLoanRateYear());
|
||||
update.setTotalInterest(loan.getTotalInterest());
|
||||
update.setTotalRepayment(loan.getTotalRepayment());
|
||||
update.setFirstRepayment(loan.getFirstRepayment());
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.bashi.dk.util;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -16,7 +18,9 @@ public class ACPIMLoanCalculator extends LoanCalculatorAdapter {
|
||||
BigDecimal loanRateMonth = rateType == LoanUtil.RATE_TYPE_YEAR ? new BigDecimal(loanRate / 100 / 12) : new BigDecimal(loanRate / 100);
|
||||
BigDecimal factor = new BigDecimal(Math.pow(1 + loanRateMonth.doubleValue(), totalMonth));
|
||||
BigDecimal avgRepayment = totalLoanMoney.multiply(loanRateMonth).multiply(factor).divide(factor.subtract(new BigDecimal(1)), 2, BigDecimal.ROUND_HALF_UP);
|
||||
loan.setLoanRate(loanRate);
|
||||
loan.setLoanRateMonth(loanRateMonth.doubleValue());
|
||||
loan.setLoanRateDay(NumberUtil.div(new Double(loan.getLoanRateMonth()), new Double(30D), 4));
|
||||
loan.setLoanRateYear(NumberUtil.mul(loan.getLoanRateMonth(), 12.0, 4).doubleValue());
|
||||
loan.setTotalLoanMoney(totalLoanMoney);
|
||||
loan.setTotalMonth(totalMonth);
|
||||
loan.setAvgRepayment(avgRepayment);
|
||||
|
||||
@@ -9,15 +9,17 @@ import java.util.List;
|
||||
/**
|
||||
* Created by WangGenshen on 1/14/16.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class Loan {
|
||||
|
||||
private BigDecimal totalLoanMoney; //贷款总额
|
||||
private int totalMonth; //还款月份
|
||||
private double loanRate; //贷款年利率
|
||||
private double loanRateYear; //贷款年利率
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private double loanRateMonth;
|
||||
private double loanRateDay; // 贷款日利率
|
||||
|
||||
private double loanRateMonth; // 贷款月利率
|
||||
|
||||
private BigDecimal totalInterest; // 总利息数
|
||||
private BigDecimal totalRepayment; // 还款总额
|
||||
@@ -27,72 +29,6 @@ public class Loan {
|
||||
private List<LoanByMonth> allLoans; // 所有月份的还款情况
|
||||
|
||||
|
||||
|
||||
|
||||
public BigDecimal getTotalLoanMoney() {
|
||||
return totalLoanMoney;
|
||||
}
|
||||
|
||||
public void setTotalLoanMoney(BigDecimal totalLoanMoney) {
|
||||
this.totalLoanMoney = totalLoanMoney;
|
||||
}
|
||||
|
||||
public int getTotalMonth() {
|
||||
return totalMonth;
|
||||
}
|
||||
|
||||
public void setTotalMonth(int totalMonth) {
|
||||
this.totalMonth = totalMonth;
|
||||
}
|
||||
|
||||
public double getLoanRate() {
|
||||
return loanRate;
|
||||
}
|
||||
|
||||
public void setLoanRate(double loanRate) {
|
||||
this.loanRate = loanRate;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalInterest() {
|
||||
return totalInterest;
|
||||
}
|
||||
|
||||
public void setTotalInterest(BigDecimal totalInterest) {
|
||||
this.totalInterest = totalInterest;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalRepayment() {
|
||||
return totalRepayment;
|
||||
}
|
||||
|
||||
public void setTotalRepayment(BigDecimal totalRepayment) {
|
||||
this.totalRepayment = totalRepayment;
|
||||
}
|
||||
|
||||
public BigDecimal getFirstRepayment() {
|
||||
return firstRepayment;
|
||||
}
|
||||
|
||||
public void setFirstRepayment(BigDecimal firstRepayment) {
|
||||
this.firstRepayment = firstRepayment;
|
||||
}
|
||||
|
||||
public BigDecimal getAvgRepayment() {
|
||||
return avgRepayment;
|
||||
}
|
||||
|
||||
public void setAvgRepayment(BigDecimal avgRepayment) {
|
||||
this.avgRepayment = avgRepayment;
|
||||
}
|
||||
|
||||
public List<LoanByMonth> getAllLoans() {
|
||||
return allLoans;
|
||||
}
|
||||
|
||||
public void setAllLoans(List<LoanByMonth> allLoans) {
|
||||
this.allLoans = allLoans;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String allLoansStr = "";
|
||||
|
||||
Reference in New Issue
Block a user