|
|
@ -1896,118 +1896,16 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl |
|
|
|
//该合同编号下的该车架号的所有认款金额
|
|
|
|
List<FinSelectedReceivablesDetailedVo> voList = finSelectedReceivablesDetailedService.selectListByVin(v.getContractNo(), finUncollectedReceivablesDetailed.getBusVinSid(), 3); |
|
|
|
BigDecimal bigDecimalVinAll = voList.stream().map(FinSelectedReceivablesDetailedVo::getSubscriptionMoney).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
List<FinUncollectedReceivablesDetailed> unList = finUncollectedReceivablesDetailedService.selectListByBusVinSid(finUncollectedReceivablesDetailed.getBusVinSid()); |
|
|
|
BigDecimal unDecimalVinAll = unList.stream().map(FinUncollectedReceivablesDetailed::getReveivableMoney).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
//查询该合同编号下的销售订单的单车成交价
|
|
|
|
ResultBean<CommonContract> commonContractResultBean = commonContractFeign.selectByNo(v.getContractNo()); |
|
|
|
if (commonContractResultBean.getSuccess()) { |
|
|
|
CommonContract commonContract = commonContractResultBean.getData(); |
|
|
|
if (commonContract != null) { |
|
|
|
ResultBean<AppOrderDetailsVo> orderDetails = busSalesOrderFeign.getSaleOrderDetails(commonContract.getBusSid()); |
|
|
|
AppOrderDetailsVo vo = orderDetails.getData(); |
|
|
|
if (vo != null) { |
|
|
|
AppOrderPriceInfoVo priceInfoVo = vo.getPriceInfo(); |
|
|
|
AppOrderDepositInfoVo depositInfo = vo.getDepositInfo(); |
|
|
|
if (depositInfo != null) { |
|
|
|
if ("02".equals(depositInfo.getDepositTypeKey())) {//订金结转
|
|
|
|
BigDecimal decimalDeposit = BigDecimal.ZERO; |
|
|
|
if (StringUtils.isNotBlank(depositInfo.getDepositTotal())) { |
|
|
|
decimalDeposit = new BigDecimal(depositInfo.getDepositTotal()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(depositInfo.getMakeUpDeposit())) { |
|
|
|
decimalDeposit = decimalDeposit.subtract(new BigDecimal(depositInfo.getMakeUpDeposit())); |
|
|
|
} |
|
|
|
decimalDeposit = decimalDeposit.divide(new BigDecimal(priceInfoVo.getNumber()), BigDecimal.ROUND_CEILING); |
|
|
|
bigDecimalVinAll = bigDecimalVinAll.add(decimalDeposit); |
|
|
|
} |
|
|
|
} |
|
|
|
//单台整体成交价
|
|
|
|
BigDecimal singleFinalPrice = new BigDecimal(priceInfoVo.getSingleFinalPrice()); |
|
|
|
BigDecimal leftAll = BigDecimal.ZERO; |
|
|
|
BigDecimal rightAll = BigDecimal.ZERO; |
|
|
|
if ("2".equals(vo.getFinancePlan()) || "2".equals(vo.getPayTypeKey())) { |
|
|
|
//根据销售订单sid查询金融方案
|
|
|
|
ResultBean<SolutionsDetailsVo> solutionsDetailsVoResultBean = loanSolutionsFeign.selectDetailss(commonContract.getBusSid()); |
|
|
|
SolutionsDetailsVo solutionsDetailsVo = solutionsDetailsVoResultBean.getData(); |
|
|
|
if (solutionsDetailsVo != null) { |
|
|
|
/*if (StringUtils.isNotBlank(solutionsDetailsVo.getTypeKey())) { |
|
|
|
if ("02".equals(solutionsDetailsVo.getTypeKey())) { |
|
|
|
//外部金融:成交价 = 订金+车款+厂家贴息-服务费
|
|
|
|
leftAll = leftAll.add(singleFinalPrice); |
|
|
|
if (StringUtils.isNotBlank(solutionsDetailsVo.getFactoryDiscount())) { |
|
|
|
leftAll = leftAll.subtract(new BigDecimal(solutionsDetailsVo.getFactoryDiscount())); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(solutionsDetailsVo.getServiceAmount())) { |
|
|
|
leftAll = leftAll.add(new BigDecimal(solutionsDetailsVo.getServiceAmount())); |
|
|
|
} |
|
|
|
rightAll = rightAll.add(bigDecimalVinAll); |
|
|
|
} else { |
|
|
|
//自营非担保: 实收订金 = 首付款及费用+订金
|
|
|
|
if (StringUtils.isNotBlank(solutionsDetailsVo.getRealTotal())) { |
|
|
|
leftAll = leftAll.add(new BigDecimal(solutionsDetailsVo.getRealTotal())); |
|
|
|
} |
|
|
|
rightAll = rightAll.add(bigDecimalVinAll); |
|
|
|
} |
|
|
|
} else {//担保贷款: 实收订金 = 首付款及费用+订金
|
|
|
|
if (StringUtils.isNotBlank(solutionsDetailsVo.getRealTotal())) { |
|
|
|
leftAll = leftAll.add(new BigDecimal(solutionsDetailsVo.getRealTotal())); |
|
|
|
} |
|
|
|
rightAll = rightAll.add(bigDecimalVinAll); |
|
|
|
}*/ |
|
|
|
if ("2".equals(vo.getPayTypeKey())) {//贷款
|
|
|
|
if (StringUtils.isNotBlank(solutionsDetailsVo.getRealTotal())) { |
|
|
|
leftAll = leftAll.add(new BigDecimal(solutionsDetailsVo.getRealTotal())); |
|
|
|
} |
|
|
|
rightAll = rightAll.add(bigDecimalVinAll); |
|
|
|
} else { |
|
|
|
if(StringUtils.isNotBlank(solutionsDetailsVo.getTypeKey())){ |
|
|
|
//外部金融:成交价 = 订金+车款+厂家贴息-服务费
|
|
|
|
leftAll = leftAll.add(singleFinalPrice); |
|
|
|
if (StringUtils.isNotBlank(solutionsDetailsVo.getDiscountCar())) { |
|
|
|
leftAll = leftAll.subtract(new BigDecimal(solutionsDetailsVo.getDiscountCar())); |
|
|
|
}else{ |
|
|
|
leftAll = leftAll.subtract(new BigDecimal(solutionsDetailsVo.getFactoryDiscount())); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(solutionsDetailsVo.getServiceAmount())) { |
|
|
|
leftAll = leftAll.add(new BigDecimal(solutionsDetailsVo.getServiceAmount())); |
|
|
|
} |
|
|
|
rightAll = rightAll.add(bigDecimalVinAll); |
|
|
|
}else{ |
|
|
|
if ("02".equals(solutionsDetailsVo.getTypeKey())) { |
|
|
|
//外部金融:成交价 = 订金+车款+厂家贴息-服务费
|
|
|
|
leftAll = leftAll.add(singleFinalPrice); |
|
|
|
if (StringUtils.isNotBlank(solutionsDetailsVo.getFactoryDiscount())) { |
|
|
|
leftAll = leftAll.subtract(new BigDecimal(solutionsDetailsVo.getFactoryDiscount())); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(solutionsDetailsVo.getServiceAmount())) { |
|
|
|
leftAll = leftAll.add(new BigDecimal(solutionsDetailsVo.getServiceAmount())); |
|
|
|
} |
|
|
|
rightAll = rightAll.add(bigDecimalVinAll); |
|
|
|
} else { |
|
|
|
//自营非担保: 实收订金 = 首付款及费用+订金
|
|
|
|
if (StringUtils.isNotBlank(solutionsDetailsVo.getRealTotal())) { |
|
|
|
leftAll = leftAll.add(new BigDecimal(solutionsDetailsVo.getRealTotal())); |
|
|
|
} |
|
|
|
rightAll = rightAll.add(bigDecimalVinAll); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 成交价 = 车款+订金
|
|
|
|
leftAll = leftAll.add(singleFinalPrice); |
|
|
|
rightAll = rightAll.add(bigDecimalVinAll); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 成交价 = 车款+订金
|
|
|
|
leftAll = leftAll.add(singleFinalPrice); |
|
|
|
rightAll = rightAll.add(bigDecimalVinAll); |
|
|
|
} |
|
|
|
if (leftAll.compareTo(rightAll) <= 0) { |
|
|
|
BaseVehicleStateDto baseVehicleStateDto = new BaseVehicleStateDto(); |
|
|
|
baseVehicleStateDto.setOperateType(BaseVehicleStateEnum.OperateTypeEnum.FIN_RQ.getTypeKey()); |
|
|
|
baseVehicleStateDto.setBusSid(finUncollectedReceivablesDetailed.getBusVinSid()); |
|
|
|
dtoList.add(baseVehicleStateDto); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
BigDecimal leftAll = unDecimalVinAll; |
|
|
|
BigDecimal rightAll = bigDecimalVinAll; |
|
|
|
if (leftAll.compareTo(rightAll) <= 0) { |
|
|
|
BaseVehicleStateDto baseVehicleStateDto = new BaseVehicleStateDto(); |
|
|
|
baseVehicleStateDto.setOperateType(BaseVehicleStateEnum.OperateTypeEnum.FIN_RQ.getTypeKey()); |
|
|
|
baseVehicleStateDto.setBusSid(finUncollectedReceivablesDetailed.getBusVinSid()); |
|
|
|
dtoList.add(baseVehicleStateDto); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|