|
|
@ -75,6 +75,7 @@ import com.yxt.anrui.fin.api.kingdee.capitalcreditresult.CwSystemYT; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.voucher.CollectionVoucher; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.voucher.GeneralVoucher; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.voucher.SceneCodeEnum; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.voucher.Voucher; |
|
|
|
import com.yxt.anrui.fin.biz.finpaymentrecord.FinPaymentrecordService; |
|
|
|
import com.yxt.anrui.fin.biz.finselectedreceivablesdetailed.FinSelectedReceivablesDetailedService; |
|
|
|
import com.yxt.anrui.fin.biz.finuncollectedreceivablesdetailed.FinUncollectedReceivablesDetailedService; |
|
|
@ -87,6 +88,10 @@ import com.yxt.anrui.fin.biz.kingdee.capitalcreditresult.OtherReceivableBillCred |
|
|
|
import com.yxt.anrui.fin.fegin.as.asbusrepairbill.AsBusrepairBillFeign; |
|
|
|
import com.yxt.anrui.fin.fegin.as.asbusrepairbill.FinBusrepairBillVo; |
|
|
|
import com.yxt.anrui.portal.api.dictcommon.DictCommonFeign; |
|
|
|
import com.yxt.anrui.portal.api.dictcommon.DictCommonVo; |
|
|
|
import com.yxt.anrui.portal.api.sysmapping.SysMappingFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysmapping.SysMappingInfoVo; |
|
|
|
import com.yxt.anrui.portal.api.sysmapping.SysMappingListInfoQuery; |
|
|
|
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationVo; |
|
|
|
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrg; |
|
|
@ -110,6 +115,8 @@ import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDe |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetailsFeign; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.LoanRepaymentSchedule; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.LoanRepaymentScheduleFeign; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrestorereportapply.AlrepaidAndArrVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrestorereportapply.LoanRestoreReportApplyFeign; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansettleapply.LoanSettleApplyFeign; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansettleapply.SettleFinVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansolutions.LoanSolutions; |
|
|
@ -147,6 +154,7 @@ import java.time.ZoneId; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.*; |
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
import java.util.function.Predicate; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -219,6 +227,12 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl |
|
|
|
private AsBusrepairBillFeign asBusrepairBillFeign; |
|
|
|
@Autowired |
|
|
|
private ScmVehRebateFeign scmVehRebateFeign; |
|
|
|
@Autowired |
|
|
|
private DictCommonFeign dictCommonFeign; |
|
|
|
@Autowired |
|
|
|
private SysMappingFeign sysMappingFeign; |
|
|
|
@Autowired |
|
|
|
private LoanRestoreReportApplyFeign loanRestoreReportApplyFeign; |
|
|
|
|
|
|
|
private QueryWrapper<FinCollectionConfirmation> createQueryWrapper(FinCollectionConfirmationQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
@ -4364,6 +4378,17 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl |
|
|
|
collectionAfterVoucher.setUseOrgCode(organizationVo.getOrgCode()); |
|
|
|
} |
|
|
|
List<CollectionVoucher.CollectionVoucherDetail> collectionAfterVoucherDetails = new ArrayList<>(); |
|
|
|
//----------------------------------------------------------
|
|
|
|
//--------------------------推送赎回款
|
|
|
|
Voucher voucher = new Voucher(); |
|
|
|
if(organizationVo != null){ |
|
|
|
voucher.setAccountBook(organizationVo.getOrgCode()); |
|
|
|
voucher.setVoucherNo(organizationVo.getOrgCode()); |
|
|
|
} |
|
|
|
List<Voucher.VoucherResultDetailDto> voucherResultDetailDtos = new ArrayList<>(); |
|
|
|
AtomicReference<List<Voucher.VoucherResultDetailDto>> resultRef = |
|
|
|
new AtomicReference<>(voucherResultDetailDtos); |
|
|
|
|
|
|
|
//===========================================
|
|
|
|
//查询该申请下的所有待审核的款项明细
|
|
|
|
BigDecimal subscriptionMoneyAll = new BigDecimal("0"); |
|
|
@ -4633,6 +4658,9 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl |
|
|
|
CollectionVoucher.CollectionVoucherDetail d = getBalanceMoneyVoucher(v, collectionDate); |
|
|
|
voucherDetails.add(d); |
|
|
|
} |
|
|
|
if("收回车辆费用".equals(v.getReceivablesName())){ |
|
|
|
resultRef.set(getAll(finalConfirmation, v, collectionDate)); |
|
|
|
} |
|
|
|
}); |
|
|
|
//查询该申请已认款金额总数
|
|
|
|
subscriptionMoneyAll = finSelectedReceivablesDetailedVos.stream().map(FinSelectedReceivablesDetailedVo::getSubscriptionMoney).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
@ -4665,9 +4693,134 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl |
|
|
|
collectionAfterVoucher.setVoucherDetails(collectionAfterVoucherDetails); |
|
|
|
finKingDeeFeignRest.saveFeeVoucher(collectionAfterVoucher); |
|
|
|
} |
|
|
|
if(resultRef.get() != null){ |
|
|
|
voucherResultDetailDtos = resultRef.get(); |
|
|
|
if(!voucherResultDetailDtos.isEmpty()){ |
|
|
|
voucher.setResultDetails(voucherResultDetailDtos); |
|
|
|
finKingDeeFeignRest.saveVoucher(voucher); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return rb.success().setMsg("款项确认成功"); |
|
|
|
} |
|
|
|
|
|
|
|
private List<Voucher.VoucherResultDetailDto> getAll(FinCollectionConfirmation finalConfirmation, FinSelectedReceivablesDetailedVo v, String collectionDate) { |
|
|
|
List<Voucher.VoucherResultDetailDto> list = new ArrayList<>(); |
|
|
|
FinUncollectedReceivablesDetailed finUncollectedReceivablesDetailed = finUncollectedReceivablesDetailedService.fetchBySid(v.getReceivablesSid()); |
|
|
|
SysOrganizationVo deptVo = sysOrganizationFeign.fetchBySid(finalConfirmation.getCreateDeptSid()).getData(); |
|
|
|
BusSalesOrderVehicle busSalesOrderVehicle = busSalesOrderVehicleFeign.details(finUncollectedReceivablesDetailed.getBusVinSid()).getData(); |
|
|
|
String customerNumber = ""; |
|
|
|
BusSalesOrder salesOrder = busSalesOrderFeign.fetchBySid(busSalesOrderVehicle.getSalesOrderSid()).getData(); |
|
|
|
if (salesOrder != null && busSalesOrderVehicle != null) { |
|
|
|
//判断财务系统是否有客户
|
|
|
|
Boolean aBoolean = finKingDeeService.customerExistState(busSalesOrderVehicle.getTemporaryNo()).getData(); |
|
|
|
String linkNo = ""; |
|
|
|
BusSalesOrderBorrowerDetailsVo borrowerDetailsVo = busSalesOrderBorrowerFeign.fetchDetailsBySid(busSalesOrderVehicle.getBorrowerSid()).getData(); |
|
|
|
if (!aBoolean) { |
|
|
|
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(deptVo.getOrgCode()); |
|
|
|
if (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()); |
|
|
|
} |
|
|
|
} |
|
|
|
ResultBean<String> resultBean = finKingDeeFeignRest.draftBdCustomer(bdCustomer); |
|
|
|
if (resultBean.getSuccess()) { |
|
|
|
customerNumber = bdCustomer.getFNumber(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
customerNumber = busSalesOrderVehicle.getTemporaryNo(); |
|
|
|
} |
|
|
|
} |
|
|
|
Voucher.VoucherResultDetailDto voucherResultDetailDtoJf = new Voucher.VoucherResultDetailDto(); |
|
|
|
Voucher.VoucherResultDetailDto voucherResultDetailDtoJf2 = new Voucher.VoucherResultDetailDto(); |
|
|
|
//贷方
|
|
|
|
Voucher.VoucherResultDetailDto voucherResultDetailDtoDf = new Voucher.VoucherResultDetailDto(); |
|
|
|
Voucher.VoucherResultDetailDto voucherResultDetailDtoDf2 = new Voucher.VoucherResultDetailDto(); |
|
|
|
Voucher.VoucherResultDetailDto voucherResultDetailDtoDf3 = new Voucher.VoucherResultDetailDto(); |
|
|
|
String payType = ""; |
|
|
|
DictCommonVo dictCommonVo = dictCommonFeign.selectBykey(finalConfirmation.getCollectionTypeKey(), "payVoucherType").getData(); |
|
|
|
if (null != dictCommonVo) { |
|
|
|
SysMappingListInfoQuery query = new SysMappingListInfoQuery(); |
|
|
|
query.setDictSid(dictCommonVo.getSid()); |
|
|
|
List<SysMappingInfoVo> data = sysMappingFeign.selectMappingListInfo(query).getData(); |
|
|
|
if (!data.isEmpty()) { |
|
|
|
SysMappingInfoVo sysMappingInfoVo = data.get(0); |
|
|
|
payType = sysMappingInfoVo.getMap_itemKey(); |
|
|
|
} |
|
|
|
} |
|
|
|
//--收款-赎回款(yyyy-MM-dd)
|
|
|
|
BigDecimal all = new BigDecimal(v.getSubscriptionMoney()); |
|
|
|
if (all.compareTo(BigDecimal.ZERO) != 0) { |
|
|
|
voucherResultDetailDtoJf.setSummary("收款-赎回款"+"(" + collectionDate + ")"); |
|
|
|
voucherResultDetailDtoJf.setSubjectNo(payType); |
|
|
|
voucherResultDetailDtoJf.setBankAccount(finalConfirmation.getCollectionBankNum()); |
|
|
|
voucherResultDetailDtoJf.setDebit(all.toString()); |
|
|
|
list.add(voucherResultDetailDtoJf); |
|
|
|
} |
|
|
|
//-----出纳收款确认后-资金占用费
|
|
|
|
AlrepaidAndArrVo alrepaidAndArrVo = loanRestoreReportApplyFeign.getAlrepaidAndArr2(finUncollectedReceivablesDetailed.getBusVinSid()).getData(); |
|
|
|
BigDecimal zjzyfMoney = BigDecimal.ZERO; |
|
|
|
String zjzyf = alrepaidAndArrVo.getWheFundOccMoney(); |
|
|
|
zjzyfMoney = new BigDecimal(StringUtils.isBlank(zjzyf) ? "0" : zjzyf); |
|
|
|
if (zjzyfMoney.compareTo(BigDecimal.ZERO) != 0) { |
|
|
|
voucherResultDetailDtoDf.setSummary("收款-赎回款"); |
|
|
|
voucherResultDetailDtoDf.setSubjectNo("1201.02.03"); |
|
|
|
//核算部门
|
|
|
|
voucherResultDetailDtoDf.setDimensionDept(deptVo.getOrgCode()); |
|
|
|
//核算客户
|
|
|
|
voucherResultDetailDtoDf.setDimensionCustom(customerNumber); |
|
|
|
voucherResultDetailDtoDf.setCredit(zjzyfMoney.toString()); |
|
|
|
list.add(voucherResultDetailDtoDf); |
|
|
|
voucherResultDetailDtoJf2.setSummary("资金占用费转收入"); |
|
|
|
voucherResultDetailDtoJf2.setSubjectNo("2191.05.00"); |
|
|
|
//核算部门
|
|
|
|
voucherResultDetailDtoJf2.setDimensionDept(deptVo.getOrgCode()); |
|
|
|
//核算客户
|
|
|
|
voucherResultDetailDtoJf2.setDimensionCustom(customerNumber); |
|
|
|
voucherResultDetailDtoJf2.setCredit(zjzyfMoney.toString()); |
|
|
|
list.add(voucherResultDetailDtoJf2); |
|
|
|
voucherResultDetailDtoDf3.setSummary("资金占用费转收入"); |
|
|
|
voucherResultDetailDtoDf3.setSubjectNo("6002.01.17"); |
|
|
|
//核算部门
|
|
|
|
voucherResultDetailDtoDf3.setDimensionDept(deptVo.getOrgCode()); |
|
|
|
//核算客户
|
|
|
|
voucherResultDetailDtoDf3.setDimensionCustom(customerNumber); |
|
|
|
voucherResultDetailDtoDf3.setCredit(zjzyfMoney.toString()); |
|
|
|
list.add(voucherResultDetailDtoDf3); |
|
|
|
} |
|
|
|
BigDecimal allM = BigDecimal.ZERO; |
|
|
|
allM = all.subtract(zjzyfMoney); |
|
|
|
if(allM.compareTo(BigDecimal.ZERO)>0){ |
|
|
|
voucherResultDetailDtoDf2.setSummary("收款-赎回款"); |
|
|
|
voucherResultDetailDtoDf2.setSubjectNo("1201.03.01"); |
|
|
|
//核算部门
|
|
|
|
voucherResultDetailDtoDf2.setDimensionDept(deptVo.getOrgCode()); |
|
|
|
//核算客户
|
|
|
|
voucherResultDetailDtoDf2.setDimensionCustom(customerNumber); |
|
|
|
voucherResultDetailDtoDf2.setCredit(allM.toString()); |
|
|
|
list.add(voucherResultDetailDtoDf2); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
//名义价其他费用推财务
|
|
|
|
private CollectionVoucher.CollectionVoucherDetail getBalanceMoneyVoucher(FinSelectedReceivablesDetailedVo v, String collectionDate) { |
|
|
|
String planSid = ""; |
|
|
|