|
|
@ -88,6 +88,8 @@ import com.yxt.anrui.fin.api.kingdee.FinKingDeeFeign; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.arreceivable.ARReceivable; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.arreceivebill.ARReceivebill; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.bdcustomer.BdCustomer; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.capitalcreditresult.CapitalCreditResult; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.capitalcreditresult.CwSystemYT; |
|
|
|
import com.yxt.anrui.fin.biz.finbillapplication.FinBillApplicationService; |
|
|
|
import com.yxt.anrui.fin.biz.finbilltrailer.FinBillTrailerService; |
|
|
|
import com.yxt.anrui.fin.biz.finbillvehicle.FinBillVehicleService; |
|
|
@ -99,6 +101,7 @@ import com.yxt.anrui.fin.biz.finvehicleinvoice.FinVehicleInvoiceService; |
|
|
|
import com.yxt.anrui.fin.biz.kingdee.FinKingDeeService; |
|
|
|
import com.yxt.anrui.fin.biz.kingdee.arreceivebill.ArReceivebillService; |
|
|
|
import com.yxt.anrui.fin.biz.kingdee.bdcustomer.BdCustomerService; |
|
|
|
import com.yxt.anrui.fin.biz.kingdee.capitalcreditresult.OtherReceivableBillCreditResultService; |
|
|
|
import com.yxt.anrui.fin.biz.kingdee.receivablebill.ReceivableBillService; |
|
|
|
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationVo; |
|
|
@ -110,6 +113,7 @@ import com.yxt.anrui.portal.api.sysuser.SysUserVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loandiff.LoanDiffFeign; |
|
|
|
import com.yxt.anrui.riskcenter.api.loandiff.LoanDiffsDto; |
|
|
|
import com.yxt.anrui.riskcenter.api.loandiffdetails.LoanDiffDetailssDto; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanfinbank.LoanFinBank; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanfinotherPolicy.LoanFinOtherPolicy; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanfinpolicy.LoanFinPolicy; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansolutions.LoanSolutions; |
|
|
@ -192,6 +196,8 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl |
|
|
|
private BaseVehicleStateFeign baseVehicleStateFeign; |
|
|
|
@Autowired |
|
|
|
private LoanDiffFeign loanDiffFeign; |
|
|
|
@Autowired |
|
|
|
private OtherReceivableBillCreditResultService creditResultService; |
|
|
|
|
|
|
|
private QueryWrapper<FinCollectionConfirmation> createQueryWrapper(FinCollectionConfirmationQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
@ -1746,8 +1752,31 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl |
|
|
|
if(finSelectedReceivablesDetailed.getSubscriptionMoney().compareTo(new BigDecimal(finUncollectedReceivablesDetailed.getReveivableMoney())) != 0){ |
|
|
|
//有差额
|
|
|
|
if(isTue){//不一致
|
|
|
|
|
|
|
|
|
|
|
|
//根据busVinSid查询融资放款的是否已认完款,若已认完,则推送,若未认完则不推送
|
|
|
|
List<FinSelectedReceivablesDetailedVo> voList = finSelectedReceivablesDetailedService.selectListByVin2(finUncollectedReceivablesDetailed.getContractNo(), finUncollectedReceivablesDetailed.getBusVinSid(), 3); |
|
|
|
BigDecimal bigDecimalVinAll = voList.stream().map(FinSelectedReceivablesDetailedVo::getSubscriptionMoney).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
List<FinUncollectedReceivablesDetailed> unList = finUncollectedReceivablesDetailedService.selectListByBusVinSid2(finUncollectedReceivablesDetailed.getBusVinSid()); |
|
|
|
BigDecimal unDecimalVinAll = unList.stream().map(FinUncollectedReceivablesDetailed::getReveivableMoney).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
if(bigDecimalVinAll.compareTo(unDecimalVinAll) == 0){//认完
|
|
|
|
if(bigAdd.compareTo(decimalAll) != 0){//不相等,推送放款差额确认待办
|
|
|
|
LoanDiffDetailssDto loanDiffDetailssDto = new LoanDiffDetailssDto(); |
|
|
|
loanDiffDetailssDto.setBankSid(loanFinPolicy.getBankSid()); |
|
|
|
loanDiffDetailssDto.setBankName(loanFinPolicy.getBankShortName()); |
|
|
|
loanDiffDetailssDto.setBorrowName(busSalesOrderVehicle.getBorrowName()); |
|
|
|
loanDiffDetailssDto.setBorrowSid(busSalesOrderVehicle.getBorrowerSid()); |
|
|
|
loanDiffDetailssDto.setMakeLoan(new BigDecimal(finUncollectedReceivablesDetailed.getReveivableMoney())); |
|
|
|
loanDiffDetailssDto.setRealityLoan(finSelectedReceivablesDetailed.getSubscriptionMoney()); |
|
|
|
loanDiffDetailssDto.setDiffLoan(decimalAll); |
|
|
|
loanDiffDetailssDto.setMakeDiscount(loanSolutions.getFactoryDiscount()); |
|
|
|
loanDiffDetailssDto.setMakeLoanMargin(loanSolutions.getBondAmount()); |
|
|
|
loanDiffDetailssDto.setMakeOtherDiscount(loanSolutionsOtherpolicy.getOtherDiscount()); |
|
|
|
loanDiffDetailssDto.setReceivedPremium(loanSolutionsDetail.getProxyAccidentPremium()); |
|
|
|
loanDiffDetailssDto.setVinNo(busSalesOrderVehicle.getLinkNo()); |
|
|
|
loanDiffDetailssDto.setVinSid(busSalesOrderVehicle.getLinkSid()); |
|
|
|
loanDiffDetailssDto.setBusVinSid(busSalesOrderVehicle.getSid()); |
|
|
|
loanDiffDetailssDtos.add(loanDiffDetailssDto); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
if(bigAdd.compareTo(decimalAll) != 0){//不相等,推送放款差额确认待办
|
|
|
|
LoanDiffDetailssDto loanDiffDetailssDto = new LoanDiffDetailssDto(); |
|
|
@ -1766,6 +1795,75 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl |
|
|
|
loanDiffDetailssDto.setVinSid(busSalesOrderVehicle.getLinkSid()); |
|
|
|
loanDiffDetailssDto.setBusVinSid(busSalesOrderVehicle.getSid()); |
|
|
|
loanDiffDetailssDtos.add(loanDiffDetailssDto); |
|
|
|
}else{ |
|
|
|
CapitalCreditResult creditResult = new CapitalCreditResult(); |
|
|
|
//推送其他应收单
|
|
|
|
BusSalesOrder busSalesOrder = baseMapper.selectByOrderSid(busSalesOrderVehicle.getSalesOrderSid()); |
|
|
|
String customerNumber = ""; |
|
|
|
//判断财务系统是否有客户
|
|
|
|
Boolean aBoolean = bdCustomerService.customerExistState(busSalesOrderVehicle.getTemporaryNo()).getData(); |
|
|
|
String linkNo = ""; |
|
|
|
if (!aBoolean) { |
|
|
|
BdCustomer bdCustomer = new BdCustomer(); |
|
|
|
bdCustomer.setFNumber(busSalesOrderVehicle.getTemporaryNo()); |
|
|
|
bdCustomer.setFShortName(busSalesOrder.getContractNo()); |
|
|
|
BasePurchaseSystemDetailsVo data = basePurchaseSystemFeign.fetchDetailsByDeptSid(busSalesOrder.getPurchaseSystemSid()).getData(); |
|
|
|
bdCustomer.setTOrgIds(data.getOrgCode()); |
|
|
|
if (com.yxt.common.base.utils.StringUtils.isNotBlank(busSalesOrderVehicle.getLinkNo())) { |
|
|
|
String vinNo = busSalesOrderVehicle.getLinkNo(); |
|
|
|
if (vinNo.length() > 8) { |
|
|
|
linkNo = vinNo.substring(vinNo.length() - 8); |
|
|
|
} else { |
|
|
|
linkNo = busSalesOrderVehicle.getLinkNo(); |
|
|
|
} |
|
|
|
bdCustomer.setFName(busSalesOrderVehicle.getBorrowName() + linkNo); |
|
|
|
} else { |
|
|
|
bdCustomer.setFName(busSalesOrderVehicle.getBorrowName() + busSalesOrderVehicle.getTemporaryNo()); |
|
|
|
} |
|
|
|
ResultBean<String> resultBean = bdCustomerService.draftBdCustomer(bdCustomer); |
|
|
|
if (resultBean.getSuccess()) { |
|
|
|
customerNumber = bdCustomer.getFNumber(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
customerNumber = busSalesOrderVehicle.getTemporaryNo(); |
|
|
|
} |
|
|
|
creditResult.setCommUnit(customerNumber); |
|
|
|
SysOrganizationVo sysOrganizationVo1 = sysOrganizationFeign.fetchBySid(busSalesOrder.getUseOrgSid()).getData(); |
|
|
|
creditResult.setCollectionOrg(sysOrganizationVo1.getOrgCode()); |
|
|
|
creditResult.setBussDate(DateUtil.formatDate(new Date())); |
|
|
|
List<CapitalCreditResult.CapitalCreditResultDetailDto> collectionDetailDtoListOne = new ArrayList<>(); |
|
|
|
SysOrganizationVo sysOrganizationVo2 = sysOrganizationFeign.fetchBySid(busSalesOrder.getOrgSid()).getData(); |
|
|
|
if (loanSolutions.getBondAmount() != null) {//贷款保证金
|
|
|
|
CapitalCreditResult.CapitalCreditResultDetailDto creditResultDetailDto = new CapitalCreditResult.CapitalCreditResultDetailDto(); |
|
|
|
creditResultDetailDto.setDearDept(sysOrganizationVo2.getOrgCode()); |
|
|
|
creditResultDetailDto.setExTaxMoney("-" + loanSolutions.getBondAmount().toString()); |
|
|
|
creditResultDetailDto.setUseTo(CwSystemYT.BOND_AMOUNTS.getType()); |
|
|
|
collectionDetailDtoListOne.add(creditResultDetailDto); |
|
|
|
} |
|
|
|
if (loanSolutions.getFactoryDiscount() != null) {//主产品厂家贴息
|
|
|
|
CapitalCreditResult.CapitalCreditResultDetailDto creditResultDetailDto = new CapitalCreditResult.CapitalCreditResultDetailDto(); |
|
|
|
creditResultDetailDto.setDearDept(sysOrganizationVo2.getOrgCode()); |
|
|
|
creditResultDetailDto.setExTaxMoney("-" + loanSolutions.getFactoryDiscount().toString()); |
|
|
|
creditResultDetailDto.setUseTo(CwSystemYT.SANFANG_TIEXI_DIECHEKUAN.getType()); |
|
|
|
collectionDetailDtoListOne.add(creditResultDetailDto); |
|
|
|
} |
|
|
|
if (loanSolutionsOtherpolicy.getOtherDiscount() != null) {//实扣其他融厂家贴息
|
|
|
|
CapitalCreditResult.CapitalCreditResultDetailDto creditResultDetailDto = new CapitalCreditResult.CapitalCreditResultDetailDto(); |
|
|
|
creditResultDetailDto.setDearDept(sysOrganizationVo2.getOrgCode()); |
|
|
|
creditResultDetailDto.setExTaxMoney("-" + loanSolutionsOtherpolicy.getOtherDiscount().toString()); |
|
|
|
creditResultDetailDto.setUseTo(CwSystemYT.SANFANG_TIEXI_DIECHEKUAN.getType()); |
|
|
|
collectionDetailDtoListOne.add(creditResultDetailDto); |
|
|
|
} |
|
|
|
if (loanSolutionsDetail.getProxyAccidentPremium() != null) {//已收意外险
|
|
|
|
CapitalCreditResult.CapitalCreditResultDetailDto creditResultDetailDto = new CapitalCreditResult.CapitalCreditResultDetailDto(); |
|
|
|
creditResultDetailDto.setDearDept(sysOrganizationVo2.getOrgCode()); |
|
|
|
creditResultDetailDto.setExTaxMoney("-" + loanSolutionsDetail.getProxyAccidentPremium().toString()); |
|
|
|
creditResultDetailDto.setUseTo(CwSystemYT.PROXY_ACCIDENT_PREMIUM.getType()); |
|
|
|
collectionDetailDtoListOne.add(creditResultDetailDto); |
|
|
|
} |
|
|
|
creditResult.setResultDetails(collectionDetailDtoListOne); |
|
|
|
creditResultService.pushOtherReceivableBill(creditResult); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -1856,6 +1954,8 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl |
|
|
|
//加装配置手续费(贷款)
|
|
|
|
List<FinSelectedReceivablesDetailedVo> finSelectedReceivablesDetailedVos3_2 = finSelectedReceivablesDetailedService.fetchByAuditState1_1(sid, "加装配置手续费", "2"); |
|
|
|
finSelectedReceivablesDetailedVos3_2.removeAll(Collections.singleton(null)); |
|
|
|
List<FinSelectedReceivablesDetailedVo> finSelectedReceivablesDetailedVos4_1 = finSelectedReceivablesDetailedService.fetchByAuditState1_1(sid, "融资放款", "2"); |
|
|
|
finSelectedReceivablesDetailedVos4_1.removeAll(Collections.singleton(null)); |
|
|
|
int carSize = 0; |
|
|
|
//全款推送车款
|
|
|
|
if (finSelectedReceivablesDetailedVos1.size() > 0) { |
|
|
@ -1980,6 +2080,23 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl |
|
|
|
carSize = loanInstaConfigFee(confirmation, arReceivebill, carSize, finSelectedReceivablesDetailedVos3_2, freceivebillentry, one, orgCode); |
|
|
|
} |
|
|
|
|
|
|
|
//融资放款
|
|
|
|
if (finSelectedReceivablesDetailedVos4_1.size() > 0) { |
|
|
|
boolean one = false; |
|
|
|
if (finSelectedReceivablesDetailedVos1.size() == 0 && |
|
|
|
finSelectedReceivablesDetailedVos1_1_1.size() == 0 && |
|
|
|
finSelectedReceivablesDetailedVos2.size() == 0 && |
|
|
|
finSelectedReceivablesDetailedVos1_1.size() == 0 && |
|
|
|
finSelectedReceivablesDetailedVos2_1.size() == 0 && |
|
|
|
finSelectedReceivablesDetailedVos1_1_2.size() == 0 && |
|
|
|
finSelectedReceivablesDetailedVos3_1.size() == 0 && |
|
|
|
finSelectedReceivablesDetailedVos3_2.size() == 0 && |
|
|
|
finSelectedReceivablesDetailedVos4_1.size() == 1) { |
|
|
|
one = true; |
|
|
|
} |
|
|
|
carSize = loanDiff(confirmation, arReceivebill, carSize, finSelectedReceivablesDetailedVos4_1, freceivebillentry, one, orgCode); |
|
|
|
} |
|
|
|
|
|
|
|
//简易订单-订金收取
|
|
|
|
if (finSelectedReceivablesDetailedVos1.isEmpty() && |
|
|
|
finSelectedReceivablesDetailedVos2.isEmpty() && |
|
|
@ -2026,6 +2143,54 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
private int loanDiff(FinCollectionConfirmation confirmation, ARReceivebill arReceivebill, int carSize, List<FinSelectedReceivablesDetailedVo> finSelectedReceivablesDetailedVos4_1, ARReceivebill.FRECEIVEBILLENTRY freceivebillentry, boolean one, String orgCode) { |
|
|
|
String sid = confirmation.getSid(); |
|
|
|
List<ARReceivebill.FRECEIVEBILLENTRY> fEntityList = new ArrayList<>(); |
|
|
|
for (int i = 0; i < finSelectedReceivablesDetailedVos4_1.size(); i++) { |
|
|
|
FinSelectedReceivablesDetailedVo vvvv = finSelectedReceivablesDetailedVos4_1.get(i); |
|
|
|
//推送客户
|
|
|
|
String customerNo = createCustomerQuery(2, vvvv, orgCode); |
|
|
|
//往来单位
|
|
|
|
arReceivebill.setFCONTACTUNIT(customerNo); |
|
|
|
fEntityList = new ArrayList<>(); |
|
|
|
String uncollSid = ""; |
|
|
|
freceivebillentry = new ARReceivebill.FRECEIVEBILLENTRY(); |
|
|
|
//结算方式
|
|
|
|
freceivebillentry.setFSETTLETYPEIDKey(confirmation.getCollectionTypeKey()); |
|
|
|
freceivebillentry.setFSETTLETYPEIDType("customerPayType"); |
|
|
|
//收款金额
|
|
|
|
freceivebillentry.setFRECTOTALAMOUNTFOR(vvvv.getSubscriptionMoney()); |
|
|
|
//登记日期
|
|
|
|
freceivebillentry.setFPOSTDATE(confirmation.getCollectionDate()); |
|
|
|
if (vvvv.getVIN().length() >= 8) { |
|
|
|
freceivebillentry.setF_PAEZ_Base1(vvvv.getVIN().substring(vvvv.getVIN().length() - 8)); |
|
|
|
} |
|
|
|
//收款用途
|
|
|
|
freceivebillentry.setFPURPOSEIDKey("001"); |
|
|
|
freceivebillentry.setFPURPOSEIDType("cw_skyt"); |
|
|
|
freceivebillentry.setFACCOUNTID(confirmation.getCollectionBankNum()); |
|
|
|
LoanFinBank loanFinBank = baseMapper.selectFinBnk(vvvv.getContractNo()); |
|
|
|
if(loanFinBank != null){ |
|
|
|
freceivebillentry.setF_PAEZ_Base(loanFinBank.getBankNo());//资方编码
|
|
|
|
} |
|
|
|
fEntityList.add(freceivebillentry); |
|
|
|
uncollSid = vvvv.getReceivablesSid(); |
|
|
|
//项目类别key、value
|
|
|
|
arReceivebill.setF_PAEZ_AssistantType("cw_sklb"); |
|
|
|
arReceivebill.setF_PAEZ_AssistantKey("062"); |
|
|
|
arReceivebill.setFRECEIVEBILLENTRY(fEntityList); |
|
|
|
if (one) { |
|
|
|
arReceivebill.setFBillNo(confirmation.getBillNo()); |
|
|
|
} else { |
|
|
|
//单据编号
|
|
|
|
carSize = carSize + 1; |
|
|
|
arReceivebill.setFBillNo(confirmation.getBillNo() + "-" + carSize); |
|
|
|
} |
|
|
|
ResultBean resultBean1 = arReceivebillService.draftArReceivebill(arReceivebill); |
|
|
|
} |
|
|
|
return carSize; |
|
|
|
} |
|
|
|
|
|
|
|
//组装客户推送
|
|
|
|
private BdCustomer createBdCustomer(String useOrgSid, String name, String mobile, String customerSid, String collSid) { |
|
|
|
BdCustomer bdCustomer = new BdCustomer(); |
|
|
|