|
|
@ -74,6 +74,7 @@ import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.*; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
@ -125,6 +126,7 @@ public class LoanRepaymentScheduleService extends MybatisBaseService<LoanRepayme |
|
|
|
private LoanFinPolicyService loanFinPolicyService; |
|
|
|
@Autowired |
|
|
|
private BaseVehicleOutApplyFeign baseVehicleOutApplyFeign; |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据销售订单SID生成还款计划表回显 |
|
|
|
* |
|
|
@ -4624,9 +4626,207 @@ public class LoanRepaymentScheduleService extends MybatisBaseService<LoanRepayme |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
LoanRepaymentDetailsVo vo = new LoanRepaymentDetailsVo(); |
|
|
|
LoanRepaymentSchedule schedule = baseMapper.selectByContractSid(salesOrderSid); |
|
|
|
List<DetailsListVo> vinList = new ArrayList<>(); |
|
|
|
if (null != schedule) { |
|
|
|
|
|
|
|
|
|
|
|
vo.setSid(schedule.getSid()); |
|
|
|
vo.setIsOtherPolicy(schedule.getIsOtherPolicy()); |
|
|
|
if (StringUtils.isNotBlank(schedule.getLoanContractNo())) { |
|
|
|
vo.setLoanContractNo(schedule.getLoanContractNo()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(schedule.getBorrowerName())) { |
|
|
|
vo.setBorrowerName(schedule.getBorrowerName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(schedule.getVehCount())) { |
|
|
|
vo.setVehCount(schedule.getVehCount()); |
|
|
|
} |
|
|
|
String sumMoney = loanRepaymentPlanDetailsService.selSumMoneyByScheduleSid(schedule.getSid()); |
|
|
|
vo.setAmountAll(sumMoney); |
|
|
|
String policyName = ""; |
|
|
|
String bankContractNo = ""; |
|
|
|
String otherPolicyName = ""; |
|
|
|
String otherBankNo = ""; |
|
|
|
if (StringUtils.isNotBlank(schedule.getPolicyName())) { |
|
|
|
policyName = schedule.getPolicyName(); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(schedule.getBankContractNo())) { |
|
|
|
bankContractNo = schedule.getBankContractNo(); |
|
|
|
} |
|
|
|
vo.setPolicyName(policyName + "-" + bankContractNo); |
|
|
|
if (schedule.getIsOtherPolicy().equals("1")) { |
|
|
|
//查看是否有其他融
|
|
|
|
LoanSolutions loanSolutions = loanSolutionsService.selectBySaleOrderSid(schedule.getSalesOrderSid()); |
|
|
|
LoanSolutionsOtherpolicy otherpolicy = loanSolutionsOtherpolicyService.selectByLoanSid(loanSolutions.getSid()); |
|
|
|
if (null != otherpolicy) { |
|
|
|
if (StringUtils.isNotBlank(otherpolicy.getOtherPolicyPeriod())) { |
|
|
|
// 其他融产品
|
|
|
|
if (StringUtils.isNotBlank(otherpolicy.getOtherPolicyName())) { |
|
|
|
otherPolicyName = otherpolicy.getOtherPolicyName(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(schedule.getOtherBankNo())) { |
|
|
|
otherBankNo = schedule.getOtherBankNo(); |
|
|
|
vo.setOtherPolicyName(otherPolicyName + "-" + otherBankNo); |
|
|
|
} |
|
|
|
BigDecimal mp = new BigDecimal(schedule.getMainPeriod()); |
|
|
|
BigDecimal mf = schedule.getMainFirstRepay(); |
|
|
|
BigDecimal mm = schedule.getMainMidRepay(); |
|
|
|
BigDecimal ml = schedule.getMainLastRepay(); |
|
|
|
BigDecimal op = new BigDecimal(schedule.getOtherPeriod()); |
|
|
|
BigDecimal of = schedule.getOtherFirstRepay(); |
|
|
|
BigDecimal om = schedule.getOtherMidRepay(); |
|
|
|
BigDecimal ol = schedule.getOtherLastRepay(); |
|
|
|
BigDecimal sm = mm.multiply((mp.subtract(new BigDecimal("2")))).add(mf).add(ml); |
|
|
|
vo.setLoanAmount(sm.toString()); |
|
|
|
vo.setMainPeriod(schedule.getMainPeriod()); |
|
|
|
vo.setMainRepayDate(DateUtil.formatDate(schedule.getMainRepayDate())); |
|
|
|
BigDecimal so = om.multiply((op.subtract(new BigDecimal("2")))).add(of).add(ol); |
|
|
|
vo.setOtherAmount(so.toString()); |
|
|
|
vo.setOtherPeriod(schedule.getOtherPeriod()); |
|
|
|
vo.setOtherRepayDate(DateUtil.formatDate(schedule.getOtherRepayDate())); |
|
|
|
} else { |
|
|
|
BigDecimal mp = new BigDecimal(schedule.getMainPeriod()); |
|
|
|
BigDecimal mf = schedule.getMainFirstRepay(); |
|
|
|
BigDecimal mm = schedule.getMainMidRepay(); |
|
|
|
BigDecimal ml = schedule.getMainLastRepay(); |
|
|
|
BigDecimal sm = mm.multiply((mp.subtract(new BigDecimal("2")))).add(mf).add(ml); |
|
|
|
vo.setLoanAmount(sm.toString()); |
|
|
|
vo.setMainPeriod(schedule.getMainPeriod()); |
|
|
|
vo.setMainRepayDate(DateUtil.formatDate(schedule.getMainRepayDate())); |
|
|
|
} |
|
|
|
if (Integer.parseInt(schedule.getVehCount()) > 1) { |
|
|
|
if (StringUtils.isNotBlank(schedule.getIsDifferent())) { |
|
|
|
if (schedule.getIsDifferent().equals("1")) { |
|
|
|
List<DetailsVehVo> vehVos = baseMapper.selMoneyAndVin(schedule.getSid()); |
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
List<String> moneys = new ArrayList<>(); |
|
|
|
List<String> vinNos = new ArrayList<>(); |
|
|
|
if (!vehVos.isEmpty()) { |
|
|
|
for (DetailsVehVo vehVo : vehVos) { |
|
|
|
map.put(vehVo.getVinNo() + "," + vehVo.getBusVinSid(), vehVo.getMoney()); |
|
|
|
moneys.add(vehVo.getMoney()); |
|
|
|
} |
|
|
|
//找出元素最多的一个
|
|
|
|
String maxCount = moneys.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting())) |
|
|
|
.entrySet() |
|
|
|
.stream() |
|
|
|
.max(Map.Entry.comparingByValue()) |
|
|
|
.map(Map.Entry::getKey) |
|
|
|
.get(); |
|
|
|
for (Map.Entry<String, String> entry : map.entrySet()) { |
|
|
|
String value = entry.getValue(); |
|
|
|
String key = entry.getKey(); |
|
|
|
String flag = ""; //0代表普通 1代表与其他不同
|
|
|
|
if (value.equals(maxCount)) { |
|
|
|
flag = "0"; |
|
|
|
} else { |
|
|
|
flag = "1"; |
|
|
|
} |
|
|
|
vinNos.add(key + ";" + flag); |
|
|
|
} |
|
|
|
// 赋值
|
|
|
|
BigDecimal mf = schedule.getMainFirstRepay(); |
|
|
|
BigDecimal mm = schedule.getMainMidRepay(); |
|
|
|
BigDecimal ml = schedule.getMainLastRepay(); |
|
|
|
BigDecimal of = new BigDecimal("0"); |
|
|
|
BigDecimal om = new BigDecimal("0"); |
|
|
|
BigDecimal ol = new BigDecimal("0"); |
|
|
|
BigDecimal mfs = schedule.getSingleMainFirstRepay(); |
|
|
|
BigDecimal mms = schedule.getSingleMainMidRepay(); |
|
|
|
BigDecimal mls = schedule.getSingleMainLastRepay(); |
|
|
|
BigDecimal ofs = new BigDecimal("0"); |
|
|
|
BigDecimal oms = new BigDecimal("0"); |
|
|
|
BigDecimal ols = new BigDecimal("0"); |
|
|
|
if (schedule.getIsOtherPolicy().equals("1")) { |
|
|
|
of = schedule.getOtherFirstRepay(); |
|
|
|
om = schedule.getOtherMidRepay(); |
|
|
|
ol = schedule.getOtherLastRepay(); |
|
|
|
ofs = schedule.getSingleOtherFirstRepay(); |
|
|
|
oms = schedule.getSingleOtherMidRepay(); |
|
|
|
ols = schedule.getSingleOtherLastRepay(); |
|
|
|
} |
|
|
|
for (String s : vinNos) { |
|
|
|
//拆分字符串
|
|
|
|
String[] split = s.split(";"); |
|
|
|
String vin = split[0]; |
|
|
|
String flag = split[1]; |
|
|
|
String[] v = vin.split(","); |
|
|
|
String vinNo = v[0]; |
|
|
|
String busVinSid = v[1]; |
|
|
|
DetailsListVo listVo = new DetailsListVo(); |
|
|
|
listVo.setVinNo(vinNo); |
|
|
|
listVo.setBusVinSid(busVinSid); |
|
|
|
if (flag.equals("0")) { |
|
|
|
//普通
|
|
|
|
listVo.setMainFirstRepay(mf.toString()); |
|
|
|
listVo.setMainMidRepay(mm.toString()); |
|
|
|
listVo.setMainLastRepay(ml.toString()); |
|
|
|
if (schedule.getIsOtherPolicy().equals("1")) { |
|
|
|
listVo.setOtherFirstRepay(of.toString()); |
|
|
|
listVo.setOtherMidRepay(om.toString()); |
|
|
|
listVo.setOtherLastRepay(ol.toString()); |
|
|
|
} |
|
|
|
} else if (flag.equals("1")) { |
|
|
|
//与其他不同
|
|
|
|
listVo.setMainFirstRepay(mfs.toString()); |
|
|
|
listVo.setMainMidRepay(mms.toString()); |
|
|
|
listVo.setMainLastRepay(mls.toString()); |
|
|
|
if (schedule.getIsOtherPolicy().equals("1")) { |
|
|
|
listVo.setOtherFirstRepay(ofs.toString()); |
|
|
|
listVo.setOtherMidRepay(oms.toString()); |
|
|
|
listVo.setOtherLastRepay(ols.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
vinList.add(listVo); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
List<DetailsVehVo> vehVos = baseMapper.selMoneyAndVin(schedule.getSid()); |
|
|
|
for (DetailsVehVo detailsVehVo : vehVos) { |
|
|
|
DetailsListVo listVo = new DetailsListVo(); |
|
|
|
listVo.setBusVinSid(detailsVehVo.getBusVinSid()); |
|
|
|
listVo.setVinNo(detailsVehVo.getVinNo()); |
|
|
|
BigDecimal mf = schedule.getMainFirstRepay(); |
|
|
|
BigDecimal mm = schedule.getMainMidRepay(); |
|
|
|
BigDecimal ml = schedule.getMainLastRepay(); |
|
|
|
listVo.setMainFirstRepay(mf.toString()); |
|
|
|
listVo.setMainMidRepay(mm.toString()); |
|
|
|
listVo.setMainLastRepay(ml.toString()); |
|
|
|
if (schedule.getIsOtherPolicy().equals("1")) { |
|
|
|
BigDecimal of = schedule.getOtherFirstRepay(); |
|
|
|
BigDecimal om = schedule.getOtherMidRepay(); |
|
|
|
BigDecimal ol = schedule.getOtherLastRepay(); |
|
|
|
listVo.setOtherFirstRepay(of.toString()); |
|
|
|
listVo.setOtherMidRepay(om.toString()); |
|
|
|
listVo.setOtherLastRepay(ol.toString()); |
|
|
|
} |
|
|
|
vinList.add(listVo); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
List<DetailsVehVo> vehVos = baseMapper.selMoneyAndVin(schedule.getSid()); |
|
|
|
DetailsVehVo detailsVehVo = vehVos.get(0); |
|
|
|
DetailsListVo listVo = new DetailsListVo(); |
|
|
|
listVo.setBusVinSid(detailsVehVo.getBusVinSid()); |
|
|
|
listVo.setVinNo(detailsVehVo.getVinNo()); |
|
|
|
BigDecimal mf = schedule.getMainFirstRepay(); |
|
|
|
BigDecimal mm = schedule.getMainMidRepay(); |
|
|
|
BigDecimal ml = schedule.getMainLastRepay(); |
|
|
|
listVo.setMainFirstRepay(mf.toString()); |
|
|
|
listVo.setMainMidRepay(mm.toString()); |
|
|
|
listVo.setMainLastRepay(ml.toString()); |
|
|
|
if (schedule.getIsOtherPolicy().equals("1")) { |
|
|
|
BigDecimal of = schedule.getOtherFirstRepay(); |
|
|
|
BigDecimal om = schedule.getOtherMidRepay(); |
|
|
|
BigDecimal ol = schedule.getOtherLastRepay(); |
|
|
|
listVo.setOtherFirstRepay(of.toString()); |
|
|
|
listVo.setOtherMidRepay(om.toString()); |
|
|
|
listVo.setOtherLastRepay(ol.toString()); |
|
|
|
} |
|
|
|
vinList.add(listVo); |
|
|
|
} |
|
|
|
vo.setVinList(vinList); |
|
|
|
} |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|