Browse Source

完善结清管理生成应收、减免结转逻辑

master
fanzongzhe 8 months ago
parent
commit
4170fdf9da
  1. 4
      anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedFeign.java
  2. 7
      anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedFeignFallback.java
  3. 2
      anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/kingdee/voucher/CollectionVoucher.java
  4. 501
      anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/fincollectionconfirmation/FinCollectionConfirmationService.java
  5. 7
      anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedRest.java
  6. 6
      anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loansettleapply/LoanSettleApplyMapper.java
  7. 19
      anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loansettleapply/LoanSettleApplyMapper.xml
  8. 419
      anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loansettleapply/LoanSettleApplyService.java

4
anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedFeign.java

@ -96,4 +96,8 @@ public interface FinSelectedReceivablesDetailedFeign {
@ApiOperation("根据维修工单sid查询待审核和已审核的认款金额之和")
@GetMapping("/selRkByBillSid")
ResultBean<BigDecimal> selRkByBillSid(@RequestParam("billSid") String billSid);
@ApiOperation("删除")
@PostMapping("/delByList")
void delByList(@RequestBody List<FinSelectedReceivablesDetailed> list);
}

7
anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedFeignFallback.java

@ -99,4 +99,9 @@ public class FinSelectedReceivablesDetailedFeignFallback implements FinSelectedR
return null;
}
}
@Override
public void delByList(List<FinSelectedReceivablesDetailed> list) {
}
}

2
anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/kingdee/voucher/CollectionVoucher.java

@ -46,5 +46,7 @@ public class CollectionVoucher {
public BigDecimal amount;
@ApiModelProperty("备注")
public String remarks;
@ApiModelProperty("差额适用于结清时计算差额")
public BigDecimal balance;
}
}

501
anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/fincollectionconfirmation/FinCollectionConfirmationService.java

@ -215,6 +215,7 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl
private DocPdfComponent docPdfComponent;
@Autowired
private LoanRepaymentScheduleFeign loanRepaymentScheduleFeign;
private QueryWrapper<FinCollectionConfirmation> createQueryWrapper(FinCollectionConfirmationQuery query) {
// todo: 这里根据具体业务调整查询条件
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
@ -3909,7 +3910,8 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl
}
loanRepaymentHistoryFeign.saveHistoryByEntity(historyEntity);
}
if (v.getReceivablesName().equals("资方退还垫款")) {
//认资方退还垫款或者结清时资方逾期利息
if (v.getReceivablesName().equals("资方退还垫款") || v.getReceivablesName().equals("结清时资方逾期利息")) {
CollectionVoucher.CollectionVoucherDetail d = getReturnBackMoneyVoucher(v, collectionDate);
voucherDetails.add(d);
}
@ -4082,109 +4084,13 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl
}
}
}
if ("月还".equals(v.getReceivablesName())
|| "垫资方逾期利息".equals(v.getReceivablesName())
|| "资金占用费".equals(v.getReceivablesName())
|| "结清时资方逾期利息".equals(v.getReceivablesName())
|| "资方逾期利息".equals(v.getReceivablesName())
|| "名义价".equals(v.getReceivablesName())
|| "合同违约金".equals(v.getReceivablesName())
|| "其他费用".equals(v.getReceivablesName())
//认名义价、合同违约金、其他费用收款
if (v.getReceivablesName().equals("名义价") ||
v.getReceivablesName().equals("合同违约金") ||
v.getReceivablesName().equals("其他费用")
) {
BigDecimal unall = BigDecimal.ZERO;//应收
String busVinSid = "";
BigDecimal yAll = BigDecimal.ZERO;
FinUncollectedReceivablesDetailedJR finUncollectedReceivablesDetailedJR = finUncollectedReceivablesDetailedJRService.fetchBySid(v.getReceivablesSid());
if (finUncollectedReceivablesDetailedJR == null) {
LoanRepaymentPlanDetails loanRepaymentPlanDetails = baseMapper.selectByBss(v.getReceivablesSid());
if (loanRepaymentPlanDetails != null) {
busVinSid = loanRepaymentPlanDetails.getBusVinSid();
BigDecimal a1 = baseMapper.selectA1(busVinSid);
// BigDecimal a2 = baseMapper.selectA2(busVinSid);
List<String> stringList = baseMapper.selectBys(loanRepaymentPlanDetails.getBusVinSid());
stringList.removeAll(Collections.singleton(null));
BigDecimal a3 = BigDecimal.ZERO;
if (!stringList.isEmpty()) {
a3 = baseMapper.selectA3(stringList);
}
unall = unall.add(a1).add(a3);
List<String> unList = baseMapper.selectUnA(busVinSid);
unList.removeAll(Collections.singleton(null));
BigDecimal a4 = BigDecimal.ZERO;
if (!unList.isEmpty()) {
//已收
a4 = baseMapper.selectA4(unList);
}
BigDecimal a5 = BigDecimal.ZERO;
if (!stringList.isEmpty()) {
a5 = baseMapper.selectA5(stringList);
}
yAll = yAll.add(a4).add(a5);
}
} else {
LoanRepaymentPlanDetails loanRepaymentPlanDetails = baseMapper.selectByBss(finUncollectedReceivablesDetailedJR.getBusSid());
if (loanRepaymentPlanDetails != null) {
busVinSid = loanRepaymentPlanDetails.getBusVinSid();
List<String> stringList = baseMapper.selectBys(loanRepaymentPlanDetails.getBusVinSid());
stringList.removeAll(Collections.singleton(null));
BigDecimal a3 = BigDecimal.ZERO;
if (!stringList.isEmpty()) {
a3 = baseMapper.selectA3(stringList);
}
BigDecimal a1 = baseMapper.selectA1(busVinSid);
unall = unall.add(a1).add(a3);
List<String> unList = baseMapper.selectUnA(busVinSid);
//已收
unList.removeAll(Collections.singleton(null));
BigDecimal a4 = BigDecimal.ZERO;
if (!unList.isEmpty()) {
//已收
a4 = baseMapper.selectA4(unList);
}
BigDecimal a5 = BigDecimal.ZERO;
if (!stringList.isEmpty()) {
a5 = baseMapper.selectA5(stringList);
}
yAll = yAll.add(a4).add(a5);
}
}
if (yAll.compareTo(unall) >= 0) {
LoanSettleApply loanSettleApply = baseMapper.selectApply(busVinSid);
LoanSettleBankCost loanSettleBankCost = baseMapper.selectMainSid(loanSettleApply.getSid());
LoanFinBank loanFinBank = baseMapper.selectByBanks(loanSettleApply.getSaleOrderSid());
//推送出纳付款
FinPaymentrecordDto finPaymentrecordDto = new FinPaymentrecordDto();
finPaymentrecordDto.setApplySid("");
finPaymentrecordDto.setPayCompanySid("");
finPaymentrecordDto.setPayType(1);
finPaymentrecordDto.setCreateOrgSid(loanSettleApply.getUseOrgSid());
finPaymentrecordDto.setUseOrgSid(loanSettleApply.getUseOrgSid());
/*finPaymentrecordDto.setCostTypeKey("007");
finPaymentrecordDto.setCostTypeValue("垫款");
finPaymentrecordDto.setCostTitleKey("008");*/
finPaymentrecordDto.setCostTitleValue("资方结清款");
/* if(loanFinBank != null){
finPaymentrecordDto.setReceiveBank(loanFinBank.getBankCollectionAcc());
finPaymentrecordDto.setReceiveBankAccount(loanFinBank.getBankCollectionNum());
}*/
finPaymentrecordDto.setReceiveCompany("");
finPaymentrecordDto.setCost(loanSettleBankCost.getBankSettlePrice().toString());
finPaymentrecordDto.setAccountsReceive(loanSettleBankCost.getBankSettlePrice().toString());
finPaymentrecordDto.setBusSid(loanSettleApply.getSid());
finPaymentrecordDto.setPayCode("");
finPaymentrecordDto.setCreateBySid(loanSettleApply.getCreateBySid());
finPaymentrecordDto.setUpdateBySid(loanSettleApply.getCreateBySid());
finPaymentrecordDto.setRemarks(loanSettleApply.getRemarks());
finPaymentrecordDto.setPurchaseSystemSid("");
finPaymentrecordDto.setPurchaseSystemName("");
finPaymentrecordService.saveDto(finPaymentrecordDto).getData();
}
// CollectionVoucher.CollectionVoucherDetail d = getBalanceMoneyVoucher(v, collectionDate);
// voucherDetails.add(d);
}
});
//查询该申请已认款金额总数
@ -4221,6 +4127,95 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl
return rb.success().setMsg("款项确认成功");
}
//名义价其他费用推财务
// private CollectionVoucher.CollectionVoucherDetail getBalanceMoneyVoucher(FinSelectedReceivablesDetailedVo v, String collectionDate) {
// String planSid = "";
// CollectionVoucher.CollectionVoucherDetail voucherDetail = new CollectionVoucher.CollectionVoucherDetail();
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// FinUncollectedReceivablesDetailedJR jr = finUncollectedReceivablesDetailedJRService.fetchBySid(v.getReceivablesSid());
// if (jr != null) {
// planSid = jr.getBusSid();
// }
// LoanRepaymentPlanDetails planDetails = loanRepaymentPlanDetailsFeign.fetchDetails(planSid).getData();
// if (null != planDetails) {
// voucherDetail.setPayCostTitleValue(v.getReceivablesName());
// LoanRepaymentSchedule schedule = loanRepaymentScheduleFeign.fetchBySid(planDetails.getScheduleSid()).getData();
// if (null != schedule) {
// if (StringUtils.isNotBlank(schedule.getCwDeptNo())) {
// voucherDetail.setDeptCode(schedule.getCwDeptNo());
// }
// }
// String busVinSid = planDetails.getBusVinSid();
// BusSalesOrderVehicle busSalesOrderVehicle = busSalesOrderVehicleFeign.details(busVinSid).getData();
// if (null != busSalesOrderVehicle) {
// String customerNumber = "";
// //判断财务系统是否有客户
// Boolean aBoolean = finKingDeeFeignRest.customerExistState(busSalesOrderVehicle.getTemporaryNo()).getData();
// String linkNo = "";
// String customerName = "";
// BusSalesOrderBorrowerDetailsVo borrowerDetailsVo = busSalesOrderBorrowerFeign.fetchDetailsBySid(busSalesOrderVehicle.getBorrowerSid()).getData();
// if (!aBoolean) {
// // List<BdCustomer> bdCustomers = new ArrayList<>();
// BdCustomer bdCustomer = new BdCustomer();
// bdCustomer.setFNumber(busSalesOrderVehicle.getTemporaryNo());
// String salesOrderSid = planDetails.getSalesOrderSid();
// BusSalesOrder salesOrder = busSalesOrderFeign.fetchBySid(salesOrderSid).getData();
// bdCustomer.setFShortName(salesOrder.getContractNo());
// BasePurchaseSystemDetailsVo data = basePurchaseSystemFeign.fetchDetailsByDeptSid(salesOrder.getPurchaseSystemSid()).getData();
// bdCustomer.setTOrgIds(data.getOrgCode());
// if (StringUtils.isNotBlank(busSalesOrderVehicle.getLinkNo())) {
// String vinNo = busSalesOrderVehicle.getLinkNo();
// if (vinNo.length() > 8) {
// linkNo = vinNo.substring(vinNo.length() - 8);
// } else {
// linkNo = busSalesOrderVehicle.getLinkNo();
// }
// if (null != borrowerDetailsVo) {
// bdCustomer.setFName(borrowerDetailsVo.getBorrowerName() + linkNo);
// customerName = borrowerDetailsVo.getBorrowerName() + linkNo;
// }
// } else {
// if (null != borrowerDetailsVo) {
// bdCustomer.setFName(borrowerDetailsVo.getBorrowerName() + busSalesOrderVehicle.getTemporaryNo());
// customerName = borrowerDetailsVo.getBorrowerName() + busSalesOrderVehicle.getTemporaryNo();
// }
// }
// // bdCustomers.add(bdCustomer);
// ResultBean<String> resultBean = finKingDeeFeignRest.draftBdCustomer(bdCustomer);
// if (resultBean.getSuccess()) {
// customerNumber = bdCustomer.getFNumber();
// }
// } else {
// customerNumber = busSalesOrderVehicle.getTemporaryNo();
// if (StringUtils.isNotBlank(busSalesOrderVehicle.getLinkNo())) {
// String vinNo = busSalesOrderVehicle.getLinkNo();
// if (vinNo.length() > 8) {
// linkNo = vinNo.substring(vinNo.length() - 8);
// } else {
// linkNo = busSalesOrderVehicle.getLinkNo();
// }
// if (null != borrowerDetailsVo) {
// customerName = borrowerDetailsVo.getBorrowerName() + linkNo;
// }
// } else {
// if (null != borrowerDetailsVo) {
// customerName = borrowerDetailsVo.getBorrowerName() + busSalesOrderVehicle.getTemporaryNo();
// }
// }
// }
// voucherDetail.setCustomerCode(customerNumber);
// voucherDetail.setCustomerName(customerName);
// }
// try {
// voucherDetail.setDataTime(sdf.parse(collectionDate));
// } catch (ParseException e) {
// e.printStackTrace();
// }
// voucherDetail.setAmount(new BigDecimal(v.getSubscriptionMoney()));
// }
// return voucherDetail;ssss
//}
private CollectionVoucher.CollectionVoucherDetail getReturnBackMoneyVoucher(FinSelectedReceivablesDetailedVo v, String collectionDate) {
String planSid = "";
CollectionVoucher.CollectionVoucherDetail voucherDetail = new CollectionVoucher.CollectionVoucherDetail();
@ -4570,306 +4565,6 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl
return voucherDetail;
}
// public ResultBean rskCashierConfirm(String sid, String userSid) {
// ResultBean rb = ResultBean.fireFail();
// FinCollectionConfirmation confirmation = fetchBySid(sid);
// if (confirmation == null) {
// return rb.setMsg("该申请不存在");
// }
// if ("3".equals(confirmation.getAuditState())) {
// return rb.setMsg("该申请已审核通过,不允许重复操作");
// }
// if ("2".equals(confirmation.getAuditState())) {
// return rb.setMsg("该申请已驳回,不允许确认");
// }
// if ("4".equals(confirmation.getAuditState())) {
// return rb.setMsg("该申请已撤回,不允许确认");
// }
// String collectionTypeKey = confirmation.getCollectionTypeKey(); //收款方式
// confirmation.setAuditState(3);
// //与收款金额作比较:更新认款状态 1未认款/2部分认款/3已认款
// confirmation.setPaymentState(3);
// baseMapper.updateById(confirmation);
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// //===========================================
// //查询该申请下的所有待审核的款项明细
// BigDecimal subscriptionMoneyAll = new BigDecimal("0");
// List<FinSelectedReceivablesDetailedVo> finSelectedReceivablesDetailedVos = finSelectedReceivablesDetailedService.fetchByAuditState(sid, 1);
// if (finSelectedReceivablesDetailedVos.size() > 0) {
// FinCollectionConfirmation finalConfirmation = confirmation;
// finSelectedReceivablesDetailedVos.stream().forEach(v -> {
// //已选款项明细sid
// String selectSid = v.getSid();
// FinSelectedReceivablesDetailed finSelectedReceivablesDetailed = finSelectedReceivablesDetailedService.fetchBySid(selectSid);
// //更新已选款项明细的审核状态1待审核/2已驳回/3已审核
// finSelectedReceivablesDetailed.setAuditState(3);
// //更新审核时间
// finSelectedReceivablesDetailed.setAuditDate(DateUtil.today());
// finSelectedReceivablesDetailedService.updateById(finSelectedReceivablesDetailed);
// //推送间还认款记录
// if (v.getReceivablesName().equals("月还")) {
// LoanRepaymentHistory historyEntity = new LoanRepaymentHistory();
// historyEntity.setPlanDetailSid(v.getReceivablesSid());
// LoanRepaymentPlanDetails planDetails = loanRepaymentPlanDetailsFeign.fetchDetails(v.getReceivablesSid()).getData();
// if (null != planDetails) {
// historyEntity.setScheduleSid(planDetails.getScheduleSid());
// historyEntity.setSkdBillNo(finalConfirmation.getBillNo());
// historyEntity.setUpdateTime(new DateTime());
// historyEntity.setUpdateState("1");
// historyEntity.setDataTime(new DateTime());
// historyEntity.setBuckle("审核通过");
// historyEntity.setBuckleKey("003");
// historyEntity.setActualMoney(new BigDecimal(v.getSubscriptionMoney()));
// try {
// Date collDate = sdf.parse(finalConfirmation.getCollectionDate());
// historyEntity.setActualDate(collDate);
// if (planDetails.getDueDate().compareTo(collDate) >= 0) {
// //未逾期
// Calendar cal_1 = Calendar.getInstance();// 使用默认时区和语言环境获得一个日历
// cal_1.setTime(planDetails.getDueDate());
// cal_1.add(Calendar.DAY_OF_MONTH, -1);
// historyEntity.setPrepareDate(cal_1.getTime());
// } else {
// //已逾期
// historyEntity.setPrepareDate(new DateTime());
// }
// } catch (ParseException e) {
// e.printStackTrace();
// }
// historyEntity.setReturnWay("间还");
// historyEntity.setReturnWayKey("02");
// historyEntity.setPaymentState("待转付");
// historyEntity.setPaymentStateKey("001");
// }
// loanRepaymentHistoryFeign.saveHistoryByEntity(historyEntity);
// }
// if (v.getReceivablesName().equals("资方退还垫款")) {
// pushReturnVoucher(v, sid);
// }
// //推送间还待转付列表
// if (v.getReceivablesName().equals("月还") || v.getReceivablesName().equals("资方逾期利息")) {
// String planSid = "";
// if (v.getReceivablesName().equals("月还")) {
// planSid = v.getReceivablesSid();
// } else {
// FinUncollectedReceivablesDetailedJR jr = finUncollectedReceivablesDetailedJRService.fetchBySid(v.getReceivablesSid());
// if (jr != null) {
// planSid = jr.getBusSid();
// }
// }
// LoanRepaymentPlanDetails planDetails = loanRepaymentPlanDetailsFeign.fetchDetails(planSid).getData();
// if (null != planDetails) {
// if (v.getReceivablesName().equals("月还")) {
// if (null != planDetails.getPaymentMoney()) {
// if (planDetails.getPaymentMoney().compareTo(BigDecimal.ZERO) == 1) {
// BigDecimal paymentMoney = planDetails.getPaymentMoney();
// String subscriptionMoney = v.getSubscriptionMoney();
// BigDecimal subtract = paymentMoney.subtract(new BigDecimal(subscriptionMoney));
// planDetails.setPaymentMoney(subtract);
// loanRepaymentPlanDetailsFeign.updateByEntity(planDetails);
// String orderSid = planDetails.getSalesOrderSid();
// ResultBean<LoanFinBank> bankResultBean = loanFinBankFeign.reAdvancesByOrderSid(orderSid);
// if (bankResultBean.getData() != null) {
// LoanFinBank loanFinBank = bankResultBean.getData();
// if (null != loanFinBank.getReAdvances()) {
// if (loanFinBank.getReAdvances() == 1) {
// FinUncollectedReceivablesDetailedJR jr = new FinUncollectedReceivablesDetailedJR();
// jr.setCreateBySid(userSid);
// SysUserVo userVo = sysUserFeign.fetchBySid(userSid).getData();
// jr.setCreateByName(userVo.getName());
// jr.setBusSid(planSid);
// jr.setCurrentReceivableMoney(new BigDecimal(v.getSubscriptionMoney()));
// jr.setReveivableMoney(new BigDecimal(v.getSubscriptionMoney()));
// jr.setPayCostTitleKey("007");
// jr.setPayCostTitleValue("资方退还垫款");
// jr.setOrgSidPath(planDetails.getOrgSidPath());
// jr.setUseOrgName(planDetails.getUseOrgName());
// jr.setUseOrgSid(planDetails.getUseOrgSid());
// jr.setStaffDeptName(planDetails.getDept());
// jr.setStaffName(planDetails.getStaffName());
// jr.setStaffDeptSid(planDetails.getDeptSid());
// jr.setStaffUserSid(planDetails.getSalesUserSid());
// finUncollectedReceivablesDetailedJRService.insert(jr);
// }
// }
// }
// }
// }
// }
// if (v.getReceivablesName().equals("资方逾期利息")) {
// if (null != planDetails.getPaymentInterest()) {
// if (planDetails.getPaymentInterest().compareTo(BigDecimal.ZERO) == 1) {
// BigDecimal paymentInterest = planDetails.getPaymentInterest();
// String subscriptionMoney = v.getSubscriptionMoney();
// BigDecimal subtract = paymentInterest.subtract(new BigDecimal(subscriptionMoney));
// planDetails.setPaymentInterest(subtract);
// BigDecimal paymentMoney = planDetails.getPaymentMoney();
// BigDecimal subtract2 = paymentMoney.subtract(new BigDecimal(subscriptionMoney));
// planDetails.setPaymentMoney(subtract2);
// loanRepaymentPlanDetailsFeign.updateByEntity(planDetails);
// String orderSid = planDetails.getSalesOrderSid();
// ResultBean<LoanFinBank> bankResultBean = loanFinBankFeign.reAdvancesByOrderSid(orderSid);
// if (bankResultBean.getData() != null) {
// LoanFinBank loanFinBank = bankResultBean.getData();
// if (null != loanFinBank.getReAdvances()) {
// if (loanFinBank.getReAdvances() == 1) {
// FinUncollectedReceivablesDetailedJR jr = new FinUncollectedReceivablesDetailedJR();
// jr.setCreateBySid(userSid);
// SysUserVo userVo = sysUserFeign.fetchBySid(userSid).getData();
// jr.setCreateByName(userVo.getName());
// jr.setBusSid(planSid);
// jr.setCurrentReceivableMoney(new BigDecimal(v.getSubscriptionMoney()));
// jr.setReveivableMoney(new BigDecimal(v.getSubscriptionMoney()));
// jr.setPayCostTitleKey("007");
// jr.setPayCostTitleValue("资方退还垫款");
// jr.setOrgSidPath(planDetails.getOrgSidPath());
// jr.setUseOrgName(planDetails.getUseOrgName());
// jr.setUseOrgSid(planDetails.getUseOrgSid());
// jr.setStaffDeptName(planDetails.getDept());
// jr.setStaffName(planDetails.getStaffName());
// jr.setStaffDeptSid(planDetails.getDeptSid());
// jr.setStaffUserSid(planDetails.getSalesUserSid());
// finUncollectedReceivablesDetailedJRService.insert(jr);
// }
// }
// }
// }
// }
// }
// }
// //推送间还月还收款凭证
// pushIndirectVoucher(v, sid);
// }
// //认资金占用费消减平台资金占用费
// if (v.getReceivablesName().equals("资金占用费")) {
// //推送资金占用费计提凭证
// pushFundVoucher(v, sid);
// //推送资金占用费出纳确认后
// pushFeeVoucher(v, sid);
// }
// if ("月还".equals(v.getReceivablesName())
// || "垫资方逾期利息".equals(v.getReceivablesName())
// || "资金占用费".equals(v.getReceivablesName())
// || "结清时资方逾期利息".equals(v.getReceivablesName())
// || "资方逾期利息".equals(v.getReceivablesName())
// || "名义价".equals(v.getReceivablesName())
// || "合同违约金".equals(v.getReceivablesName())
// || "其他费用".equals(v.getReceivablesName())
// ) {
// BigDecimal unall = BigDecimal.ZERO;//应收
// String busVinSid = "";
// BigDecimal yAll = BigDecimal.ZERO;
// FinUncollectedReceivablesDetailedJR finUncollectedReceivablesDetailedJR = finUncollectedReceivablesDetailedJRService.fetchBySid(v.getReceivablesSid());
// if (finUncollectedReceivablesDetailedJR == null) {
// LoanRepaymentPlanDetails loanRepaymentPlanDetails = baseMapper.selectByBss(v.getReceivablesSid());
// if (loanRepaymentPlanDetails != null) {
// busVinSid = loanRepaymentPlanDetails.getBusVinSid();
// BigDecimal a1 = baseMapper.selectA1(busVinSid);
//// BigDecimal a2 = baseMapper.selectA2(busVinSid);
// List<String> stringList = baseMapper.selectBys(loanRepaymentPlanDetails.getBusVinSid());
// stringList.removeAll(Collections.singleton(null));
// BigDecimal a3 = BigDecimal.ZERO;
// if (!stringList.isEmpty()) {
// a3 = baseMapper.selectA3(stringList);
// }
// unall = unall.add(a1).add(a3);
// List<String> unList = baseMapper.selectUnA(busVinSid);
// unList.removeAll(Collections.singleton(null));
// BigDecimal a4 = BigDecimal.ZERO;
// if (!unList.isEmpty()) {
// //已收
// a4 = baseMapper.selectA4(unList);
// }
// BigDecimal a5 = BigDecimal.ZERO;
// if (!stringList.isEmpty()) {
// a5 = baseMapper.selectA5(stringList);
// }
//
// yAll = yAll.add(a4).add(a5);
// }
//
// } else {
// LoanRepaymentPlanDetails loanRepaymentPlanDetails = baseMapper.selectByBss(finUncollectedReceivablesDetailedJR.getBusSid());
// if (loanRepaymentPlanDetails != null) {
// busVinSid = loanRepaymentPlanDetails.getBusVinSid();
// List<String> stringList = baseMapper.selectBys(loanRepaymentPlanDetails.getBusVinSid());
// stringList.removeAll(Collections.singleton(null));
// BigDecimal a3 = BigDecimal.ZERO;
// if (!stringList.isEmpty()) {
// a3 = baseMapper.selectA3(stringList);
// }
// BigDecimal a1 = baseMapper.selectA1(busVinSid);
// unall = unall.add(a1).add(a3);
// List<String> unList = baseMapper.selectUnA(busVinSid);
// //已收
// unList.removeAll(Collections.singleton(null));
// BigDecimal a4 = BigDecimal.ZERO;
// if (!unList.isEmpty()) {
// //已收
// a4 = baseMapper.selectA4(unList);
// }
// BigDecimal a5 = BigDecimal.ZERO;
// if (!stringList.isEmpty()) {
// a5 = baseMapper.selectA5(stringList);
// }
// yAll = yAll.add(a4).add(a5);
// }
// }
// if (yAll.compareTo(unall) >= 0) {
// LoanSettleApply loanSettleApply = baseMapper.selectApply(busVinSid);
// LoanSettleBankCost loanSettleBankCost = baseMapper.selectMainSid(loanSettleApply.getSid());
// LoanFinBank loanFinBank = baseMapper.selectByBanks(loanSettleApply.getSaleOrderSid());
// //推送出纳付款
// FinPaymentrecordDto finPaymentrecordDto = new FinPaymentrecordDto();
// finPaymentrecordDto.setApplySid("");
// finPaymentrecordDto.setPayCompanySid("");
// finPaymentrecordDto.setPayType(1);
// finPaymentrecordDto.setCreateOrgSid(loanSettleApply.getUseOrgSid());
// finPaymentrecordDto.setUseOrgSid(loanSettleApply.getUseOrgSid());
// /*finPaymentrecordDto.setCostTypeKey("007");
// finPaymentrecordDto.setCostTypeValue("垫款");
// finPaymentrecordDto.setCostTitleKey("008");*/
// finPaymentrecordDto.setCostTitleValue("资方结清款");
// /* if(loanFinBank != null){
// finPaymentrecordDto.setReceiveBank(loanFinBank.getBankCollectionAcc());
// finPaymentrecordDto.setReceiveBankAccount(loanFinBank.getBankCollectionNum());
// }*/
//
// finPaymentrecordDto.setReceiveCompany("");
// finPaymentrecordDto.setCost(loanSettleBankCost.getBankSettlePrice().toString());
// finPaymentrecordDto.setAccountsReceive(loanSettleBankCost.getBankSettlePrice().toString());
// finPaymentrecordDto.setBusSid(loanSettleApply.getSid());
// finPaymentrecordDto.setPayCode("");
// finPaymentrecordDto.setCreateBySid(loanSettleApply.getCreateBySid());
// finPaymentrecordDto.setUpdateBySid(loanSettleApply.getCreateBySid());
// finPaymentrecordDto.setRemarks(loanSettleApply.getRemarks());
// finPaymentrecordDto.setPurchaseSystemSid("");
// finPaymentrecordDto.setPurchaseSystemName("");
// finPaymentrecordService.saveDto(finPaymentrecordDto).getData();
//
// }
//
//
// }
// });
// //查询该申请已认款金额总数
// subscriptionMoneyAll = finSelectedReceivablesDetailedVos.stream().map(FinSelectedReceivablesDetailedVo::getSubscriptionMoney).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add);
// }
// confirmation = fetchBySid(sid);
// //更新收款申请的余额以及审核状态
// BigDecimal balanceBigDecimal = confirmation.getCollectionMoney().subtract(subscriptionMoneyAll);
// confirmation.setBalance(balanceBigDecimal);
// //查询当前登录人信息并更新审核人和审核时间
// ResultBean<SysUserVo> userVoResultBean = sysUserFeign.fetchBySid(userSid);
// if (userVoResultBean.getData() != null) {
// confirmation.setConfirmName(userVoResultBean.getData().getName());
// }
// confirmation.setConfirmDate(DateUtil.today());
// confirmation.setConfirmNameSid(userSid);
// baseMapper.updateById(confirmation);
// return rb.success().setMsg("款项确认成功");
// }
private void pushFundVoucher(FinSelectedReceivablesDetailedVo v, String sid) {
String planSid = "";

7
anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedRest.java

@ -125,4 +125,11 @@ public class FinSelectedReceivablesDetailedRest implements FinSelectedReceivable
return finSelectedReceivablesDetailedService.selRkByBillSid(billSid);
}
@Override
public void delByList(List<FinSelectedReceivablesDetailed> list) {
for (FinSelectedReceivablesDetailed detailed : list) {
finSelectedReceivablesDetailedService.deleteBySid(detailed.getSid());
}
}
}

6
anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loansettleapply/LoanSettleApplyMapper.java

@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrder;
import com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectedReceivablesDetailed;
import com.yxt.anrui.fin.api.finuncollectedreceivablesdetailedjr.FinUncollectedReceivablesDetailedJR;
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.LoanRepaymentHistory;
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetails;
import com.yxt.anrui.riskcenter.api.loansettleapply.LoanSettleApply;
import com.yxt.anrui.riskcenter.api.loansettleapply.LoanSettleApplyVo;
@ -76,4 +78,8 @@ public interface LoanSettleApplyMapper extends BaseMapper<LoanSettleApply> {
void updatePaymentStateByBusVinSid(@Param("busVinSid") String busVinSid);
int selectNum(String bill);
List<FinSelectedReceivablesDetailed> selJMSelectedByBusVinSid(@Param("busVinSid") String busVinSid);
List<LoanRepaymentHistory> selLoanHistories(@Param("busVinSid") String busVinSid);
}

19
anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loansettleapply/LoanSettleApplyMapper.xml

@ -352,4 +352,23 @@ FROM (
from loan_settle_apply
where billNo LIKE concat(#{bill}, '%')
</select>
<select id="selJMSelectedByBusVinSid"
resultType="com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectedReceivablesDetailed">
SELECT
s.*
FROM
anrui_fin.fin_selected_receivables_detailed AS s
LEFT JOIN anrui_fin.fin_uncollected_receivables_detailed_jr as jr ON s.receivablesSid = jr.sid
LEFT JOIN anrui_riskcenter.loan_repayment_plan_details as p ON jr.busSid = p.sid
WHERE s.remarks = '结清减免' AND p.busVinSid = #{busVinSid}
</select>
<select id="selLoanHistories"
resultType="com.yxt.anrui.riskcenter.api.loanrepaymenthistory.LoanRepaymentHistory">
SELECT
*
FROM
loan_repayment_history as h
LEFT JOIN loan_repayment_plan_details as p ON h.planDetailSid = p.sid
WHERE p.busVinSid = #{busVinSid} AND h.buckleKey != '002' AND h.buckleKey != '003' AND h.actualMoney < 0
</select>
</mapper>

419
anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loansettleapply/LoanSettleApplyService.java

@ -173,6 +173,7 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
private MessageListFeign messageListFeign;
@Autowired
private DocPdfComponent docPdfComponent;
public PagerVo<LoanSettleApplyVo> listPageVo(PagerQuery<LoanSettleApplyQuery> pq) {
LoanSettleApplyQuery query = pq.getParams();
QueryWrapper<LoanSettleApply> qw = new QueryWrapper<>();
@ -379,6 +380,20 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
String orgPath = query.getOrgPath();
String userSid = query.getUserSid();
if (StringUtils.isBlank(sid)) {
//校验选择的结清车辆是否存在以往的带结清减免标识的实收记录,若存在则删除
List<FinSelectedReceivablesDetailed> list = baseMapper.selJMSelectedByBusVinSid(busVinSid);
if (null != list) {
if (!list.isEmpty() && list.size() > 0) {
finSelectedReceivablesDetailedFeign.delByList(list);
}
}
//资方划扣还款明细中存在结清车辆转付负数的还款记录时,不能发起结清申请。
List<LoanRepaymentHistory> histories = baseMapper.selLoanHistories(busVinSid);
if (null != histories) {
if (!histories.isEmpty() && histories.size() > 0) {
return rb.setMsg("请将结清车辆间还款项,在平台上操作完成转付资方数据更新后,再发起结清申请审批!");
}
}
//新增初始化
//根据用户查询发起人、发起部门、发起日期为当前日期
String deptName = "";
@ -474,26 +489,7 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
if (StringUtils.isNotBlank(loanSettleApply.getNodeState())) {
if (loanSettleApply.getNodeState().equals("已办结")) {
if (loanSettleApply.getState().intValue() == 0) {
//获取公司减免情况
BigDecimal amountTo = BigDecimal.ZERO;
if (loanSettleApply.getTrueReduction() == 1) {
LoanSettleCompanyReduction reduction = loanSettleCompanyReductionService.selectByMainSid(sid);
if (null != reduction) {
if (null != reduction.getAmountTo()) {
amountTo = reduction.getAmountTo();
}
}
} else {
loanSettleCompanyCost = loanSettleCompanyCostService.selectByMainSid(sid);
if (null != loanSettleCompanyCost) {
if (null != loanSettleCompanyCost.getSettleAll()) {
amountTo = loanSettleCompanyCost.getSettleAll();
}
}
}
if (amountTo.compareTo(BigDecimal.ZERO) >= 0) {
loanSettleApplyDetailsVo.setConfirmAtn(true);
}
loanSettleApplyDetailsVo.setConfirmAtn(true);
}
}
}
@ -829,12 +825,12 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
}
//生成结清应收
pushNewUnLists(loanSettleApply);
//减免资金占用费、贷款保证金扣罚、其他费用应收
reliefMoney(loanSettleApply);
if (amountTo.compareTo(BigDecimal.ZERO) <= 0) {
//减免后结清合计 <= 0
//结转剩余保证金
carryForward(loanSettleApply);
//减免剩余应收
reliefMoney(loanSettleApply);
//设置结清申请的“客户结清确认”状态为是
loanSettleApply.setState(1);
//更新车辆表结清状态
@ -907,6 +903,7 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
}
}
}
FinUncollectedReceivablesDetailedJR jr2 = finUncollectedReceivablesDetailedJRFeign.getUnJrByPayCostTitleKeyAndBusSid("009", planDetailsSid).getData();
if (null != jr2) {
if (null != loanSettleCompanyCost.getCompanyNominalPrice()) {
@ -959,18 +956,18 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
}
}
}
BigDecimal otherAmount = BigDecimal.ZERO;
BigDecimal otherAmountJM = BigDecimal.ZERO;
BigDecimal otherAmountMoney = BigDecimal.ZERO;
// BigDecimal otherAmountJM = BigDecimal.ZERO;
// BigDecimal otherAmountMoney = BigDecimal.ZERO;
if (null != loanSettleCompanyCost.getCompanyOtherPrice()) {
otherAmount = loanSettleCompanyCost.getCompanyOtherPrice();
otherAmountMoney = loanSettleCompanyCost.getCompanyOtherPrice();
}
if (null != companyReduction) {
if (null != companyReduction.getOtherCost()) {
otherAmountJM = companyReduction.getOtherCost();
}
}
otherAmountMoney = otherAmount.subtract(otherAmountJM);
// if (null != companyReduction) {
// if (null != companyReduction.getOtherCost()) {
// otherAmountJM = companyReduction.getOtherCost();
// }
// }
// otherAmountMoney = otherAmount.subtract(otherAmountJM);
FinUncollectedReceivablesDetailedJR jr4 = finUncollectedReceivablesDetailedJRFeign.getUnJrByPayCostTitleKeyAndBusSid("011", planDetailsSid).getData();
if (null != jr4) {
jr4.setReveivableMoney(otherAmountMoney);
@ -993,6 +990,33 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
list.add(jr);
}
}
FinUncollectedReceivablesDetailedJR jr5 = finUncollectedReceivablesDetailedJRFeign.getUnJrByPayCostTitleKeyAndBusSid("013", planDetailsSid).getData();
if (null != jr5) {
if (null != loanSettleCompanyCost.getBankOverInterest()) {
jr5.setReveivableMoney(loanSettleCompanyCost.getBankOverInterest());
updateList.add(jr5);
}
} else {
if (loanSettleCompanyCost.getDeductionAmount() != null) {
if (loanSettleCompanyCost.getDeductionAmount().compareTo(BigDecimal.ZERO) > 0) {
//贷款保证金扣罚
FinUncollectedReceivablesDetailedJR jr = new FinUncollectedReceivablesDetailedJR();
jr.setBusSid(planDetails.getSid());
jr.setReveivableMoney(loanSettleCompanyCost.getDeductionAmount());
jr.setPayCostTitleKey("013");
jr.setPayCostTitleValue("贷款保证金扣罚");
jr.setOrgSidPath(planDetails.getOrgSidPath());
jr.setUseOrgName(planDetails.getUseOrgName());
jr.setUseOrgSid(planDetails.getUseOrgSid());
jr.setStaffDeptName(planDetails.getDept());
jr.setStaffName(planDetails.getStaffName());
jr.setStaffDeptSid(planDetails.getDeptSid());
jr.setStaffUserSid(planDetails.getSalesUserSid());
list.add(jr);
}
}
}
list.removeAll(Collections.singleton(null));
updateList.removeAll(Collections.singleton(null));
if (!list.isEmpty() && list.size() > 0) {
@ -1012,6 +1036,7 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
BigDecimal amountTo = BigDecimal.ZERO; // 资方结清合计
String busVinSid = loanSettleApply.getBusVinSid();
List<LoanRepaymentHistory> histories = new ArrayList<>();//还款记录
List<LoanRepaymentPlanDetails> updatePsList = new ArrayList<>();//还款计划明细集合
List<FinSelectedReceivablesDetailed> selectList = new ArrayList<>();
LoanRepaymentPlanDetails planDetails = baseMapper.selectByBusVinSidAndDesc(loanSettleApply.getBusVinSid());
String scheduleSid = planDetails.getScheduleSid();
@ -1052,6 +1077,7 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
for (PlanNoReturnMoney m : p) {
if (deposit.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal money = new BigDecimal(m.getMoney());
BigDecimal mm = BigDecimal.ZERO;
String sid = m.getSid();
String mSid = m.getMSid();
LoanRepaymentHistory history = new LoanRepaymentHistory();
@ -1063,19 +1089,31 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
history.setBuckleKey("003");
history.setBuckle("审核通过");
history.setReturnWayKey("04");
history.setReturnWay("结转");
history.setReturnWay("贷款保证金抵顶");
history.setPayState(0);
history.setPlanDetailSid(sid);
history.setScheduleSid(mSid);
if (deposit.compareTo(money) >= 0) {
mm = money;
history.setActualMoney(money);
histories.add(history);
deposit = deposit.subtract(money);
} else {
mm = deposit;
history.setActualMoney(deposit);
histories.add(history);
deposit = BigDecimal.ZERO;
}
LoanRepaymentPlanDetails details = loanRepaymentPlanDetailsService.fetchBySid(sid);
if (null != details) {
if (null != details.getPaymentMoney()) {
BigDecimal paymentMoney = details.getPaymentMoney();
if (paymentMoney.compareTo(BigDecimal.ZERO) > 0) {
details.setPaymentMoney(paymentMoney.subtract(mm));
updatePsList.add(details);
}
}
}
}
}
}
@ -1088,17 +1126,20 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
for (PlanNoReturnMoney m : p) {
if (deposit.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal money = new BigDecimal(m.getMoney());
BigDecimal mm = BigDecimal.ZERO;
String sid = m.getSid();
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed();
fin.setCreateBySid(userSid);
fin.setRemarks("结转");
fin.setRemarks("贷款保证金抵顶");
fin.setVIN(planDetails.getVinNo());
fin.setUseOrgSid(planDetails.getUseOrgSid());
fin.setReceivablesName("资方逾期利息");
if (deposit.compareTo(money) >= 0) {
mm = money;
fin.setSubscriptionMoney(money);
deposit = deposit.subtract(money);
} else {
mm = deposit;
fin.setSubscriptionMoney(deposit);
deposit = BigDecimal.ZERO;
}
@ -1110,6 +1151,18 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
fin.setUseOrgName(planDetails.getUseOrgName());
fin.setOrgSidPath(loanSettleApply.getOrgSidPath());
selectList.add(fin);
LoanRepaymentPlanDetails details = loanRepaymentPlanDetailsService.fetchBySid(sid);
if (null != details) {
if (null != details.getPaymentInterest()) {
BigDecimal paymentInterest = details.getPaymentInterest();
BigDecimal paymentMoney = details.getPaymentMoney();
if (paymentInterest.compareTo(BigDecimal.ZERO) > 0) {
details.setPaymentMoney(paymentMoney.subtract(mm));
details.setPaymentInterest(paymentInterest.subtract(mm));
updatePsList.add(details);
}
}
}
}
}
}
@ -1120,7 +1173,7 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
BigDecimal money = new BigDecimal(p.getMoney());
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed();
fin.setCreateBySid(planDetails.getSalesUserSid());
fin.setRemarks("结转");
fin.setRemarks("贷款保证金抵顶");
fin.setVIN(planDetails.getVinNo());
fin.setUseOrgSid(planDetails.getUseOrgSid());
fin.setReceivablesName("结清时资方逾期利息");
@ -1149,7 +1202,7 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
BigDecimal money = new BigDecimal(p.getMoney());
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed();
fin.setCreateBySid(planDetails.getSalesUserSid());
fin.setRemarks("结转");
fin.setRemarks("贷款保证金抵顶");
fin.setVIN(planDetails.getVinNo());
fin.setUseOrgSid(planDetails.getUseOrgSid());
fin.setReceivablesName("名义价");
@ -1178,7 +1231,7 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
BigDecimal money = new BigDecimal(p.getMoney());
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed();
fin.setCreateBySid(planDetails.getSalesUserSid());
fin.setRemarks("结转");
fin.setRemarks("贷款保证金抵顶");
fin.setVIN(planDetails.getVinNo());
fin.setUseOrgSid(planDetails.getUseOrgSid());
fin.setReceivablesName("合同违约金");
@ -1207,7 +1260,7 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
BigDecimal money = new BigDecimal(p.getMoney());
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed();
fin.setCreateBySid(planDetails.getSalesUserSid());
fin.setRemarks("结转");
fin.setRemarks("贷款保证金抵顶");
fin.setVIN(planDetails.getVinNo());
fin.setUseOrgSid(planDetails.getUseOrgSid());
fin.setReceivablesName("其他费用");
@ -1240,7 +1293,7 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
BigDecimal money = new BigDecimal(m.getMoney());
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed();
fin.setCreateBySid(userSid);
fin.setRemarks("结转");
fin.setRemarks("贷款保证金抵顶");
fin.setVIN(planDetails.getVinNo());
fin.setUseOrgSid(planDetails.getUseOrgSid());
fin.setReceivablesName("资金占用费");
@ -1270,6 +1323,10 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
if (selectList.size() > 0 && !selectList.isEmpty()) {
ResultBean resultBean = finSelectedReceivablesDetailedFeign.saveAll(selectList);
}
updatePsList.removeAll(Collections.singleton(null));
if (!updatePsList.isEmpty() && updatePsList.size() > 0) {
loanRepaymentPlanDetailsService.updateList(updatePsList);
}
}
//--------------------------------- 减免 ----------------------------
@ -1285,224 +1342,102 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
planDetails = baseMapper.selectMainPeriodByBusVinSid(loanSettleApply.getBusVinSid());
}
String planDetailsSid = planDetails.getSid();
//资金占用费减免费用
BigDecimal fundJM = BigDecimal.ZERO;
//其他费用减免费用
BigDecimal depositJM = BigDecimal.ZERO;
//贷款保证金减免费用
BigDecimal otherJM = BigDecimal.ZERO;
LoanSettleCompanyReduction reduction = loanSettleCompanyReductionService.selectByMainSid(loanSettleApply.getSid());
if (null != reduction) {
if (null != reduction.getFundPenalty()) {
fundJM = reduction.getFundPenalty();
}
if (null != reduction.getDepositPenalty()) {
depositJM = reduction.getDepositPenalty();
}
if (null != reduction.getOtherCost()) {
otherJM = reduction.getOtherCost();
}
}
//资金占用费
List<PlanNoReturnMoney> p = baseMapper.selNoReturnJrMoneyByBusVinSidAndKeyDesc(busVinSid, "006");
p.removeAll(Collections.singleton(null));
if (!p.isEmpty() && p.size() > 0) {
for (PlanNoReturnMoney m : p) {
BigDecimal money = new BigDecimal(m.getMoney());
if (fundJM.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal money = new BigDecimal(m.getMoney());
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed();
fin.setCreateBySid(userSid);
fin.setRemarks("结清减免");
fin.setVIN(planDetails.getVinNo());
fin.setUseOrgSid(planDetails.getUseOrgSid());
fin.setReceivablesName("资金占用费");
if (money.compareTo(fundJM) >= 0) {
fin.setSubscriptionMoney(fundJM);
} else {
fin.setSubscriptionMoney(money);
}
fin.setSubscriptionDate(DateUtil.today());
fin.setAuditState(3);
fin.setAuditDate(DateUtil.today());
fin.setReceivablesSid(m.getJrSid());
fin.setKxState("01");
fin.setUseOrgName(planDetails.getUseOrgName());
fin.setOrgSidPath(loanSettleApply.getOrgSidPath());
selectList.add(fin);
fundJM = fundJM.subtract(money);
}
}
}
//贷款保证金扣罚
PlanNoReturnMoney p3 = baseMapper.selectNoReturnMoneyByType(planDetailsSid, "贷款保证金扣罚");
if (null != p3) {
if (depositJM.compareTo(BigDecimal.ZERO) > 0) {
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed();
fin.setCreateBySid(userSid);
fin.setRemarks("减免");
fin.setCreateBySid(planDetails.getSalesUserSid());
fin.setRemarks("结清减免");
fin.setVIN(planDetails.getVinNo());
fin.setUseOrgSid(planDetails.getUseOrgSid());
fin.setReceivablesName("资金占用费");
fin.setSubscriptionMoney(money);
fin.setReceivablesName("贷款保证金扣罚");
fin.setSubscriptionMoney(depositJM);
fin.setSubscriptionDate(DateUtil.today());
fin.setAuditState(3);
fin.setAuditDate(DateUtil.today());
fin.setReceivablesSid(m.getJrSid());
fin.setReceivablesSid(p3.getJrSid());
fin.setKxState("01");
fin.setPurchaseSystemSid("");
fin.setPurchaseSystemName("");
fin.setStaffUserSid("");
fin.setUseOrgName(planDetails.getUseOrgName());
fin.setOrgSidPath(loanSettleApply.getOrgSidPath());
selectList.add(fin);
}
}
//月还
List<PlanNoReturnMoney> p1 = baseMapper.selPlansNoReturnMoneyByBusVinSidDesc(busVinSid);
p1.removeAll(Collections.singleton(null));
if (!p1.isEmpty() && p1.size() > 0) {
for (PlanNoReturnMoney m : p1) {
BigDecimal money = new BigDecimal(m.getMoney());
String sid = m.getSid();
String mSid = m.getMSid();
LoanRepaymentHistory history = new LoanRepaymentHistory();
history.setCreateBySid(userSid);
history.setDataTime(new Date());
history.setUpdateState("1");
history.setUpdateTime(new Date());
history.setActualDate(new Date());
history.setBuckleKey("003");
history.setBuckle("审核通过");
history.setReturnWayKey("05");
history.setReturnWay("减免");
history.setPayState(0);
history.setPlanDetailSid(sid);
history.setScheduleSid(mSid);
history.setActualMoney(money);
histories.add(history);
}
}
//垫资方逾期利息
List<PlanNoReturnMoney> p2 = baseMapper.selNoReturnJrMoneyByBusVinSidAndKeyDesc(busVinSid, "005");
p2.removeAll(Collections.singleton(null));
if (!p2.isEmpty() && p2.size() > 0) {
for (PlanNoReturnMoney m : p2) {
BigDecimal money = new BigDecimal(m.getMoney());
String sid = m.getSid();
//其他费用
PlanNoReturnMoney p6 = baseMapper.selectNoReturnMoneyByType(planDetailsSid, "其他费用");
if (null != p6) {
if (otherJM.compareTo(BigDecimal.ZERO) > 0) {
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed();
fin.setCreateBySid(userSid);
fin.setRemarks("减免");
fin.setCreateBySid(planDetails.getSalesUserSid());
fin.setRemarks("结清减免");
fin.setVIN(planDetails.getVinNo());
fin.setUseOrgSid(planDetails.getUseOrgSid());
fin.setReceivablesName("资方逾期利息");
fin.setSubscriptionMoney(money);
fin.setReceivablesName("其他费用");
fin.setSubscriptionMoney(otherJM);
fin.setSubscriptionDate(DateUtil.today());
fin.setAuditState(3);
fin.setAuditDate(DateUtil.today());
fin.setReceivablesSid(m.getJrSid());
fin.setReceivablesSid(p6.getJrSid());
fin.setKxState("01");
fin.setPurchaseSystemSid("");
fin.setPurchaseSystemName("");
fin.setStaffUserSid("");
fin.setUseOrgName(planDetails.getUseOrgName());
fin.setOrgSidPath(loanSettleApply.getOrgSidPath());
selectList.add(fin);
}
}
//资方逾期利息
PlanNoReturnMoney p3 = baseMapper.selectNoReturnMoneyByType(planDetailsSid, "结清时资方逾期利息");
if (null != p3) {
BigDecimal money = new BigDecimal(p3.getMoney());
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed();
fin.setCreateBySid(planDetails.getSalesUserSid());
fin.setRemarks("减免");
fin.setVIN(planDetails.getVinNo());
fin.setUseOrgSid(planDetails.getUseOrgSid());
fin.setReceivablesName("结清时资方逾期利息");
fin.setSubscriptionMoney(money);
fin.setSubscriptionDate(DateUtil.today());
fin.setAuditState(3);
fin.setAuditDate(DateUtil.today());
fin.setReceivablesSid(p3.getJrSid());
fin.setKxState("01");
fin.setPurchaseSystemSid("");
fin.setPurchaseSystemName("");
fin.setStaffUserSid("");
fin.setUseOrgName(planDetails.getUseOrgName());
fin.setOrgSidPath(loanSettleApply.getOrgSidPath());
selectList.add(fin);
}
//名义价
PlanNoReturnMoney p4 = baseMapper.selectNoReturnMoneyByType(planDetailsSid, "名义价");
if (null != p4) {
BigDecimal money = new BigDecimal(p4.getMoney());
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed();
fin.setCreateBySid(planDetails.getSalesUserSid());
fin.setRemarks("减免");
fin.setVIN(planDetails.getVinNo());
fin.setUseOrgSid(planDetails.getUseOrgSid());
fin.setReceivablesName("名义价");
fin.setSubscriptionMoney(money);
fin.setSubscriptionDate(DateUtil.today());
fin.setAuditState(3);
fin.setAuditDate(DateUtil.today());
fin.setReceivablesSid(p4.getJrSid());
fin.setKxState("01");
fin.setPurchaseSystemSid("");
fin.setPurchaseSystemName("");
fin.setStaffUserSid("");
fin.setUseOrgName(planDetails.getUseOrgName());
fin.setOrgSidPath(loanSettleApply.getOrgSidPath());
selectList.add(fin);
}
//合同违约金
PlanNoReturnMoney p5 = baseMapper.selectNoReturnMoneyByType(planDetailsSid, "合同违约金");
if (null != p5) {
BigDecimal money = new BigDecimal(p5.getMoney());
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed();
fin.setCreateBySid(planDetails.getSalesUserSid());
fin.setRemarks("减免");
fin.setVIN(planDetails.getVinNo());
fin.setUseOrgSid(planDetails.getUseOrgSid());
fin.setReceivablesName("合同违约金");
fin.setSubscriptionMoney(money);
fin.setSubscriptionDate(DateUtil.today());
fin.setAuditState(3);
fin.setAuditDate(DateUtil.today());
fin.setReceivablesSid(p5.getJrSid());
fin.setKxState("01");
fin.setPurchaseSystemSid("");
fin.setPurchaseSystemName("");
fin.setStaffUserSid("");
fin.setUseOrgName(planDetails.getUseOrgName());
fin.setOrgSidPath(loanSettleApply.getOrgSidPath());
selectList.add(fin);
}
//其他费用
PlanNoReturnMoney p6 = baseMapper.selectNoReturnMoneyByType(planDetailsSid, "其他费用");
if (null != p6) {
BigDecimal money = new BigDecimal(p6.getMoney());
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed();
fin.setCreateBySid(planDetails.getSalesUserSid());
fin.setRemarks("减免");
fin.setVIN(planDetails.getVinNo());
fin.setUseOrgSid(planDetails.getUseOrgSid());
fin.setReceivablesName("其他费用");
fin.setSubscriptionMoney(money);
fin.setSubscriptionDate(DateUtil.today());
fin.setAuditState(3);
fin.setAuditDate(DateUtil.today());
fin.setReceivablesSid(p6.getJrSid());
fin.setKxState("01");
fin.setPurchaseSystemSid("");
fin.setPurchaseSystemName("");
fin.setStaffUserSid("");
fin.setUseOrgName(planDetails.getUseOrgName());
fin.setOrgSidPath(loanSettleApply.getOrgSidPath());
selectList.add(fin);
}
// //资方退还垫款应收
// List<PlanNoReturnMoney> p7 = baseMapper.selNoReturnJrMoneyByBusVinSidAndKeyDesc(busVinSid, "007");
// p7.removeAll(Collections.singleton(null));
// if (!p7.isEmpty() && p7.size() > 0) {
// for (PlanNoReturnMoney m : p7) {
// BigDecimal money = new BigDecimal(m.getMoney());
// String sid = m.getSid();
// LoanRepaymentPlanDetails pd = loanRepaymentPlanDetailsService.fetchBySid(sid);
// FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed();
// fin.setCreateBySid(userSid);
// fin.setRemarks("减免");
// fin.setVIN(pd.getVinNo());
// fin.setUseOrgSid(pd.getUseOrgSid());
// fin.setReceivablesName("资方退还垫款");
// fin.setSubscriptionMoney(money);
// fin.setSubscriptionDate(DateUtil.today());
// fin.setAuditState(3);
// fin.setAuditDate(DateUtil.today());
// fin.setReceivablesSid(m.getJrSid());
// fin.setKxState("01");
// fin.setUseOrgName(pd.getUseOrgName());
// fin.setOrgSidPath(loanSettleApply.getOrgSidPath());
// selectList.add(fin);
// }
// }
//对应的垫款金额、资方逾期利息设置0
List<LoanRepaymentPlanDetails> ps = baseMapper.selectPlanListByBusVinSid(busVinSid);
ps.removeAll(Collections.singleton(null));
Set<String> set = new HashSet<>();
if (!ps.isEmpty() && ps.size() > 0) {
for (LoanRepaymentPlanDetails pp : ps) {
if (pp.getPaymentMoney() != null) {
if (pp.getPaymentMoney().compareTo(BigDecimal.ZERO) == 0) {
} else {
set.add(pp.getSid());
}
}
if (pp.getPaymentInterest() != null) {
if (pp.getPaymentInterest().compareTo(BigDecimal.ZERO) == 0) {
} else {
set.add(pp.getSid());
}
}
}
}
List<String> sids = new ArrayList<>(set);
if (!sids.isEmpty() && sids.size() > 0) {
loanRepaymentPlanDetailsService.updatePaymentMoneyBySids(sids);
}
if (histories.size() > 0 && !histories.isEmpty()) {
loanRepaymentHistoryService.saveList(histories);
}
selectList.removeAll(Collections.singleton(null));
if (selectList.size() > 0 && !selectList.isEmpty()) {
ResultBean resultBean = finSelectedReceivablesDetailedFeign.saveAll(selectList);
@ -1523,9 +1458,9 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
finPaymentrecordDto.setPayType(1);
finPaymentrecordDto.setCreateOrgSid(loanSettleApply.getUseOrgSid());
finPaymentrecordDto.setUseOrgSid(loanSettleApply.getUseOrgSid());
finPaymentrecordDto.setCostTypeKey("");
finPaymentrecordDto.setCostTypeKey("008");
finPaymentrecordDto.setCostTypeValue("资方结清款");
finPaymentrecordDto.setCostTitleKey("");
finPaymentrecordDto.setCostTitleKey("014");
finPaymentrecordDto.setCostTitleValue("资方结清款");
finPaymentrecordDto.setReceiveBank("");
if (StringUtils.isNotBlank(bankCost.getBankAccount())) {
@ -2485,12 +2420,11 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
return rb.setMsg("结清款尚未认款完毕,请继续认款!");
}
if (formatDate.compareTo(settingDate) > 0) {
return rb.setMsg("只能在结清申请发起当日确认客户结清,若需结清,请重新发起结清申请!");
return rb.setMsg("只能在结清申请发起当日确认客户结清,若需结清,请将结清日期修改为当天,重新发起结清申请!");
}
loanSettleApply.setState(1);
baseMapper.updateById(loanSettleApply);
carryForward(loanSettleApply);
reliefMoney(loanSettleApply);
//更新车辆表结清状态
baseMapper.updateBus(loanSettleApply.getBusVinSid(), "1");
//推送资方结清款到出纳代付款列表
@ -2514,14 +2448,25 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
String dMoney = baseMapper.selDueMoneyByBusVinSidAndCloseDate(busVinSid, formatDate);
dueMoney = new BigDecimal(dMoney);
sumMoney = jrMoney.add(dueMoney);
LoanSettleCompanyReduction reduction = loanSettleCompanyReductionService.selectByMainSid(loanSettleApply.getSid());
if (null != reduction) {
if (null != reduction.getAmountTo()) {
BigDecimal amountTo = reduction.getAmountTo();
if (sumMoney.compareTo(amountTo) < 0) {
isSettle = false;
//获取公司减免情况
BigDecimal amountTo = BigDecimal.ZERO;
if (loanSettleApply.getTrueReduction() == 1) {
LoanSettleCompanyReduction reduction = loanSettleCompanyReductionService.selectByMainSid(loanSettleApply.getSid());
if (null != reduction) {
if (null != reduction.getAmountTo()) {
amountTo = reduction.getAmountTo();
}
}
} else {
LoanSettleCompanyCost loanSettleCompanyCost = loanSettleCompanyCostService.selectByMainSid(loanSettleApply.getSid());
if (null != loanSettleCompanyCost) {
if (null != loanSettleCompanyCost.getSettleAll()) {
amountTo = loanSettleCompanyCost.getSettleAll();
}
}
}
if (sumMoney.compareTo(amountTo) < 0) {
isSettle = false;
}
return isSettle;
}

Loading…
Cancel
Save