From 4b3a44751ea1382e373ec07358c8c4297bec3baf Mon Sep 17 00:00:00 2001 From: dimengzhe Date: Tue, 4 Jul 2023 13:29:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...inSelectedReceivablesPaymentDetailsVo.java | 2 + .../FinSelectedReceivablesDetailedVo.java | 2 + .../FinCollectionConfirmationService.java | 272 +++++++++--------- .../FinSelectedReceivablesDetailedMapper.xml | 21 +- 4 files changed, 153 insertions(+), 144 deletions(-) diff --git a/anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/fincollectionconfirmation/AppFinSelectedReceivablesPaymentDetailsVo.java b/anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/fincollectionconfirmation/AppFinSelectedReceivablesPaymentDetailsVo.java index f5cb1fcd0b..b540f16a9b 100644 --- a/anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/fincollectionconfirmation/AppFinSelectedReceivablesPaymentDetailsVo.java +++ b/anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/fincollectionconfirmation/AppFinSelectedReceivablesPaymentDetailsVo.java @@ -49,4 +49,6 @@ public class AppFinSelectedReceivablesPaymentDetailsVo implements Vo { @ApiModelProperty("分公司sid") private String useOrgSid; + private int subscribedOf; + } diff --git a/anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedVo.java b/anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedVo.java index 72f9b030c4..e9f373a5f1 100644 --- a/anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedVo.java +++ b/anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedVo.java @@ -116,4 +116,6 @@ public class FinSelectedReceivablesDetailedVo implements Vo { private String payTypeKey; @ApiModelProperty("全款贷款") private String payType; + + private int subscribedOf; } diff --git a/anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/fincollectionconfirmation/FinCollectionConfirmationService.java b/anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/fincollectionconfirmation/FinCollectionConfirmationService.java index 83eb889ae1..503d354bda 100644 --- a/anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/fincollectionconfirmation/FinCollectionConfirmationService.java +++ b/anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/fincollectionconfirmation/FinCollectionConfirmationService.java @@ -57,7 +57,6 @@ import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicleFeig import com.yxt.anrui.crm.api.crmcustomertemp.CrmCustomerTempFeign; import com.yxt.anrui.crm.api.crmcustomertemp.CrmCustomerTempVo; import com.yxt.anrui.crm.api.crmcustomertemp.CustomerQuery; -import com.yxt.anrui.fin.api.finbillapplication.FinBillApplicationVo; import com.yxt.anrui.fin.api.fincollectionconfirmation.*; import com.yxt.anrui.fin.api.fincollectionconfirmation.app.AppBusArrearsCarryMoneyVo; import com.yxt.anrui.fin.api.fincollectionconfirmation.app.FinConfirmDto; @@ -101,7 +100,6 @@ import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.Stream; /** * Project: anrui-fin(销售相关)
@@ -493,11 +491,14 @@ public class FinCollectionConfirmationService extends MybatisBaseService resultBean = busSalesOrderFeign.getVinSidByConSid(v.getContractNo(), v.getVIN()); - if (resultBean.getSuccess()) { - baseVehicleTempstateDto.setVehSid(resultBean.getData()); - } - ResultBean vehicleStateResult = baseVehicleTempstateFeign.save(baseVehicleTempstateDto);*/ - //应收未收减去相应的认款 - FinUncollectedReceivablesDetailed finUncollectedReceivablesDetailed = finUncollectedReceivablesDetailedService.fetchBySid(finSelectedReceivablesDetailed.getReceivablesSid()); - BigDecimal currentReceivableMoney = finUncollectedReceivablesDetailed.getCurrentReceivableMoney().subtract(finSelectedReceivablesDetailed.getSubscriptionMoney()); - finUncollectedReceivablesDetailed.setCurrentReceivableMoney(currentReceivableMoney); - finUncollectedReceivablesDetailedService.updateById(finUncollectedReceivablesDetailed); }); } finCollectionConfirmation.setAuditState(1); @@ -1019,11 +1003,14 @@ public class FinCollectionConfirmationService extends MybatisBaseService new TreeSet<>(Comparator.comparing(AppFinUncollectedReceivablesDetailedVo::getSid))), ArrayList::new)); //根据合同编号倒序排序 collList = collList.stream().sorted(Comparator.comparing(AppFinUncollectedReceivablesDetailedVo::getContractId).reversed()).collect(Collectors.toList()); - //分页 + /*//分页 IPage page1 = new Page<>(); page1.setRecords(collList); page1.setTotal(collList.size()); page1.setPages((collList.size() / pagerQuery.getSize()) + 1); page1.setCurrent(pagerQuery.getCurrent()); page1.setSize(pagerQuery.getSize()); + return page1;*/ + //分页 + IPage page1 = new Page<>(); + page1.setTotal(collList.size()); + page1.setPages(collList.size()/pagerQuery.getSize()+(collList.size()%pagerQuery.getSize()==0?0:1)); + collList = collList.stream().skip((pagerQuery.getCurrent() - 1) *pagerQuery.getSize()).limit(pagerQuery.getSize()).collect(Collectors.toList()); //开始分页 + page1.setRecords(collList); + page1.setCurrent(pagerQuery.getCurrent()); + page1.setSize(pagerQuery.getSize()); return page1; } @@ -1185,11 +1181,14 @@ public class FinCollectionConfirmationService extends MybatisBaseService voList = finSelectedReceivablesDetailedService.selectListByVin(v.getContractNo(), finUncollectedReceivablesDetailed.getBusVinSid(), 3); - BigDecimal bigDecimalVinAll = voList.stream().map(FinSelectedReceivablesDetailedVo::getSubscriptionMoney).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add); - //查询该合同编号下的销售订单的单车成交价 - ResultBean commonContractResultBean = commonContractFeign.selectByNo(v.getContractNo()); - if (commonContractResultBean.getSuccess()) { - CommonContract commonContract = commonContractResultBean.getData(); - if (commonContract != null) { - ResultBean orderDetails = busSalesOrderFeign.getSaleOrderDetails(commonContract.getBusSid()); - AppOrderDetailsVo vo = orderDetails.getData(); - if (vo != null) { - AppOrderPriceInfoVo priceInfoVo = vo.getPriceInfo(); - AppOrderDepositInfoVo depositInfo = vo.getDepositInfo(); - if (depositInfo != null) { - if ("02".equals(depositInfo.getDepositTypeKey())) {//订金结转 - BigDecimal decimalDeposit = BigDecimal.ZERO; - if (StringUtils.isNotBlank(depositInfo.getDepositTotal())) { - decimalDeposit = new BigDecimal(depositInfo.getDepositTotal()); - } - if (StringUtils.isNotBlank(depositInfo.getMakeUpDeposit())) { - decimalDeposit = decimalDeposit.subtract(new BigDecimal(depositInfo.getMakeUpDeposit())); + if(v.getSubscribedOf() == 0){ + List voList = finSelectedReceivablesDetailedService.selectListByVin(v.getContractNo(), finUncollectedReceivablesDetailed.getBusVinSid(), 3); + BigDecimal bigDecimalVinAll = voList.stream().map(FinSelectedReceivablesDetailedVo::getSubscriptionMoney).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add); + //查询该合同编号下的销售订单的单车成交价 + ResultBean commonContractResultBean = commonContractFeign.selectByNo(v.getContractNo()); + if (commonContractResultBean.getSuccess()) { + CommonContract commonContract = commonContractResultBean.getData(); + if (commonContract != null) { + ResultBean orderDetails = busSalesOrderFeign.getSaleOrderDetails(commonContract.getBusSid()); + AppOrderDetailsVo vo = orderDetails.getData(); + if (vo != null) { + AppOrderPriceInfoVo priceInfoVo = vo.getPriceInfo(); + AppOrderDepositInfoVo depositInfo = vo.getDepositInfo(); + if (depositInfo != null) { + if ("02".equals(depositInfo.getDepositTypeKey())) {//订金结转 + BigDecimal decimalDeposit = BigDecimal.ZERO; + if (StringUtils.isNotBlank(depositInfo.getDepositTotal())) { + decimalDeposit = new BigDecimal(depositInfo.getDepositTotal()); + } + if (StringUtils.isNotBlank(depositInfo.getMakeUpDeposit())) { + decimalDeposit = decimalDeposit.subtract(new BigDecimal(depositInfo.getMakeUpDeposit())); + } + decimalDeposit = decimalDeposit.divide(new BigDecimal(priceInfoVo.getNumber()), BigDecimal.ROUND_CEILING); + bigDecimalVinAll = bigDecimalVinAll.add(decimalDeposit); } - decimalDeposit = decimalDeposit.divide(new BigDecimal(priceInfoVo.getNumber()), BigDecimal.ROUND_CEILING); - bigDecimalVinAll = bigDecimalVinAll.add(decimalDeposit); } - } - //单台整体成交价 - BigDecimal singleFinalPrice = new BigDecimal(priceInfoVo.getSingleFinalPrice()); - BigDecimal leftAll = BigDecimal.ZERO; - BigDecimal rightAll = BigDecimal.ZERO; - if ("2".equals(vo.getFinancePlan()) || "2".equals(vo.getPayTypeKey())) { - //根据销售订单sid查询金融方案 - ResultBean solutionsDetailsVoResultBean = loanSolutionsFeign.selectDetailss(commonContract.getBusSid()); - SolutionsDetailsVo solutionsDetailsVo = solutionsDetailsVoResultBean.getData(); - if (solutionsDetailsVo != null) { - if (StringUtils.isNotBlank(solutionsDetailsVo.getTypeKey())) { - if ("02".equals(solutionsDetailsVo.getTypeKey())) { - //外部金融:成交价 = 订金+车款+厂家贴息-服务费 - leftAll = leftAll.add(singleFinalPrice); - if (StringUtils.isNotBlank(solutionsDetailsVo.getFactoryDiscount())) { - leftAll = leftAll.subtract(new BigDecimal(solutionsDetailsVo.getFactoryDiscount())); + //单台整体成交价 + BigDecimal singleFinalPrice = new BigDecimal(priceInfoVo.getSingleFinalPrice()); + BigDecimal leftAll = BigDecimal.ZERO; + BigDecimal rightAll = BigDecimal.ZERO; + if ("2".equals(vo.getFinancePlan()) || "2".equals(vo.getPayTypeKey())) { + //根据销售订单sid查询金融方案 + ResultBean solutionsDetailsVoResultBean = loanSolutionsFeign.selectDetailss(commonContract.getBusSid()); + SolutionsDetailsVo solutionsDetailsVo = solutionsDetailsVoResultBean.getData(); + if (solutionsDetailsVo != null) { + if (StringUtils.isNotBlank(solutionsDetailsVo.getTypeKey())) { + if ("02".equals(solutionsDetailsVo.getTypeKey())) { + //外部金融:成交价 = 订金+车款+厂家贴息-服务费 + leftAll = leftAll.add(singleFinalPrice); + if (StringUtils.isNotBlank(solutionsDetailsVo.getFactoryDiscount())) { + leftAll = leftAll.subtract(new BigDecimal(solutionsDetailsVo.getFactoryDiscount())); + } + if (StringUtils.isNotBlank(solutionsDetailsVo.getServiceAmount())) { + leftAll = leftAll.add(new BigDecimal(solutionsDetailsVo.getServiceAmount())); + } + rightAll = rightAll.add(bigDecimalVinAll); + } else { + //自营非担保: 实收订金 = 首付款及费用+订金 + if (StringUtils.isNotBlank(solutionsDetailsVo.getRealTotal())) { + leftAll = leftAll.add(new BigDecimal(solutionsDetailsVo.getRealTotal())); + } + rightAll = rightAll.add(bigDecimalVinAll); } - if (StringUtils.isNotBlank(solutionsDetailsVo.getServiceAmount())) { - leftAll = leftAll.add(new BigDecimal(solutionsDetailsVo.getServiceAmount())); - } - rightAll = rightAll.add(bigDecimalVinAll); - } else { - //自营非担保: 实收订金 = 首付款及费用+订金 + } else {//担保贷款: 实收订金 = 首付款及费用+订金 if (StringUtils.isNotBlank(solutionsDetailsVo.getRealTotal())) { leftAll = leftAll.add(new BigDecimal(solutionsDetailsVo.getRealTotal())); } rightAll = rightAll.add(bigDecimalVinAll); } - } else {//担保贷款: 实收订金 = 首付款及费用+订金 - if (StringUtils.isNotBlank(solutionsDetailsVo.getRealTotal())) { - leftAll = leftAll.add(new BigDecimal(solutionsDetailsVo.getRealTotal())); - } + } else { + // 成交价 = 车款+订金 + leftAll = leftAll.add(singleFinalPrice); rightAll = rightAll.add(bigDecimalVinAll); } } else { - // 成交价 = 车款+订金 + // 成交价 = 车款+订金 leftAll = leftAll.add(singleFinalPrice); rightAll = rightAll.add(bigDecimalVinAll); } - } else { - // 成交价 = 车款+订金 - leftAll = leftAll.add(singleFinalPrice); - rightAll = rightAll.add(bigDecimalVinAll); - } - //根据busVinSid查询待出库中是否存在该数据 - ResultBean busDeliveredResultBean = busDeliveredFeign.selectByBusVinSid(finUncollectedReceivablesDetailed.getBusVinSid()); - if (busDeliveredResultBean.getData() == null) { - if (leftAll.compareTo(rightAll) <= 0) {//推送待出库 - BusDeliveredDto busDeliveredDto = new BusDeliveredDto(); - busDeliveredDto.setSubscriptionKey(VehicleStateTempOrLast.PaymentEnum.PAY_MODELS.getCode()); - busDeliveredDto.setSubscription(VehicleStateTempOrLast.PaymentEnum.PAY_MODELS.getRemarks()); - busDeliveredDto.setPaymentMethodKey(vo.getPayTypeKey()); - busDeliveredDto.setPaymentMethod(vo.getPayType()); - busDeliveredDto.setContractNo(v.getContractNo()); - busDeliveredDto.setName(v.getCustomerName()); - busDeliveredDto.setVinNo(v.getVIN()); - busDeliveredDto.setMobile(v.getCustomerPhone()); - busDeliveredDto.setPrice(priceInfoVo.getSingleFinalPrice()); - busDeliveredDto.setCreateBySid(confirmation.getStaffUserSid()); - SubmitVo intermediary1 = vo.getIntermediary1(); - if (intermediary1 != null) { - busDeliveredDto.setDistributorName(intermediary1.getIntermediaryName()); - busDeliveredDto.setDistributorPrice(intermediary1.getAgencyFee()); - } - SubmitVo intermediary2 = vo.getIntermediary2(); - if (intermediary2 != null) { - busDeliveredDto.setDistributorNameTwo(intermediary2.getIntermediaryName()); - busDeliveredDto.setDistributorPriceTwo(intermediary2.getAgencyFee()); - } - busDeliveredDto.setSingleCarDiscountPrice(priceInfoVo.getSingleCarDiscountPrice()); - //根据客户sid查询客户的身份证号 - AppOrderModelInfoVo appOrderModelInfoVo = vo.getModelInfo(); - busDeliveredDto.setModelName(appOrderModelInfoVo.getModelName()); - busDeliveredDto.setUseOrgSid(confirmation.getUseOrgSid()); - ResultBean sysOrganizationVoResultBean = sysOrganizationFeign.fetchBySid(confirmation.getUseOrgSid()); - if (sysOrganizationVoResultBean.getData() != null) { - busDeliveredDto.setUseOrgName(sysOrganizationVoResultBean.getData().getName()); + //根据busVinSid查询待出库中是否存在该数据 + ResultBean busDeliveredResultBean = busDeliveredFeign.selectByBusVinSid(finUncollectedReceivablesDetailed.getBusVinSid()); + if (busDeliveredResultBean.getData() == null) { + if (leftAll.compareTo(rightAll) <= 0) {//推送待出库 + BusDeliveredDto busDeliveredDto = new BusDeliveredDto(); + busDeliveredDto.setSubscriptionKey(VehicleStateTempOrLast.PaymentEnum.PAY_MODELS.getCode()); + busDeliveredDto.setSubscription(VehicleStateTempOrLast.PaymentEnum.PAY_MODELS.getRemarks()); + busDeliveredDto.setPaymentMethodKey(vo.getPayTypeKey()); + busDeliveredDto.setPaymentMethod(vo.getPayType()); + busDeliveredDto.setContractNo(v.getContractNo()); + busDeliveredDto.setName(v.getCustomerName()); + busDeliveredDto.setVinNo(v.getVIN()); + busDeliveredDto.setMobile(v.getCustomerPhone()); + busDeliveredDto.setPrice(priceInfoVo.getSingleFinalPrice()); + busDeliveredDto.setCreateBySid(confirmation.getStaffUserSid()); + SubmitVo intermediary1 = vo.getIntermediary1(); + if (intermediary1 != null) { + busDeliveredDto.setDistributorName(intermediary1.getIntermediaryName()); + busDeliveredDto.setDistributorPrice(intermediary1.getAgencyFee()); + } + SubmitVo intermediary2 = vo.getIntermediary2(); + if (intermediary2 != null) { + busDeliveredDto.setDistributorNameTwo(intermediary2.getIntermediaryName()); + busDeliveredDto.setDistributorPriceTwo(intermediary2.getAgencyFee()); + } + busDeliveredDto.setSingleCarDiscountPrice(priceInfoVo.getSingleCarDiscountPrice()); + //根据客户sid查询客户的身份证号 + AppOrderModelInfoVo appOrderModelInfoVo = vo.getModelInfo(); + busDeliveredDto.setModelName(appOrderModelInfoVo.getModelName()); + busDeliveredDto.setUseOrgSid(confirmation.getUseOrgSid()); + ResultBean sysOrganizationVoResultBean = sysOrganizationFeign.fetchBySid(confirmation.getUseOrgSid()); + if (sysOrganizationVoResultBean.getData() != null) { + busDeliveredDto.setUseOrgName(sysOrganizationVoResultBean.getData().getName()); + } + busDeliveredDto.setBusVinSid(finUncollectedReceivablesDetailed.getBusVinSid()); + ResultBean resultBean1 = busDeliveredFeign.save(busDeliveredDto); } - busDeliveredDto.setBusVinSid(finUncollectedReceivablesDetailed.getBusVinSid()); - ResultBean resultBean1 = busDeliveredFeign.save(busDeliveredDto); } - } + } } } } + }); //查询该申请已认款金额总数 subscriptionMoneyAll = finSelectedReceivablesDetailedVos.stream().map(FinSelectedReceivablesDetailedVo::getSubscriptionMoney).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add); @@ -2258,10 +2260,12 @@ public class FinCollectionConfirmationService extends MybatisBaseService @@ -180,7 +181,7 @@ where collSid = #{sid} and auditState = #{state} and receivablesName = #{type} - and payTypeKey = #{payTypeKey} + and payTypeKey = #{payTypeKey} and subscribedOf = 0 group by contractNo @@ -191,7 +192,7 @@ where collSid = #{sid} and auditState = #{state} and receivablesName = #{type} - and payTypeKey = #{payTypeKey} + and payTypeKey = #{payTypeKey} and subscribedOf = 0 @@ -208,7 +209,7 @@ select * from fin_selected_receivables_detailed where collSid = #{sid} - and auditState = #{state} + and auditState = #{state} and subscribedOf = 0 and receivablesName = #{type} @@ -220,7 +221,7 @@ and auditState = #{state} and receivablesName = #{type} and customerName = #{customerName} - and customerPhone = #{customerPhone} + and customerPhone = #{customerPhone} and subscribedOf = 0 and length(VIN) > 0 @@ -231,7 +232,7 @@ where collSid = #{sid} and auditState = #{state} and receivablesName = #{type} - and contractNo = #{contractNo} + and contractNo = #{contractNo} and subscribedOf = 0 and length(VIN) > 0 @@ -242,7 +243,7 @@ where collSid = #{sid} and auditState = #{state} and receivablesName = #{type} - and contractNo = #{contractNo} + and contractNo = #{contractNo} and subscribedOf = 0 and length(VIN) = 0 @@ -254,7 +255,7 @@ and auditState = #{state} and receivablesName = #{type} and customerName = #{customerName} - and customerPhone = #{customerPhone} + and customerPhone = #{customerPhone} and subscribedOf = 0 and length(VIN) = 0 @@ -263,7 +264,7 @@ from fin_selected_receivables_detailed fd left join fin_uncollected_receivables_detailed ff on ff.sid = fd.receivablesSid where ff.busVinSid = #{busVinSid} - and fd.auditState = 3 + and fd.auditState = 3 and subscribedOf = 0