|
|
@ -7,6 +7,7 @@ import com.yxt.anrui.buscenter.api.bussalesorder.app.order.AppOrderPriceInfoVo; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.FlowTaskFeign; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansolutions.LoanSolutions; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansolutions.SolutionDetailsDto; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansolutions.app.SolutionsDetailsVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansolutions.app.SolutionsDto; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansolutionsdetail.LoanSolutionsDetail; |
|
|
@ -17,6 +18,7 @@ import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.StringUtils; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
@ -670,7 +672,7 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public ResultBean saveDtos(SolutionsDto dto) { |
|
|
|
public ResultBean saveDtoss(SolutionDetailsDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String mainVehicleAmount = dto.getMainVehicleAmount(); |
|
|
|
if (StringUtils.isBlank(mainVehicleAmount)) { |
|
|
@ -740,420 +742,150 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
return rb.setMsg("主方案期数不能为空"); |
|
|
|
} |
|
|
|
//查詢是否有金融方案
|
|
|
|
LoanSolutions loanSolutions = baseMapper.selectByApplySid(dto.getSaleOrderSid()); |
|
|
|
LoanSolutions loanSolutions = baseMapper.selectByApplySid(dto.getBusSid()); |
|
|
|
if (loanSolutions != null) { |
|
|
|
//删除该销售订单的
|
|
|
|
baseMapper.deleteByOrderSid(dto.getSaleOrderSid()); |
|
|
|
baseMapper.deleteByOrderSid(dto.getBusSid()); |
|
|
|
loanSolutionsOtherpolicyService.deleteByLoanSid(loanSolutions.getSid()); |
|
|
|
loanSolutionsDetailService.deleteByLoanSid(loanSolutions.getSid()); |
|
|
|
} |
|
|
|
|
|
|
|
//保存金融方案
|
|
|
|
loanSolutions = new LoanSolutions(); |
|
|
|
if (StringUtils.isNotBlank(dto.getSaleOrderSid())) { |
|
|
|
loanSolutions.setSalesOrderSid(dto.getSaleOrderSid()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getTypeKey())) { |
|
|
|
loanSolutions.setType(dto.getType()); |
|
|
|
loanSolutions.setTypeKey(dto.getTypeKey()); |
|
|
|
} |
|
|
|
//是否打包
|
|
|
|
String isPack = dto.getIsPack(); |
|
|
|
if (StringUtils.isNotBlank(isPack)) { |
|
|
|
loanSolutions.setIsPack(isPack); |
|
|
|
loanSolutions.setSaleOrderState(1); |
|
|
|
if (StringUtils.isNotBlank(dto.getBusSid())) { |
|
|
|
loanSolutions.setSalesOrderSid(dto.getBusSid()); |
|
|
|
} |
|
|
|
//产品政策名称
|
|
|
|
String policyName = dto.getPolicyName(); |
|
|
|
if (StringUtils.isNotBlank(policyName)) { |
|
|
|
loanSolutions.setPolicyName(policyName); |
|
|
|
} |
|
|
|
//融资项目总额 = 主车发票价+融资票据+挂车+保险+购置税+车损上浮
|
|
|
|
BigDecimal loanTotal = new BigDecimal(BigInteger.ZERO); |
|
|
|
BeanUtil.copyProperties(dto, loanSolutions, "sid"); |
|
|
|
//主车发票价
|
|
|
|
loanTotal = loanTotal.add(new BigDecimal(mainVehicleAmount)); |
|
|
|
loanSolutions.setMainVehicleAmount(new BigDecimal(mainVehicleAmount)); |
|
|
|
|
|
|
|
//是否勾选融资票据
|
|
|
|
if (dto.isAccessoriesAmountCb()) { |
|
|
|
//融资票据
|
|
|
|
String accessoriesAmount = dto.getAccessoriesAmount(); |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(accessoriesAmount)); |
|
|
|
loanSolutions.setAccessoriesAmount(new BigDecimal(accessoriesAmount)); |
|
|
|
loanSolutions.setAccessoriesAmountCb(1); |
|
|
|
} else { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(BigInteger.ZERO)); |
|
|
|
loanSolutions.setAccessoriesAmountCb(0); |
|
|
|
} |
|
|
|
loanSolutions.setAccessoriesAmountCb(dto.isAccessoriesAmountCb() ? 1 : 0); |
|
|
|
loanSolutions.setAccessoriesAmount(dto.isAccessoriesAmountCb() ? new BigDecimal(dto.getAccessoriesAmount()) : BigDecimal.ZERO); |
|
|
|
//是否勾选挂车
|
|
|
|
if (dto.isTrailerAmountCb()) { |
|
|
|
//挂车
|
|
|
|
String trailerAmount = dto.getTrailerAmount(); |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(trailerAmount)); |
|
|
|
loanSolutions.setTrailerAmount(new BigDecimal(trailerAmount)); |
|
|
|
loanSolutions.setTrailerAmountCb(1); |
|
|
|
} else { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(BigInteger.ZERO)); |
|
|
|
loanSolutions.setTrailerAmountCb(0); |
|
|
|
} |
|
|
|
loanSolutions.setTrailerAmountCb(dto.isTrailerAmountCb() ? 1 : 0); |
|
|
|
loanSolutions.setTrailerAmount(dto.isTrailerAmountCb() ? new BigDecimal(dto.getTrailerAmount()) : BigDecimal.ZERO); |
|
|
|
//是否勾选保险
|
|
|
|
if (dto.isPremiumCb()) { |
|
|
|
//保险
|
|
|
|
String premium = dto.getPremium(); |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(premium)); |
|
|
|
loanSolutions.setPremium(new BigDecimal(premium)); |
|
|
|
loanSolutions.setPremiumCb(1); |
|
|
|
if (StringUtils.isNotBlank(dto.getOffsetPremium())) { |
|
|
|
if (new BigDecimal(dto.getOffsetPremium()).compareTo(new BigDecimal(premium)) > 0) { |
|
|
|
return rb.setMsg("抵顶首年保险费不能超过保险费用"); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(BigInteger.ZERO)); |
|
|
|
loanSolutions.setPremiumCb(0); |
|
|
|
} |
|
|
|
loanSolutions.setPremiumCb(dto.isPremiumCb() ? 1 : 0); |
|
|
|
loanSolutions.setPremium(StringUtils.isNotBlank(dto.getPremium()) ? new BigDecimal(dto.getPremium()) : BigDecimal.ZERO); |
|
|
|
//是否勾选购置税
|
|
|
|
if (dto.isPurchaseTaxCb()) { |
|
|
|
//购置税
|
|
|
|
String purchaseTax = dto.getPurchaseTax(); |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(purchaseTax)); |
|
|
|
loanSolutions.setPurchaseTax(new BigDecimal(purchaseTax)); |
|
|
|
loanSolutions.setPurchaseTaxCb(1); |
|
|
|
if (StringUtils.isNotBlank(dto.getOffsetPurchasetax())) { |
|
|
|
if (new BigDecimal(dto.getOffsetPurchasetax()).compareTo(new BigDecimal(purchaseTax)) > 0) { |
|
|
|
return rb.setMsg("抵顶购置税不能超过购置税"); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(BigInteger.ZERO)); |
|
|
|
loanSolutions.setPurchaseTaxCb(0); |
|
|
|
} |
|
|
|
loanSolutions.setLoanTotal(loanTotal); |
|
|
|
//产品贷款金额
|
|
|
|
BigDecimal loanAmount = new BigDecimal(BigInteger.ZERO); |
|
|
|
BigDecimal downPayAmount = new BigDecimal(BigInteger.ZERO); |
|
|
|
//首付金额填写、首付款比例计算。首付款比例 = 首付金额/融资总额*100
|
|
|
|
if (StringUtils.isNotBlank(dto.getDownPayAmount())) { |
|
|
|
//首付金额
|
|
|
|
downPayAmount = downPayAmount.add(new BigDecimal(dto.getDownPayAmount())); |
|
|
|
//首付款比例
|
|
|
|
String downPayRatio = ""; |
|
|
|
BigDecimal downPayRatio1 = downPayAmount.divide(loanTotal, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP); |
|
|
|
downPayRatio = downPayRatio1.toString() + "%"; |
|
|
|
//产品贷款金额 = 融资项目总额-首付金额
|
|
|
|
loanAmount = loanTotal.subtract(downPayAmount); |
|
|
|
loanSolutions.setDownPayAmount(downPayAmount); |
|
|
|
loanSolutions.setDownPayRatio(downPayRatio); |
|
|
|
} else { |
|
|
|
loanAmount = loanTotal; |
|
|
|
loanSolutions.setDownPayAmount(BigDecimal.ZERO); |
|
|
|
loanSolutions.setDownPayRatio("0"); |
|
|
|
} |
|
|
|
loanSolutions.setLoanAmount(loanAmount); |
|
|
|
|
|
|
|
loanSolutions.setPurchaseTaxCb(dto.isPurchaseTaxCb() ? 1 : 0); |
|
|
|
loanSolutions.setPurchaseTax(StringUtils.isNotBlank(dto.getPurchaseTax()) ? new BigDecimal(dto.getPurchaseTax()) : BigDecimal.ZERO); |
|
|
|
//项目融资总额
|
|
|
|
String loanTotal = dto.getLoanTotal(); |
|
|
|
loanSolutions.setLoanTotal(StringUtils.isNotBlank(loanTotal) ? new BigDecimal(loanTotal) : BigDecimal.ZERO); |
|
|
|
//首付比例
|
|
|
|
String downPayRatio = dto.getDownPayRatio(); |
|
|
|
loanSolutions.setDownPayRatio(downPayRatio); |
|
|
|
//首付金额
|
|
|
|
String downPayAmount = dto.getDownPayAmount(); |
|
|
|
loanSolutions.setDownPayAmount(StringUtils.isNotBlank(downPayAmount) ? new BigDecimal(downPayAmount) : BigDecimal.ZERO); |
|
|
|
//贷款金额
|
|
|
|
String loanAmount = dto.getLoanAmount(); |
|
|
|
loanSolutions.setLoanAmount(StringUtils.isNotBlank(loanAmount) ? new BigDecimal(loanAmount) : BigDecimal.ZERO); |
|
|
|
//贷款保证金比例
|
|
|
|
String bondRatio = dto.getBondRatio(); |
|
|
|
loanSolutions.setBondRatio(bondRatio); |
|
|
|
//期数
|
|
|
|
loanSolutions.setLoanPeriod(loanPeriod); |
|
|
|
//贷款保证金填写、贷款保证金比例计算。贷款保证金比例 = 贷款保证金/贷款金额*100
|
|
|
|
if (StringUtils.isNotBlank(dto.getBondAmount())) { |
|
|
|
//贷款保证金
|
|
|
|
BigDecimal bondAmount = new BigDecimal(dto.getBondAmount()); |
|
|
|
//贷款保证金比例
|
|
|
|
String bondRatio = ""; |
|
|
|
BigDecimal bondRatio1 = bondAmount.divide(loanAmount, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP); |
|
|
|
bondRatio = bondRatio1.toString() + "%"; |
|
|
|
loanSolutions.setBondAmount(bondAmount); |
|
|
|
loanSolutions.setBondRatio(bondRatio); |
|
|
|
} else { |
|
|
|
loanSolutions.setBondAmount(BigDecimal.ZERO); |
|
|
|
loanSolutions.setBondRatio("0"); |
|
|
|
} |
|
|
|
//保证金金额
|
|
|
|
String bondAmount = dto.getBondAmount(); |
|
|
|
loanSolutions.setBondAmount(StringUtils.isNotBlank(bondAmount) ? new BigDecimal(bondAmount) : BigDecimal.ZERO); |
|
|
|
//厂家贴息
|
|
|
|
String factoryDiscount = dto.getFactoryDiscount(); |
|
|
|
if (StringUtils.isNotBlank(factoryDiscount)) { |
|
|
|
loanSolutions.setFactoryDiscount(new BigDecimal(factoryDiscount)); |
|
|
|
} else { |
|
|
|
loanSolutions.setFactoryDiscount(new BigDecimal(BigInteger.ZERO)); |
|
|
|
} |
|
|
|
//厂家贴息用途
|
|
|
|
String factoryDiscountUse = dto.getFactoryDiscountUse(); |
|
|
|
if (StringUtils.isNotBlank(factoryDiscountUse)) { |
|
|
|
loanSolutions.setFactoryDiscountUse(factoryDiscountUse); |
|
|
|
} |
|
|
|
|
|
|
|
loanSolutions.setFactoryDiscount(StringUtils.isNotBlank(factoryDiscount) ? new BigDecimal(factoryDiscount) : BigDecimal.ZERO); |
|
|
|
String discountCar = dto.getDiscountCar(); |
|
|
|
loanSolutions.setDiscountCar(StringUtils.isNotBlank(discountCar) ? new BigDecimal(discountCar) : BigDecimal.ZERO); |
|
|
|
//年利率
|
|
|
|
String policyYearRatio = dto.getPolicyYearRatio(); |
|
|
|
loanSolutions.setPolicyYearRatio(policyYearRatio); |
|
|
|
//月还金额
|
|
|
|
String loanPayMoney = dto.getLoanPayMoney(); |
|
|
|
BigDecimal monthlyRepay1 = new BigDecimal(BigInteger.ZERO); |
|
|
|
if (StringUtils.isNotBlank(loanPayMoney)) { |
|
|
|
loanSolutions.setLoanPayMoney(new BigDecimal(loanPayMoney)); |
|
|
|
monthlyRepay1 = monthlyRepay1.add(new BigDecimal(loanPayMoney)); |
|
|
|
} else { |
|
|
|
loanSolutions.setLoanPayMoney(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
loanSolutions.setLoanPayMoney(StringUtils.isNotBlank(loanPayMoney) ? new BigDecimal(loanPayMoney) : BigDecimal.ZERO); |
|
|
|
//利息总额
|
|
|
|
BigDecimal interest = new BigDecimal(BigInteger.ZERO); |
|
|
|
String loanInterest = dto.getLoanInterest(); |
|
|
|
if (StringUtils.isNotBlank(loanInterest)) { |
|
|
|
loanSolutions.setLoanInterest(new BigDecimal(loanInterest)); |
|
|
|
interest = interest.add(new BigDecimal(loanInterest)); |
|
|
|
} else { |
|
|
|
loanSolutions.setLoanInterest(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
BigDecimal otherPolicyAmount1 = new BigDecimal(BigInteger.ZERO); |
|
|
|
int ii = 0; |
|
|
|
//=================================其它融
|
|
|
|
//勾选其它融
|
|
|
|
loanSolutions.setLoanInterest(StringUtils.isNotBlank(loanInterest) ? new BigDecimal(loanInterest) : BigDecimal.ZERO); |
|
|
|
LoanSolutionsOtherpolicy loanSolutionsOtherpolicy = new LoanSolutionsOtherpolicy(); |
|
|
|
if (dto.isOtherPolicyState()) { |
|
|
|
//其它融名称
|
|
|
|
if (StringUtils.isNotBlank(dto.getOtherPolicyName())) { |
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyName(dto.getOtherPolicyName()); |
|
|
|
} |
|
|
|
BeanUtil.copyProperties(dto, loanSolutionsOtherpolicy, "sid"); |
|
|
|
//贷款金额
|
|
|
|
String otherPolicyAmount = dto.getOtherPolicyAmount(); |
|
|
|
if (StringUtils.isNotBlank(otherPolicyAmount)) { |
|
|
|
otherPolicyAmount1 = otherPolicyAmount1.add(new BigDecimal(otherPolicyAmount)); |
|
|
|
} |
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyAmount(otherPolicyAmount1); |
|
|
|
String otherPolicyPeriod = dto.getOtherPolicyPeriod(); |
|
|
|
if (StringUtils.isNotBlank(otherPolicyPeriod)) { |
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyPeriod(otherPolicyPeriod); |
|
|
|
ii = ii + Integer.valueOf(otherPolicyPeriod); |
|
|
|
} |
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyAmount(StringUtils.isNotBlank(otherPolicyAmount) ? new BigDecimal(otherPolicyAmount) : BigDecimal.ZERO); |
|
|
|
//其它融月还
|
|
|
|
String otherPolicyMonthlyRepay = dto.getOtherPolicyMonthlyRepay(); |
|
|
|
if (StringUtils.isNotBlank(otherPolicyMonthlyRepay)) { |
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyMonthlyRepay(new BigDecimal(otherPolicyMonthlyRepay)); |
|
|
|
monthlyRepay1 = monthlyRepay1.add(new BigDecimal(otherPolicyMonthlyRepay)); |
|
|
|
} else { |
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyMonthlyRepay(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyMonthlyRepay(StringUtils.isNotBlank(otherPolicyMonthlyRepay) ? new BigDecimal(otherPolicyMonthlyRepay) : BigDecimal.ZERO); |
|
|
|
//其它融利息总额
|
|
|
|
String otherPolicyInterest = dto.getOtherPolicyInterest(); |
|
|
|
if (StringUtils.isNotBlank(otherPolicyInterest)) { |
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyInterest(new BigDecimal(otherPolicyInterest)); |
|
|
|
interest = interest.add(new BigDecimal(otherPolicyInterest)); |
|
|
|
} else { |
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyInterest(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
//方案汇总==========================================
|
|
|
|
//融资首付 = 首付金额-其它融贷款金额
|
|
|
|
BigDecimal loanDownPay = new BigDecimal(BigInteger.ZERO); |
|
|
|
loanDownPay = loanDownPay.add(downPayAmount).subtract(otherPolicyAmount1); |
|
|
|
loanSolutionsOtherpolicy.setLoanDownPay(loanDownPay); |
|
|
|
//总贷款金额 = 主方案贷款金额+其它融贷款金额
|
|
|
|
BigDecimal loanAmountTotal = new BigDecimal(BigInteger.ZERO); |
|
|
|
loanAmountTotal = loanAmountTotal.add(loanAmount).add(otherPolicyAmount1); |
|
|
|
loanSolutionsOtherpolicy.setLoanAmountTotal(loanAmountTotal); |
|
|
|
//期数 = 其它融期数拼接剩余期数(6/18)
|
|
|
|
int i = Integer.valueOf(loanPeriod) - Integer.valueOf(otherPolicyPeriod); |
|
|
|
String period = otherPolicyPeriod + "/" + i; |
|
|
|
loanSolutionsOtherpolicy.setPeriod(period); |
|
|
|
//月还金额 = 总月还/贷款月还
|
|
|
|
String monthlyRepay = ""; |
|
|
|
if (StringUtils.isNotBlank(dto.getMonthlyRepay())) { |
|
|
|
if (loanPeriod.equals(otherPolicyPeriod)) { |
|
|
|
monthlyRepay = monthlyRepay1.toString() + "/-"; |
|
|
|
} else { |
|
|
|
monthlyRepay = monthlyRepay1.toString() + "/" + dto.getLoanPayMoney(); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
monthlyRepay = monthlyRepay1.toString() + "/-"; |
|
|
|
} |
|
|
|
//实际首付比例
|
|
|
|
String downPayAmountsRatio = ""; |
|
|
|
BigDecimal downPayAmountsRatio1 = loanDownPay.divide(loanTotal, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP); |
|
|
|
downPayAmountsRatio = downPayAmountsRatio1.toString() + "%"; |
|
|
|
loanSolutionsOtherpolicy.setDownPayAmountsRatio(downPayAmountsRatio); |
|
|
|
|
|
|
|
|
|
|
|
//预计首期还款日
|
|
|
|
String returnTime = dto.getReturnTime(); |
|
|
|
loanSolutionsOtherpolicy.setMonthlyRepay(monthlyRepay); |
|
|
|
loanSolutionsOtherpolicy.setReturnTime(returnTime); |
|
|
|
//利息总额
|
|
|
|
loanSolutionsOtherpolicy.setInterest(interest); |
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyInterest(StringUtils.isNotBlank(otherPolicyInterest) ? new BigDecimal(otherPolicyInterest) : BigDecimal.ZERO); |
|
|
|
loanSolutions.setOtherPolicyState(1); |
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyYearRatio(dto.getOtherPolicyYearRatio()); |
|
|
|
String loanDownPay = dto.getLoanDownPay(); |
|
|
|
loanSolutionsOtherpolicy.setLoanDownPay(StringUtils.isNotBlank(loanDownPay) ? new BigDecimal(loanDownPay) : BigDecimal.ZERO); |
|
|
|
} else { |
|
|
|
//不勾选其它融
|
|
|
|
//方案汇总
|
|
|
|
//融资首付 = 首付金额-其它融贷款金额
|
|
|
|
BigDecimal loanDownPay = new BigDecimal(BigInteger.ZERO); |
|
|
|
loanDownPay = loanDownPay.add(downPayAmount).subtract(otherPolicyAmount1); |
|
|
|
loanSolutionsOtherpolicy.setLoanDownPay(loanDownPay); |
|
|
|
//总贷款金额 = 主方案贷款金额+其它融贷款金额
|
|
|
|
BigDecimal loanAmountTotal = new BigDecimal(BigInteger.ZERO); |
|
|
|
loanAmountTotal = loanAmountTotal.add(loanAmount).add(otherPolicyAmount1); |
|
|
|
loanSolutionsOtherpolicy.setLoanAmountTotal(loanAmountTotal); |
|
|
|
//实际首付比例
|
|
|
|
String downPayAmountsRatio = ""; |
|
|
|
BigDecimal downPayAmountsRatio1 = loanDownPay.divide(loanTotal, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP); |
|
|
|
downPayAmountsRatio = downPayAmountsRatio1.toString() + "%"; |
|
|
|
loanSolutionsOtherpolicy.setDownPayAmountsRatio(downPayAmountsRatio); |
|
|
|
//期数 = 其它融期数拼接剩余期数(6/18)
|
|
|
|
int i = Integer.valueOf(loanPeriod) - ii; |
|
|
|
String period = ii + "/" + i; |
|
|
|
loanSolutionsOtherpolicy.setPeriod(period); |
|
|
|
//月还金额 = 总月还/贷款月还
|
|
|
|
String monthlyRepay = monthlyRepay1.toString(); |
|
|
|
//预计首期还款日
|
|
|
|
String returnTime = dto.getReturnTime(); |
|
|
|
loanSolutionsOtherpolicy.setMonthlyRepay(monthlyRepay); |
|
|
|
loanSolutionsOtherpolicy.setReturnTime(returnTime); |
|
|
|
//利息总额
|
|
|
|
loanSolutionsOtherpolicy.setInterest(interest); |
|
|
|
BeanUtil.copyProperties(dto, loanSolutionsOtherpolicy, "sid"); |
|
|
|
String loanDownPay = dto.getLoanDownPay(); |
|
|
|
loanSolutionsOtherpolicy.setLoanDownPay(StringUtils.isNotBlank(loanDownPay) ? new BigDecimal(loanDownPay) : BigDecimal.ZERO); |
|
|
|
loanSolutions.setOtherPolicyState(0); |
|
|
|
} |
|
|
|
baseMapper.insert(loanSolutions); |
|
|
|
loanSolutionsOtherpolicy.setSolutionsSid(loanSolutions.getSid()); |
|
|
|
loanSolutionsOtherpolicyService.insert(loanSolutionsOtherpolicy); |
|
|
|
//=========================应收明细
|
|
|
|
/***********************应收明细************************************/ |
|
|
|
LoanSolutionsDetail loanSolutionsDetail = new LoanSolutionsDetail(); |
|
|
|
//应收合计 = 融资首付+贷款保证金+保险保证金+落户保证金+服务费+代收意外险+补车价+上牌费+运管费+其它费用
|
|
|
|
BigDecimal receivableTotal = new BigDecimal(BigInteger.ZERO); |
|
|
|
//融资首付 = 首付金额-其它融贷款金额
|
|
|
|
BigDecimal downPayAmounts = new BigDecimal(BigInteger.ZERO); |
|
|
|
downPayAmounts = downPayAmounts.add(downPayAmount).subtract(otherPolicyAmount1); |
|
|
|
loanSolutionsDetail.setDownPayAmounts(downPayAmounts); |
|
|
|
receivableTotal = receivableTotal.add(downPayAmounts); |
|
|
|
BeanUtil.copyProperties(dto, loanSolutionsDetail, "sid"); |
|
|
|
//融资首付
|
|
|
|
String downPayAmounts = dto.getDownPayAmounts(); |
|
|
|
loanSolutionsDetail.setDownPayAmounts(StringUtils.isNotBlank(downPayAmounts) ? new BigDecimal(downPayAmounts) : BigDecimal.ZERO); |
|
|
|
//贷款保证金
|
|
|
|
if (StringUtils.isNotBlank(dto.getBondAmount())) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(dto.getBondAmount())); |
|
|
|
loanSolutionsDetail.setBondAmounts(new BigDecimal(dto.getBondAmount())); |
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setBondAmounts(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
String bondAmounts = dto.getBondAmounts(); |
|
|
|
loanSolutionsDetail.setBondAmounts(StringUtils.isNotBlank(bondAmounts) ? new BigDecimal(bondAmounts) : BigDecimal.ZERO); |
|
|
|
//保险保证金
|
|
|
|
String depositPremium = dto.getDepositPremium(); |
|
|
|
if (StringUtils.isNotBlank(depositPremium)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(depositPremium)); |
|
|
|
loanSolutionsDetail.setDepositPremium(new BigDecimal(depositPremium)); |
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setDepositPremium(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
loanSolutionsDetail.setDepositPremium(StringUtils.isNotBlank(depositPremium) ? new BigDecimal(depositPremium) : BigDecimal.ZERO); |
|
|
|
//落户保证金
|
|
|
|
String depositSettle = dto.getDepositSettle(); |
|
|
|
if (StringUtils.isNotBlank(depositSettle)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(depositSettle)); |
|
|
|
loanSolutionsDetail.setDepositSettle(new BigDecimal(depositSettle)); |
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setDepositSettle(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
loanSolutionsDetail.setDepositSettle(StringUtils.isNotBlank(depositSettle) ? new BigDecimal(depositSettle) : BigDecimal.ZERO); |
|
|
|
//服务费
|
|
|
|
String serviceAmount = dto.getServiceAmount(); |
|
|
|
if (StringUtils.isNotBlank(serviceAmount)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(serviceAmount)); |
|
|
|
loanSolutionsDetail.setServiceAmount(new BigDecimal(serviceAmount)); |
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setServiceAmount(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
loanSolutionsDetail.setServiceAmount(StringUtils.isNotBlank(serviceAmount) ? new BigDecimal(serviceAmount) : BigDecimal.ZERO); |
|
|
|
//代收意外险
|
|
|
|
String proxyAccidentPremium = dto.getProxyAccidentPremium(); |
|
|
|
if (StringUtils.isNotBlank(proxyAccidentPremium)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(proxyAccidentPremium)); |
|
|
|
loanSolutionsDetail.setProxyAccidentPremium(new BigDecimal(proxyAccidentPremium)); |
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setProxyAccidentPremium(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
loanSolutionsDetail.setProxyAccidentPremium(StringUtils.isNotBlank(proxyAccidentPremium) ? new BigDecimal(proxyAccidentPremium) : BigDecimal.ZERO); |
|
|
|
//上牌费
|
|
|
|
String registerAmount = dto.getRegisterAmount(); |
|
|
|
if (StringUtils.isNotBlank(registerAmount)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(registerAmount)); |
|
|
|
loanSolutionsDetail.setRegisterAmount(new BigDecimal(registerAmount)); |
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setRegisterAmount(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
loanSolutionsDetail.setRegisterAmount(StringUtils.isNotBlank(registerAmount) ? new BigDecimal(registerAmount) : BigDecimal.ZERO); |
|
|
|
//运管费
|
|
|
|
String operationAmount = dto.getOperationAmount(); |
|
|
|
if (StringUtils.isNotBlank(operationAmount)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(operationAmount)); |
|
|
|
loanSolutionsDetail.setOperationAmount(new BigDecimal(operationAmount)); |
|
|
|
|
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setOperationAmount(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
loanSolutionsDetail.setOperationAmount(StringUtils.isNotBlank(operationAmount) ? new BigDecimal(operationAmount) : BigDecimal.ZERO); |
|
|
|
//补车价
|
|
|
|
String vehOtherPrice = dto.getVehOtherPrice(); |
|
|
|
if (StringUtils.isNotBlank(vehOtherPrice)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(vehOtherPrice)); |
|
|
|
loanSolutionsDetail.setVehOtherPrice(new BigDecimal(vehOtherPrice)); |
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setVehOtherPrice(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
loanSolutionsDetail.setVehOtherPrice(StringUtils.isNotBlank(vehOtherPrice) ? new BigDecimal(vehOtherPrice) : BigDecimal.ZERO); |
|
|
|
//其它费用
|
|
|
|
String otherAmount = dto.getOtherAmount(); |
|
|
|
if (StringUtils.isNotBlank(otherAmount)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(otherAmount)); |
|
|
|
loanSolutionsDetail.setOtherAmount(new BigDecimal(otherAmount)); |
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setOtherAmount(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
//其它费用说明
|
|
|
|
String otherAmountRemark = dto.getOtherAmountRemark(); |
|
|
|
loanSolutionsDetail.setOtherAmountRemark(otherAmountRemark); |
|
|
|
//办理方式选择
|
|
|
|
String dealWay = dto.getDealWay(); |
|
|
|
loanSolutionsDetail.setDealWay(dealWay); |
|
|
|
String dealWayKey = dto.getDealWayKey(); |
|
|
|
loanSolutionsDetail.setDealWayKey(dealWayKey); |
|
|
|
loanSolutionsDetail.setOtherAmount(StringUtils.isNotBlank(otherAmount) ? new BigDecimal(otherAmount) : BigDecimal.ZERO); |
|
|
|
//代收首年保险费
|
|
|
|
String proxyPremium = dto.getProxyPremium(); |
|
|
|
if (StringUtils.isNotBlank(proxyPremium)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(proxyPremium)); |
|
|
|
loanSolutionsDetail.setProxyPremium(new BigDecimal(proxyPremium)); |
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setProxyPremium(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
loanSolutionsDetail.setProxyPremium(StringUtils.isNotBlank(proxyPremium) ? new BigDecimal(proxyPremium) : BigDecimal.ZERO); |
|
|
|
//代收购置费
|
|
|
|
String proxyPurchasetax = dto.getProxyPurchasetax(); |
|
|
|
if (StringUtils.isNotBlank(proxyPurchasetax)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(proxyPurchasetax)); |
|
|
|
loanSolutionsDetail.setProxyPurchasetax(new BigDecimal(proxyPurchasetax)); |
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setProxyPurchasetax(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
//抵顶费用合计 = 抵顶首年保险费+抵顶购置税
|
|
|
|
BigDecimal offsetTotal = new BigDecimal(BigInteger.ZERO); |
|
|
|
loanSolutionsDetail.setProxyPurchasetax(StringUtils.isNotBlank(proxyPurchasetax) ? new BigDecimal(proxyPurchasetax) : BigDecimal.ZERO); |
|
|
|
//抵顶首年保险费
|
|
|
|
String offsetPremium = dto.getOffsetPremium(); |
|
|
|
if (dto.isPremiumCb()) { |
|
|
|
if (StringUtils.isNotBlank(offsetPremium)) { |
|
|
|
offsetTotal = offsetTotal.add(new BigDecimal(offsetPremium)); |
|
|
|
loanSolutionsDetail.setOffsetPremium(new BigDecimal(offsetPremium)); |
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setOffsetPremium(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
} |
|
|
|
if (dto.isPurchaseTaxCb()) { |
|
|
|
//抵顶购置税
|
|
|
|
String offsetPurchasetax = dto.getOffsetPurchasetax(); |
|
|
|
if (StringUtils.isNotBlank(offsetPurchasetax)) { |
|
|
|
offsetTotal = offsetTotal.add(new BigDecimal(offsetPurchasetax)); |
|
|
|
loanSolutionsDetail.setOffsetPurchasetax(new BigDecimal(offsetPurchasetax)); |
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setOffsetPurchasetax(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
} |
|
|
|
//实收合计 = 应收合计-抵顶合计
|
|
|
|
BigDecimal realTotal = receivableTotal.subtract(offsetTotal); |
|
|
|
loanSolutionsDetail.setOffsetPremium(StringUtils.isNotBlank(offsetPremium) ? new BigDecimal(offsetPremium) : BigDecimal.ZERO); |
|
|
|
String proxyTotal = dto.getProxyTotal(); |
|
|
|
loanSolutionsDetail.setProxyTotal(StringUtils.isNotBlank(proxyTotal) ? new BigDecimal(proxyTotal) : BigDecimal.ZERO); |
|
|
|
String offsetTotal = dto.getOffsetTotal(); |
|
|
|
loanSolutionsDetail.setOffsetTotal(StringUtils.isNotBlank(offsetTotal) ? new BigDecimal(offsetTotal) : BigDecimal.ZERO); |
|
|
|
//应收合计
|
|
|
|
String receivableTotal = dto.getReceivableTotal(); |
|
|
|
loanSolutionsDetail.setReceivableTotal(StringUtils.isNotBlank(receivableTotal) ? new BigDecimal(receivableTotal) : BigDecimal.ZERO); |
|
|
|
//实收合计
|
|
|
|
String realTotal = dto.getRealTotal(); |
|
|
|
loanSolutionsDetail.setRealTotal(StringUtils.isNotBlank(realTotal) ? new BigDecimal(realTotal) : BigDecimal.ZERO); |
|
|
|
//车辆总价
|
|
|
|
String vehTotalPrice = dto.getVehTotalPrice(); |
|
|
|
loanSolutionsDetail.setVehTotalPrice(StringUtils.isNotBlank(vehTotalPrice) ? new BigDecimal(vehTotalPrice) : BigDecimal.ZERO); |
|
|
|
//名义留购价
|
|
|
|
String nominalPrice = dto.getNominalPrice(); |
|
|
|
loanSolutionsDetail.setRealTotal(realTotal); |
|
|
|
loanSolutionsDetail.setReceivableTotal(receivableTotal); |
|
|
|
loanSolutionsDetail.setOffsetTotal(offsetTotal); |
|
|
|
if (StringUtils.isNotBlank(vehTotalPrice)) { |
|
|
|
loanSolutionsDetail.setVehTotalPrice(new BigDecimal(vehTotalPrice)); |
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setVehTotalPrice(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(nominalPrice)) { |
|
|
|
loanSolutionsDetail.setNominalPrice(new BigDecimal(nominalPrice)); |
|
|
|
} else { |
|
|
|
loanSolutionsDetail.setNominalPrice(BigDecimal.ZERO); |
|
|
|
} |
|
|
|
loanSolutionsDetail.setNominalPrice(StringUtils.isNotBlank(nominalPrice) ? new BigDecimal(nominalPrice) : BigDecimal.ZERO); |
|
|
|
loanSolutionsDetail.setSolutionsSid(loanSolutions.getSid()); |
|
|
|
loanSolutionsDetailService.insert(loanSolutionsDetail); |
|
|
|
return rb.success(); |
|
|
|