|
|
@ -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; |
|
|
|
} |
|
|
|