@ -3,37 +3,26 @@ package com.yxt.anrui.riskcenter.biz.loansettleapply;
import cn.hutool.core.bean.BeanUtil ;
import cn.hutool.core.date.DateUtil ;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.JSONObject ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.google.common.util.concurrent.ThreadFactoryBuilder ;
import com.yxt.anrui.base.api.basemiddleman.BaseMiddlemanDetailsVo ;
import com.yxt.anrui.base.api.basepurchasesystem.BasePurchaseSystemDetailsVo ;
import com.yxt.anrui.base.api.basepurchasesystem.BasePurchaseSystemFeign ;
import com.yxt.anrui.base.api.commoncontract.CommonContract ;
import com.yxt.anrui.base.common.enums.BillTypeEnum ;
import com.yxt.anrui.base.common.utils.Rule ;
import com.yxt.anrui.base.common.utils.domain.BillNo ;
import com.yxt.anrui.buscenter.api.busdeposit.BusDeposit ;
import com.yxt.anrui.buscenter.api.busdepositfictitious.BusDepositFictitious ;
import com.yxt.anrui.buscenter.api.bussalesorder.* ;
import com.yxt.anrui.buscenter.api.bussalesorder.app.order.AppOrderDiscountListVo ;
import com.yxt.anrui.buscenter.api.bussalesorder.flowable.BusSalesOrderDelegateQuery ;
import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrder ;
import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrderFeign ;
import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrderSourceLCVo ;
import com.yxt.anrui.buscenter.api.bussalesorderborrower.BusSalesOrderBorrowerDetailsVo ;
import com.yxt.anrui.buscenter.api.bussalesorderborrower.BusSalesOrderBorrowerFeign ;
import com.yxt.anrui.buscenter.api.bussalesorderdeposit.BusSalesOrderDeposit ;
import com.yxt.anrui.buscenter.api.bussalesorderinsurance.BusSalesOrderInsuranceDetailsVo ;
import com.yxt.anrui.buscenter.api.bussalesordermodel.BusSalesOrderModel ;
import com.yxt.anrui.buscenter.api.bussalesorderprice.BusSalesOrderPrice ;
import com.yxt.anrui.buscenter.api.bussalesordersubmit.BusSalesOrderSubmit ;
import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicle ;
import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicleFeign ;
import com.yxt.anrui.fin.api.finmanufacturerbank.FinManufacturerBank ;
import com.yxt.anrui.fin.api.finpaymentrecord.FinPaymentrecord ;
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.fin.api.kingdee.FinKingDeeFeign ;
@ -54,16 +43,13 @@ 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 ;
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationVo ;
import com.yxt.anrui.portal.api.sysparameter.SysParameterFeign ;
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgFeign ;
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgVo ;
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.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 ;
@ -79,10 +65,9 @@ import com.yxt.anrui.riskcenter.api.loansettlecompanycost.LoanSettleCompanyCostV
import com.yxt.anrui.riskcenter.api.loansettlecompanyreduction.LoanSettleCompanyReduction ;
import com.yxt.anrui.riskcenter.api.loansettlecompanyreduction.LoanSettleCompanyReductionVo ;
import com.yxt.anrui.riskcenter.api.loansettlevehicle.LoanSettleVehicleDto ;
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.api.loanvoucher.RskPaymentVoucher ;
import com.yxt.anrui.riskcenter.api.loanvoucher.RskVoucher ;
import com.yxt.anrui.riskcenter.biz.loanpushfundhistory.LoanPushFundHistoryService ;
import com.yxt.anrui.riskcenter.biz.loanrepaymenthistory.LoanRepaymentHistoryService ;
import com.yxt.anrui.riskcenter.biz.loanrepaymentplandetails.LoanRepaymentPlanDetailsService ;
@ -100,8 +85,10 @@ import com.yxt.anrui.riskcenter.biz.loansolutionsdetail.LoanSolutionsDetailServi
import com.yxt.common.base.config.component.DocPdfComponent ;
import com.yxt.common.base.config.component.FileUploadComponent ;
import com.yxt.common.base.service.MybatisBaseService ;
import com.yxt.common.base.utils.* ;
import com.yxt.common.base.utils.Base64 ;
import com.yxt.common.base.utils.ConstantUtils ;
import com.yxt.common.base.utils.PagerUtil ;
import com.yxt.common.base.utils.WordConvertUtils ;
import com.yxt.common.core.query.PagerQuery ;
import com.yxt.common.core.result.ResultBean ;
import com.yxt.common.core.vo.PagerVo ;
@ -111,7 +98,6 @@ import com.yxt.messagecenter.api.message.MessageFlowVo;
import com.yxt.messagecenter.api.message.MessageFlowableQuery ;
import com.yxt.messagecenter.api.messagelist.MessageList ;
import com.yxt.messagecenter.api.messagelist.MessageListFeign ;
import io.swagger.annotations.ApiModelProperty ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.tomcat.util.threads.ThreadPoolExecutor ;
import org.springframework.beans.factory.annotation.Autowired ;
@ -119,7 +105,6 @@ import org.springframework.stereotype.Service;
import java.io.* ;
import java.math.BigDecimal ;
import java.math.RoundingMode ;
import java.net.HttpURLConnection ;
import java.net.URL ;
import java.net.URLEncoder ;
@ -970,14 +955,9 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
int check = 0 ; // 0不推抵顶保证金凭证 1推送
//结清合计 + 贷款保证金结转金额
BigDecimal add = amountTo . add ( depositJZ ) ;
// BigDecimal actualDeposit = BigDecimal.ZERO;
List < LoanSettleVoucherVo > settleVoucherVos = new ArrayList < > ( ) ;
if ( add . compareTo ( BigDecimal . ZERO ) > 0 ) {
//结转剩余保证金
// BigDecimal decimal = carryForward(loanSettleApply);
// if (null != decimal) {
// actualDeposit = decimal;
// }
settleVoucherVos = carryForward2 ( loanSettleApply ) ;
check = 1 ;
}
@ -990,7 +970,6 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
//设置认款月还为已转付
updatePaymentStateByBusVinSid ( loanSettleApply . getBusVinSid ( ) ) ;
//推送财务凭证
// pushSettleVoucher(loanSettleApply, check, actualDeposit);
pushSettleVoucher2 ( loanSettleApply , check , settleVoucherVos ) ;
}
baseMapper . updateById ( loanSettleApply ) ;
@ -2269,6 +2248,15 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
BigDecimal zfJQK = BigDecimal . ZERO ; //资方结清款
int topping = 0 ;
BigDecimal bbjDDMoney = BigDecimal . ZERO ; //资方保证金抵顶
BigDecimal wdqlxjm = BigDecimal . ZERO ; //未到期利息减免
BigDecimal gsdqwdqyh = BigDecimal . ZERO ; //公司当期未到期月还
BigDecimal gswdqje = BigDecimal . ZERO ; //公司未到期金额
BigDecimal gswdqlxjm = BigDecimal . ZERO ; //公司未到期利息减免
BigDecimal zfdqwdqyh = BigDecimal . ZERO ; //资方当期未到期月还
BigDecimal zfwdqje = BigDecimal . ZERO ; //资方未到期金额
BigDecimal zfwdqlxjm = BigDecimal . ZERO ; //资方未到期利息减免
if ( null ! = reduction ) {
if ( null ! = reduction . getFundPenalty ( ) ) {
fund = reduction . getFundPenalty ( ) ;
@ -2276,6 +2264,12 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
if ( null ! = reduction . getDepositPenalty ( ) ) {
bzjJM = reduction . getDepositPenalty ( ) ;
}
if ( null ! = reduction . getNotDuePriceRelief ( ) ) {
gswdqlxjm = reduction . getNotDuePriceRelief ( ) ;
}
if ( null ! = reduction . getReliefBasis ( ) ) {
zfwdqlxjm = reduction . getReliefBasis ( ) ;
}
}
if ( null ! = companyCost ) {
if ( null ! = companyCost . getLoanDeposit ( ) ) {
@ -2284,6 +2278,13 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
if ( null ! = companyCost . getDeductionAmount ( ) ) {
bzjKF = companyCost . getDeductionAmount ( ) ;
}
if ( null ! = companyCost . getCompanyCurrentNotPrice ( ) ) {
gsdqwdqyh = companyCost . getCompanyCurrentNotPrice ( ) ;
}
if ( null ! = companyCost . getBankNotPrice ( ) ) {
gswdqje = companyCost . getBankNotPrice ( ) ;
}
}
if ( null ! = bankCost ) {
if ( null ! = bankCost . getBankSettlePrice ( ) ) {
@ -2293,6 +2294,12 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
if ( null ! = bankCost . getLoanDeposit ( ) ) {
bbjDDMoney = bankCost . getLoanDeposit ( ) ;
}
if ( null ! = bankCost . getCurrentNotDuePrice ( ) ) {
zfdqwdqyh = bankCost . getCurrentNotDuePrice ( ) ;
}
if ( null ! = bankCost . getNotDuePrice ( ) ) {
zfwdqje = bankCost . getNotDuePrice ( ) ;
}
}
sybzj = bzjMoney . subtract ( bzjKF ) . add ( bzjJM ) ;
bzjKFCw = bzjKF . subtract ( bzjJM ) ;
@ -2497,6 +2504,37 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
voucherDetail . setDebit ( amountAll . toString ( ) ) ;
resultDetails . add ( voucherDetail ) ;
}
BigDecimal yhcesrCompany = gsdqwdqyh . add ( gswdqje ) . subtract ( gswdqlxjm ) ; //月还差额计收入 公司部分
BigDecimal yhcesrBank = zfdqwdqyh . add ( zfwdqje ) . subtract ( zfwdqlxjm ) ; //月还差额计收入 资方部分
BigDecimal yhcejsr = yhcesrCompany . subtract ( yhcesrBank ) ; //月还差额记收入
BigDecimal yhjmjf = yhcejsr . add ( gswdqlxjm ) ;
if ( yhjmjf . compareTo ( BigDecimal . ZERO ) > 0 ) {
Voucher . VoucherResultDetailDto voucherDetail = new Voucher . VoucherResultDetailDto ( ) ;
voucherDetail . setSummary ( planDetails . getBankName ( ) + "结清" ) ;
voucherDetail . setSubjectNo ( bankCode ) ;
voucherDetail . setDimensionDept ( deptCode ) ;
voucherDetail . setDimensionCustom ( customerNumber ) ;
voucherDetail . setDebit ( yhjmjf . toString ( ) ) ;
resultDetails . add ( voucherDetail ) ;
}
if ( gswdqlxjm . compareTo ( BigDecimal . ZERO ) > 0 ) {
Voucher . VoucherResultDetailDto voucherDetail = new Voucher . VoucherResultDetailDto ( ) ;
voucherDetail . setSummary ( planDetails . getBankName ( ) + "结清未到期利息减免" ) ;
voucherDetail . setSubjectNo ( "1201.01.00" ) ;
voucherDetail . setDimensionDept ( deptCode ) ;
voucherDetail . setDimensionCustom ( customerNumber ) ;
voucherDetail . setCredit ( gswdqlxjm . toString ( ) ) ;
resultDetails . add ( voucherDetail ) ;
}
if ( yhcejsr . compareTo ( BigDecimal . ZERO ) > 0 ) {
Voucher . VoucherResultDetailDto voucherDetail = new Voucher . VoucherResultDetailDto ( ) ;
voucherDetail . setSummary ( planDetails . getBorrowerName ( ) + "结清收入" ) ;
voucherDetail . setSubjectNo ( "6002.01.17" ) ;
voucherDetail . setDimensionDept ( deptCode ) ;
voucherDetail . setCredit ( yhcejsr . toString ( ) ) ;
resultDetails . add ( voucherDetail ) ;
}
newVoucher . setResultDetails ( resultDetails ) ;
if ( ! fundHistoryList . isEmpty ( ) ) {
loanPushFundHistoryService . saveLists ( fundHistoryList ) ;
@ -2514,6 +2552,7 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
BigDecimal bankSettlePrice = bankCost . getBankSettlePrice ( ) ;
if ( bankSettlePrice . compareTo ( BigDecimal . ZERO ) > 0 ) {
FinPaymentrecordDto finPaymentrecordDto = new FinPaymentrecordDto ( ) ;
finPaymentrecordDto . setFinDataType ( 1 ) ;
finPaymentrecordDto . setApplySid ( "" ) ;
finPaymentrecordDto . setPayCompanySid ( "" ) ;
finPaymentrecordDto . setPayType ( 1 ) ;
@ -3596,13 +3635,8 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
}
loanSettleApply . setState ( 1 ) ;
baseMapper . updateById ( loanSettleApply ) ;
// BigDecimal actualDeposit = BigDecimal.ZERO;
//结转剩余保证金
List < LoanSettleVoucherVo > settleVoucherVos = carryForward2 ( loanSettleApply ) ;
// BigDecimal decimal = carryForward(loanSettleApply);
// if (null != decimal) {
// actualDeposit = decimal;
// }
//更新车辆表结清状态
baseMapper . updateBus ( loanSettleApply . getBusVinSid ( ) , "1" ) ;
//推送资方结清款到出纳代付款列表
@ -3610,7 +3644,6 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
//设置认款月还为已转付
updatePaymentStateByBusVinSid ( loanSettleApply . getBusVinSid ( ) ) ;
//推送财务凭证
// pushSettleVoucher(loanSettleApply, 1, actualDeposit);
pushSettleVoucher2 ( loanSettleApply , 1 , settleVoucherVos ) ;
return rb . success ( ) ;
}
@ -4004,8 +4037,10 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
BigDecimal kuanxiang = BigDecimal . ZERO ; //差额
BigDecimal companyAmount = BigDecimal . ZERO ; //公司收
BigDecimal subtrahend = BigDecimal . ZERO ; //资方收
BigDecimal qtfyjm = BigDecimal . ZERO ; //其他费用减免
LoanSettleCompanyCost companyCost = loanSettleCompanyCostService . selectByMainSid ( sid ) ;
LoanSettleBankCost bankCost = loanSettleBankCostService . selectByMainSid ( sid ) ;
LoanSettleCompanyReduction reduction = loanSettleCompanyReductionService . selectByMainSid ( sid ) ;
if ( null ! = bankCost ) {
if ( receivablesName . equals ( "名义价" ) ) {
if ( null ! = bankCost . getBankNominalPrice ( ) ) {
@ -4050,6 +4085,12 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
}
}
}
if ( null ! = reduction ) {
if ( null ! = reduction . getOtherCost ( ) ) {
qtfyjm = reduction . getOtherCost ( ) ;
}
}
PlanNoReturnMoney p = baseMapper . selectNoReturnMoneyByType ( planDetailsSid , receivablesName ) ;
if ( null ! = p ) {
BigDecimal money = new BigDecimal ( p . getMoney ( ) ) ;
@ -4059,6 +4100,9 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
} else {
balance = companyAmount . subtract ( subtrahend ) ;
}
if ( receivablesName . equals ( "其他费用" ) ) {
balance = balance . subtract ( qtfyjm ) ;
}
kuanxiang = amount . subtract ( balance ) ;
vo . setBusSid ( sid ) ;
vo . setAmount ( amount ) ;
@ -4073,31 +4117,26 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
ResultBean rb = ResultBean . fireFail ( ) ;
LoanSettleApply apply = fetchBySid ( sid ) ;
LoanSettleBankCost bankCost = loanSettleBankCostService . selectByMainSid ( sid ) ;
// LoanSettleCompanyCost companyCost = loanSettleCompanyCostService.selectByMainSid(sid);
LoanSettleCompanyReduction reduction = loanSettleCompanyReductionService . selectByMainSid ( sid ) ;
if ( null ! = apply ) {
BigDecimal amountAll = BigDecimal . ZERO ; //推送资方结清款总数
BigDecimal zfJQK = BigDecimal . ZERO ; //资方结清款
BigDecimal bankRelief = BigDecimal . ZERO ; //资方结清未到期利息减免
BigDecimal companyRelief = BigDecimal . ZERO ; //公司结清未到期利息减免
BigDecimal noRelief = BigDecimal . ZERO ; //结清未到期利息不减免
// BigDecimal bankRelief = BigDecimal.ZERO; //资方结清未到期利息减免
// BigDecimal companyRelief = BigDecimal.ZERO; //公司结清未到期利息减免
// BigDecimal noRelief = BigDecimal.ZERO; //结清未到期利息不减免
int topping = 0 ;
BigDecimal bbjDDMoney = BigDecimal . ZERO ; //资方保证金抵顶
BigDecimal sub = BigDecimal . ZERO ; //资方保证金差额
BigDecimal shouxufeiCW = new BigDecimal ( shouxufei ) ;
// // 资方未到期金额
// BigDecimal zfwdq = BigDecimal.ZERO;
// // 公司未到期金额
// BigDecimal gswdq = BigDecimal.ZERO;
if ( null ! = reduction ) {
if ( null ! = reduction . getNotDuePriceRelief ( ) ) {
companyRelief = reduction . getNotDuePriceRelief ( ) ;
}
if ( null ! = reduction . getReliefBasis ( ) ) {
bankRelief = reduction . getReliefBasis ( ) ;
}
noRelief = bankRelief . subtract ( companyRelief ) ;
}
// if (null != reduction) {
// if (null != reduction.getNotDuePriceRelief()) {
// companyRelief = reduction.getNotDuePriceRelief();
// }
// if (null != reduction.getReliefBasis()) {
// bankRelief = reduction.getReliefBasis();
// }
// noRelief = bankRelief.subtract(companyRelief);
// }
if ( null ! = bankCost ) {
if ( null ! = bankCost . getBankSettlePrice ( ) ) {
zfJQK = bankCost . getBankSettlePrice ( ) ;
@ -4106,20 +4145,10 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
if ( null ! = bankCost . getLoanDeposit ( ) ) {
bbjDDMoney = bankCost . getLoanDeposit ( ) ;
}
// if (null != bankCost.getNotDuePrice()) {
// zfwdq = bankCost.getNotDuePrice();
// }
}
// if (null != companyCost) {
// if (null != companyCost.getBankNotPrice()) {
// gswdq = companyCost.getBankNotPrice();
// }
// }
// if (companyRelief.compareTo(BigDecimal.ZERO) == 0 && bankRelief.compareTo(BigDecimal.ZERO) == 0) {
// noRelief = gswdq.subtract(zfwdq);
// }
sub = zfJQK . subtract ( bbjDDMoney ) ;
amountAll = noRelief . add ( companyRelief ) . add ( bbjDDMoney ) . add ( sub ) ;
// amountAll = noRelief.add(companyRelief).add(bbjDDMoney).add(sub);
amountAll = bbjDDMoney . add ( sub ) ;
if ( zfJQK . compareTo ( BigDecimal . ZERO ) > 0 ) {
PaymentVoucher paymentVoucher = new PaymentVoucher ( ) ;
paymentVoucher . setBankAccount ( accountNumber ) ;
@ -4198,8 +4227,8 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
voucherDetail . setAmount ( amountAll ) ;
voucherDetail . setSubtrahend ( bbjDDMoney ) ;
voucherDetail . setBalance ( sub . add ( shouxufeiCW ) ) ;
voucherDetail . setRelief ( companyRelief ) ;
voucherDetail . setNoRelief ( noRelief ) ;
// voucherDetail.setRelief(companyRelief);
// voucherDetail.setNoRelief(noRelief);
voucherDetail . setPaymentCharges ( shouxufeiCW ) ;
voucherDetails . add ( voucherDetail ) ;
}
@ -4210,4 +4239,214 @@ public class LoanSettleApplyService extends MybatisBaseService<LoanSettleApplyMa
return rb . success ( ) ;
}
public ResultBean < RskVoucher > pushBankReturnVoucher ( String sid , String accountNumber , String payTypeCode , String shouxufei ) {
ResultBean rb = ResultBean . fireFail ( ) ;
LoanSettleApply apply = fetchBySid ( sid ) ;
LoanSettleBankCost bankCost = loanSettleBankCostService . selectByMainSid ( sid ) ;
LoanSettleCompanyReduction reduction = loanSettleCompanyReductionService . selectByMainSid ( sid ) ;
if ( null ! = apply ) {
BigDecimal amountAll = BigDecimal . ZERO ; //推送资方结清款总数
BigDecimal zfJQK = BigDecimal . ZERO ; //资方结清款
int topping = 0 ;
BigDecimal bbjDDMoney = BigDecimal . ZERO ; //资方保证金抵顶
BigDecimal sub = BigDecimal . ZERO ; //资方保证金差额
BigDecimal shouxufeiCW = new BigDecimal ( shouxufei ) ;
if ( null ! = bankCost ) {
if ( null ! = bankCost . getBankSettlePrice ( ) ) {
zfJQK = bankCost . getBankSettlePrice ( ) ;
}
topping = bankCost . getTopping ( ) ;
if ( null ! = bankCost . getLoanDeposit ( ) ) {
bbjDDMoney = bankCost . getLoanDeposit ( ) ;
}
}
sub = zfJQK . subtract ( bbjDDMoney ) ;
amountAll = bbjDDMoney . add ( sub ) ;
if ( zfJQK . compareTo ( BigDecimal . ZERO ) > 0 ) {
RskPaymentVoucher paymentVoucher = new RskPaymentVoucher ( ) ;
paymentVoucher . setBankAccount ( accountNumber ) ;
paymentVoucher . setPayTypeCode ( payTypeCode ) ;
List < RskPaymentVoucher . PaymentVoucherDetail > voucherDetails = new ArrayList < > ( ) ;
LoanRepaymentPlanDetails planDetails = baseMapper . selectByBusVinSidAndDesc ( apply . getBusVinSid ( ) ) ;
String scheduleSid = planDetails . getScheduleSid ( ) ;
LoanRepaymentSchedule schedule = loanRepaymentScheduleService . fetchBySid ( scheduleSid ) ;
if ( schedule . getIsOtherPolicy ( ) . equals ( "1" ) & & schedule . getSameBank ( ) . equals ( "0" ) ) {
planDetails = baseMapper . selectMainPeriodByBusVinSid ( apply . getBusVinSid ( ) ) ;
}
if ( null ! = planDetails ) {
RskPaymentVoucher . PaymentVoucherDetail voucherDetail = new RskPaymentVoucher . PaymentVoucherDetail ( ) ;
if ( topping = = 1 ) {
if ( bbjDDMoney . compareTo ( BigDecimal . ZERO ) > 0 ) {
voucherDetail . setSceneCode ( SceneCodeEnum . settle_VOUCHER1 . getCode ( ) ) ;
} else {
voucherDetail . setSceneCode ( SceneCodeEnum . settle_VOUCHER2 . getCode ( ) ) ;
}
} else {
voucherDetail . setSceneCode ( SceneCodeEnum . settle_VOUCHER2 . getCode ( ) ) ;
}
if ( StringUtils . isNotBlank ( planDetails . getBankName ( ) ) ) {
voucherDetail . setBankName ( planDetails . getBankName ( ) ) ;
}
String useOrgSid = planDetails . getUseOrgSid ( ) ;
SysOrganizationVo organizationVo = sysOrganizationFeign . fetchBySid ( useOrgSid ) . getData ( ) ;
if ( null ! = organizationVo ) {
paymentVoucher . setUseOrgCode ( organizationVo . getOrgCode ( ) ) ;
}
if ( StringUtils . isNotBlank ( schedule . getCwDeptNo ( ) ) ) {
voucherDetail . setDeptCode ( schedule . getCwDeptNo ( ) ) ;
}
BusSalesOrderVehicle busSalesOrderVehicle = busSalesOrderVehicleFeign . details ( planDetails . getBusVinSid ( ) ) . getData ( ) ;
BusSalesOrder salesOrder = busSalesOrderFeign . fetchBySid ( planDetails . getSalesOrderSid ( ) ) . getData ( ) ;
if ( null ! = salesOrder ) {
if ( null ! = busSalesOrderVehicle ) {
String customerNumber = "" ;
//判断财务系统是否有客户
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 ( ) ) ;
BasePurchaseSystemDetailsVo data = basePurchaseSystemFeign . fetchDetailsByDeptSid ( salesOrder . getPurchaseSystemSid ( ) ) . getData ( ) ;
bdCustomer . setTOrgIds ( data . getOrgCode ( ) ) ;
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 ( ) ;
}
voucherDetail . setCustomerCode ( customerNumber ) ;
}
}
voucherDetail . setAmount ( amountAll ) ;
voucherDetail . setSubtrahend ( bbjDDMoney ) ;
voucherDetail . setBalance ( sub . add ( shouxufeiCW ) ) ;
voucherDetail . setPaymentCharges ( shouxufeiCW ) ;
voucherDetails . add ( voucherDetail ) ;
}
paymentVoucher . setVoucherDetails ( voucherDetails ) ;
RskVoucher rskVoucher = returnSettleBankVoucher ( paymentVoucher ) ;
return rb . success ( ) . setData ( rskVoucher ) ;
}
}
return rb . success ( ) ;
}
public RskVoucher returnSettleBankVoucher ( RskPaymentVoucher voucher ) {
RskVoucher newVoucher = new RskVoucher ( ) ;
List < RskVoucher . VoucherResultDetailDto > resultDetails = new ArrayList < > ( ) ;
if ( com . yxt . common . base . utils . StringUtils . isNotBlank ( voucher . getUseOrgCode ( ) ) ) {
newVoucher . setAccountBook ( voucher . getUseOrgCode ( ) ) ;
newVoucher . setVoucherNo ( voucher . getUseOrgCode ( ) ) ;
}
List < RskPaymentVoucher . PaymentVoucherDetail > voucherDetails = voucher . getVoucherDetails ( ) ;
if ( ! voucherDetails . isEmpty ( ) ) {
for ( RskPaymentVoucher . PaymentVoucherDetail voucherDetail : voucherDetails ) {
String bankCode = "" ;
//正常
DictCommonVo dictCommonVo = dictCommonFeign . selectBykey ( voucherDetail . getBankName ( ) , "investorsCode" ) . getData ( ) ;
if ( null ! = dictCommonVo ) {
bankCode = dictCommonVo . getDictValue ( ) ;
}
if ( voucherDetail . getSceneCode ( ) . equals ( SceneCodeEnum . settle_VOUCHER1 . getCode ( ) ) ) {
if ( voucherDetail . getAmount ( ) . compareTo ( BigDecimal . ZERO ) ! = 0 ) {
RskVoucher . VoucherResultDetailDto dto1 = new RskVoucher . VoucherResultDetailDto ( ) ; //借方
dto1 . setSummary ( voucherDetail . getBankName ( ) + "结清" ) ;
dto1 . setSubjectNo ( bankCode ) ;
dto1 . setDimensionDept ( voucherDetail . getDeptCode ( ) ) ;
dto1 . setDimensionCustom ( voucherDetail . getCustomerCode ( ) ) ;
dto1 . setDebit ( String . valueOf ( voucherDetail . getAmount ( ) ) ) ;
resultDetails . add ( dto1 ) ;
}
if ( voucherDetail . getPaymentCharges ( ) . compareTo ( BigDecimal . ZERO ) ! = 0 ) {
RskVoucher . VoucherResultDetailDto dto0 = new RskVoucher . VoucherResultDetailDto ( ) ; //借方
dto0 . setSummary ( "付款手续费" ) ;
dto0 . setSubjectNo ( "6603.03.00" ) ;
dto0 . setDebit ( String . valueOf ( voucherDetail . getPaymentCharges ( ) ) ) ;
resultDetails . add ( dto0 ) ;
}
if ( voucherDetail . getSubtrahend ( ) . compareTo ( BigDecimal . ZERO ) ! = 0 ) {
RskVoucher . VoucherResultDetailDto dto4 = new RskVoucher . VoucherResultDetailDto ( ) ; //贷方
dto4 . setSummary ( voucherDetail . getBankName ( ) + "个贷保证金抵结清款" ) ;
dto4 . setSubjectNo ( "1009.01.00" ) ;
dto4 . setDimensionDept ( voucherDetail . getDeptCode ( ) ) ;
dto4 . setDimensionCustom ( voucherDetail . getCustomerCode ( ) ) ;
dto4 . setBank ( "342" ) ;
dto4 . setCredit ( String . valueOf ( voucherDetail . getSubtrahend ( ) ) ) ;
resultDetails . add ( dto4 ) ;
}
if ( voucherDetail . getBalance ( ) . compareTo ( BigDecimal . ZERO ) ! = 0 ) {
RskVoucher . VoucherResultDetailDto dto5 = new RskVoucher . VoucherResultDetailDto ( ) ; //贷方
dto5 . setSummary ( voucherDetail . getBankName ( ) + "结清" ) ;
if ( voucher . getPayTypeCode ( ) . equals ( "02" ) ) {
dto5 . setSubjectNo ( "1002.01.00" ) ;
} else if ( voucher . getPayTypeCode ( ) . equals ( "01" ) ) {
dto5 . setSubjectNo ( "1002.02.01" ) ;
}
dto5 . setBankAccount ( voucher . getBankAccount ( ) ) ;
dto5 . setCredit ( String . valueOf ( voucherDetail . getBalance ( ) ) ) ;
resultDetails . add ( dto5 ) ;
}
} else {
if ( voucherDetail . getAmount ( ) . compareTo ( BigDecimal . ZERO ) ! = 0 ) {
RskVoucher . VoucherResultDetailDto dto1 = new RskVoucher . VoucherResultDetailDto ( ) ; //借方
dto1 . setSummary ( voucherDetail . getBankName ( ) + "结清" ) ;
dto1 . setSubjectNo ( bankCode ) ;
dto1 . setDimensionDept ( voucherDetail . getDeptCode ( ) ) ;
dto1 . setDimensionCustom ( voucherDetail . getCustomerCode ( ) ) ;
dto1 . setDebit ( String . valueOf ( voucherDetail . getAmount ( ) ) ) ;
resultDetails . add ( dto1 ) ;
}
if ( voucherDetail . getPaymentCharges ( ) . compareTo ( BigDecimal . ZERO ) ! = 0 ) {
RskVoucher . VoucherResultDetailDto dto0 = new RskVoucher . VoucherResultDetailDto ( ) ; //借方
dto0 . setSummary ( "付款手续费" ) ;
dto0 . setSubjectNo ( "6603.03.00" ) ;
dto0 . setDebit ( String . valueOf ( voucherDetail . getPaymentCharges ( ) ) ) ;
resultDetails . add ( dto0 ) ;
}
if ( voucherDetail . getBalance ( ) . compareTo ( BigDecimal . ZERO ) ! = 0 ) {
RskVoucher . VoucherResultDetailDto dto4 = new RskVoucher . VoucherResultDetailDto ( ) ; //贷方
dto4 . setSummary ( voucherDetail . getBankName ( ) + "结清" ) ;
if ( voucher . getPayTypeCode ( ) . equals ( "02" ) ) {
dto4 . setSubjectNo ( "1002.01.00" ) ;
} else if ( voucher . getPayTypeCode ( ) . equals ( "01" ) ) {
dto4 . setSubjectNo ( "1002.02.01" ) ;
}
dto4 . setBankAccount ( voucher . getBankAccount ( ) ) ;
dto4 . setCredit ( String . valueOf ( voucherDetail . getBalance ( ) ) ) ;
resultDetails . add ( dto4 ) ;
}
}
}
newVoucher . setResultDetails ( resultDetails ) ;
}
return newVoucher ;
}
}