|
|
@ -3,6 +3,8 @@ package com.yxt.anrui.riskcenter.biz.loansolutions; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrderFeign; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorder.app.order.AppOrderDetailsVo; |
|
|
|
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.app.SolutionsDetailsVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansolutions.app.SolutionsDto; |
|
|
@ -19,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigInteger; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* Project: anrui-riskcenter(风控中心) <br/> |
|
|
@ -43,6 +46,9 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
@Autowired |
|
|
|
private BusSalesOrderFeign busSalesOrderFeign; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private FlowTaskFeign flowTaskFeign; |
|
|
|
|
|
|
|
public ResultBean<SolutionsDetailsVo> selectDetails(String saleOrderSid) { |
|
|
|
ResultBean<SolutionsDetailsVo> rb = ResultBean.fireFail(); |
|
|
|
SolutionsDetailsVo solutionsDetailsVo = new SolutionsDetailsVo(); |
|
|
@ -78,9 +84,25 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
} |
|
|
|
return rb.success().setData(solutionsDetailsVo); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public ResultBean saveDto(SolutionsDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
//查询销售订单的状态
|
|
|
|
ResultBean<AppOrderDetailsVo> detailsVoResultBean = busSalesOrderFeign.getSaleOrderDetails(dto.getSaleOrderSid()); |
|
|
|
if (detailsVoResultBean.getData() != null) { |
|
|
|
AppOrderDetailsVo appOrderDetailsVo = detailsVoResultBean.getData(); |
|
|
|
if (StringUtils.isNotBlank(appOrderDetailsVo.getProcInsId())) { |
|
|
|
ResultBean<List<LatestTaskVo>> listResultBean = flowTaskFeign.getLatestTasks(appOrderDetailsVo.getProcInsId()); |
|
|
|
if (listResultBean.getData() != null && listResultBean.getData().size() > 0) { |
|
|
|
LatestTaskVo latestTaskVo = listResultBean.getData().get(0); |
|
|
|
if (!"Activity_0z788pp".equals(latestTaskVo.getTask_def_key_()) && !"Activity_1ckx8lq".equals(latestTaskVo.getTask_def_key_())) { |
|
|
|
return rb.setMsg("当前所处环节不允许修改金融方案"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//查询金融方案
|
|
|
|
LoanSolutions loanSolutions = baseMapper.selectBySaleOrderSid(dto.getSaleOrderSid()); |
|
|
|
if (loanSolutions != null) { |
|
|
@ -91,23 +113,23 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
} |
|
|
|
//保存金融方案
|
|
|
|
loanSolutions = new LoanSolutions(); |
|
|
|
if(StringUtils.isNotBlank(dto.getSaleOrderSid())){ |
|
|
|
if (StringUtils.isNotBlank(dto.getSaleOrderSid())) { |
|
|
|
loanSolutions.setSalesOrderSid(dto.getSaleOrderSid()); |
|
|
|
} |
|
|
|
//自营非担保和贷款的需要填写金融方案
|
|
|
|
if ("01".equals(dto.getTypeKey()) || StringUtils.isBlank(dto.getTypeKey())) { |
|
|
|
if(StringUtils.isNotBlank(dto.getTypeKey())){ |
|
|
|
if (StringUtils.isNotBlank(dto.getTypeKey())) { |
|
|
|
loanSolutions.setType(dto.getType()); |
|
|
|
loanSolutions.setTypeKey(dto.getTypeKey()); |
|
|
|
} |
|
|
|
//是否打包
|
|
|
|
String isPack = dto.getIsPack(); |
|
|
|
if(StringUtils.isNotBlank(isPack)){ |
|
|
|
if (StringUtils.isNotBlank(isPack)) { |
|
|
|
loanSolutions.setIsPack(isPack); |
|
|
|
} |
|
|
|
//产品政策名称
|
|
|
|
String policyName = dto.getPolicyName(); |
|
|
|
if(StringUtils.isNotBlank(policyName)){ |
|
|
|
if (StringUtils.isNotBlank(policyName)) { |
|
|
|
loanSolutions.setPolicyName(policyName); |
|
|
|
} |
|
|
|
//融资项目总额 = 主车发票价+融资票据+挂车+保险+购置税+车损上浮
|
|
|
@ -205,7 +227,7 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
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); |
|
|
|
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); |
|
|
@ -229,7 +251,7 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
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); |
|
|
|
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); |
|
|
@ -323,14 +345,14 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
loanSolutionsOtherpolicy.setPeriod(period); |
|
|
|
//月还金额 = 总月还/贷款月还
|
|
|
|
String monthlyRepay = ""; |
|
|
|
if(StringUtils.isNotBlank(dto.getMonthlyRepay())){ |
|
|
|
if(loanPeriod.equals(otherPolicyPeriod)){ |
|
|
|
if (StringUtils.isNotBlank(dto.getMonthlyRepay())) { |
|
|
|
if (loanPeriod.equals(otherPolicyPeriod)) { |
|
|
|
monthlyRepay = monthlyRepay1.toString() + "/-"; |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
monthlyRepay = monthlyRepay1.toString() + "/" + dto.getLoanPayMoney(); |
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
monthlyRepay = monthlyRepay1.toString() + "/-"; |
|
|
|
} |
|
|
|
|
|
|
@ -518,13 +540,13 @@ public class LoanSolutionsService extends MybatisBaseService<LoanSolutionsMapper |
|
|
|
} else {//外部金融的只需要录入厂家贴息
|
|
|
|
//查询金融方案
|
|
|
|
loanSolutions = new LoanSolutions(); |
|
|
|
if(StringUtils.isNotBlank(dto.getTypeKey())){ |
|
|
|
if (StringUtils.isNotBlank(dto.getTypeKey())) { |
|
|
|
loanSolutions.setType(dto.getType()); |
|
|
|
loanSolutions.setTypeKey(dto.getTypeKey()); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(dto.getFactoryDiscount())) { |
|
|
|
loanSolutions.setFactoryDiscount(new BigDecimal(BigInteger.ZERO)); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
loanSolutions.setFactoryDiscount(new BigDecimal(dto.getFactoryDiscount())); |
|
|
|
} |
|
|
|
loanSolutions.setFactoryDiscountUse(dto.getFactoryDiscountUse()); |
|
|
|