123
This commit is contained in:
@@ -57,7 +57,7 @@ public class AppSettingController {
|
|||||||
|
|
||||||
@GetMapping("/loans")
|
@GetMapping("/loans")
|
||||||
@ApiOperation(value = "贷款信息")
|
@ApiOperation(value = "贷款信息")
|
||||||
public AjaxResult<LoansSetting> loans() {
|
public AjaxResult<LoansSettingVO> loans() {
|
||||||
LoansSetting setting = loansSettingService.getLoansSetting();
|
LoansSetting setting = loansSettingService.getLoansSetting();
|
||||||
LoansSettingVO vo = BeanConvertUtil.convertTo(setting, LoansSettingVO::new);
|
LoansSettingVO vo = BeanConvertUtil.convertTo(setting, LoansSettingVO::new);
|
||||||
Double minDayServiceRate = Arrays.stream(setting.getServiceRate().split(","))
|
Double minDayServiceRate = Arrays.stream(setting.getServiceRate().split(","))
|
||||||
@@ -68,7 +68,7 @@ public class AppSettingController {
|
|||||||
minDayServiceRate = 0D;
|
minDayServiceRate = 0D;
|
||||||
}
|
}
|
||||||
vo.setMinDayServiceRate(minDayServiceRate);
|
vo.setMinDayServiceRate(minDayServiceRate);
|
||||||
return AjaxResult.success(setting);
|
return AjaxResult.success(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,11 @@ public class CalLoanResp {
|
|||||||
@ApiModelProperty("还款月份")
|
@ApiModelProperty("还款月份")
|
||||||
private int totalMonth; //
|
private int totalMonth; //
|
||||||
@ApiModelProperty("贷款年利率")
|
@ApiModelProperty("贷款年利率")
|
||||||
private double loanRate; //
|
private double loanRateYear; //
|
||||||
|
@ApiModelProperty("贷款日利率")
|
||||||
|
private double loanRateDay; //
|
||||||
|
@ApiModelProperty("贷款日利率")
|
||||||
|
private double loanRateMonth; //
|
||||||
|
|
||||||
@ApiModelProperty("总利息数")
|
@ApiModelProperty("总利息数")
|
||||||
private BigDecimal totalInterest; //
|
private BigDecimal totalInterest; //
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.bashi.dk.kit;
|
package com.bashi.dk.kit;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import com.bashi.dk.domain.LoansSetting;
|
import com.bashi.dk.domain.LoansSetting;
|
||||||
import com.bashi.dk.dto.app.req.CalLoanReq;
|
import com.bashi.dk.dto.app.req.CalLoanReq;
|
||||||
import com.bashi.dk.service.LoansSettingService;
|
import com.bashi.dk.service.LoansSettingService;
|
||||||
@@ -18,9 +19,7 @@ public class CalLoanManager {
|
|||||||
|
|
||||||
public Loan calLoan(BigDecimal totalLoanMoney,Integer totalMonth, Double loanRate){
|
public Loan calLoan(BigDecimal totalLoanMoney,Integer totalMonth, Double loanRate){
|
||||||
ACPIMLoanCalculator calculator = new ACPIMLoanCalculator();
|
ACPIMLoanCalculator calculator = new ACPIMLoanCalculator();
|
||||||
Loan loan = calculator.calLoan(totalLoanMoney, totalMonth, loanRate, LoanUtil.RATE_TYPE_MONTH);
|
return calculator.calLoan(totalLoanMoney, totalMonth, loanRate, LoanUtil.RATE_TYPE_MONTH);
|
||||||
loan.setLoanRateMonth(loanRate);
|
|
||||||
return loan;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Loan calLoan(CalLoanReq calLoanReq){
|
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.setTotalLoanMoney(loan.getTotalLoanMoney());
|
||||||
borrow.setTotalMonth(loan.getTotalMonth());
|
borrow.setTotalMonth(loan.getTotalMonth());
|
||||||
borrow.setLoanMonthRate(loan.getLoanRateMonth());
|
borrow.setLoanMonthRate(loan.getLoanRateMonth());
|
||||||
borrow.setLoanYearRate(loan.getLoanRate());
|
borrow.setLoanYearRate(loan.getLoanRateYear());
|
||||||
borrow.setTotalInterest(loan.getTotalInterest());
|
borrow.setTotalInterest(loan.getTotalInterest());
|
||||||
borrow.setTotalRepayment(loan.getTotalRepayment());
|
borrow.setTotalRepayment(loan.getTotalRepayment());
|
||||||
borrow.setFirstRepayment(loan.getFirstRepayment());
|
borrow.setFirstRepayment(loan.getFirstRepayment());
|
||||||
@@ -135,7 +135,7 @@ public class BorrowServiceImpl extends ServiceImpl<BorrowMapper, Borrow> impleme
|
|||||||
update.setTotalLoanMoney(loan.getTotalLoanMoney());
|
update.setTotalLoanMoney(loan.getTotalLoanMoney());
|
||||||
update.setTotalMonth(loan.getTotalMonth());
|
update.setTotalMonth(loan.getTotalMonth());
|
||||||
update.setLoanMonthRate(loan.getLoanRateMonth());
|
update.setLoanMonthRate(loan.getLoanRateMonth());
|
||||||
update.setLoanYearRate(loan.getLoanRate());
|
update.setLoanYearRate(loan.getLoanRateYear());
|
||||||
update.setTotalInterest(loan.getTotalInterest());
|
update.setTotalInterest(loan.getTotalInterest());
|
||||||
update.setTotalRepayment(loan.getTotalRepayment());
|
update.setTotalRepayment(loan.getTotalRepayment());
|
||||||
update.setFirstRepayment(loan.getFirstRepayment());
|
update.setFirstRepayment(loan.getFirstRepayment());
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.bashi.dk.util;
|
package com.bashi.dk.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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 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 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);
|
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.setTotalLoanMoney(totalLoanMoney);
|
||||||
loan.setTotalMonth(totalMonth);
|
loan.setTotalMonth(totalMonth);
|
||||||
loan.setAvgRepayment(avgRepayment);
|
loan.setAvgRepayment(avgRepayment);
|
||||||
|
|||||||
@@ -9,15 +9,17 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Created by WangGenshen on 1/14/16.
|
* Created by WangGenshen on 1/14/16.
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
public class Loan {
|
public class Loan {
|
||||||
|
|
||||||
private BigDecimal totalLoanMoney; //贷款总额
|
private BigDecimal totalLoanMoney; //贷款总额
|
||||||
private int totalMonth; //还款月份
|
private int totalMonth; //还款月份
|
||||||
private double loanRate; //贷款年利率
|
private double loanRateYear; //贷款年利率
|
||||||
|
|
||||||
@Getter
|
private double loanRateDay; // 贷款日利率
|
||||||
@Setter
|
|
||||||
private double loanRateMonth;
|
private double loanRateMonth; // 贷款月利率
|
||||||
|
|
||||||
private BigDecimal totalInterest; // 总利息数
|
private BigDecimal totalInterest; // 总利息数
|
||||||
private BigDecimal totalRepayment; // 还款总额
|
private BigDecimal totalRepayment; // 还款总额
|
||||||
@@ -27,72 +29,6 @@ public class Loan {
|
|||||||
private List<LoanByMonth> allLoans; // 所有月份的还款情况
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String allLoansStr = "";
|
String allLoansStr = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user