|
|
@ -41,6 +41,7 @@ import com.yxt.anrui.fin.api.kingdee.bdcustomer.BdCustomer; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.voucher.GeneralVoucher; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.voucher.PaymentVoucher; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.voucher.SceneCodeEnum; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.voucher.Voucher; |
|
|
|
import com.yxt.anrui.flowable.api.flow.FlowableFeign; |
|
|
|
import com.yxt.anrui.flowable.api.flow.UpdateFlowFieldVo; |
|
|
|
import com.yxt.anrui.flowable.api.flow2.FlowDelegateQuery; |
|
|
@ -50,6 +51,8 @@ import com.yxt.anrui.flowable.api.flowtask.FlowTaskVo; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo; |
|
|
|
import com.yxt.anrui.flowable.api.utils.ProcDefEnum; |
|
|
|
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables; |
|
|
|
import com.yxt.anrui.portal.api.dictcommon.DictCommonFeign; |
|
|
|
import com.yxt.anrui.portal.api.dictcommon.DictCommonVo; |
|
|
|
import com.yxt.anrui.portal.api.flow.PCHistTaskListAndCommentList; |
|
|
|
import com.yxt.anrui.portal.api.sysorganization.SysOrganization; |
|
|
|
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationFeign; |
|
|
@ -62,7 +65,9 @@ import com.yxt.anrui.portal.api.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanmonthlyaccrualrecord.LoanMonthlyAccrualRecord; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanoverduefin.UrlQuery; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanpushfundhistory.LoanPushFundHistory; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.LoanRepaymentHistory; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanPlanDetailsVoForFundVoucher; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetails; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.LoanRepaymentSchedule; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansettleapply.*; |
|
|
@ -78,6 +83,7 @@ import com.yxt.anrui.riskcenter.api.loansolutions.LoanSolutions; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansolutions.app.SolutionsDetailsVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansolutionsdetail.LoanSolutionsDetail; |
|
|
|
import com.yxt.anrui.riskcenter.api.loantransferpaymentrecord.LoanTransferPaymentRecord; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanpushfundhistory.LoanPushFundHistoryService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepaymenthistory.LoanRepaymentHistoryService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepaymentplandetails.LoanRepaymentPlanDetailsService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepaymentschedule.LoanRepaymentScheduleService; |
|
|
@ -119,6 +125,9 @@ import java.net.URL; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.ZoneId; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
@ -199,6 +208,11 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
private BasePurchaseSystemFeign basePurchaseSystemFeign; |
|
|
|
@Autowired |
|
|
|
private LoanSolutionsService loanSolutionsService; |
|
|
|
@Autowired |
|
|
|
private DictCommonFeign dictCommonFeign; |
|
|
|
@Autowired |
|
|
|
private LoanPushFundHistoryService loanPushFundHistoryService; |
|
|
|
|
|
|
|
|
|
|
|
public PagerVo<LoanSettleApplyVo> listPageVo(PagerQuery<LoanSettleApplyQuery> pq) { |
|
|
|
LoanSettleApplyQuery query = pq.getParams(); |
|
|
@ -956,13 +970,15 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
int check = 0;// 0不推抵顶保证金凭证 1推送
|
|
|
|
//结清合计 + 贷款保证金结转金额
|
|
|
|
BigDecimal add = amountTo.add(depositJZ); |
|
|
|
BigDecimal actualDeposit = BigDecimal.ZERO; |
|
|
|
// BigDecimal actualDeposit = BigDecimal.ZERO;
|
|
|
|
List<LoanSettleVoucherVo> settleVoucherVos = new ArrayList<>(); |
|
|
|
if (add.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
//结转剩余保证金
|
|
|
|
BigDecimal decimal = carryForward(loanSettleApply); |
|
|
|
if (null != decimal) { |
|
|
|
actualDeposit = decimal; |
|
|
|
} |
|
|
|
// BigDecimal decimal = carryForward(loanSettleApply);
|
|
|
|
// if (null != decimal) {
|
|
|
|
// actualDeposit = decimal;
|
|
|
|
// }
|
|
|
|
settleVoucherVos = carryForward2(loanSettleApply); |
|
|
|
check = 1; |
|
|
|
} |
|
|
|
//设置结清申请的“客户结清确认”状态为是
|
|
|
@ -974,7 +990,8 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
//设置认款月还为已转付
|
|
|
|
updatePaymentStateByBusVinSid(loanSettleApply.getBusVinSid()); |
|
|
|
//推送财务凭证
|
|
|
|
pushSettleVoucher(loanSettleApply, check, actualDeposit); |
|
|
|
// pushSettleVoucher(loanSettleApply, check, actualDeposit);
|
|
|
|
pushSettleVoucher2(loanSettleApply, check, settleVoucherVos); |
|
|
|
} |
|
|
|
baseMapper.updateById(loanSettleApply); |
|
|
|
} else { |
|
|
@ -1460,6 +1477,377 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
return returnDecimal; |
|
|
|
} |
|
|
|
|
|
|
|
private List<LoanSettleVoucherVo> carryForward2(LoanSettleApply loanSettleApply) { |
|
|
|
List<LoanSettleVoucherVo> list = new ArrayList<>(); |
|
|
|
String userSid = loanSettleApply.getCreateBySid(); |
|
|
|
BigDecimal cwWDQ = BigDecimal.ZERO;//未到期
|
|
|
|
BigDecimal cwWYQ = BigDecimal.ZERO;//未逾期
|
|
|
|
BigDecimal cwYYQ = BigDecimal.ZERO;//已逾期
|
|
|
|
BigDecimal fund = BigDecimal.ZERO;//资金占用费
|
|
|
|
BigDecimal deposit = 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(); |
|
|
|
LoanRepaymentSchedule schedule = loanRepaymentScheduleService.fetchBySid(scheduleSid); |
|
|
|
if (schedule.getIsOtherPolicy().equals("1") && schedule.getSameBank().equals("0")) { |
|
|
|
planDetails = baseMapper.selectMainPeriodByBusVinSid(loanSettleApply.getBusVinSid()); |
|
|
|
} |
|
|
|
String planDetailsSid = planDetails.getSid(); |
|
|
|
LoanSettleCompanyCost companyCost = loanSettleCompanyCostService.selectByMainSid(loanSettleApply.getSid()); |
|
|
|
if (null != companyCost) { |
|
|
|
if (null != companyCost.getLoanDeposit()) { |
|
|
|
deposit = companyCost.getLoanDeposit(); |
|
|
|
} |
|
|
|
} |
|
|
|
//按照顺序结转
|
|
|
|
//月还
|
|
|
|
if (deposit.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
List<PlanNoReturnMoney> p = baseMapper.selPlansNoReturnMoneyByBusVinSidDesc(busVinSid); |
|
|
|
p.removeAll(Collections.singleton(null)); |
|
|
|
if (!p.isEmpty() && p.size() > 0) { |
|
|
|
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(); |
|
|
|
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("04"); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (null != planDetails.getOweState()) { |
|
|
|
if (planDetails.getOweState() == 0) { |
|
|
|
cwYYQ = cwYYQ.add(mm); |
|
|
|
} else if (planDetails.getOweState() == 1) { |
|
|
|
//获取收款日期的当月最后一天
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|
|
|
LocalDate localDate = LocalDate.parse(DateUtil.formatDate(new Date()), formatter); |
|
|
|
LocalDate date = localDate.withDayOfMonth(localDate.lengthOfMonth()); |
|
|
|
Date dueDate = planDetails.getDueDate(); //应还日期
|
|
|
|
// Date -> LocalDate
|
|
|
|
LocalDate localDueDate = dueDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
|
|
|
boolean after = localDueDate.isAfter(date); |
|
|
|
if (after) { |
|
|
|
cwWDQ = cwWDQ.add(mm); |
|
|
|
} else { |
|
|
|
cwWYQ = cwWYQ.add(mm); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//结转垫资方逾期利息
|
|
|
|
if (deposit.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
List<PlanNoReturnMoney> p = baseMapper.selNoReturnJrMoneyByBusVinSidAndKeyDesc(busVinSid, "005"); |
|
|
|
p.removeAll(Collections.singleton(null)); |
|
|
|
if (!p.isEmpty() && p.size() > 0) { |
|
|
|
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.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; |
|
|
|
} |
|
|
|
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); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
cwYYQ = cwYYQ.add(mm); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//结转资方逾期利息
|
|
|
|
if (deposit.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
PlanNoReturnMoney p = baseMapper.selectNoReturnMoneyByType(planDetailsSid, "结清时资方逾期利息"); |
|
|
|
if (null != p) { |
|
|
|
BigDecimal money = new BigDecimal(p.getMoney()); |
|
|
|
BigDecimal mm = BigDecimal.ZERO; |
|
|
|
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed(); |
|
|
|
fin.setCreateBySid(planDetails.getSalesUserSid()); |
|
|
|
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; |
|
|
|
} |
|
|
|
fin.setSubscriptionDate(DateUtil.today()); |
|
|
|
fin.setAuditState(3); |
|
|
|
fin.setAuditDate(DateUtil.today()); |
|
|
|
fin.setReceivablesSid(p.getJrSid()); |
|
|
|
fin.setKxState("01"); |
|
|
|
fin.setPurchaseSystemSid(""); |
|
|
|
fin.setPurchaseSystemName(""); |
|
|
|
fin.setStaffUserSid(""); |
|
|
|
fin.setUseOrgName(planDetails.getUseOrgName()); |
|
|
|
fin.setOrgSidPath(loanSettleApply.getOrgSidPath()); |
|
|
|
selectList.add(fin); |
|
|
|
cwYYQ = cwYYQ.add(mm); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
//名义价
|
|
|
|
if (deposit.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
PlanNoReturnMoney p = baseMapper.selectNoReturnMoneyByType(planDetailsSid, "名义价"); |
|
|
|
if (null != p) { |
|
|
|
BigDecimal mm = BigDecimal.ZERO; |
|
|
|
BigDecimal money = new BigDecimal(p.getMoney()); |
|
|
|
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed(); |
|
|
|
fin.setCreateBySid(planDetails.getSalesUserSid()); |
|
|
|
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; |
|
|
|
} |
|
|
|
fin.setSubscriptionDate(DateUtil.today()); |
|
|
|
fin.setAuditState(3); |
|
|
|
fin.setAuditDate(DateUtil.today()); |
|
|
|
fin.setReceivablesSid(p.getJrSid()); |
|
|
|
fin.setKxState("01"); |
|
|
|
fin.setPurchaseSystemSid(""); |
|
|
|
fin.setPurchaseSystemName(""); |
|
|
|
fin.setStaffUserSid(""); |
|
|
|
fin.setUseOrgName(planDetails.getUseOrgName()); |
|
|
|
fin.setOrgSidPath(loanSettleApply.getOrgSidPath()); |
|
|
|
selectList.add(fin); |
|
|
|
LoanSettleVoucherVo v = new LoanSettleVoucherVo(); |
|
|
|
v.setReceivablesName("名义价"); |
|
|
|
v.setSubscriptionMoney(mm); |
|
|
|
list.add(v); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
//合同违约金
|
|
|
|
if (deposit.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
PlanNoReturnMoney p = baseMapper.selectNoReturnMoneyByType(planDetailsSid, "合同违约金"); |
|
|
|
if (null != p) { |
|
|
|
BigDecimal mm = BigDecimal.ZERO; |
|
|
|
BigDecimal money = new BigDecimal(p.getMoney()); |
|
|
|
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed(); |
|
|
|
fin.setCreateBySid(planDetails.getSalesUserSid()); |
|
|
|
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; |
|
|
|
} |
|
|
|
fin.setSubscriptionDate(DateUtil.today()); |
|
|
|
fin.setAuditState(3); |
|
|
|
fin.setAuditDate(DateUtil.today()); |
|
|
|
fin.setReceivablesSid(p.getJrSid()); |
|
|
|
fin.setKxState("01"); |
|
|
|
fin.setPurchaseSystemSid(""); |
|
|
|
fin.setPurchaseSystemName(""); |
|
|
|
fin.setStaffUserSid(""); |
|
|
|
fin.setUseOrgName(planDetails.getUseOrgName()); |
|
|
|
fin.setOrgSidPath(loanSettleApply.getOrgSidPath()); |
|
|
|
selectList.add(fin); |
|
|
|
LoanSettleVoucherVo v = new LoanSettleVoucherVo(); |
|
|
|
v.setReceivablesName("合同违约金"); |
|
|
|
v.setSubscriptionMoney(mm); |
|
|
|
list.add(v); |
|
|
|
} |
|
|
|
} |
|
|
|
//其他费用
|
|
|
|
if (deposit.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
PlanNoReturnMoney p = baseMapper.selectNoReturnMoneyByType(planDetailsSid, "其他费用"); |
|
|
|
if (null != p) { |
|
|
|
BigDecimal mm = BigDecimal.ZERO; |
|
|
|
BigDecimal money = new BigDecimal(p.getMoney()); |
|
|
|
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed(); |
|
|
|
fin.setCreateBySid(planDetails.getSalesUserSid()); |
|
|
|
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; |
|
|
|
} |
|
|
|
fin.setSubscriptionDate(DateUtil.today()); |
|
|
|
fin.setAuditState(3); |
|
|
|
fin.setAuditDate(DateUtil.today()); |
|
|
|
fin.setReceivablesSid(p.getJrSid()); |
|
|
|
fin.setKxState("01"); |
|
|
|
fin.setPurchaseSystemSid(""); |
|
|
|
fin.setPurchaseSystemName(""); |
|
|
|
fin.setStaffUserSid(""); |
|
|
|
fin.setUseOrgName(planDetails.getUseOrgName()); |
|
|
|
fin.setOrgSidPath(loanSettleApply.getOrgSidPath()); |
|
|
|
selectList.add(fin); |
|
|
|
LoanSettleVoucherVo v = new LoanSettleVoucherVo(); |
|
|
|
v.setReceivablesName("其他费用"); |
|
|
|
v.setSubscriptionMoney(mm); |
|
|
|
list.add(v); |
|
|
|
} |
|
|
|
} |
|
|
|
//资金占用费
|
|
|
|
if (deposit.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
List<PlanNoReturnMoney> p = baseMapper.selNoReturnJrMoneyByBusVinSidAndKeyDesc(busVinSid, "006"); |
|
|
|
p.removeAll(Collections.singleton(null)); |
|
|
|
if (!p.isEmpty() && p.size() > 0) { |
|
|
|
for (PlanNoReturnMoney m : p) { |
|
|
|
if (deposit.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
BigDecimal mm = BigDecimal.ZERO; |
|
|
|
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 (deposit.compareTo(money) >= 0) { |
|
|
|
mm = money; |
|
|
|
fin.setSubscriptionMoney(money); |
|
|
|
deposit = deposit.subtract(money); |
|
|
|
} else { |
|
|
|
mm = deposit; |
|
|
|
fin.setSubscriptionMoney(deposit); |
|
|
|
deposit = BigDecimal.ZERO; |
|
|
|
} |
|
|
|
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); |
|
|
|
fund = fund.add(mm); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
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); |
|
|
|
} |
|
|
|
updatePsList.removeAll(Collections.singleton(null)); |
|
|
|
if (!updatePsList.isEmpty() && updatePsList.size() > 0) { |
|
|
|
loanRepaymentPlanDetailsService.updateList(updatePsList); |
|
|
|
} |
|
|
|
if (cwWDQ.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
LoanSettleVoucherVo v = new LoanSettleVoucherVo(); |
|
|
|
v.setReceivablesName("未到期"); |
|
|
|
v.setSubscriptionMoney(cwWDQ); |
|
|
|
list.add(v); |
|
|
|
} |
|
|
|
if (cwWYQ.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
LoanSettleVoucherVo v = new LoanSettleVoucherVo(); |
|
|
|
v.setReceivablesName("未逾期"); |
|
|
|
v.setSubscriptionMoney(cwWYQ); |
|
|
|
list.add(v); |
|
|
|
} |
|
|
|
if (cwYYQ.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
LoanSettleVoucherVo v = new LoanSettleVoucherVo(); |
|
|
|
v.setReceivablesName("已逾期"); |
|
|
|
v.setSubscriptionMoney(cwYYQ); |
|
|
|
list.add(v); |
|
|
|
} |
|
|
|
if (fund.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
LoanSettleVoucherVo v = new LoanSettleVoucherVo(); |
|
|
|
v.setReceivablesName("资金占用费"); |
|
|
|
v.setSubscriptionMoney(fund); |
|
|
|
list.add(v); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------- 减免 ----------------------------
|
|
|
|
private void reliefMoney(LoanSettleApply loanSettleApply) { |
|
|
|
String userSid = loanSettleApply.getCreateBySid(); |
|
|
@ -1792,6 +2180,328 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void pushSettleVoucher2(LoanSettleApply loanSettleApply, int check, List<LoanSettleVoucherVo> vos) { |
|
|
|
String sid = loanSettleApply.getSid(); |
|
|
|
BigDecimal amountAll = BigDecimal.ZERO; //贷款保证金抵结清款 预收贷款车费用_贷款保证金_贷款保证金
|
|
|
|
LoanSettleCompanyCost companyCost = loanSettleCompanyCostService.selectByMainSid(sid); |
|
|
|
LoanSettleCompanyReduction reduction = loanSettleCompanyReductionService.selectByMainSid(sid); |
|
|
|
LoanSettleBankCost bankCost = loanSettleBankCostService.selectByMainSid(sid); |
|
|
|
Voucher newVoucher = new Voucher(); |
|
|
|
List<Voucher.VoucherResultDetailDto> resultDetails = new ArrayList<>(); |
|
|
|
SimpleDateFormat sdfTimes = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
//--------------推送资金占用费计提记录表--------------------
|
|
|
|
List<LoanPushFundHistory> fundHistoryList = new ArrayList<>(); |
|
|
|
LoanRepaymentPlanDetails planDetails = baseMapper.selectByBusVinSidAndDesc(loanSettleApply.getBusVinSid()); |
|
|
|
String scheduleSid = planDetails.getScheduleSid(); |
|
|
|
LoanRepaymentSchedule schedule = loanRepaymentScheduleService.fetchBySid(scheduleSid); |
|
|
|
if (schedule.getIsOtherPolicy().equals("1") && schedule.getSameBank().equals("0")) { |
|
|
|
planDetails = baseMapper.selectMainPeriodByBusVinSid(loanSettleApply.getBusVinSid()); |
|
|
|
} |
|
|
|
if (null != planDetails) { |
|
|
|
String useOrgSid = planDetails.getUseOrgSid(); |
|
|
|
SysOrganizationVo organizationVo = sysOrganizationFeign.fetchBySid(useOrgSid).getData(); |
|
|
|
if (null != organizationVo) { |
|
|
|
newVoucher.setAccountBook(organizationVo.getOrgCode()); |
|
|
|
newVoucher.setVoucherNo(organizationVo.getOrgCode()); |
|
|
|
} |
|
|
|
String deptCode = ""; |
|
|
|
String customerNumber = ""; |
|
|
|
String bankCode = ""; //资方编码
|
|
|
|
if (StringUtils.isNotBlank(schedule.getCwDeptNo())) { |
|
|
|
deptCode = schedule.getCwDeptNo(); |
|
|
|
} |
|
|
|
DictCommonVo dictCommonVo = dictCommonFeign.selectBykey(planDetails.getBankName(), "investorsCode").getData(); |
|
|
|
if (null != dictCommonVo) { |
|
|
|
bankCode = dictCommonVo.getDictValue(); |
|
|
|
} |
|
|
|
BusSalesOrderVehicle busSalesOrderVehicle = busSalesOrderVehicleFeign.details(planDetails.getBusVinSid()).getData(); |
|
|
|
BusSalesOrder salesOrder = busSalesOrderFeign.fetchBySid(planDetails.getSalesOrderSid()).getData(); |
|
|
|
if (null != salesOrder) { |
|
|
|
if (null != busSalesOrderVehicle) { |
|
|
|
//判断财务系统是否有客户
|
|
|
|
Boolean aBoolean = finKingDeeFeign.customerExistState(busSalesOrderVehicle.getTemporaryNo()).getData(); |
|
|
|
String linkNo = ""; |
|
|
|
BusSalesOrderBorrowerDetailsVo borrowerDetailsVo = busSalesOrderBorrowerFeign.fetchDetailsBySid(busSalesOrderVehicle.getBorrowerSid()).getData(); |
|
|
|
if (!aBoolean) { |
|
|
|
// List<BdCustomer> bdCustomers = new ArrayList<>();
|
|
|
|
BdCustomer bdCustomer = new BdCustomer(); |
|
|
|
bdCustomer.setFNumber(busSalesOrderVehicle.getTemporaryNo()); |
|
|
|
bdCustomer.setFShortName(salesOrder.getContractNo()); |
|
|
|
if (StringUtils.isNotBlank(salesOrder.getPurchaseSystemSid())) { |
|
|
|
BasePurchaseSystemDetailsVo data = basePurchaseSystemFeign.fetchDetailsByDeptSid(salesOrder.getPurchaseSystemSid()).getData(); |
|
|
|
bdCustomer.setTOrgIds(data.getOrgCode()); |
|
|
|
} |
|
|
|
bdCustomer.setTOrgIds(deptCode); |
|
|
|
if (org.apache.commons.lang3.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); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (null != borrowerDetailsVo) { |
|
|
|
bdCustomer.setFName(borrowerDetailsVo.getBorrowerName() + busSalesOrderVehicle.getTemporaryNo()); |
|
|
|
} |
|
|
|
} |
|
|
|
// bdCustomers.add(bdCustomer);
|
|
|
|
ResultBean<String> resultBean = finKingDeeFeign.draftBdCustomer(bdCustomer); |
|
|
|
if (resultBean.getSuccess()) { |
|
|
|
customerNumber = bdCustomer.getFNumber(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
customerNumber = busSalesOrderVehicle.getTemporaryNo(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
BigDecimal fund = BigDecimal.ZERO;//资金占用费减免
|
|
|
|
BigDecimal bzjMoney = BigDecimal.ZERO;//剩余贷款保证金结转
|
|
|
|
BigDecimal bzjJM = BigDecimal.ZERO;//贷款保证金减免
|
|
|
|
BigDecimal bzjKF = BigDecimal.ZERO;//贷款保证金扣罚
|
|
|
|
BigDecimal bzjKFCw = BigDecimal.ZERO;//贷款保证金扣罚
|
|
|
|
BigDecimal sybzj = BigDecimal.ZERO;//贷款保证金扣罚
|
|
|
|
BigDecimal zfJQK = BigDecimal.ZERO;//资方结清款
|
|
|
|
int topping = 0; |
|
|
|
BigDecimal bbjDDMoney = BigDecimal.ZERO; //资方保证金抵顶
|
|
|
|
if (null != reduction) { |
|
|
|
if (null != reduction.getFundPenalty()) { |
|
|
|
fund = reduction.getFundPenalty(); |
|
|
|
} |
|
|
|
if (null != reduction.getDepositPenalty()) { |
|
|
|
bzjJM = reduction.getDepositPenalty(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (null != companyCost) { |
|
|
|
if (null != companyCost.getLoanDeposit()) { |
|
|
|
bzjMoney = companyCost.getLoanDeposit(); |
|
|
|
} |
|
|
|
if (null != companyCost.getDeductionAmount()) { |
|
|
|
bzjKF = companyCost.getDeductionAmount(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (null != bankCost) { |
|
|
|
if (null != bankCost.getBankSettlePrice()) { |
|
|
|
zfJQK = bankCost.getBankSettlePrice(); |
|
|
|
} |
|
|
|
topping = bankCost.getTopping(); |
|
|
|
if (null != bankCost.getLoanDeposit()) { |
|
|
|
bbjDDMoney = bankCost.getLoanDeposit(); |
|
|
|
} |
|
|
|
} |
|
|
|
sybzj = bzjMoney.subtract(bzjKF).add(bzjJM); |
|
|
|
bzjKFCw = bzjKF.subtract(bzjJM); |
|
|
|
//资金占用费减免凭证
|
|
|
|
if (fund.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail1 = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail1.setSummary("公司逾期利息减免"); |
|
|
|
voucherDetail1.setSubjectNo("1201.02.02"); |
|
|
|
voucherDetail1.setDimensionDept(deptCode); |
|
|
|
voucherDetail1.setDimensionCustom(customerNumber); |
|
|
|
voucherDetail1.setDebit("-" + bbjDDMoney.toString()); |
|
|
|
resultDetails.add(voucherDetail1); |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail2 = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail2.setSummary("公司逾期利息减免"); |
|
|
|
voucherDetail2.setSubjectNo("2191.05.00"); |
|
|
|
voucherDetail2.setDimensionDept(deptCode); |
|
|
|
voucherDetail2.setDebit(bbjDDMoney.toString()); |
|
|
|
resultDetails.add(voucherDetail2); |
|
|
|
} |
|
|
|
//剩余贷款保证金结转
|
|
|
|
if (check == 1) { |
|
|
|
if (vos.size() > 0 && !vos.isEmpty()) { |
|
|
|
for (LoanSettleVoucherVo v : vos) { |
|
|
|
BigDecimal subscriptionMoney = v.getSubscriptionMoney(); |
|
|
|
String receivablesName = v.getReceivablesName(); |
|
|
|
amountAll = amountAll.add(subscriptionMoney); |
|
|
|
if (receivablesName.equals("未到期")) { |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail.setSummary("贷款保证金抵结清款"); |
|
|
|
voucherDetail.setSubjectNo("1201.01.00"); |
|
|
|
voucherDetail.setDimensionDept(deptCode); |
|
|
|
voucherDetail.setDimensionCustom(customerNumber); |
|
|
|
voucherDetail.setCredit(subscriptionMoney.toString()); |
|
|
|
resultDetails.add(voucherDetail); |
|
|
|
} |
|
|
|
if (receivablesName.equals("未逾期")) { |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail.setSummary("贷款保证金抵结清款"); |
|
|
|
voucherDetail.setSubjectNo("1201.02.01"); |
|
|
|
voucherDetail.setDimensionDept(deptCode); |
|
|
|
voucherDetail.setDimensionCustom(customerNumber); |
|
|
|
voucherDetail.setCredit(subscriptionMoney.toString()); |
|
|
|
resultDetails.add(voucherDetail); |
|
|
|
} |
|
|
|
if (receivablesName.equals("已逾期")) { |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail.setSummary("贷款保证金抵结清款"); |
|
|
|
voucherDetail.setSubjectNo("1201.02.03"); |
|
|
|
voucherDetail.setDimensionDept(deptCode); |
|
|
|
voucherDetail.setDimensionCustom(customerNumber); |
|
|
|
voucherDetail.setCredit(subscriptionMoney.toString()); |
|
|
|
resultDetails.add(voucherDetail); |
|
|
|
} |
|
|
|
if (receivablesName.equals("名义价") || receivablesName.equals("合同违约金") || receivablesName.equals("其他费用")) { |
|
|
|
SettleFinVo finVo = getFinSettleVo(planDetails.getBusVinSid(), receivablesName, subscriptionMoney.toString()).getData(); |
|
|
|
if (null != finVo) { |
|
|
|
if (null != finVo.getSubtrahend()) { |
|
|
|
if (finVo.getSubtrahend().compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail.setSummary("贷款保证金抵结清款"); |
|
|
|
voucherDetail.setSubjectNo(bankCode); |
|
|
|
voucherDetail.setDimensionDept(deptCode); |
|
|
|
voucherDetail.setDimensionCustom(customerNumber); |
|
|
|
voucherDetail.setCredit(finVo.getSubtrahend().toString()); |
|
|
|
resultDetails.add(voucherDetail); |
|
|
|
} |
|
|
|
} |
|
|
|
if (null != finVo.getBalance()) { |
|
|
|
if (finVo.getBalance().compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
if (receivablesName.equals("其他费用")) { |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail.setSummary("收其他费用"); |
|
|
|
voucherDetail.setSubjectNo("1133.10.00"); |
|
|
|
voucherDetail.setDimensionDept(deptCode); |
|
|
|
voucherDetail.setDimensionCustom(customerNumber); |
|
|
|
voucherDetail.setCredit(finVo.getBalance().toString()); |
|
|
|
resultDetails.add(voucherDetail); |
|
|
|
} else { |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail.setSummary("其他费用差额转收入"); |
|
|
|
voucherDetail.setSubjectNo("6002.01.17"); |
|
|
|
voucherDetail.setDimensionDept(deptCode); |
|
|
|
voucherDetail.setCredit(finVo.getBalance().toString()); |
|
|
|
resultDetails.add(voucherDetail); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (receivablesName.equals("资金占用费")) { |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail.setSummary("贷款保证金抵结清款"); |
|
|
|
voucherDetail.setSubjectNo("1201.02.02"); |
|
|
|
voucherDetail.setDimensionDept(deptCode); |
|
|
|
voucherDetail.setDimensionCustom(customerNumber); |
|
|
|
voucherDetail.setCredit(subscriptionMoney.toString()); |
|
|
|
resultDetails.add(voucherDetail); |
|
|
|
SimpleDateFormat sdfnew = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
String date = sdfnew.format(new Date()); |
|
|
|
String[] split = date.split("-"); |
|
|
|
String month = split[1]; |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail1 = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail1.setSummary(month + "月逾期利息确认收入"); |
|
|
|
voucherDetail1.setSubjectNo("2191.05.00"); |
|
|
|
voucherDetail1.setDimensionDept(deptCode); |
|
|
|
voucherDetail1.setDebit(subscriptionMoney.toString()); |
|
|
|
resultDetails.add(voucherDetail1); |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail2 = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail2.setSummary(month + "月逾期利息确认收入"); |
|
|
|
voucherDetail2.setSubjectNo("6002.01.19"); |
|
|
|
voucherDetail2.setDimensionDept(deptCode); |
|
|
|
voucherDetail2.setCredit(subscriptionMoney.toString()); |
|
|
|
resultDetails.add(voucherDetail2); |
|
|
|
//资金占用费未计提的部分
|
|
|
|
LoanPlanDetailsVoForFundVoucher f = loanRepaymentPlanDetailsService.getLoanPlanDetailsVoForFundVoucher(planDetails.getBusVinSid()); |
|
|
|
if (null != f) { |
|
|
|
if (null != f.getDuePushMoney()) { |
|
|
|
BigDecimal duePushMoney = f.getDuePushMoney(); |
|
|
|
if (duePushMoney.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail3 = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail3.setSummary("计提" + month + "月逾期利息"); |
|
|
|
voucherDetail3.setSubjectNo("1201.02.02"); |
|
|
|
voucherDetail3.setDimensionDept(deptCode); |
|
|
|
voucherDetail3.setDimensionCustom(customerNumber); |
|
|
|
voucherDetail3.setDebit(duePushMoney.toString()); |
|
|
|
resultDetails.add(voucherDetail3); |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail4 = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail4.setSummary("计提" + month + "月逾期利息"); |
|
|
|
voucherDetail4.setSubjectNo("2191.05.00"); |
|
|
|
List<SysOrganizationVo> deptVo = sysOrganizationFeign.selectChildrenListBySid(planDetails.getUseOrgSid()).getData(); |
|
|
|
if (!deptVo.isEmpty()) { |
|
|
|
for (SysOrganizationVo d : deptVo) { |
|
|
|
if (d.getName().equals("金融服务部")) { |
|
|
|
voucherDetail4.setDimensionDept(d.getOrgCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
voucherDetail4.setCredit(duePushMoney.toString()); |
|
|
|
resultDetails.add(voucherDetail4); |
|
|
|
LoanPushFundHistory loanPushFundHistory = new LoanPushFundHistory(); |
|
|
|
loanPushFundHistory.setFund(f.getDuePushMoney()); |
|
|
|
loanPushFundHistory.setBusVinSid(planDetails.getBusVinSid()); |
|
|
|
loanPushFundHistory.setUseOrgName(planDetails.getUseOrgName()); |
|
|
|
loanPushFundHistory.setUseOrgSid(planDetails.getUseOrgSid()); |
|
|
|
String lastTimes = loanPushFundHistoryService.getLastDateByBusVinSid(planDetails.getBusVinSid()).getData(); |
|
|
|
if (StringUtils.isNotBlank(lastTimes)) { |
|
|
|
try { |
|
|
|
loanPushFundHistory.setLastAccrualDate(sdfTimes.parse(lastTimes)); |
|
|
|
} catch (ParseException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
fundHistoryList.add(loanPushFundHistory); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//贷款保证金扣罚
|
|
|
|
if (bzjKFCw.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail.setSubjectNo("6002.01.21"); |
|
|
|
voucherDetail.setSummary("贷款保证金抵结清款"); |
|
|
|
voucherDetail.setDimensionDept(deptCode); |
|
|
|
voucherDetail.setDimensionCustom(customerNumber); |
|
|
|
voucherDetail.setCredit(bzjKFCw.toString()); |
|
|
|
resultDetails.add(voucherDetail); |
|
|
|
amountAll = amountAll.add(bzjKFCw); |
|
|
|
} |
|
|
|
//资方结清款付款
|
|
|
|
if (zfJQK.compareTo(BigDecimal.ZERO) <= 0) { |
|
|
|
if (topping == 1) { |
|
|
|
if (bbjDDMoney.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail1 = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail1.setSummary(planDetails.getBankName() + "结清"); |
|
|
|
voucherDetail1.setSubjectNo(bankCode); |
|
|
|
voucherDetail1.setDimensionDept(deptCode); |
|
|
|
voucherDetail1.setDimensionCustom(customerNumber); |
|
|
|
voucherDetail1.setDebit(bbjDDMoney.toString()); |
|
|
|
resultDetails.add(voucherDetail1); |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail2 = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail2.setSummary(planDetails.getBankName() + "个贷保证金抵结清款"); |
|
|
|
voucherDetail2.setSubjectNo("1009.01.00"); |
|
|
|
voucherDetail2.setDimensionDept(deptCode); |
|
|
|
voucherDetail2.setDimensionCustom(customerNumber); |
|
|
|
voucherDetail2.setCredit(bbjDDMoney.toString()); |
|
|
|
resultDetails.add(voucherDetail2); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//贷款保证金扣罚
|
|
|
|
if (amountAll.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
Voucher.VoucherResultDetailDto voucherDetail = new Voucher.VoucherResultDetailDto(); |
|
|
|
voucherDetail.setSubjectNo("2182.01.01"); |
|
|
|
voucherDetail.setSummary("贷款保证金抵结清款"); |
|
|
|
voucherDetail.setDimensionDept(deptCode); |
|
|
|
voucherDetail.setDimensionCustom(customerNumber); |
|
|
|
voucherDetail.setDebit(amountAll.toString()); |
|
|
|
resultDetails.add(voucherDetail); |
|
|
|
} |
|
|
|
newVoucher.setResultDetails(resultDetails); |
|
|
|
if (!fundHistoryList.isEmpty()) { |
|
|
|
loanPushFundHistoryService.saveLists(fundHistoryList); |
|
|
|
} |
|
|
|
finKingDeeFeign.saveVoucher(newVoucher); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------资方结清款到出纳代付款列表------------------
|
|
|
|
private void pushBankSettlePrice(LoanSettleApply loanSettleApply) { |
|
|
|
if (StringUtils.isBlank(loanSettleApply.getBusSid())) { |
|
|
@ -2883,12 +3593,13 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
} |
|
|
|
loanSettleApply.setState(1); |
|
|
|
baseMapper.updateById(loanSettleApply); |
|
|
|
BigDecimal actualDeposit = BigDecimal.ZERO; |
|
|
|
// BigDecimal actualDeposit = BigDecimal.ZERO;
|
|
|
|
//结转剩余保证金
|
|
|
|
BigDecimal decimal = carryForward(loanSettleApply); |
|
|
|
if (null != decimal) { |
|
|
|
actualDeposit = decimal; |
|
|
|
} |
|
|
|
List<LoanSettleVoucherVo> settleVoucherVos = carryForward2(loanSettleApply); |
|
|
|
// BigDecimal decimal = carryForward(loanSettleApply);
|
|
|
|
// if (null != decimal) {
|
|
|
|
// actualDeposit = decimal;
|
|
|
|
// }
|
|
|
|
//更新车辆表结清状态
|
|
|
|
baseMapper.updateBus(loanSettleApply.getBusVinSid(), "1"); |
|
|
|
//推送资方结清款到出纳代付款列表
|
|
|
@ -2896,7 +3607,8 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
//设置认款月还为已转付
|
|
|
|
updatePaymentStateByBusVinSid(loanSettleApply.getBusVinSid()); |
|
|
|
//推送财务凭证
|
|
|
|
pushSettleVoucher(loanSettleApply, 1, actualDeposit); |
|
|
|
// pushSettleVoucher(loanSettleApply, 1, actualDeposit);
|
|
|
|
pushSettleVoucher2(loanSettleApply, 1, settleVoucherVos); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
@ -3276,10 +3988,19 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
SettleFinVo vo = new SettleFinVo(); |
|
|
|
LoanSettleApply apply = baseMapper.getFinSettleVo(busVinSid); |
|
|
|
if (null != apply) { |
|
|
|
LoanRepaymentPlanDetails planDetails = baseMapper.selectByBusVinSidAndDesc(busVinSid); |
|
|
|
String scheduleSid = planDetails.getScheduleSid(); |
|
|
|
LoanRepaymentSchedule schedule = loanRepaymentScheduleService.fetchBySid(scheduleSid); |
|
|
|
if (schedule.getIsOtherPolicy().equals("1") && schedule.getSameBank().equals("0")) { |
|
|
|
planDetails = baseMapper.selectMainPeriodByBusVinSid(busVinSid); |
|
|
|
} |
|
|
|
String planDetailsSid = planDetails.getSid(); |
|
|
|
String sid = apply.getSid(); |
|
|
|
BigDecimal amount = new BigDecimal(subscriptionMoney); |
|
|
|
BigDecimal balance = BigDecimal.ZERO; |
|
|
|
BigDecimal subtrahend = BigDecimal.ZERO; |
|
|
|
BigDecimal balance = BigDecimal.ZERO; //差额
|
|
|
|
BigDecimal kuanxiang = BigDecimal.ZERO; //差额
|
|
|
|
BigDecimal companyAmount = BigDecimal.ZERO; //公司收
|
|
|
|
BigDecimal subtrahend = BigDecimal.ZERO; //资方收
|
|
|
|
LoanSettleCompanyCost companyCost = loanSettleCompanyCostService.selectByMainSid(sid); |
|
|
|
LoanSettleBankCost bankCost = loanSettleBankCostService.selectByMainSid(sid); |
|
|
|
if (null != bankCost) { |
|
|
@ -3299,11 +4020,37 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
balance = amount.subtract(subtrahend); |
|
|
|
if (null != companyCost) { |
|
|
|
if (receivablesName.equals("名义价")) { |
|
|
|
if (null != companyCost.getCompanyNominalPrice()) { |
|
|
|
companyAmount = companyCost.getCompanyNominalPrice(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (receivablesName.equals("合同违约金")) { |
|
|
|
if (null != companyCost.getContractLiquidated()) { |
|
|
|
companyAmount = companyCost.getContractLiquidated(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (receivablesName.equals("其他费用")) { |
|
|
|
if (null != companyCost.getCompanyOtherPrice()) { |
|
|
|
companyAmount = companyCost.getCompanyOtherPrice(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
PlanNoReturnMoney p = baseMapper.selectNoReturnMoneyByType(planDetailsSid, receivablesName); |
|
|
|
if (null != p) { |
|
|
|
BigDecimal money = new BigDecimal(p.getMoney()); |
|
|
|
if (money.compareTo(BigDecimal.ZERO) == 0) { |
|
|
|
balance = companyAmount.subtract(subtrahend); |
|
|
|
} |
|
|
|
} else { |
|
|
|
balance = companyAmount.subtract(subtrahend); |
|
|
|
} |
|
|
|
kuanxiang = amount.subtract(balance); |
|
|
|
vo.setBusSid(sid); |
|
|
|
vo.setAmount(amount); |
|
|
|
vo.setBalance(balance); |
|
|
|
vo.setSubtrahend(subtrahend); |
|
|
|
vo.setSubtrahend(kuanxiang); |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
return rb; |
|
|
|