|
|
@ -8,8 +8,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrder; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorder.flowable.BusSalesOrderDelegateQuery; |
|
|
|
import com.yxt.anrui.fin.api.finpaymentrecord.FinPaymentrecordDto; |
|
|
|
import com.yxt.anrui.fin.api.finpaymentrecord.FinPaymentrecordFeign; |
|
|
|
import com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectedReceivablesDetailed; |
|
|
|
import com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectedReceivablesDetailedFeign; |
|
|
|
import com.yxt.anrui.fin.api.finuncollectedreceivablesdetailed.FinUncollectedReceivablesDetailed; |
|
|
|
import com.yxt.anrui.fin.api.finuncollectedreceivablesdetailedjr.FinUncollectedReceivablesDetailedJR; |
|
|
|
import com.yxt.anrui.fin.api.finuncollectedreceivablesdetailedjr.FinUncollectedReceivablesDetailedJRFeign; |
|
|
|
import com.yxt.anrui.flowable.api.flow.FlowableFeign; |
|
|
@ -29,6 +32,7 @@ import com.yxt.anrui.portal.api.sysuser.PrivilegeQuery; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanoverduefin.UrlQuery; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.LoanRepaymentHistory; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetails; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.LoanRepaymentSchedule; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansettleapply.*; |
|
|
@ -42,6 +46,8 @@ import com.yxt.anrui.riskcenter.api.loansettlecompanyreduction.LoanSettleCompany |
|
|
|
import com.yxt.anrui.riskcenter.api.loansettlevehicle.LoanSettleVehicleDto; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansolutions.LoanSolutions; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansolutionsdetail.LoanSolutionsDetail; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepaymenthistory.LoanRepaymentHistoryService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepaymentplandetails.LoanRepaymentPlanDetailsService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepaymentschedule.LoanRepaymentScheduleService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loansettlebankcost.LoanSettleBankCostMapper; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loansettlebankcost.LoanSettleBankCostService; |
|
|
@ -82,6 +88,8 @@ import java.util.stream.Collectors; |
|
|
|
@Service |
|
|
|
public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMapper, LoanSettleApply> { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private FinPaymentrecordFeign finPaymentrecordFeign; |
|
|
|
@Autowired |
|
|
|
private FlowFeign flowFeign; |
|
|
|
@Autowired |
|
|
@ -124,7 +132,10 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
private FinUncollectedReceivablesDetailedJRFeign finUncollectedReceivablesDetailedJRFeign; |
|
|
|
@Autowired |
|
|
|
private FinSelectedReceivablesDetailedFeign finSelectedReceivablesDetailedFeign; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private LoanRepaymentHistoryService loanRepaymentHistoryService; |
|
|
|
@Autowired |
|
|
|
private LoanRepaymentPlanDetailsService loanRepaymentPlanDetailsService; |
|
|
|
|
|
|
|
public PagerVo<LoanSettleApplyVo> listPageVo(PagerQuery<LoanSettleApplyQuery> pq) { |
|
|
|
LoanSettleApplyQuery query = pq.getParams(); |
|
|
@ -308,7 +319,8 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
String busVinSid = query.getBusVinSid(); |
|
|
|
String orgPath = query.getOrgPath(); |
|
|
|
String userSid = query.getUserSid(); |
|
|
|
if (StringUtils.isBlank(sid)) {//新增初始化
|
|
|
|
if (StringUtils.isBlank(sid)) { |
|
|
|
//新增初始化
|
|
|
|
//根据用户查询发起人、发起部门、发起日期为当前日期
|
|
|
|
String deptName = ""; |
|
|
|
String deptSid = ""; |
|
|
@ -479,20 +491,20 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
settleApplyCommonVo.setPutBankInterest(putBankInterest); |
|
|
|
//资金占用费
|
|
|
|
String funfCost = baseMapper.selectZjzyf(busVinSid, settingDate); |
|
|
|
String dk = baseMapper.selectDk(busVinSid, settingDate); |
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
//计算当日资金占用费根据垫款总额
|
|
|
|
try { |
|
|
|
Date d1 = format.parse(settingDate);//毫秒ms
|
|
|
|
Date d2 = format.parse(DateUtil.today());//毫秒ms
|
|
|
|
long diff = d2.getTime() - d1.getTime(); |
|
|
|
long diffDays = diff / (24 * 60 * 60 * 1000); |
|
|
|
int i = new Long(diffDays).intValue() + 1; |
|
|
|
String dks = new BigDecimal(dk).multiply(new BigDecimal("0.0007")).multiply(new BigDecimal(i)).setScale(2, RoundingMode.HALF_UP).toString(); |
|
|
|
funfCost = new BigDecimal(funfCost).add(new BigDecimal(dks)).toString(); |
|
|
|
} catch (ParseException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
// String dk = baseMapper.selectDk(busVinSid, settingDate);
|
|
|
|
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
// //计算当日资金占用费根据垫款总额
|
|
|
|
// try {
|
|
|
|
// Date d1 = format.parse(settingDate);//毫秒ms
|
|
|
|
// Date d2 = format.parse(DateUtil.today());//毫秒ms
|
|
|
|
// long diff = d2.getTime() - d1.getTime();
|
|
|
|
// long diffDays = diff / (24 * 60 * 60 * 1000);
|
|
|
|
// int i = new Long(diffDays).intValue() + 1;
|
|
|
|
// String dks = new BigDecimal(dk).multiply(new BigDecimal("0.0007")).multiply(new BigDecimal(i)).setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
|
// funfCost = new BigDecimal(funfCost).add(new BigDecimal(dks)).toString();
|
|
|
|
// } catch (ParseException e) {
|
|
|
|
// e.printStackTrace();
|
|
|
|
// }
|
|
|
|
|
|
|
|
settleApplyCommonVo.setFunfCost(funfCost); |
|
|
|
//公司当前逾期月还
|
|
|
@ -510,6 +522,9 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
//根据销售订单查询还款计划主表
|
|
|
|
LoanRepaymentSchedule schedule = loanRepaymentScheduleService.fetchBySid(scheduleSid); |
|
|
|
if (null != schedule) { |
|
|
|
if (StringUtils.isNotBlank(schedule.getBankSid())) { |
|
|
|
settleApplyCommonVo.setBankSid(schedule.getBankSid()); |
|
|
|
} |
|
|
|
BigDecimal bondAmounts = BigDecimal.ZERO; |
|
|
|
if (null != schedule.getBondAmounts()) { |
|
|
|
bondAmounts = schedule.getBondAmounts(); |
|
|
@ -717,25 +732,34 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(resultBean.getData())); |
|
|
|
if ("Event_end".equals(resultBean.getData().getTaskDefKey())) { |
|
|
|
loanSettleApply = fetchBySid(businessSid); |
|
|
|
loanSettleApply.setCloseDate(DateUtil.today()); |
|
|
|
loanSettleApply.setCloseDate(new Date()); |
|
|
|
loanSettleApply.setSettingDate(DateUtil.today()); |
|
|
|
baseMapper.updateById(loanSettleApply); |
|
|
|
// //更新车辆表结清状态
|
|
|
|
// baseMapper.updateBus(loanSettleApply.getBusVinSid(),"1");
|
|
|
|
//推送到结清车辆台账
|
|
|
|
// pushSettlevehicle(businessSid);
|
|
|
|
LoanSettleCompanyReduction reduction = loanSettleCompanyReductionService.selectByMainSid(businessSid); |
|
|
|
if (null != reduction) { |
|
|
|
//获取公司减免情况
|
|
|
|
BigDecimal amountTo = BigDecimal.ZERO; |
|
|
|
if (null != reduction.getAmountTo()) { |
|
|
|
amountTo = reduction.getAmountTo(); |
|
|
|
} |
|
|
|
if (amountTo.compareTo(BigDecimal.ZERO) <= 0) { |
|
|
|
//推送应收、结转、减免。
|
|
|
|
pushUnColl(businessSid); |
|
|
|
if (loanSettleApply.getTrueReduction() == 1) { |
|
|
|
LoanSettleCompanyReduction reduction = loanSettleCompanyReductionService.selectByMainSid(businessSid); |
|
|
|
if (null != reduction) { |
|
|
|
//获取公司减免情况
|
|
|
|
BigDecimal amountTo = BigDecimal.ZERO; |
|
|
|
if (null != reduction.getAmountTo()) { |
|
|
|
amountTo = reduction.getAmountTo(); |
|
|
|
} |
|
|
|
//生成结清应收
|
|
|
|
pushNewUnLists(loanSettleApply); |
|
|
|
if (amountTo.compareTo(BigDecimal.ZERO) <= 0) { |
|
|
|
//减免后结清合计 <= 0
|
|
|
|
//结转剩余保证金
|
|
|
|
carryForward(loanSettleApply); |
|
|
|
//减免剩余应收
|
|
|
|
reliefMoney(loanSettleApply); |
|
|
|
//设置结清申请的“客户结清确认”状态为是
|
|
|
|
loanSettleApply.setState(1); |
|
|
|
//更新车辆表结清状态
|
|
|
|
baseMapper.updateBus(loanSettleApply.getBusVinSid(), "1"); |
|
|
|
//推送资方结清款到出纳代付款列表
|
|
|
|
pushBankSettlePrice(loanSettleApply); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
baseMapper.updateById(loanSettleApply); |
|
|
|
} else { |
|
|
|
//极光推送
|
|
|
|
loanSettleApply = fetchBySid(businessSid); |
|
|
@ -758,6 +782,676 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//---------------------------------- 结清生成应收新逻辑 ---------------------
|
|
|
|
private void pushNewUnLists(LoanSettleApply loanSettleApply) { |
|
|
|
List<FinUncollectedReceivablesDetailedJR> list = new ArrayList<>(); |
|
|
|
List<FinUncollectedReceivablesDetailedJR> updateList = new ArrayList<>(); |
|
|
|
//资方逾期利息应收、名义价应收、合同违约金应收、其他费用应收
|
|
|
|
LoanSettleCompanyCost loanSettleCompanyCost = loanSettleCompanyCostService.selectByMainSid(loanSettleApply.getSid()); |
|
|
|
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(); |
|
|
|
FinUncollectedReceivablesDetailedJR jr1 = finUncollectedReceivablesDetailedJRFeign.getUnJrByPayCostTitleKeyAndBusSid("012", planDetailsSid).getData(); |
|
|
|
if (null != jr1) { |
|
|
|
if (null != loanSettleCompanyCost.getBankOverInterest()) { |
|
|
|
jr1.setReveivableMoney(loanSettleCompanyCost.getBankOverInterest()); |
|
|
|
updateList.add(jr1); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (loanSettleCompanyCost.getBankOverInterest().compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
//资方逾期利息应收
|
|
|
|
FinUncollectedReceivablesDetailedJR jr = new FinUncollectedReceivablesDetailedJR(); |
|
|
|
jr.setBusSid(planDetails.getSid()); |
|
|
|
jr.setReveivableMoney(loanSettleCompanyCost.getBankOverInterest()); |
|
|
|
jr.setPayCostTitleKey("012"); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
FinUncollectedReceivablesDetailedJR jr2 = finUncollectedReceivablesDetailedJRFeign.getUnJrByPayCostTitleKeyAndBusSid("009", planDetailsSid).getData(); |
|
|
|
if (null != jr2) { |
|
|
|
if (null != loanSettleCompanyCost.getCompanyNominalPrice()) { |
|
|
|
jr2.setReveivableMoney(loanSettleCompanyCost.getCompanyNominalPrice()); |
|
|
|
updateList.add(jr1); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (loanSettleCompanyCost.getCompanyNominalPrice().compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
//名义价应收
|
|
|
|
FinUncollectedReceivablesDetailedJR jr = new FinUncollectedReceivablesDetailedJR(); |
|
|
|
jr.setBusSid(planDetails.getSid()); |
|
|
|
jr.setReveivableMoney(loanSettleCompanyCost.getCompanyNominalPrice()); |
|
|
|
jr.setPayCostTitleKey("009"); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
FinUncollectedReceivablesDetailedJR jr3 = finUncollectedReceivablesDetailedJRFeign.getUnJrByPayCostTitleKeyAndBusSid("010", planDetailsSid).getData(); |
|
|
|
if (null != jr3) { |
|
|
|
if (null != loanSettleCompanyCost.getContractLiquidated()) { |
|
|
|
jr3.setReveivableMoney(loanSettleCompanyCost.getContractLiquidated()); |
|
|
|
updateList.add(jr3); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (loanSettleCompanyCost.getContractLiquidated().compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
//合同违约金应收
|
|
|
|
FinUncollectedReceivablesDetailedJR jr = new FinUncollectedReceivablesDetailedJR(); |
|
|
|
jr.setBusSid(planDetails.getSid()); |
|
|
|
jr.setReveivableMoney(loanSettleCompanyCost.getContractLiquidated()); |
|
|
|
jr.setPayCostTitleKey("010"); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
FinUncollectedReceivablesDetailedJR jr4 = finUncollectedReceivablesDetailedJRFeign.getUnJrByPayCostTitleKeyAndBusSid("011", planDetailsSid).getData(); |
|
|
|
if (null != jr4) { |
|
|
|
if (null != loanSettleCompanyCost.getContractLiquidated()) { |
|
|
|
jr4.setReveivableMoney(loanSettleCompanyCost.getContractLiquidated()); |
|
|
|
updateList.add(jr4); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (loanSettleCompanyCost.getCompanyOtherPrice().compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
//公司其他费用应收
|
|
|
|
FinUncollectedReceivablesDetailedJR jr = new FinUncollectedReceivablesDetailedJR(); |
|
|
|
jr.setBusSid(planDetails.getSid()); |
|
|
|
jr.setReveivableMoney(loanSettleCompanyCost.getCompanyOtherPrice()); |
|
|
|
jr.setPayCostTitleKey("011"); |
|
|
|
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) { |
|
|
|
finUncollectedReceivablesDetailedJRFeign.saveAll(list); |
|
|
|
} |
|
|
|
if (!updateList.isEmpty() && updateList.size() > 0) { |
|
|
|
finUncollectedReceivablesDetailedJRFeign.updateList(updateList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------- 贷款保证金结转 -------------------------
|
|
|
|
private void carryForward(LoanSettleApply loanSettleApply) { |
|
|
|
String userSid = loanSettleApply.getCreateBySid(); |
|
|
|
BigDecimal deposit = BigDecimal.ZERO; // 贷款保证金 - (扣罚金额-贷款保证金减免)
|
|
|
|
BigDecimal depositKF = BigDecimal.ZERO; // 贷款保证金 - (扣罚金额-贷款保证金减免)
|
|
|
|
BigDecimal depositJM = BigDecimal.ZERO; // 贷款保证金 - (扣罚金额-贷款保证金减免)
|
|
|
|
BigDecimal amountTo = BigDecimal.ZERO; // 资方结清合计
|
|
|
|
String busVinSid = loanSettleApply.getBusVinSid(); |
|
|
|
List<LoanRepaymentHistory> histories = new ArrayList<>();//还款记录
|
|
|
|
List<FinSelectedReceivablesDetailed> selectList = new ArrayList<>(); |
|
|
|
List<LoanRepaymentPlanDetails> payments = new ArrayList<>(); //消减垫款金额列表
|
|
|
|
List<LoanRepaymentPlanDetails> yqlx = 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 (null != companyCost.getDeductionAmount()) { |
|
|
|
depositKF = companyCost.getDeductionAmount(); |
|
|
|
} |
|
|
|
} |
|
|
|
LoanSettleCompanyReduction reduction = loanSettleCompanyReductionService.selectByMainSid(loanSettleApply.getSid()); |
|
|
|
if (null != reduction) { |
|
|
|
if (null != reduction.getDepositPenalty()) { |
|
|
|
depositJM = reduction.getDepositPenalty(); |
|
|
|
} |
|
|
|
if (null != reduction.getAmountTo()) { |
|
|
|
amountTo = reduction.getAmountTo(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (amountTo.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
deposit = deposit.subtract(depositKF).add(depositJM); |
|
|
|
} else if (amountTo.compareTo(BigDecimal.ZERO) <= 0) { |
|
|
|
deposit = deposit.subtract(depositKF).add(depositJM).add(amountTo); |
|
|
|
} |
|
|
|
//按照顺序结转
|
|
|
|
//月还
|
|
|
|
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 pd = loanRepaymentPlanDetailsService.fetchBySid(sid); |
|
|
|
if (null != pd.getPaymentMoney()) { |
|
|
|
BigDecimal paymentMoney = pd.getPaymentMoney(); |
|
|
|
if (mm.compareTo(paymentMoney) >= 0) { |
|
|
|
pd.setPaymentMoney(new BigDecimal("0")); |
|
|
|
} else { |
|
|
|
pd.setPaymentMoney(paymentMoney.subtract(mm)); |
|
|
|
} |
|
|
|
payments.add(pd); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//结转垫资方逾期利息
|
|
|
|
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(); |
|
|
|
LoanRepaymentPlanDetails pd = loanRepaymentPlanDetailsService.fetchBySid(sid); |
|
|
|
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed(); |
|
|
|
fin.setCreateBySid(userSid); |
|
|
|
fin.setRemarks("结转"); |
|
|
|
fin.setVIN(pd.getVinNo()); |
|
|
|
fin.setUseOrgSid(pd.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(pd.getUseOrgName()); |
|
|
|
fin.setOrgSidPath(loanSettleApply.getOrgSidPath()); |
|
|
|
selectList.add(fin); |
|
|
|
if (null != pd.getPaymentInterest()) { |
|
|
|
BigDecimal paymentInterest = pd.getPaymentInterest(); |
|
|
|
if (mm.compareTo(paymentInterest) >= 0) { |
|
|
|
pd.setPaymentInterest(new BigDecimal("0")); |
|
|
|
} else { |
|
|
|
pd.setPaymentInterest(paymentInterest.subtract(mm)); |
|
|
|
} |
|
|
|
yqlx.add(pd); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//结转资方逾期利息
|
|
|
|
if (deposit.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
PlanNoReturnMoney p = baseMapper.selectNoReturnMoneyByType(planDetailsSid, "结清时资方逾期利息"); |
|
|
|
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) { |
|
|
|
fin.setSubscriptionMoney(money); |
|
|
|
deposit = deposit.subtract(money); |
|
|
|
} else { |
|
|
|
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); |
|
|
|
} |
|
|
|
//名义价
|
|
|
|
if (deposit.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
PlanNoReturnMoney p = baseMapper.selectNoReturnMoneyByType(planDetailsSid, "名义价"); |
|
|
|
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) { |
|
|
|
fin.setSubscriptionMoney(money); |
|
|
|
deposit = deposit.subtract(money); |
|
|
|
} else { |
|
|
|
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); |
|
|
|
} |
|
|
|
//合同违约金
|
|
|
|
if (deposit.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
PlanNoReturnMoney p = baseMapper.selectNoReturnMoneyByType(planDetailsSid, "合同违约金"); |
|
|
|
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) { |
|
|
|
fin.setSubscriptionMoney(money); |
|
|
|
deposit = deposit.subtract(money); |
|
|
|
} else { |
|
|
|
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); |
|
|
|
} |
|
|
|
//其他费用
|
|
|
|
if (deposit.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
PlanNoReturnMoney p = baseMapper.selectNoReturnMoneyByType(planDetailsSid, "其他费用"); |
|
|
|
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) { |
|
|
|
fin.setSubscriptionMoney(money); |
|
|
|
deposit = deposit.subtract(money); |
|
|
|
} else { |
|
|
|
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); |
|
|
|
} |
|
|
|
//资金占用费
|
|
|
|
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 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) { |
|
|
|
fin.setSubscriptionMoney(money); |
|
|
|
deposit = deposit.subtract(money); |
|
|
|
} else { |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (histories.size() > 0 && !histories.isEmpty()) { |
|
|
|
loanRepaymentHistoryService.saveList(histories); |
|
|
|
} |
|
|
|
if (payments.size() > 0 && !payments.isEmpty()) { |
|
|
|
loanRepaymentPlanDetailsService.updateList(payments); |
|
|
|
} |
|
|
|
if (yqlx.size() > 0 && !yqlx.isEmpty()) { |
|
|
|
loanRepaymentPlanDetailsService.updateList(yqlx); |
|
|
|
} |
|
|
|
selectList.removeAll(Collections.singleton(null)); |
|
|
|
if (selectList.size() > 0 && !selectList.isEmpty()) { |
|
|
|
ResultBean resultBean = finSelectedReceivablesDetailedFeign.saveAll(selectList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------- 减免 ----------------------------
|
|
|
|
private void reliefMoney(LoanSettleApply loanSettleApply) { |
|
|
|
String userSid = loanSettleApply.getCreateBySid(); |
|
|
|
String busVinSid = loanSettleApply.getBusVinSid(); |
|
|
|
List<LoanRepaymentHistory> histories = new ArrayList<>();//还款记录
|
|
|
|
List<FinSelectedReceivablesDetailed> selectList = new ArrayList<>(); |
|
|
|
List<LoanRepaymentPlanDetails> payments = new ArrayList<>(); //消减垫款金额列表
|
|
|
|
List<LoanRepaymentPlanDetails> yqlx = 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(); |
|
|
|
//资金占用费
|
|
|
|
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()); |
|
|
|
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed(); |
|
|
|
fin.setCreateBySid(userSid); |
|
|
|
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(m.getJrSid()); |
|
|
|
fin.setKxState("01"); |
|
|
|
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); |
|
|
|
LoanRepaymentPlanDetails pd = loanRepaymentPlanDetailsService.fetchBySid(sid); |
|
|
|
if (null != pd.getPaymentMoney()) { |
|
|
|
BigDecimal paymentMoney = pd.getPaymentMoney(); |
|
|
|
pd.setPaymentMoney(new BigDecimal("0")); |
|
|
|
payments.add(pd); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//垫资方逾期利息
|
|
|
|
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(); |
|
|
|
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); |
|
|
|
if (null != pd.getPaymentInterest()) { |
|
|
|
BigDecimal paymentInterest = pd.getPaymentInterest(); |
|
|
|
pd.setPaymentInterest(new BigDecimal("0")); |
|
|
|
yqlx.add(pd); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//资方逾期利息
|
|
|
|
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); |
|
|
|
} |
|
|
|
if (histories.size() > 0 && !histories.isEmpty()) { |
|
|
|
loanRepaymentHistoryService.saveList(histories); |
|
|
|
} |
|
|
|
if (payments.size() > 0 && !payments.isEmpty()) { |
|
|
|
loanRepaymentPlanDetailsService.updateList(payments); |
|
|
|
} |
|
|
|
if (yqlx.size() > 0 && !yqlx.isEmpty()) { |
|
|
|
loanRepaymentPlanDetailsService.updateList(yqlx); |
|
|
|
} |
|
|
|
selectList.removeAll(Collections.singleton(null)); |
|
|
|
if (selectList.size() > 0 && !selectList.isEmpty()) { |
|
|
|
ResultBean resultBean = finSelectedReceivablesDetailedFeign.saveAll(selectList); |
|
|
|
} |
|
|
|
} |
|
|
|
//--------------------资方结清款到出纳代付款列表------------------
|
|
|
|
private void pushBankSettlePrice(LoanSettleApply loanSettleApply) { |
|
|
|
if (StringUtils.isBlank(loanSettleApply.getBusSid())) { |
|
|
|
LoanSettleBankCost bankCost = loanSettleBankCostService.selectByMainSid(loanSettleApply.getSid()); |
|
|
|
if (null != bankCost) { |
|
|
|
if (null != bankCost.getBankSettlePrice()) { |
|
|
|
BigDecimal bankSettlePrice = bankCost.getBankSettlePrice(); |
|
|
|
if (bankSettlePrice.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
FinPaymentrecordDto finPaymentrecordDto = new FinPaymentrecordDto(); |
|
|
|
finPaymentrecordDto.setApplySid(""); |
|
|
|
finPaymentrecordDto.setPayCompanySid(""); |
|
|
|
finPaymentrecordDto.setPayType(1); |
|
|
|
finPaymentrecordDto.setCreateOrgSid(loanSettleApply.getUseOrgSid()); |
|
|
|
finPaymentrecordDto.setUseOrgSid(loanSettleApply.getUseOrgSid()); |
|
|
|
finPaymentrecordDto.setCostTypeKey(""); |
|
|
|
finPaymentrecordDto.setCostTypeValue("资方结清款"); |
|
|
|
finPaymentrecordDto.setCostTitleKey(""); |
|
|
|
finPaymentrecordDto.setCostTitleValue("资方结清款"); |
|
|
|
finPaymentrecordDto.setReceiveBank(""); |
|
|
|
if (StringUtils.isNotBlank(bankCost.getBankAccount())) { |
|
|
|
finPaymentrecordDto.setReceiveBankAccount(bankCost.getBankAccount()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(bankCost.getAccountName())) { |
|
|
|
finPaymentrecordDto.setReceiveCompany(bankCost.getAccountName()); |
|
|
|
} |
|
|
|
finPaymentrecordDto.setCost(bankSettlePrice.toString()); |
|
|
|
finPaymentrecordDto.setAccountsReceive(bankSettlePrice.toString()); |
|
|
|
finPaymentrecordDto.setBusSid(loanSettleApply.getSid()); |
|
|
|
finPaymentrecordDto.setPayRemark(""); |
|
|
|
finPaymentrecordDto.setPayCode(""); |
|
|
|
finPaymentrecordDto.setCreateBySid(loanSettleApply.getCreateBySid()); |
|
|
|
finPaymentrecordDto.setUpdateBySid(loanSettleApply.getCreateBySid()); |
|
|
|
finPaymentrecordDto.setRemarks(loanSettleApply.getRemarks()); |
|
|
|
finPaymentrecordDto.setPurchaseSystemSid(""); |
|
|
|
finPaymentrecordDto.setPurchaseSystemName(""); |
|
|
|
finPaymentrecordDto.setBusRemarks(""); |
|
|
|
String sid = finPaymentrecordFeign.save(finPaymentrecordDto).getData(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void pushUnColl(String businessSid) { |
|
|
|
LoanSettleApply loanSettleApply = fetchBySid(businessSid); |
|
|
|
List<FinUncollectedReceivablesDetailedJR> list = new ArrayList<>(); |
|
|
@ -1452,8 +2146,8 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
updateFlowFiled(map); |
|
|
|
loanSettleApply = fetchBySid(query.getBusinessSid()); |
|
|
|
if (loanSettleApply.getNodeState().equals("终止")) { |
|
|
|
//修改车辆结算状态为0
|
|
|
|
baseMapper.updateBus(loanSettleApply.getBusVinSid(),"0"); |
|
|
|
//修改车辆结算状态为0
|
|
|
|
baseMapper.updateBus(loanSettleApply.getBusVinSid(), "0"); |
|
|
|
} |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} else { |
|
|
@ -1469,7 +2163,7 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
loanSettleApply = fetchBySid(query.getBusinessSid()); |
|
|
|
if (loanSettleApply.getNodeState().equals("终止")) { |
|
|
|
//修改车辆结算状态为0
|
|
|
|
baseMapper.updateBus(loanSettleApply.getBusVinSid(),"0"); |
|
|
|
baseMapper.updateBus(loanSettleApply.getBusVinSid(), "0"); |
|
|
|
} |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} |
|
|
@ -1626,7 +2320,7 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
qw.eq("bv.repoState", 0); |
|
|
|
} |
|
|
|
} |
|
|
|
qw.eq("ld.repaymentState",1); |
|
|
|
qw.eq("ld.repaymentState", 1); |
|
|
|
qw.orderBy(true, true, "ld.loanContractNo", "bv.linkNo"); |
|
|
|
} |
|
|
|
IPage<LoanSettleApply> page = PagerUtil.queryToPage(pagerQuery); |
|
|
@ -1640,13 +2334,47 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa |
|
|
|
LoanSettleApply loanSettleApply = fetchBySid(sid); |
|
|
|
String settingDate = loanSettleApply.getSettingDate(); |
|
|
|
String formatDate = DateUtil.formatDate(new Date()); |
|
|
|
boolean settle = isSettle(loanSettleApply); |
|
|
|
if (!settle) { |
|
|
|
return rb.setMsg("结清款尚未认款完毕,请继续认款!"); |
|
|
|
} |
|
|
|
if (formatDate.compareTo(settingDate) > 0) { |
|
|
|
return rb.setMsg("只能在结清申请发起当日确认客户结清,若需结清,请重新发起结清申请!"); |
|
|
|
} else { |
|
|
|
pushConfirm(sid); |
|
|
|
loanSettleApply.setState(1); |
|
|
|
baseMapper.updateById(loanSettleApply); |
|
|
|
} |
|
|
|
loanSettleApply.setState(1); |
|
|
|
baseMapper.updateById(loanSettleApply); |
|
|
|
carryForward(loanSettleApply); |
|
|
|
reliefMoney(loanSettleApply); |
|
|
|
//更新车辆表结清状态
|
|
|
|
baseMapper.updateBus(loanSettleApply.getBusVinSid(), "1"); |
|
|
|
//推送资方结清款到出纳代付款列表
|
|
|
|
pushBankSettlePrice(loanSettleApply); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public boolean isSettle(LoanSettleApply loanSettleApply) { |
|
|
|
boolean isSettle = true; |
|
|
|
String busVinSid = loanSettleApply.getBusVinSid(); |
|
|
|
BigDecimal sumMoney = BigDecimal.ZERO; |
|
|
|
BigDecimal dueMoney = BigDecimal.ZERO; //月还
|
|
|
|
BigDecimal jrMoney = BigDecimal.ZERO; //金融认款金额
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
Date closeDate = loanSettleApply.getCloseDate(); |
|
|
|
String formatDate = sdf.format(closeDate); |
|
|
|
String jMoney = baseMapper.selJrMoneyByBusVinSidAndCloseDate(busVinSid,formatDate); |
|
|
|
jrMoney = new BigDecimal(jMoney); |
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return isSettle; |
|
|
|
} |
|
|
|
} |
|
|
|