|
|
@ -46,16 +46,16 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
ResultBean<SolutionsDetailsVo> rb = ResultBean.fireFail(); |
|
|
|
SolutionsDetailsVo solutionsDetailsVo = new SolutionsDetailsVo(); |
|
|
|
LoanSolutions loanSolutions = baseMapper.selectBySaleOrderSid(saleOrderSid); |
|
|
|
if(loanSolutions != null){ |
|
|
|
if (loanSolutions != null) { |
|
|
|
BeanUtil.copyProperties(loanSolutions, solutionsDetailsVo); |
|
|
|
//查询其它融以及金融费用明细是否存在
|
|
|
|
LoanSolutionsOtherpolicy loanSolutionsOtherpolicy = loanSolutionsOtherpolicyService.selectByLoanSid(loanSolutions.getSid()); |
|
|
|
if(loanSolutionsOtherpolicy != null){ |
|
|
|
BeanUtil.copyProperties(loanSolutionsOtherpolicy,solutionsDetailsVo); |
|
|
|
if (loanSolutionsOtherpolicy != null) { |
|
|
|
BeanUtil.copyProperties(loanSolutionsOtherpolicy, solutionsDetailsVo); |
|
|
|
} |
|
|
|
LoanSolutionsDetail loanSolutionsDetail = loanSolutionsDetailService.selectLoanSid(loanSolutions.getSid()); |
|
|
|
if(loanSolutionsDetail != null){ |
|
|
|
BeanUtil.copyProperties(loanSolutionsDetail,solutionsDetailsVo); |
|
|
|
if (loanSolutionsDetail != null) { |
|
|
|
BeanUtil.copyProperties(loanSolutionsDetail, solutionsDetailsVo); |
|
|
|
} |
|
|
|
} |
|
|
|
//根据销售订单sid查询销售订单的信息
|
|
|
@ -65,10 +65,10 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
if ("1".equals(appOrderDetailsVo.getPayTypeKey())) { |
|
|
|
if ("2".equals(appOrderDetailsVo.getFinancePlan())) { |
|
|
|
solutionsDetailsVo.setFinPlanState(true); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
solutionsDetailsVo.setFinPlanState(false); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
solutionsDetailsVo.setFinPlanState(false); |
|
|
|
} |
|
|
|
} |
|
|
@ -80,182 +80,326 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
|
|
|
|
public ResultBean saveDto(SolutionsDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
//查询金融方案
|
|
|
|
LoanSolutions loanSolutions = baseMapper.selectBySaleOrderSid(dto.getSaleOrderSid()); |
|
|
|
if (loanSolutions != null) { |
|
|
|
//删除该销售订单的
|
|
|
|
baseMapper.deleteByOrderSid(dto.getSaleOrderSid()); |
|
|
|
loanSolutionsOtherpolicyService.deleteByLoanSid(loanSolutions.getSid()); |
|
|
|
loanSolutionsDetailService.deleteByLoanSid(loanSolutions.getSid()); |
|
|
|
} |
|
|
|
//保存金融方案
|
|
|
|
loanSolutions = new LoanSolutions(); |
|
|
|
//自营非担保和贷款的需要填写金融方案
|
|
|
|
if ("01".equals(dto.getTypeKey()) || StringUtils.isBlank(dto.getTypeKey())) { |
|
|
|
//是否打包
|
|
|
|
String isPack = dto.getIsPack(); |
|
|
|
//产品政策名称
|
|
|
|
String policyName = dto.getPolicyName(); |
|
|
|
//融资项目总额 = 主车发票价+融资票据+挂车+保险+购置税+车损上浮
|
|
|
|
BigDecimal loanTotal = new BigDecimal(BigInteger.ZERO); |
|
|
|
//主车发票价
|
|
|
|
String mainVehicleAmount = dto.getMainVehicleAmount(); |
|
|
|
if (StringUtils.isNotBlank(mainVehicleAmount)) { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(mainVehicleAmount)); |
|
|
|
loanSolutions.setMainVehicleAmount(new BigDecimal(mainVehicleAmount)); |
|
|
|
} else { |
|
|
|
return rb.setMsg("主车发票价不能为空"); |
|
|
|
} |
|
|
|
//融资票据
|
|
|
|
String accessoriesAmount = dto.getAccessoriesAmount(); |
|
|
|
if (StringUtils.isNotBlank(accessoriesAmount)) { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(accessoriesAmount)); |
|
|
|
} |
|
|
|
//挂车
|
|
|
|
String trailerAmount = dto.getTrailerAmount(); |
|
|
|
if (StringUtils.isNotBlank(trailerAmount)) { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(trailerAmount)); |
|
|
|
} |
|
|
|
//购置税
|
|
|
|
String purchaseTax = dto.getPurchaseTax(); |
|
|
|
if (StringUtils.isNotBlank(purchaseTax)) { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(purchaseTax)); |
|
|
|
} |
|
|
|
//保险金额
|
|
|
|
String premium = dto.getPremium(); |
|
|
|
if (StringUtils.isNotBlank(premium)) { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(premium)); |
|
|
|
} |
|
|
|
//车损上浮
|
|
|
|
String vehDamageFloat = dto.getVehDamageFloat(); |
|
|
|
if (StringUtils.isNotBlank(vehDamageFloat)) { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(vehDamageFloat)); |
|
|
|
} |
|
|
|
//首付款比例
|
|
|
|
String downPayRatio = dto.getDownPayRatio(); |
|
|
|
//首付金额
|
|
|
|
BigDecimal downPayAmount = new BigDecimal(BigInteger.ZERO); |
|
|
|
//首付金额 = 融资项目总*首付比例(可调整)
|
|
|
|
if (StringUtils.isBlank(downPayRatio)) { |
|
|
|
return rb.setMsg("首付款比例不能为空"); |
|
|
|
//是否勾选融资票据
|
|
|
|
if (dto.isAccessoriesAmountCb()) { |
|
|
|
//融资票据
|
|
|
|
String accessoriesAmount = dto.getAccessoriesAmount(); |
|
|
|
if (StringUtils.isNotBlank(accessoriesAmount)) { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(accessoriesAmount)); |
|
|
|
loanSolutions.setAccessoriesAmount(new BigDecimal(accessoriesAmount)); |
|
|
|
} else { |
|
|
|
return rb.setMsg("请输入融资票据"); |
|
|
|
} |
|
|
|
loanSolutions.setAccessoriesAmountCb(1); |
|
|
|
} else { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(BigInteger.ZERO)); |
|
|
|
loanSolutions.setAccessoriesAmountCb(0); |
|
|
|
} |
|
|
|
//是否勾选挂车
|
|
|
|
if (dto.isTrailerAmountCb()) { |
|
|
|
//挂车
|
|
|
|
String trailerAmount = dto.getTrailerAmount(); |
|
|
|
if (StringUtils.isNotBlank(trailerAmount)) { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(trailerAmount)); |
|
|
|
loanSolutions.setTrailerAmount(new BigDecimal(trailerAmount)); |
|
|
|
} else { |
|
|
|
return rb.setMsg("请输入挂车金额"); |
|
|
|
} |
|
|
|
loanSolutions.setTrailerAmountCb(1); |
|
|
|
} else { |
|
|
|
if (StringUtils.isBlank(dto.getDownPayAmount())) { |
|
|
|
downPayAmount = loanTotal.multiply(new BigDecimal(downPayRatio)).divide(new BigDecimal("100")); |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(BigInteger.ZERO)); |
|
|
|
loanSolutions.setTrailerAmountCb(0); |
|
|
|
} |
|
|
|
//是否勾选保险
|
|
|
|
if (dto.isPremiumCb()) { |
|
|
|
//保险
|
|
|
|
String premium = dto.getPremium(); |
|
|
|
if (StringUtils.isNotBlank(premium)) { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(premium)); |
|
|
|
loanSolutions.setPremium(new BigDecimal(premium)); |
|
|
|
} else { |
|
|
|
downPayAmount = new BigDecimal(dto.getDownPayAmount()); |
|
|
|
return rb.setMsg("请输入保险金额"); |
|
|
|
} |
|
|
|
loanSolutions.setPremiumCb(1); |
|
|
|
} else { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(BigInteger.ZERO)); |
|
|
|
loanSolutions.setPremiumCb(0); |
|
|
|
} |
|
|
|
int loanPeriod = dto.getLoanPeriod(); |
|
|
|
//产品贷款金额 = 融资项目总额-首付金额
|
|
|
|
BigDecimal loanAmount = loanTotal.subtract(downPayAmount); |
|
|
|
//贷款保证金比例
|
|
|
|
String bondRatio = dto.getBondRatio(); |
|
|
|
//贷款保证金 = 贷款金额*贷款保证金比例(可调整)
|
|
|
|
BigDecimal bondAmount = new BigDecimal(BigInteger.ZERO); |
|
|
|
if (StringUtils.isBlank(bondRatio)) { |
|
|
|
return rb.setMsg("贷款保证金比例不能为空"); |
|
|
|
//是否勾选购置税
|
|
|
|
if (dto.isPurchaseTaxCb()) { |
|
|
|
//购置税
|
|
|
|
String purchaseTax = dto.getPurchaseTax(); |
|
|
|
if (StringUtils.isNotBlank(purchaseTax)) { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(purchaseTax)); |
|
|
|
loanSolutions.setPurchaseTax(new BigDecimal(purchaseTax)); |
|
|
|
} else { |
|
|
|
return rb.setMsg("请输入购置税"); |
|
|
|
} |
|
|
|
loanSolutions.setPurchaseTaxCb(1); |
|
|
|
} else { |
|
|
|
if (StringUtils.isBlank(dto.getBondAmount())) { |
|
|
|
bondAmount = loanAmount.multiply(new BigDecimal(bondRatio)).divide(new BigDecimal("100")); |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(BigInteger.ZERO)); |
|
|
|
loanSolutions.setPurchaseTaxCb(0); |
|
|
|
} |
|
|
|
//是否勾选车损上浮
|
|
|
|
if (dto.isVehDamageFloatCb()) { |
|
|
|
//车损上浮
|
|
|
|
String vehDamageFloat = dto.getVehDamageFloat(); |
|
|
|
if (StringUtils.isNotBlank(vehDamageFloat)) { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(vehDamageFloat)); |
|
|
|
loanSolutions.setVehDamageFloat(new BigDecimal(vehDamageFloat)); |
|
|
|
} else { |
|
|
|
bondAmount = new BigDecimal(dto.getBondAmount()); |
|
|
|
return rb.setMsg("请输入车损上浮金额"); |
|
|
|
} |
|
|
|
|
|
|
|
loanSolutions.setVehDamageFloatCb(1); |
|
|
|
} else { |
|
|
|
loanTotal = loanTotal.add(new BigDecimal(BigInteger.ZERO)); |
|
|
|
loanSolutions.setVehDamageFloatCb(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).multiply(new BigDecimal("100")); |
|
|
|
downPayRatio = downPayRatio1.toString() + "%"; |
|
|
|
//产品贷款金额 = 融资项目总额-首付金额
|
|
|
|
loanAmount = loanTotal.subtract(downPayAmount); |
|
|
|
loanSolutions.setDownPayAmount(downPayAmount); |
|
|
|
loanSolutions.setDownPayRatio(downPayRatio); |
|
|
|
} else { |
|
|
|
loanAmount = loanTotal; |
|
|
|
} |
|
|
|
loanSolutions.setLoanAmount(loanAmount); |
|
|
|
//产品期数
|
|
|
|
String loanPeriod = dto.getLoanPeriod(); |
|
|
|
if (StringUtils.isBlank(loanPeriod)) { |
|
|
|
return rb.setMsg("主方案期数不能为空"); |
|
|
|
} |
|
|
|
loanSolutions.setLoanPeriod(loanPeriod); |
|
|
|
//贷款保证金填写、贷款保证金比例计算。贷款保证金比例 = 贷款保证金/贷款金额*100
|
|
|
|
if (StringUtils.isNotBlank(dto.getBondAmount())) { |
|
|
|
//贷款保证金
|
|
|
|
BigDecimal bondAmount = new BigDecimal(dto.getBondAmount()); |
|
|
|
//贷款保证金比例
|
|
|
|
String bondRatio = ""; |
|
|
|
BigDecimal bondRatio1 = bondAmount.divide(loanAmount).multiply(new BigDecimal("100")); |
|
|
|
bondRatio = bondRatio1.toString() + "%"; |
|
|
|
loanSolutions.setBondAmount(bondAmount); |
|
|
|
loanSolutions.setBondRatio(bondRatio); |
|
|
|
} |
|
|
|
//厂家贴息
|
|
|
|
String factoryDiscount = dto.getFactoryDiscount(); |
|
|
|
//年利率 =
|
|
|
|
if (StringUtils.isNotBlank(factoryDiscount)) { |
|
|
|
loanSolutions.setFactoryDiscount(new BigDecimal(factoryDiscount)); |
|
|
|
} |
|
|
|
//年利率
|
|
|
|
String policyYearRatio = dto.getPolicyYearRatio(); |
|
|
|
loanSolutions.setPolicyYearRatio(policyYearRatio); |
|
|
|
//月还金额
|
|
|
|
String loanPayMoney = dto.getLoanPayMoney(); |
|
|
|
//利息总额 = 贷款利息总额+利息总额
|
|
|
|
BigDecimal interest = new BigDecimal(BigInteger.ZERO); |
|
|
|
if (StringUtils.isNotBlank(loanPayMoney)) { |
|
|
|
loanSolutions.setLoanPayMoney(new BigDecimal(loanPayMoney)); |
|
|
|
} |
|
|
|
//利息总额
|
|
|
|
//利息总额
|
|
|
|
BigDecimal interest = new BigDecimal(BigInteger.ZERO); |
|
|
|
String loanInterest = dto.getLoanInterest(); |
|
|
|
if (StringUtils.isNotBlank(loanInterest)) { |
|
|
|
interest = interest.add(new BigDecimal(loanInterest)); |
|
|
|
} |
|
|
|
//==================================其它融
|
|
|
|
//其它融名称
|
|
|
|
String otherPolicyName = dto.getOtherPolicyName(); |
|
|
|
//其它融贷款金额
|
|
|
|
BigDecimal otherPolicyAmount = new BigDecimal(BigInteger.ZERO); |
|
|
|
if (StringUtils.isNotBlank(dto.getOtherPolicyAmount())) { |
|
|
|
otherPolicyAmount = new BigDecimal(dto.getOtherPolicyAmount()); |
|
|
|
} |
|
|
|
//其它融期数
|
|
|
|
int otherPolicyPeriod = dto.getOtherPolicyPeriod(); |
|
|
|
//其它融月还
|
|
|
|
String otherPolicyMonthlyRepay = dto.getOtherPolicyMonthlyRepay(); |
|
|
|
//其它融利息总额
|
|
|
|
String otherPolicyInterest = dto.getOtherPolicyInterest(); |
|
|
|
if (StringUtils.isNotBlank(otherPolicyInterest)) { |
|
|
|
interest = interest.add(new BigDecimal(otherPolicyInterest)); |
|
|
|
} |
|
|
|
|
|
|
|
//==================================方案汇总
|
|
|
|
//融资首付 = 首付金额-其它融贷款金额
|
|
|
|
BigDecimal loanDownPay = downPayAmount.subtract(otherPolicyAmount); |
|
|
|
//期数 = 其它融期数/剩余期数
|
|
|
|
int periods = loanPeriod - otherPolicyPeriod; |
|
|
|
String period = otherPolicyInterest + "/" + periods; |
|
|
|
//总贷款金额 = 产品贷款金额+其它融贷款金额
|
|
|
|
BigDecimal loanAmountTotal = loanAmount.add(otherPolicyAmount); |
|
|
|
//月还金额 = 总月还/贷款月还
|
|
|
|
String monthlyRepay = dto.getLoanPayMoney() + "/" + dto.getOtherPolicyMonthlyRepay(); |
|
|
|
//预计首期还款日
|
|
|
|
String returnTime = dto.getReturnTime(); |
|
|
|
|
|
|
|
//====================================应收明细
|
|
|
|
loanSolutions.setLoanInterest(new BigDecimal(loanInterest)); |
|
|
|
interest.add(new BigDecimal(loanInterest)); |
|
|
|
} |
|
|
|
BigDecimal otherPolicyAmount1 = new BigDecimal(BigInteger.ZERO); |
|
|
|
int ii = 0; |
|
|
|
//=================================其它融
|
|
|
|
//勾选其它融
|
|
|
|
LoanSolutionsOtherpolicy loanSolutionsOtherpolicy = new LoanSolutionsOtherpolicy(); |
|
|
|
if (dto.isOtherPolicyState()) { |
|
|
|
//其它融名称
|
|
|
|
if (StringUtils.isNotBlank(dto.getOtherPolicyName())) { |
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyName(dto.getOtherPolicyName()); |
|
|
|
} |
|
|
|
//贷款金额
|
|
|
|
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); |
|
|
|
} |
|
|
|
//其它融月还
|
|
|
|
String otherPolicyMonthlyRepay = dto.getOtherPolicyMonthlyRepay(); |
|
|
|
if (StringUtils.isNotBlank(otherPolicyMonthlyRepay)) { |
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyMonthlyRepay(new BigDecimal(otherPolicyMonthlyRepay)); |
|
|
|
} |
|
|
|
//其它融利息总额
|
|
|
|
String otherPolicyInterest = dto.getOtherPolicyInterest(); |
|
|
|
if (StringUtils.isNotBlank(otherPolicyInterest)) { |
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyInterest(new BigDecimal(otherPolicyInterest)); |
|
|
|
interest = interest.add(new BigDecimal(otherPolicyInterest)); |
|
|
|
} |
|
|
|
//方案汇总==========================================
|
|
|
|
//融资首付 = 首付金额-其它融贷款金额
|
|
|
|
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 = dto.getLoanPayMoney() + "/" + dto.getOtherPolicyMonthlyRepay(); |
|
|
|
//预计首期还款日
|
|
|
|
String returnTime = dto.getReturnTime(); |
|
|
|
loanSolutionsOtherpolicy.setMonthlyRepay(monthlyRepay); |
|
|
|
loanSolutionsOtherpolicy.setReturnTime(returnTime); |
|
|
|
//利息总额
|
|
|
|
loanSolutionsOtherpolicy.setInterest(interest); |
|
|
|
loanSolutions.setOtherPolicyState(1); |
|
|
|
} 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); |
|
|
|
//期数 = 其它融期数拼接剩余期数(6/18)
|
|
|
|
int i = Integer.valueOf(loanPeriod) - ii; |
|
|
|
String period = ii + "/" + i; |
|
|
|
loanSolutionsOtherpolicy.setPeriod(period); |
|
|
|
//月还金额 = 总月还/贷款月还
|
|
|
|
String monthlyRepay = dto.getLoanPayMoney() + "/" + dto.getOtherPolicyMonthlyRepay(); |
|
|
|
//预计首期还款日
|
|
|
|
String returnTime = dto.getReturnTime(); |
|
|
|
loanSolutionsOtherpolicy.setMonthlyRepay(monthlyRepay); |
|
|
|
loanSolutionsOtherpolicy.setReturnTime(returnTime); |
|
|
|
//利息总额
|
|
|
|
loanSolutionsOtherpolicy.setInterest(interest); |
|
|
|
loanSolutions.setOtherPolicyState(0); |
|
|
|
} |
|
|
|
baseMapper.insert(loanSolutions); |
|
|
|
loanSolutionsOtherpolicyService.insert(loanSolutionsOtherpolicy); |
|
|
|
//=========================应收明细
|
|
|
|
LoanSolutionsDetail loanSolutionsDetail = new LoanSolutionsDetail(); |
|
|
|
//应收合计 = 融资首付+贷款保证金+保险保证金+落户保证金+服务费+代收意外险+补车价+上牌费+运管费+其它费用
|
|
|
|
BigDecimal receivableTotal = new BigDecimal(BigInteger.ZERO); |
|
|
|
//融资首付 = 首付金额-其它融贷款金额
|
|
|
|
BigDecimal downPayAmounts = new BigDecimal(BigInteger.ZERO); |
|
|
|
downPayAmounts = loanDownPay; |
|
|
|
|
|
|
|
downPayAmounts = downPayAmounts.add(downPayAmount).subtract(otherPolicyAmount1); |
|
|
|
loanSolutionsDetail.setDownPayAmount(downPayAmounts); |
|
|
|
//贷款保证金
|
|
|
|
String bondAmounts = dto.getBondAmounts(); |
|
|
|
if (StringUtils.isNotBlank(bondAmounts)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(bondAmounts)); |
|
|
|
loanSolutionsDetail.setBondAmounts(new BigDecimal(bondAmounts)); |
|
|
|
} |
|
|
|
//保险保证金
|
|
|
|
String depositPremium = dto.getDepositPremium(); |
|
|
|
if (StringUtils.isNotBlank(depositPremium)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(depositPremium)); |
|
|
|
loanSolutionsDetail.setDepositPremium(new BigDecimal(depositPremium)); |
|
|
|
} |
|
|
|
//落户保证金
|
|
|
|
String depositSettle = dto.getDepositSettle(); |
|
|
|
if (StringUtils.isNotBlank(depositSettle)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(depositPremium)); |
|
|
|
loanSolutionsDetail.setDepositSettle(new BigDecimal(depositSettle)); |
|
|
|
} |
|
|
|
//服务费
|
|
|
|
String serviceAmount = dto.getServiceAmount(); |
|
|
|
if (StringUtils.isNotBlank(serviceAmount)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(serviceAmount)); |
|
|
|
loanSolutionsDetail.setServiceAmount(new BigDecimal(serviceAmount)); |
|
|
|
} |
|
|
|
//代收意外险
|
|
|
|
String proxyAccidentPremium = dto.getProxyAccidentPremium(); |
|
|
|
if (StringUtils.isNotBlank(proxyAccidentPremium)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(proxyAccidentPremium)); |
|
|
|
loanSolutionsDetail.setProxyAccidentPremium(new BigDecimal(proxyAccidentPremium)); |
|
|
|
|
|
|
|
} |
|
|
|
//上牌费
|
|
|
|
String registerAmount = dto.getRegisterAmount(); |
|
|
|
if (StringUtils.isNotBlank(registerAmount)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(registerAmount)); |
|
|
|
loanSolutionsDetail.setRegisterAmount(new BigDecimal(registerAmount)); |
|
|
|
} |
|
|
|
//运管费
|
|
|
|
String operationAmount = dto.getOperationAmount(); |
|
|
|
if (StringUtils.isNotBlank(operationAmount)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(operationAmount)); |
|
|
|
loanSolutionsDetail.setOperationAmount(new BigDecimal(operationAmount)); |
|
|
|
|
|
|
|
} |
|
|
|
//补车价
|
|
|
|
String vehOtherPrice = dto.getVehOtherPrice(); |
|
|
|
if (StringUtils.isNotBlank(vehOtherPrice)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(vehOtherPrice)); |
|
|
|
loanSolutionsDetail.setVehOtherPrice(new BigDecimal(vehOtherPrice)); |
|
|
|
} |
|
|
|
//其它费用
|
|
|
|
String otherAmount = dto.getOtherAmount(); |
|
|
|
if (StringUtils.isNotBlank(otherAmount)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(otherAmount)); |
|
|
|
loanSolutionsDetail.setOtherAmount(new BigDecimal(otherAmount)); |
|
|
|
} |
|
|
|
//其它费用说明
|
|
|
|
String otherAmountRemark = dto.getOtherAmountRemark(); |
|
|
|
loanSolutionsDetail.setOtherAmountRemark(otherAmountRemark); |
|
|
|
//办理方式选择
|
|
|
|
String dealWay = dto.getDealWay(); |
|
|
|
loanSolutionsDetail.setDealWay(dealWay); |
|
|
|
//代收首年保险费
|
|
|
|
String proxyPremium = dto.getProxyPremium(); |
|
|
|
if (StringUtils.isNotBlank(proxyPremium)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(proxyPremium)); |
|
|
|
loanSolutionsDetail.setProxyPremium(new BigDecimal(proxyPremium)); |
|
|
|
} |
|
|
|
//代收购置费
|
|
|
|
String proxyPurchasetax = dto.getProxyPurchasetax(); |
|
|
|
if (StringUtils.isNotBlank(proxyPurchasetax)) { |
|
|
|
receivableTotal = receivableTotal.add(new BigDecimal(proxyPurchasetax)); |
|
|
|
loanSolutionsDetail.setProxyPurchasetax(new BigDecimal(proxyPurchasetax)); |
|
|
|
} |
|
|
|
//抵顶费用合计 = 抵顶首年保险费+抵顶购置税
|
|
|
|
BigDecimal offsetTotal = new BigDecimal(BigInteger.ZERO); |
|
|
@ -263,11 +407,13 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
String offsetPremium = dto.getOffsetPremium(); |
|
|
|
if (StringUtils.isNotBlank(offsetPremium)) { |
|
|
|
offsetTotal = offsetTotal.add(new BigDecimal(offsetPremium)); |
|
|
|
loanSolutionsDetail.setOffsetPremium(new BigDecimal(offsetPremium)); |
|
|
|
} |
|
|
|
//抵顶购置税
|
|
|
|
String offsetPurchasetax = dto.getOffsetPurchasetax(); |
|
|
|
if (StringUtils.isNotBlank(offsetPurchasetax)) { |
|
|
|
offsetTotal = offsetTotal.add(new BigDecimal(offsetPurchasetax)); |
|
|
|
loanSolutionsDetail.setOffsetPurchasetax(new BigDecimal(offsetPurchasetax)); |
|
|
|
} |
|
|
|
//实收合计 = 应收合计-抵顶合计
|
|
|
|
BigDecimal realTotal = receivableTotal.subtract(offsetTotal); |
|
|
@ -275,64 +421,18 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
String vehTotalPrice = dto.getVehTotalPrice(); |
|
|
|
//名义留购价
|
|
|
|
String nominalPrice = dto.getNominalPrice(); |
|
|
|
//查询金融方案
|
|
|
|
LoanSolutions loanSolutions = baseMapper.selectBySaleOrderSid(dto.getSaleOrderSid()); |
|
|
|
if (loanSolutions != null) { |
|
|
|
//删除该销售订单的
|
|
|
|
baseMapper.deleteByOrderSid(dto.getSaleOrderSid()); |
|
|
|
loanSolutionsOtherpolicyService.deleteByLoanSid(loanSolutions.getSid()); |
|
|
|
loanSolutionsDetailService.deleteByLoanSid(loanSolutions.getSid()); |
|
|
|
} |
|
|
|
|
|
|
|
BeanUtil.copyProperties(dto, loanSolutions); |
|
|
|
//融资项目总额
|
|
|
|
loanSolutions.setLoanTotal(loanTotal); |
|
|
|
//首付金额
|
|
|
|
loanSolutions.setDownPayAmount(downPayAmount); |
|
|
|
//产品贷款金额
|
|
|
|
loanSolutions.setLoanAmount(loanAmount); |
|
|
|
//贷款保证金
|
|
|
|
loanSolutions.setBondAmount(bondAmount); |
|
|
|
baseMapper.insert(loanSolutions); |
|
|
|
//其他融
|
|
|
|
LoanSolutionsOtherpolicy loanSolutionsOtherpolicy = new LoanSolutionsOtherpolicy(); |
|
|
|
loanSolutionsOtherpolicy.setSolutionsSid(loanSolutions.getSid()); |
|
|
|
BeanUtil.copyProperties(dto, loanSolutionsOtherpolicy); |
|
|
|
//其它融贷款金额
|
|
|
|
loanSolutionsOtherpolicy.setOtherPolicyAmount(otherPolicyAmount); |
|
|
|
//方案汇总:融资首付
|
|
|
|
loanSolutionsOtherpolicy.setLoanDownPay(loanDownPay); |
|
|
|
//总贷款金额
|
|
|
|
loanSolutionsOtherpolicy.setLoanAmountTotal(loanAmountTotal); |
|
|
|
//期数
|
|
|
|
loanSolutionsOtherpolicy.setPeriod(period); |
|
|
|
//月还金额
|
|
|
|
loanSolutionsOtherpolicy.setMonthlyRepay(monthlyRepay); |
|
|
|
//利息总额
|
|
|
|
loanSolutionsOtherpolicy.setInterest(interest); |
|
|
|
loanSolutionsOtherpolicyService.insert(loanSolutionsOtherpolicy); |
|
|
|
//费用明细
|
|
|
|
LoanSolutionsDetail loanSolutionsDetail = new LoanSolutionsDetail(); |
|
|
|
loanSolutionsDetail.setSolutionsSid(loanSolutions.getSid()); |
|
|
|
BeanUtil.copyProperties(dto, loanSolutionsDetail); |
|
|
|
loanSolutionsDetail.setDownPayAmount(downPayAmounts); |
|
|
|
//抵顶费用合计
|
|
|
|
loanSolutionsDetail.setOffsetTotal(offsetTotal); |
|
|
|
//应收合计
|
|
|
|
loanSolutionsDetail.setReceivableTotal(receivableTotal); |
|
|
|
//实收合计
|
|
|
|
loanSolutionsDetail.setRealTotal(realTotal); |
|
|
|
loanSolutionsDetail.setReceivableTotal(receivableTotal); |
|
|
|
loanSolutionsDetail.setOffsetTotal(offsetTotal); |
|
|
|
if (StringUtils.isNotBlank(vehTotalPrice)) { |
|
|
|
loanSolutionsDetail.setVehTotalPrice(new BigDecimal(vehTotalPrice)); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(nominalPrice)) { |
|
|
|
loanSolutionsDetail.setNominalPrice(new BigDecimal(nominalPrice)); |
|
|
|
} |
|
|
|
loanSolutionsDetailService.insert(loanSolutionsDetail); |
|
|
|
|
|
|
|
} else {//外部金融的只需要录入厂家贴息
|
|
|
|
//查询金融方案
|
|
|
|
LoanSolutions loanSolutions = baseMapper.selectBySaleOrderSid(dto.getSaleOrderSid()); |
|
|
|
if (loanSolutions != null) { |
|
|
|
//删除该销售订单的
|
|
|
|
baseMapper.deleteByOrderSid(dto.getSaleOrderSid()); |
|
|
|
loanSolutionsOtherpolicyService.deleteByLoanSid(loanSolutions.getSid()); |
|
|
|
loanSolutionsDetailService.deleteByLoanSid(loanSolutions.getSid()); |
|
|
|
} |
|
|
|
//查询金融方案
|
|
|
|
loanSolutions = new LoanSolutions(); |
|
|
|
BeanUtil.copyProperties(dto, loanSolutions); |
|
|
@ -340,6 +440,17 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<SolutionsDetailsVo> selectDetailss(String businessSid) { |
|
|
|
ResultBean<SolutionsDetailsVo> rb = ResultBean.fireFail(); |
|
|
|
SolutionsDetailsVo solutionsDetailsVo = new SolutionsDetailsVo(); |
|
|
|
LoanSolutions loanSolutions = baseMapper.selectBySaleOrderSid(businessSid); |
|
|
|
if (loanSolutions == null) { |
|
|
|
return rb; |
|
|
|
} |
|
|
|
BeanUtil.copyProperties(loanSolutions, solutionsDetailsVo); |
|
|
|
return rb.success().setData(solutionsDetailsVo); |
|
|
|
} |
|
|
|
/* @Autowired |
|
|
|
private LoanSolutionsTopService loanSolutionsTopService; |
|
|
|
@Autowired |
|
|
|