diff --git a/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/busdelivered/AppDeliveredDetailsVo.java b/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/busdelivered/AppDeliveredDetailsVo.java index fb21be4280..edda9175dc 100644 --- a/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/busdelivered/AppDeliveredDetailsVo.java +++ b/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/busdelivered/AppDeliveredDetailsVo.java @@ -101,5 +101,7 @@ public class AppDeliveredDetailsVo implements Vo { private String taskDefKey; + private boolean showLoanUser; + } diff --git a/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/busdelivered/BusDeliveredService.java b/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/busdelivered/BusDeliveredService.java index c457969a33..61218ce387 100644 --- a/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/busdelivered/BusDeliveredService.java +++ b/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/busdelivered/BusDeliveredService.java @@ -150,8 +150,8 @@ public class BusDeliveredService extends MybatisBaseService page = PagerUtil.queryToPage(pq); @@ -214,8 +214,8 @@ public class BusDeliveredService extends MybatisBaseService iPage = baseMapper.getRetrievalNotList(page, qw, name); for (AppBusDeliveredPageVo record : iPage.getRecords()) { @@ -298,6 +298,9 @@ public class BusDeliveredService extends MybatisBaseService trailerList = baseTrailerFeign.trailerList(vinSid,contractNo); + ResultBean trailerList = baseTrailerFeign.trailerList(vinSid, contractNo); if (trailerList.getData().getList().isEmpty() && trailerList.getData().getVehillModelList().isEmpty()) { appCarListVo.setShowHandCarBtn(false); } else { @@ -366,7 +369,7 @@ public class BusDeliveredService extends MybatisBaseService> listResultBean = dictCommonFeign.getTypeValues("buyerType", "0"); List dictCommonVoList = listResultBean.getData(); List voList = Optional.ofNullable(dictCommonVoList).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), DeliveredDictVo.class)).collect(Collectors.toList()); - if("1".equals(appOrderDetailsVo.getPayTypeKey())){//贷款 + if ("1".equals(appOrderDetailsVo.getPayTypeKey())) {//贷款 voList.remove(1); } appDeliveredDetailsVo.setBuyerType(voList); @@ -413,11 +416,14 @@ public class BusDeliveredService extends MybatisBaseService busDeliveredApplyDetailsList = busDeliveredApplyDetailsService.selectByApplySid(query.getOutboundSid()); busDeliveredApplyDetailsList.removeAll(Collections.singleton(null)); - //pc发起人 + //pc发起人 appDeliveredDetailsVo.setPcApplyName(busDeliveredApply.getApplyName()); appDeliveredDetailsVo.setPcApplySid(busDeliveredApply.getApplySid()); appDeliveredDetailsVo.setPcApplyDept(busDeliveredApply.getApplyDept()); @@ -445,14 +451,14 @@ public class BusDeliveredService extends MybatisBaseService carList = new ArrayList<>(); List detailsList = busDeliveredApplyDetailsService.selectByApplySid(query.getOutboundSid()); detailsList.removeAll(Collections.singleton(null)); - if(!detailsList.isEmpty()){ + if (!detailsList.isEmpty()) { for (int i = 0; i < detailsList.size(); i++) { BusDeliveredApplyDetails busDeliveredApplyDetails = detailsList.get(i); AppCarListVo appCarListVo = new AppCarListVo(); appCarListVo.setDiscount(busDeliveredApplyDetails.getSingleCarDiscountPrice()); appCarListVo.setVinSid(busDeliveredApplyDetails.getVinSid()); //查询该车辆是否有挂车 - ResultBean trailerList = baseTrailerFeign.trailerList(busDeliveredApplyDetails.getVinSid(),busDeliveredApply.getContractNo()); + ResultBean trailerList = baseTrailerFeign.trailerList(busDeliveredApplyDetails.getVinSid(), busDeliveredApply.getContractNo()); if (trailerList.getData().getList().isEmpty() && trailerList.getData().getVehillModelList().isEmpty()) { appCarListVo.setShowHandCarBtn(false); } else { @@ -475,7 +481,7 @@ public class BusDeliveredService extends MybatisBaseService> listResultBean = dictCommonFeign.getTypeValues("buyerType", "0"); List dictCommonVoList = listResultBean.getData(); List voList = Optional.ofNullable(dictCommonVoList).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), DeliveredDictVo.class)).collect(Collectors.toList()); - if("1".equals(busDeliveredApply.getPaymentMethodKey())){//全款 + if ("1".equals(busDeliveredApply.getPaymentMethodKey())) {//全款 voList.remove(1); } appDeliveredDetailsVo.setBuyerType(voList); @@ -568,9 +574,9 @@ public class BusDeliveredService extends MybatisBaseService trailerList = baseTrailerFeign.trailerList(vinSid,query.getContractNo()); + ResultBean trailerList = baseTrailerFeign.trailerList(vinSid, query.getContractNo()); if (trailerList.getData().getList().isEmpty() && trailerList.getData().getVehillModelList().isEmpty()) { appCarListVo.setShowHandCarBtn(false); } else { diff --git a/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/busdeliveredapply/BusDeliveredApplyService.java b/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/busdeliveredapply/BusDeliveredApplyService.java index b2a425caed..c630101ab6 100644 --- a/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/busdeliveredapply/BusDeliveredApplyService.java +++ b/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/busdeliveredapply/BusDeliveredApplyService.java @@ -1235,9 +1235,7 @@ public class BusDeliveredApplyService extends MybatisBaseService resultBean = busSalesOrderService.getSaleOrderDetailsByContractNo(contractNo); if (!resultBean.getSuccess()) { @@ -1341,8 +1339,6 @@ public class BusDeliveredApplyService extends MybatisBaseService carList = appDeliveredApplyDto.getCarList(); - //根据申请人sid查询分公司sid - ResultBean stringResultBean = sysStaffOrgFeign.getPathSidByUserSid(appDeliveredApplyDto.getUserSid()); - if (stringResultBean.getSuccess()) { - busDeliveredApply.setUseOrgSid(stringResultBean.getData()); - } - if (carList.size() > 0) { - String vin = carList.get(0).getVin(); - baseVehicle = baseVehicleFeign.selectByVinNoAndOrgSid(vin, stringResultBean.getData()).getData(); - busDeliveredApplyDetailsService.appSaveList(carList, busDeliveredApply.getSid()); - //更改车辆状态 - for (int i = 0; i < carList.size(); i++) { - String vinNo = carList.get(i).getVin(); - busDeliveredService.updateState(vinNo, 0); - } - } - baseMapper.updateStateBySid(2, dtoSid); - busDeliveredApply.setApplySid(sysUserVo.getSid()); - busDeliveredApply.setApplyName(sysUserVo.getName()); - busDeliveredApply.setModelSid(baseVehicle.getModelSid()); - busDeliveredApply.setConfigSid(baseVehicle.getModelConfigSid()); - save(busDeliveredApply); - return rb.success().setData(busDeliveredApply.getSid()); - } else { - BusDeliveredApply busDeliveredApply = fetchBySid(dtoSid); - if (busDeliveredApply == null) { - return rb.setMsg("该申请不存在"); - } - BeanUtil.copyProperties(appDeliveredApplyDto, busDeliveredApply, "sid"); - //删除 - busDeliveredApplyDetailsService.deleteByApplySid(dtoSid); - busDeliveredUseMessageService.deleteByApplySid(dtoSid); - List carList = appDeliveredApplyDto.getCarList(); - //根据申请人sid查询分公司sid - ResultBean stringResultBean = sysStaffOrgFeign.getPathSidByUserSid(appDeliveredApplyDto.getUserSid()); - if (carList.size() > 0) { - String vin = carList.get(0).getVin(); - baseVehicle = baseVehicleFeign.selectByVinNoAndOrgSid(vin, stringResultBean.getData()).getData(); - busDeliveredApply.setModelSid(baseVehicle.getModelSid()); - busDeliveredApply.setConfigSid(baseVehicle.getModelConfigSid()); - busDeliveredApplyDetailsService.appSaveList(carList, busDeliveredApply.getSid()); - } - updateById(busDeliveredApply); - return rb.success().setData(busDeliveredApply.getSid()); - }*/ return rb.success().setData(sid); } diff --git a/anrui-crm/anrui-crm-api/src/main/java/com/yxt/anrui/crm/api/crmcustomertemp/CrmCustomerTempFeign.java b/anrui-crm/anrui-crm-api/src/main/java/com/yxt/anrui/crm/api/crmcustomertemp/CrmCustomerTempFeign.java index 1d38062c39..2c8162741d 100644 --- a/anrui-crm/anrui-crm-api/src/main/java/com/yxt/anrui/crm/api/crmcustomertemp/CrmCustomerTempFeign.java +++ b/anrui-crm/anrui-crm-api/src/main/java/com/yxt/anrui/crm/api/crmcustomertemp/CrmCustomerTempFeign.java @@ -57,7 +57,7 @@ public interface CrmCustomerTempFeign { @ApiOperation("推送财务客户-否") @PostMapping("/sendFinCustomer/{orgCode}") - public ResultBean sendFinCustomer(@RequestBody String[] customerSids,@PathVariable("orgCode") String orgCode); + public ResultBean sendFinCustomer(@RequestBody String[] customerSids, @PathVariable("orgCode") String orgCode); @ApiOperation("推送财务客户-是") @PostMapping("/sendFinCustomerTrue") @@ -180,4 +180,15 @@ public interface CrmCustomerTempFeign { @ApiOperation("合同审核通过后更新客户档案证件") ResultBean saveFileCustomer(@RequestBody CrmCustomerFileDDto dto); + /** + * 检查并创建金蝶中的客户 + * + * @param customerQuery 相关参数 + * @return + */ + @ResponseBody + @PostMapping("/checkCustomerOrUpdate") + @ApiOperation("检查并创建金蝶中的客户") + ResultBean checkCustomerOrUpdate(@Valid @RequestBody CustomerQuery customerQuery); + } \ No newline at end of file diff --git a/anrui-crm/anrui-crm-api/src/main/java/com/yxt/anrui/crm/api/crmcustomertemp/CrmCustomerTempFeignFallback.java b/anrui-crm/anrui-crm-api/src/main/java/com/yxt/anrui/crm/api/crmcustomertemp/CrmCustomerTempFeignFallback.java index dcd57b8f79..2e0a1d9240 100644 --- a/anrui-crm/anrui-crm-api/src/main/java/com/yxt/anrui/crm/api/crmcustomertemp/CrmCustomerTempFeignFallback.java +++ b/anrui-crm/anrui-crm-api/src/main/java/com/yxt/anrui/crm/api/crmcustomertemp/CrmCustomerTempFeignFallback.java @@ -145,5 +145,10 @@ public class CrmCustomerTempFeignFallback implements CrmCustomerTempFeign { return null; } + @Override + public ResultBean checkCustomerOrUpdate(CustomerQuery customerQuery) { + return null; + } + } \ No newline at end of file diff --git a/anrui-crm/anrui-crm-api/src/main/java/com/yxt/anrui/crm/api/crmcustomertemp/CustomerQuery.java b/anrui-crm/anrui-crm-api/src/main/java/com/yxt/anrui/crm/api/crmcustomertemp/CustomerQuery.java new file mode 100644 index 0000000000..953c5a9b86 --- /dev/null +++ b/anrui-crm/anrui-crm-api/src/main/java/com/yxt/anrui/crm/api/crmcustomertemp/CustomerQuery.java @@ -0,0 +1,25 @@ +package com.yxt.anrui.crm.api.crmcustomertemp; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @description: 客户相关 + * @author: dimengzhe + * @date: 2023/5/11 + **/ +@Data +public class CustomerQuery { + + @ApiModelProperty("客户编码") + @NotBlank(message = "客户编码不能为空") + private String customerNo; + @ApiModelProperty("客户名称") + @NotBlank(message = "客户名称不能为空") + private String customerName; + @ApiModelProperty("当前分公司code") + @NotBlank(message = "当前分公司code不能为空") + private String orgCode; +} diff --git a/anrui-crm/anrui-crm-biz/src/main/java/com/yxt/anrui/crm/biz/crmcustomertemp/CrmCustomerTempRest.java b/anrui-crm/anrui-crm-biz/src/main/java/com/yxt/anrui/crm/biz/crmcustomertemp/CrmCustomerTempRest.java index 33ecff6120..b9dfde9895 100644 --- a/anrui-crm/anrui-crm-biz/src/main/java/com/yxt/anrui/crm/biz/crmcustomertemp/CrmCustomerTempRest.java +++ b/anrui-crm/anrui-crm-biz/src/main/java/com/yxt/anrui/crm/biz/crmcustomertemp/CrmCustomerTempRest.java @@ -294,5 +294,10 @@ public class CrmCustomerTempRest implements CrmCustomerTempFeign { return crmCustomerTempService.saveFileCustomer(dto); } + @Override + public ResultBean checkCustomerOrUpdate(CustomerQuery customerQuery) { + return crmCustomerTempService.checkCustomerOrUpdate(customerQuery); + } + } diff --git a/anrui-crm/anrui-crm-biz/src/main/java/com/yxt/anrui/crm/biz/crmcustomertemp/CrmCustomerTempService.java b/anrui-crm/anrui-crm-biz/src/main/java/com/yxt/anrui/crm/biz/crmcustomertemp/CrmCustomerTempService.java index 004d70142f..0d82a22b54 100644 --- a/anrui-crm/anrui-crm-biz/src/main/java/com/yxt/anrui/crm/biz/crmcustomertemp/CrmCustomerTempService.java +++ b/anrui-crm/anrui-crm-biz/src/main/java/com/yxt/anrui/crm/biz/crmcustomertemp/CrmCustomerTempService.java @@ -51,6 +51,8 @@ import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.result.ResultBean; import com.yxt.common.core.vo.PagerVo; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -73,6 +75,7 @@ import java.util.*; */ @Service public class CrmCustomerTempService extends MybatisBaseService { + public static final Logger logger = LoggerFactory.getLogger(CrmCustomerTempService.class); @Autowired @@ -229,7 +232,7 @@ public class CrmCustomerTempService extends MybatisBaseService rb = ResultBean.fireFail(); + //根据客户编码查询金蝶中是否存在该客户 + Boolean aBoolean = finKingDeeFeign.customerExistState(customerQuery.getCustomerNo()).getData(); + if (!aBoolean) {//不存在则创建 + BdCustomer bdCustomer = new BdCustomer(); + bdCustomer.setFNumber(customerQuery.getCustomerNo()); + bdCustomer.setFName(customerQuery.getCustomerName()); + bdCustomer.setTOrgIds(customerQuery.getOrgCode()); + ResultBean resultBean = finKingDeeFeign.draftBdCustomer(bdCustomer); + logger.info("推送客户{}", resultBean); + } + return rb.success().setData(customerQuery.getCustomerNo()); + } } \ No newline at end of file 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 09874143b0..819ba3db9a 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 @@ -54,6 +54,7 @@ import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicle; import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicleFeign; 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.fincollectionconfirmation.*; import com.yxt.anrui.fin.api.fincollectionconfirmation.app.AppBusArrearsCarryMoneyVo; import com.yxt.anrui.fin.api.fincollectionconfirmation.app.FinConfirmDto; @@ -274,7 +275,7 @@ public class FinCollectionConfirmationService extends MybatisBaseService finSelectedReceivablesDetailedVos = finSelectedReceivablesDetailedService.fetchByCillSid(finCollectionConfirmation.getSid()); - BigDecimal totalSubscriptionMone = new BigDecimal(0); - for (FinSelectedReceivablesDetailedVo finSelectedReceivablesDetailedVo : finSelectedReceivablesDetailedVos) { - BigDecimal subscriptionMoney = new BigDecimal(finSelectedReceivablesDetailedVo.getSubscriptionMoney()); - totalSubscriptionMone = totalSubscriptionMone.add(subscriptionMoney); - } - BigDecimal collectionMoney = finCollectionConfirmation.getCollectionMoney(); - BigDecimal subtract = collectionMoney.subtract(totalSubscriptionMone); - if (subtract.compareTo(BigDecimal.ZERO) < 0) { - return rb.setMsg("已选应收款项金额已超出该确认单应收金额总额,请重新核对"); - } - finCollectionConfirmation.setBalance(subtract); - finCollectionConfirmation.setPaymentState(1); - save(finCollectionConfirmation); - return rb.success().setData(finCollectionConfirmation.getSid());*/ } /** @@ -935,12 +899,8 @@ public class FinCollectionConfirmationService extends MybatisBaseService resultBean = busSalesOrderFeign.getVinSidByConSid(finSelectedReceivablesDetailed.getContractNo(), finSelectedReceivablesDetailed.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); @@ -1117,7 +1057,7 @@ public class FinCollectionConfirmationService extends MybatisBaseService finSelectedReceivablesDetailedVos1_1_1 = finSelectedReceivablesDetailedService.fetchByAuditState1(sid, 1, "首付款", "1"); //推送全款订金 List finSelectedReceivablesDetailedVos2 = finSelectedReceivablesDetailedService.fetchByAuditState1(sid, 1, "订金", "1"); - + //贷款推送车款 + List finSelectedReceivablesDetailedVos1_1 = finSelectedReceivablesDetailedService.fetchByAuditState1_1(sid, 1, "车款", "2"); + finSelectedReceivablesDetailedVos1_1.removeAll(Collections.singleton(null)); + //贷款推送订金 + List finSelectedReceivablesDetailedVos2_1 = finSelectedReceivablesDetailedService.fetchByAuditState1_1(sid, 1, "订金", "2"); + finSelectedReceivablesDetailedVos2_1.removeAll(Collections.singleton(null)); + //贷款推送车款(应收未收中为首付款的) + List finSelectedReceivablesDetailedVos1_1_2 = finSelectedReceivablesDetailedService.fetchByAuditState1_1(sid, 1, "首付款及费用", "2"); + finSelectedReceivablesDetailedVos1_1_2.removeAll(Collections.singleton(null)); int carSize = 0; //全款推送车款 if (finSelectedReceivablesDetailedVos1.size() > 0) { @@ -1325,7 +1273,6 @@ public class FinCollectionConfirmationService extends MybatisBaseService 0) { @@ -1460,7 +1402,6 @@ public class FinCollectionConfirmationService extends MybatisBaseService 0) { List voListv = finSelectedReceivablesDetailedService.selectDetailsList(sid, 1, "订金"); @@ -1596,13 +1531,10 @@ public class FinCollectionConfirmationService extends MybatisBaseService finSelectedReceivablesDetailedVos1_1 = finSelectedReceivablesDetailedService.fetchByAuditState1_1(sid, 1, "车款", "2"); - finSelectedReceivablesDetailedVos1_1.removeAll(Collections.singleton(null)); if (finSelectedReceivablesDetailedVos1_1.size() > 0) { for (int i = 0; i < finSelectedReceivablesDetailedVos1_1.size(); i++) { FinSelectedReceivablesDetailedVo vvvv = finSelectedReceivablesDetailedVos1_1.get(i); @@ -1716,11 +1638,9 @@ public class FinCollectionConfirmationService extends MybatisBaseService finSelectedReceivablesDetailedVos2_1 = finSelectedReceivablesDetailedService.fetchByAuditState1_1(sid, 1, "订金", "2"); - finSelectedReceivablesDetailedVos2_1.removeAll(Collections.singleton(null)); if (finSelectedReceivablesDetailedVos2_1.size() > 0) { for (int i = 0; i < finSelectedReceivablesDetailedVos2_1.size(); i++) { FinSelectedReceivablesDetailedVo vvvv = finSelectedReceivablesDetailedVos2_1.get(i); @@ -1773,9 +1689,7 @@ public class FinCollectionConfirmationService extends MybatisBaseService finSelectedReceivablesDetailedVos1_1_2 = finSelectedReceivablesDetailedService.fetchByAuditState1_1(sid, 1, "首付款及费用", "2"); - finSelectedReceivablesDetailedVos1_1_2.removeAll(Collections.singleton(null)); if (finSelectedReceivablesDetailedVos1_1_2.size() > 0) { for (int i = 0; i < finSelectedReceivablesDetailedVos1_1_2.size(); i++) { FinSelectedReceivablesDetailedVo vvvv = finSelectedReceivablesDetailedVos1_1_2.get(i); @@ -1829,13 +1737,9 @@ public class FinCollectionConfirmationService extends MybatisBaseService resultBean = sysOrganizationFeign.fetchBySid(useOrgSid); - if (resultBean.getSuccess()) { - SysOrganizationVo vo = resultBean.getData(); - if (vo != null) { - bdCustomer.setTOrgIds(vo.getOrgCode()); + //备份 + public ResultBean cashierConfirm1(String sid, String userSid) { + ResultBean rb = ResultBean.fireFail(); + FinCollectionConfirmation confirmation = fetchBySid(sid); + if (confirmation == null) { + return rb.setMsg("该申请不存在"); + } + //=========================================== + //推送收款单 + ARReceivebill arReceivebill = new ARReceivebill(); + //业务日期 + arReceivebill.setFDATE(DateUtil.today()); + //收款日期 + arReceivebill.setF_PAEZ_Date(confirmation.getCollectionDate()); + //收款组织 + ResultBean resultBean = sysOrganizationFeign.fetchBySid(confirmation.getUseOrgSid()); + BasePurchaseSystemDetailsVo data = basePurchaseSystemFeign.fetchDetailsByDeptSid(confirmation.getPurchaseSystemSid()).getData(); + if (data != null) { + arReceivebill.setFPAYORGID(data.getOrgCode()); + } else { + if (resultBean.getSuccess()) { + SysOrganizationVo vo = resultBean.getData(); + if (vo != null) { + arReceivebill.setFPAYORGID(vo.getOrgCode()); + } } } - String fname = name + mobile; - bdCustomer.setFName(fname); - String code = ""; - if (StringUtils.isNotBlank(customerSid)) {//存在客户sid - //根据客户sid查询客户的编码 - ResultBean crmCustomerTempVoResultBean = crmCustomerTempFeign.fetchSid(customerSid); - if (crmCustomerTempVoResultBean.getData() != null) { - code = crmCustomerTempVoResultBean.getData().getCustomerNo(); + //销售部门 + if (StringUtils.isNotBlank(confirmation.getStaffDeptSid())) { + resultBean = sysOrganizationFeign.fetchBySid(confirmation.getStaffDeptSid()); + if (resultBean.getSuccess()) { + SysOrganizationVo vo = resultBean.getData(); + if (vo != null) { + arReceivebill.setFSALEDEPTID(vo.getOrgCode()); + } } - } else { - //简易订单-订金收取 - code = getPrefix(collSid, name, mobile); } - bdCustomer.setFNumber(code); - return bdCustomer; + arReceivebill.setFREMARK("付款人:" + confirmation.getPayerName()); + //物料列表 + List fEntityList = new ArrayList<>(); + ARReceivebill.FRECEIVEBILLENTRY freceivebillentry = new ARReceivebill.FRECEIVEBILLENTRY(); + //推送全款车款 + List finSelectedReceivablesDetailedVos1 = finSelectedReceivablesDetailedService.fetchByAuditState1(sid, 1, "车款", "1"); + List finSelectedReceivablesDetailedVos1_1_1 = finSelectedReceivablesDetailedService.fetchByAuditState1(sid, 1, "首付款", "1"); + //推送全款订金 + List finSelectedReceivablesDetailedVos2 = finSelectedReceivablesDetailedService.fetchByAuditState1(sid, 1, "订金", "1"); + + int carSize = 0; + //全款推送车款 + if (finSelectedReceivablesDetailedVos1.size() > 0) { + List voListv = finSelectedReceivablesDetailedService.selectDetailsList(sid, 1, "车款"); + //查询是否含有车架号 + List stringsVin = voListv.stream().filter(v -> StringUtils.isNotBlank(v.getVIN())).map(v -> v.getVIN()).collect(Collectors.toList()); + stringsVin.removeAll(Collections.singleton(null)); + if (!stringsVin.isEmpty()) { + //查询根据客户名称和手机号有哪些客户 + List customerList = finSelectedReceivablesDetailedService.selectCustomerList(sid, 1, "车款"); + for (int i = 0; i < customerList.size(); i++) { + String customerName = customerList.get(i).getCustomerName(); + String customerMobile = customerList.get(i).getCustomerPhone(); + String customerSid = customerList.get(i).getCustomerSid(); + BdCustomer bdCustomer = createBdCustomer(confirmation.getUseOrgSid(), customerName, customerMobile, customerSid, sid); + //推送金蝶客户,修改目标组织为采购系统对应的金蝶分公司code + if (data != null) { + bdCustomer.setTOrgIds(data.getOrgCode()); + } + ResultBean resultBeanMiddle = bdCustomerService.draftBdCustomer(bdCustomer); + //往来单位 + arReceivebill.setFCONTACTUNIT(bdCustomer.getFNumber()); + fEntityList = new ArrayList<>(); + String uncollSid = ""; + //查询该客户的车架号不为空的情况 + List vinListVo = finSelectedReceivablesDetailedService.selectVinListVo(sid, 1, "车款", customerName, customerMobile); + vinListVo.removeAll(Collections.singleton(null)); + if (!vinListVo.isEmpty()) { + for (FinSelectedReceivablesDetailedVo vvvv : vinListVo) { + freceivebillentry = new ARReceivebill.FRECEIVEBILLENTRY(); + //结算方式 + freceivebillentry.setFSETTLETYPEIDKey(confirmation.getCollectionTypeKey()); + freceivebillentry.setFSETTLETYPEIDType("customerPayType"); + //收款金额 + freceivebillentry.setFRECTOTALAMOUNTFOR(vvvv.getSubscriptionMoney()); + //登记日期 + freceivebillentry.setFPOSTDATE(confirmation.getCollectionDate()); + freceivebillentry.setF_PAEZ_Base1(vvvv.getVIN().substring(vvvv.getVIN().length() - 8)); + //收款用途 + freceivebillentry.setFPURPOSEIDKey("001"); + freceivebillentry.setFPURPOSEIDType("cw_skyt"); +// freceivebillentry.setFACCOUNTID(confirmation.getCollectionBankNum()); + freceivebillentry.setFACCOUNTID(StringUtils.deleteWhitespace(confirmation.getCollectionBankNum())); + fEntityList.add(freceivebillentry); + uncollSid = vvvv.getReceivablesSid(); + } + } + //查询该客户的车架号为空的情况 + FinSelectedReceivablesDetailedVo vvVo = finSelectedReceivablesDetailedService.fetchByAuditStateV(sid, 1, "车款", customerName, customerMobile); + if (vvVo != null) { + uncollSid = vvVo.getReceivablesSid(); + freceivebillentry = new ARReceivebill.FRECEIVEBILLENTRY(); + //结算方式 + freceivebillentry.setFSETTLETYPEIDKey(confirmation.getCollectionTypeKey()); + freceivebillentry.setFSETTLETYPEIDType("customerPayType"); + //收款金额 + freceivebillentry.setFRECTOTALAMOUNTFOR(vvVo.getSumAll()); + //登记日期 + freceivebillentry.setFPOSTDATE(confirmation.getCollectionDate()); + //收款用途 + freceivebillentry.setFPURPOSEIDKey("001"); + freceivebillentry.setFPURPOSEIDType("cw_skyt"); +// freceivebillentry.setFACCOUNTID(confirmation.getCollectionBankNum()); + freceivebillentry.setFACCOUNTID(StringUtils.deleteWhitespace(confirmation.getCollectionBankNum())); + fEntityList.add(freceivebillentry); + } + //项目类别key、value + arReceivebill.setF_PAEZ_AssistantType("cw_sklb"); + FinUncollectedReceivablesDetailed finUncollectedReceivablesDetailed = finUncollectedReceivablesDetailedService.fetchBySid(uncollSid); + if ("1".equals(finUncollectedReceivablesDetailed.getPayTypeKey())) { + arReceivebill.setF_PAEZ_AssistantKey("001"); + } else if ("2".equals(finUncollectedReceivablesDetailed.getPayTypeKey())) { + arReceivebill.setF_PAEZ_AssistantKey("002"); + } + arReceivebill.setFRECEIVEBILLENTRY(fEntityList); + if (customerList.size() == 1 && finSelectedReceivablesDetailedVos2.size() == 0) { + arReceivebill.setFBillNo(confirmation.getBillNo()); + } else { + carSize = i + 1; + arReceivebill.setFBillNo(confirmation.getBillNo() + "-" + carSize); + } + ResultBean resultBean1 = arReceivebillService.draftArReceivebill(arReceivebill); + } + + } else { + finSelectedReceivablesDetailedVos1.removeAll(Collections.singleton(null)); + if (!finSelectedReceivablesDetailedVos1.isEmpty()) { + for (int i = 0; i < finSelectedReceivablesDetailedVos1.size(); i++) { + fEntityList = new ArrayList<>(); + freceivebillentry = new ARReceivebill.FRECEIVEBILLENTRY(); + FinSelectedReceivablesDetailedVo finSelectedReceivablesDetailedVo = finSelectedReceivablesDetailedVos1.get(i); + //先推送客户 + BdCustomer bdCustomer = createBdCustomer(confirmation.getUseOrgSid(), finSelectedReceivablesDetailedVo.getCustomerName(), finSelectedReceivablesDetailedVo.getCustomerPhone(), finSelectedReceivablesDetailedVo.getCustomerSid(), sid); + //推送金蝶客户,修改目标组织为采购系统对应的金蝶分公司code + if (data != null) { + bdCustomer.setTOrgIds(data.getOrgCode()); + } + ResultBean resultBeanMiddle = bdCustomerService.draftBdCustomer(bdCustomer); + //往来单位 + arReceivebill.setFCONTACTUNIT(bdCustomer.getFNumber()); + //结算方式 + freceivebillentry.setFSETTLETYPEIDKey(confirmation.getCollectionTypeKey()); + freceivebillentry.setFSETTLETYPEIDType("customerPayType"); + //收款金额 + freceivebillentry.setFRECTOTALAMOUNTFOR(finSelectedReceivablesDetailedVo.getSumAll()); + //登记日期 + freceivebillentry.setFPOSTDATE(confirmation.getCollectionDate()); + //收款用途 + freceivebillentry.setFPURPOSEIDKey("001"); + freceivebillentry.setFPURPOSEIDType("cw_skyt"); +// freceivebillentry.setFACCOUNTID(confirmation.getCollectionBankNum()); + freceivebillentry.setFACCOUNTID(StringUtils.deleteWhitespace(confirmation.getCollectionBankNum())); + fEntityList.add(freceivebillentry); + //项目类别key、value + arReceivebill.setF_PAEZ_AssistantType("cw_sklb"); + FinUncollectedReceivablesDetailed finUncollectedReceivablesDetailed = finUncollectedReceivablesDetailedService.fetchBySid(finSelectedReceivablesDetailedVos1.get(0).getReceivablesSid()); + if ("1".equals(finUncollectedReceivablesDetailed.getPayTypeKey())) { + arReceivebill.setF_PAEZ_AssistantKey("001"); + } else if ("2".equals(finUncollectedReceivablesDetailed.getPayTypeKey())) { + arReceivebill.setF_PAEZ_AssistantKey("002"); + } + arReceivebill.setFRECEIVEBILLENTRY(fEntityList); + if (finSelectedReceivablesDetailedVos1.size() > 1) { + int size = 0; + size = i + 1; + arReceivebill.setFBillNo(confirmation.getBillNo() + "-" + size); + } else { + arReceivebill.setFBillNo(confirmation.getBillNo()); + } + + ResultBean resultBean1 = arReceivebillService.draftArReceivebill(arReceivebill); + } + } + } + + } + //全款推送车款(应收未收中为首付款的) + if (finSelectedReceivablesDetailedVos1_1_1.size() > 0) { + List voListv = finSelectedReceivablesDetailedService.selectDetailsList(sid, 1, "首付款及费用"); + //查询是否含有车架号 + List stringsVin = voListv.stream().filter(v -> StringUtils.isNotBlank(v.getVIN())).map(v -> v.getVIN()).collect(Collectors.toList()); + stringsVin.removeAll(Collections.singleton(null)); + if (!stringsVin.isEmpty()) { + //查询根据客户名称和手机号有哪些客户 + List customerList = finSelectedReceivablesDetailedService.selectCustomerList(sid, 1, "首付款及费用"); + for (int i = 0; i < customerList.size(); i++) { + String customerName = customerList.get(i).getCustomerName(); + String customerMobile = customerList.get(i).getCustomerPhone(); + String customerSid = customerList.get(i).getCustomerSid(); + BdCustomer bdCustomer = createBdCustomer(confirmation.getUseOrgSid(), customerName, customerMobile, customerSid, sid); + //推送金蝶客户,修改目标组织为采购系统对应的金蝶分公司code + if (data != null) { + bdCustomer.setTOrgIds(data.getOrgCode()); + } + ResultBean resultBeanMiddle = bdCustomerService.draftBdCustomer(bdCustomer); + //往来单位 + arReceivebill.setFCONTACTUNIT(bdCustomer.getFNumber()); + fEntityList = new ArrayList<>(); + String uncollSid = ""; + //查询该客户的车架号不为空的情况 + List vinListVo = finSelectedReceivablesDetailedService.selectVinListVo(sid, 1, "首付款及费用", customerName, customerMobile); + vinListVo.removeAll(Collections.singleton(null)); + if (!vinListVo.isEmpty()) { + for (FinSelectedReceivablesDetailedVo vvvv : vinListVo) { + freceivebillentry = new ARReceivebill.FRECEIVEBILLENTRY(); + //结算方式 + freceivebillentry.setFSETTLETYPEIDKey(confirmation.getCollectionTypeKey()); + freceivebillentry.setFSETTLETYPEIDType("customerPayType"); + //收款金额 + freceivebillentry.setFRECTOTALAMOUNTFOR(vvvv.getSubscriptionMoney()); + //登记日期 + freceivebillentry.setFPOSTDATE(confirmation.getCollectionDate()); + freceivebillentry.setF_PAEZ_Base1(vvvv.getVIN().substring(vvvv.getVIN().length() - 8)); + //收款用途 + freceivebillentry.setFPURPOSEIDKey("001"); + freceivebillentry.setFPURPOSEIDType("cw_skyt"); +// freceivebillentry.setFACCOUNTID(confirmation.getCollectionBankNum()); + freceivebillentry.setFACCOUNTID(StringUtils.deleteWhitespace(confirmation.getCollectionBankNum())); + fEntityList.add(freceivebillentry); + uncollSid = vvvv.getReceivablesSid(); + } + } + //查询该客户的车架号为空的情况 + FinSelectedReceivablesDetailedVo vvVo = finSelectedReceivablesDetailedService.fetchByAuditStateV(sid, 1, "首付款及费用", customerName, customerMobile); + if (vvVo != null) { + uncollSid = vvVo.getReceivablesSid(); + freceivebillentry = new ARReceivebill.FRECEIVEBILLENTRY(); + //结算方式 + freceivebillentry.setFSETTLETYPEIDKey(confirmation.getCollectionTypeKey()); + freceivebillentry.setFSETTLETYPEIDType("customerPayType"); + //收款金额 + freceivebillentry.setFRECTOTALAMOUNTFOR(vvVo.getSumAll()); + //登记日期 + freceivebillentry.setFPOSTDATE(confirmation.getCollectionDate()); + //收款用途 + freceivebillentry.setFPURPOSEIDKey("001"); + freceivebillentry.setFPURPOSEIDType("cw_skyt"); +// freceivebillentry.setFACCOUNTID(confirmation.getCollectionBankNum()); + freceivebillentry.setFACCOUNTID(StringUtils.deleteWhitespace(confirmation.getCollectionBankNum())); + fEntityList.add(freceivebillentry); + } + //项目类别key、value + arReceivebill.setF_PAEZ_AssistantType("cw_sklb"); + FinUncollectedReceivablesDetailed finUncollectedReceivablesDetailed = finUncollectedReceivablesDetailedService.fetchBySid(uncollSid); + if ("1".equals(finUncollectedReceivablesDetailed.getPayTypeKey())) { + arReceivebill.setF_PAEZ_AssistantKey("001"); + } else if ("2".equals(finUncollectedReceivablesDetailed.getPayTypeKey())) { + arReceivebill.setF_PAEZ_AssistantKey("002"); + } + arReceivebill.setFRECEIVEBILLENTRY(fEntityList); + if (customerList.size() == 1 && finSelectedReceivablesDetailedVos2.size() == 0 && finSelectedReceivablesDetailedVos1.size() == 0) { + arReceivebill.setFBillNo(confirmation.getBillNo()); + } else { + carSize = i + 1; + arReceivebill.setFBillNo(confirmation.getBillNo() + "-" + carSize); + } + ResultBean resultBean1 = arReceivebillService.draftArReceivebill(arReceivebill); + } + + } else { + finSelectedReceivablesDetailedVos1.removeAll(Collections.singleton(null)); + if (!finSelectedReceivablesDetailedVos1.isEmpty()) { + for (int i = 0; i < finSelectedReceivablesDetailedVos1.size(); i++) { + fEntityList = new ArrayList<>(); + freceivebillentry = new ARReceivebill.FRECEIVEBILLENTRY(); + FinSelectedReceivablesDetailedVo finSelectedReceivablesDetailedVo = finSelectedReceivablesDetailedVos1.get(i); + //先推送客户 + BdCustomer bdCustomer = createBdCustomer(confirmation.getUseOrgSid(), finSelectedReceivablesDetailedVo.getCustomerName(), finSelectedReceivablesDetailedVo.getCustomerPhone(), finSelectedReceivablesDetailedVo.getCustomerSid(), sid); + //推送金蝶客户,修改目标组织为采购系统对应的金蝶分公司code + if (data != null) { + bdCustomer.setTOrgIds(data.getOrgCode()); + } + ResultBean resultBeanMiddle = bdCustomerService.draftBdCustomer(bdCustomer); + //往来单位 + arReceivebill.setFCONTACTUNIT(bdCustomer.getFNumber()); + //结算方式 + freceivebillentry.setFSETTLETYPEIDKey(confirmation.getCollectionTypeKey()); + freceivebillentry.setFSETTLETYPEIDType("customerPayType"); + //收款金额 + freceivebillentry.setFRECTOTALAMOUNTFOR(finSelectedReceivablesDetailedVo.getSumAll()); + //登记日期 + freceivebillentry.setFPOSTDATE(confirmation.getCollectionDate()); + //收款用途 + freceivebillentry.setFPURPOSEIDKey("001"); + freceivebillentry.setFPURPOSEIDType("cw_skyt"); +// freceivebillentry.setFACCOUNTID(confirmation.getCollectionBankNum()); + freceivebillentry.setFACCOUNTID(StringUtils.deleteWhitespace(confirmation.getCollectionBankNum())); + fEntityList.add(freceivebillentry); + //项目类别key、value + arReceivebill.setF_PAEZ_AssistantType("cw_sklb"); + FinUncollectedReceivablesDetailed finUncollectedReceivablesDetailed = finUncollectedReceivablesDetailedService.fetchBySid(finSelectedReceivablesDetailedVos1.get(0).getReceivablesSid()); + if ("1".equals(finUncollectedReceivablesDetailed.getPayTypeKey())) { + arReceivebill.setF_PAEZ_AssistantKey("001"); + } else if ("2".equals(finUncollectedReceivablesDetailed.getPayTypeKey())) { + arReceivebill.setF_PAEZ_AssistantKey("002"); + } + arReceivebill.setFRECEIVEBILLENTRY(fEntityList); + if (finSelectedReceivablesDetailedVos1_1_1.size() > 1) { + int size = 0; + size = i + 1; + arReceivebill.setFBillNo(confirmation.getBillNo() + "-" + size); + } else { + arReceivebill.setFBillNo(confirmation.getBillNo()); + } + + ResultBean resultBean1 = arReceivebillService.draftArReceivebill(arReceivebill); + } + } + } + + } + + //全款推送订金 + if (finSelectedReceivablesDetailedVos2.size() > 0) { + List voListv = finSelectedReceivablesDetailedService.selectDetailsList(sid, 1, "订金"); + //查询是否含有车架号 + List stringsVin = voListv.stream().filter(v -> StringUtils.isNotBlank(v.getVIN())).map(v -> v.getVIN()).collect(Collectors.toList()); + stringsVin.removeAll(Collections.singleton(null)); + if (!stringsVin.isEmpty()) { + //查询根据客户名称和手机号有哪些客户 + List customerList = finSelectedReceivablesDetailedService.selectCustomerList(sid, 1, "订金"); + for (int i = 0; i < customerList.size(); i++) { + String customerName = customerList.get(i).getCustomerName(); + String customerMobile = customerList.get(i).getCustomerPhone(); + String customerSid = customerList.get(i).getCustomerSid(); + //先推送客户 + BdCustomer bdCustomer = createBdCustomer(confirmation.getUseOrgSid(), customerName, customerMobile, customerSid, sid); + //推送金蝶客户,修改目标组织为采购系统对应的金蝶分公司code + if (data != null) { + bdCustomer.setTOrgIds(data.getOrgCode()); + } + ResultBean resultBeanMiddle = bdCustomerService.draftBdCustomer(bdCustomer); + //往来单位 + arReceivebill.setFCONTACTUNIT(bdCustomer.getFNumber()); + fEntityList = new ArrayList<>(); + //查询该客户的车架号不为空的情况 + List vinListVo = finSelectedReceivablesDetailedService.selectVinListVo(sid, 1, "订金", customerName, customerMobile); + vinListVo.removeAll(Collections.singleton(null)); + if (!vinListVo.isEmpty()) { + for (FinSelectedReceivablesDetailedVo vvvv : vinListVo) { + freceivebillentry = new ARReceivebill.FRECEIVEBILLENTRY(); + //结算方式 + freceivebillentry.setFSETTLETYPEIDKey(confirmation.getCollectionTypeKey()); + freceivebillentry.setFSETTLETYPEIDType("customerPayType"); + //收款金额 + freceivebillentry.setFRECTOTALAMOUNTFOR(vvvv.getSubscriptionMoney()); + //登记日期 + freceivebillentry.setFPOSTDATE(confirmation.getCollectionDate()); + freceivebillentry.setF_PAEZ_Base1(vvvv.getVIN().substring(vvvv.getVIN().length() - 8)); + //收款用途 + freceivebillentry.setFPURPOSEIDKey("002"); + freceivebillentry.setFPURPOSEIDType("cw_skyt"); +// freceivebillentry.setFACCOUNTID(confirmation.getCollectionBankNum()); + freceivebillentry.setFACCOUNTID(StringUtils.deleteWhitespace(confirmation.getCollectionBankNum())); + + fEntityList.add(freceivebillentry); + } + } + + //查询该客户的车架号为空的情况 + FinSelectedReceivablesDetailedVo vvVo = finSelectedReceivablesDetailedService.fetchByAuditStateV(sid, 1, "订金", customerName, customerMobile); + if (vvVo != null) { + freceivebillentry = new ARReceivebill.FRECEIVEBILLENTRY(); + //结算方式 + freceivebillentry.setFSETTLETYPEIDKey(confirmation.getCollectionTypeKey()); + freceivebillentry.setFSETTLETYPEIDType("customerPayType"); + //收款金额 + freceivebillentry.setFRECTOTALAMOUNTFOR(vvVo.getSumAll()); + //登记日期 + freceivebillentry.setFPOSTDATE(confirmation.getCollectionDate()); + //收款用途 + freceivebillentry.setFPURPOSEIDKey("002"); + freceivebillentry.setFPURPOSEIDType("cw_skyt"); +// freceivebillentry.setFACCOUNTID(confirmation.getCollectionBankNum()); + freceivebillentry.setFACCOUNTID(StringUtils.deleteWhitespace(confirmation.getCollectionBankNum())); + + fEntityList.add(freceivebillentry); + } + //项目类别key、value + arReceivebill.setF_PAEZ_AssistantType("cw_sklb"); + arReceivebill.setF_PAEZ_AssistantKey("006"); + arReceivebill.setFRECEIVEBILLENTRY(fEntityList); + if (finSelectedReceivablesDetailedVos1.size() == 0 && customerList.size() == 1 && finSelectedReceivablesDetailedVos1_1_1.size() == 0) { + arReceivebill.setFBillNo(confirmation.getBillNo()); + + } else { + //单据编号 + carSize = carSize + 1; + arReceivebill.setFBillNo(confirmation.getBillNo() + "-" + carSize); + } + ResultBean resultBean1 = arReceivebillService.draftArReceivebill(arReceivebill); + + } + } else { + finSelectedReceivablesDetailedVos2.removeAll(Collections.singleton(null)); + if (!finSelectedReceivablesDetailedVos2.isEmpty()) { + for (int i = 0; i < finSelectedReceivablesDetailedVos2.size(); i++) { + fEntityList = new ArrayList<>(); + freceivebillentry = new ARReceivebill.FRECEIVEBILLENTRY(); + FinSelectedReceivablesDetailedVo finSelectedReceivablesDetailedVo = finSelectedReceivablesDetailedVos2.get(i); + //先推送客户 + BdCustomer bdCustomer = createBdCustomer(confirmation.getUseOrgSid(), finSelectedReceivablesDetailedVo.getCustomerName(), finSelectedReceivablesDetailedVo.getCustomerPhone(), finSelectedReceivablesDetailedVo.getCustomerSid(), sid); + //推送金蝶客户,修改目标组织为采购系统对应的金蝶分公司code + if (data != null) { + bdCustomer.setTOrgIds(data.getOrgCode()); + } + ResultBean resultBeanMiddle = bdCustomerService.draftBdCustomer(bdCustomer); + //往来单位 + arReceivebill.setFCONTACTUNIT(bdCustomer.getFNumber()); + //结算方式 + freceivebillentry.setFSETTLETYPEIDKey(confirmation.getCollectionTypeKey()); + freceivebillentry.setFSETTLETYPEIDType("customerPayType"); + //收款金额 + freceivebillentry.setFRECTOTALAMOUNTFOR(finSelectedReceivablesDetailedVo.getSumAll()); + //登记日期 + freceivebillentry.setFPOSTDATE(confirmation.getCollectionDate()); + //收款用途 + freceivebillentry.setFPURPOSEIDKey("002"); + freceivebillentry.setFPURPOSEIDType("cw_skyt"); +// freceivebillentry.setFACCOUNTID(confirmation.getCollectionBankNum()); + freceivebillentry.setFACCOUNTID(StringUtils.deleteWhitespace(confirmation.getCollectionBankNum())); + fEntityList.add(freceivebillentry); + arReceivebill.setFRECEIVEBILLENTRY(fEntityList); + //项目类别key、value + arReceivebill.setF_PAEZ_AssistantType("cw_sklb"); + arReceivebill.setF_PAEZ_AssistantKey("006"); + if (finSelectedReceivablesDetailedVos2.size() > 1) { + int size = 0; + size = i + 1; + arReceivebill.setFBillNo(confirmation.getBillNo() + "-" + size); + } else { + arReceivebill.setFBillNo(confirmation.getBillNo()); + } + ResultBean resultBean2 = arReceivebillService.draftArReceivebill(arReceivebill); + } + } + } + + } + + //贷款推送车款 + List finSelectedReceivablesDetailedVos1_1 = finSelectedReceivablesDetailedService.fetchByAuditState1_1(sid, 1, "车款", "2"); + finSelectedReceivablesDetailedVos1_1.removeAll(Collections.singleton(null)); + if (finSelectedReceivablesDetailedVos1_1.size() > 0) { + for (int i = 0; i < finSelectedReceivablesDetailedVos1_1.size(); i++) { + FinSelectedReceivablesDetailedVo vvvv = finSelectedReceivablesDetailedVos1_1.get(i); + String contractNo = vvvv.getContractNo(); + String vinNo = vvvv.getVIN(); + BdCustomer bdCustomer = createBdCustomer1(confirmation.getUseOrgSid(), vvvv.getCustomerName(), contractNo, sid, vinNo); + //推送金蝶客户,修改目标组织为采购系统对应的金蝶分公司code + if (data != null) { + bdCustomer.setTOrgIds(data.getOrgCode()); + } + ResultBean resultBeanMiddle = bdCustomerService.draftBdCustomer(bdCustomer); + //往来单位 + arReceivebill.setFCONTACTUNIT(bdCustomer.getFNumber()); + 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(StringUtils.deleteWhitespace(confirmation.getCollectionBankNum())); + fEntityList.add(freceivebillentry); + uncollSid = vvvv.getReceivablesSid(); + //项目类别key、value + arReceivebill.setF_PAEZ_AssistantType("cw_sklb"); + FinUncollectedReceivablesDetailed finUncollectedReceivablesDetailed = finUncollectedReceivablesDetailedService.fetchBySid(uncollSid); + if ("1".equals(finUncollectedReceivablesDetailed.getPayTypeKey())) { + arReceivebill.setF_PAEZ_AssistantKey("001"); + } else if ("2".equals(finUncollectedReceivablesDetailed.getPayTypeKey())) { + arReceivebill.setF_PAEZ_AssistantKey("002"); + } + arReceivebill.setFRECEIVEBILLENTRY(fEntityList); + if (finSelectedReceivablesDetailedVos1_1.size() == 1 && finSelectedReceivablesDetailedVos1.size() == 0 && finSelectedReceivablesDetailedVos2.size() == 0 && finSelectedReceivablesDetailedVos1_1_1.size() == 0) { + arReceivebill.setFBillNo(confirmation.getBillNo()); + } else { + //单据编号 + carSize = carSize + 1; + arReceivebill.setFBillNo(confirmation.getBillNo() + "-" + carSize); + } + ResultBean resultBean1 = arReceivebillService.draftArReceivebill(arReceivebill); + + } + } + //贷款推送订金 + List finSelectedReceivablesDetailedVos2_1 = finSelectedReceivablesDetailedService.fetchByAuditState1_1(sid, 1, "订金", "2"); + finSelectedReceivablesDetailedVos2_1.removeAll(Collections.singleton(null)); + if (finSelectedReceivablesDetailedVos2_1.size() > 0) { + for (int i = 0; i < finSelectedReceivablesDetailedVos2_1.size(); i++) { + FinSelectedReceivablesDetailedVo vvvv = finSelectedReceivablesDetailedVos2_1.get(i); + //先推送客户 + String contractNo = vvvv.getContractNo(); + String vinNo = vvvv.getVIN(); + BdCustomer bdCustomer = createBdCustomer1(confirmation.getUseOrgSid(), vvvv.getCustomerName(), contractNo, sid, vinNo); + //推送金蝶客户,修改目标组织为采购系统对应的金蝶分公司code + if (data != null) { + bdCustomer.setTOrgIds(data.getOrgCode()); + } + ResultBean resultBeanMiddle = bdCustomerService.draftBdCustomer(bdCustomer); + //往来单位 + arReceivebill.setFCONTACTUNIT(bdCustomer.getFNumber()); + fEntityList = new ArrayList<>(); + 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("002"); + freceivebillentry.setFPURPOSEIDType("cw_skyt"); +// freceivebillentry.setFACCOUNTID(confirmation.getCollectionBankNum()); + freceivebillentry.setFACCOUNTID(StringUtils.deleteWhitespace(confirmation.getCollectionBankNum())); + + fEntityList.add(freceivebillentry); + //项目类别key、value + arReceivebill.setF_PAEZ_AssistantType("cw_sklb"); + arReceivebill.setF_PAEZ_AssistantKey("006"); + arReceivebill.setFRECEIVEBILLENTRY(fEntityList); + if (finSelectedReceivablesDetailedVos1.size() == 0 && finSelectedReceivablesDetailedVos2_1.size() == 1 && + finSelectedReceivablesDetailedVos2.size() == 0 && finSelectedReceivablesDetailedVos1_1.size() == 0 + && finSelectedReceivablesDetailedVos1_1_1.size() == 0) { + arReceivebill.setFBillNo(confirmation.getBillNo()); + } else { + //单据编号 + carSize = carSize + 1; + arReceivebill.setFBillNo(confirmation.getBillNo() + "-" + carSize); + } + ResultBean resultBean1 = arReceivebillService.draftArReceivebill(arReceivebill); + + } + + } + + //==========================================贷款-首付款开始 + //贷款推送车款(应收未收中为首付款的) + List finSelectedReceivablesDetailedVos1_1_2 = finSelectedReceivablesDetailedService.fetchByAuditState1_1(sid, 1, "首付款及费用", "2"); + finSelectedReceivablesDetailedVos1_1_2.removeAll(Collections.singleton(null)); + if (finSelectedReceivablesDetailedVos1_1_2.size() > 0) { + for (int i = 0; i < finSelectedReceivablesDetailedVos1_1_2.size(); i++) { + FinSelectedReceivablesDetailedVo vvvv = finSelectedReceivablesDetailedVos1_1_2.get(i); + String contractNo = vvvv.getContractNo(); + String vinNo = vvvv.getVIN(); + BdCustomer bdCustomer = createBdCustomer1(confirmation.getUseOrgSid(), vvvv.getCustomerName(), contractNo, sid, vinNo); + //推送金蝶客户,修改目标组织为采购系统对应的金蝶分公司code + if (data != null) { + bdCustomer.setTOrgIds(data.getOrgCode()); + } + ResultBean resultBeanMiddle = bdCustomerService.draftBdCustomer(bdCustomer); + //往来单位 + arReceivebill.setFCONTACTUNIT(bdCustomer.getFNumber()); + 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()); + freceivebillentry.setFACCOUNTID(StringUtils.deleteWhitespace(confirmation.getCollectionBankNum())); + + + fEntityList.add(freceivebillentry); + uncollSid = vvvv.getReceivablesSid(); + + //项目类别key、value + arReceivebill.setF_PAEZ_AssistantType("cw_sklb"); + FinUncollectedReceivablesDetailed finUncollectedReceivablesDetailed = finUncollectedReceivablesDetailedService.fetchBySid(uncollSid); + if ("1".equals(finUncollectedReceivablesDetailed.getPayTypeKey())) { + arReceivebill.setF_PAEZ_AssistantKey("001"); + } else if ("2".equals(finUncollectedReceivablesDetailed.getPayTypeKey())) { + arReceivebill.setF_PAEZ_AssistantKey("002"); + } + arReceivebill.setFRECEIVEBILLENTRY(fEntityList); + if (finSelectedReceivablesDetailedVos1_1_2.size() == 1 && + finSelectedReceivablesDetailedVos1.size() == 0 && + finSelectedReceivablesDetailedVos2.size() == 0 && + finSelectedReceivablesDetailedVos1_1_1.size() == 0 && + finSelectedReceivablesDetailedVos1_1.size() == 0 && + finSelectedReceivablesDetailedVos2_1.size() == 0) { + arReceivebill.setFBillNo(confirmation.getBillNo()); + } else { + //单据编号 + carSize = carSize + 1; + arReceivebill.setFBillNo(confirmation.getBillNo() + "-" + carSize); + } + ResultBean resultBean1 = arReceivebillService.draftArReceivebill(arReceivebill); + + } + } + //==========================================贷款首付款结束 + //简易订单-订金收取 + if (finSelectedReceivablesDetailedVos1.isEmpty() && + finSelectedReceivablesDetailedVos2.isEmpty() && + finSelectedReceivablesDetailedVos1_1.isEmpty() && + finSelectedReceivablesDetailedVos2_1.isEmpty() && + finSelectedReceivablesDetailedVos1_1_1.isEmpty() && + finSelectedReceivablesDetailedVos1_1_2.isEmpty()) { + //先推送客户 + AppBusDepositBuscenterDetailVo busDeposit = busDepositFeign.getDepositInfoDetails(confirmation.getBusSid()).getData(); + BdCustomer bdCustomer = createBdCustomer(confirmation.getUseOrgSid(), busDeposit.getPayName(), busDeposit.getPhone(), "", sid); + //推送金蝶客户,修改目标组织为采购系统对应的金蝶分公司code + if (data != null) { + bdCustomer.setTOrgIds(data.getOrgCode()); + } + ResultBean resultBeanMiddle = bdCustomerService.draftBdCustomer(bdCustomer); + log.info("客户推送:" + resultBeanMiddle.getMsg()); + //往来单位 + arReceivebill.setFCONTACTUNIT(bdCustomer.getFNumber()); + fEntityList = new ArrayList<>(); + freceivebillentry = new ARReceivebill.FRECEIVEBILLENTRY(); + //结算方式 + freceivebillentry.setFSETTLETYPEIDKey(confirmation.getCollectionTypeKey()); + freceivebillentry.setFSETTLETYPEIDType("customerPayType"); + BigDecimal bigAll = confirmation.getCollectionMoney(); + //收款金额 + freceivebillentry.setFRECTOTALAMOUNTFOR(bigAll.toString()); + //登记日期 + freceivebillentry.setFPOSTDATE(confirmation.getCollectionDate()); + //收款用途:订金 + freceivebillentry.setFPURPOSEIDKey("002"); + freceivebillentry.setFPURPOSEIDType("cw_skyt"); +// freceivebillentry.setFACCOUNTID(confirmation.getCollectionBankNum()); + freceivebillentry.setFACCOUNTID(StringUtils.deleteWhitespace(confirmation.getCollectionBankNum())); + fEntityList.add(freceivebillentry); + arReceivebill.setFRECEIVEBILLENTRY(fEntityList); + //项目类别key、value + arReceivebill.setF_PAEZ_AssistantType("cw_sklb"); + arReceivebill.setF_PAEZ_AssistantKey("006"); + arReceivebill.setFBillNo(confirmation.getBillNo()); + ResultBean resultBean2 = arReceivebillService.draftArReceivebill(arReceivebill); + log.info("收款单推送:" + resultBean2.getMsg()); + } + //=========================================== + //查询该申请下的所有待审核的款项明细 + BigDecimal subscriptionMoneyAll = new BigDecimal("0"); + List finSelectedReceivablesDetailedVos = finSelectedReceivablesDetailedService.fetchByAuditState(sid, 1); + if (finSelectedReceivablesDetailedVos.size() > 0) { + finSelectedReceivablesDetailedVos.stream().forEach(v -> { + //已选款项明细sid + String selectSid = v.getSid(); + //应收未收款项明细sid + String receivablesSid = v.getReceivablesSid(); + FinUncollectedReceivablesDetailed finUncollectedReceivablesDetailed = finUncollectedReceivablesDetailedService.fetchBySid(receivablesSid); + //更新认款状态 + finUncollectedReceivablesDetailed.setSubscriptionState(finUncollectedReceivablesDetailed.getCurrentReceivableMoney().compareTo(BigDecimal.ZERO) == 0 ? 3 : 2); + finUncollectedReceivablesDetailedService.updateById(finUncollectedReceivablesDetailed); + FinSelectedReceivablesDetailed finSelectedReceivablesDetailed = finSelectedReceivablesDetailedService.fetchBySid(selectSid); + //更新已选款项明细的审核状态1待审核/2已驳回/3已审核 + finSelectedReceivablesDetailed.setAuditState(3); + //更新审核时间 + finSelectedReceivablesDetailed.setAuditDate(DateUtil.today()); + finSelectedReceivablesDetailedService.updateById(finSelectedReceivablesDetailed); + //ToDo:查询是否符合待出库的条件 + //该合同编号下的该车架号的所有认款金额 + 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(); + //单台整体成交价 + 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); + } + } else {//担保贷款: 实收订金 = 首付款及费用+订金 + if (StringUtils.isNotBlank(solutionsDetailsVo.getRealTotal())) { + leftAll = leftAll.add(new BigDecimal(solutionsDetailsVo.getRealTotal())); + } + rightAll = rightAll.add(bigDecimalVinAll); + } + } else { + // 成交价 = 车款+订金 + leftAll = leftAll.add(singleFinalPrice); + rightAll = rightAll.add(bigDecimalVinAll); + } + } else { + // 成交价 = 车款+订金 + leftAll = leftAll.add(singleFinalPrice); + rightAll = rightAll.add(bigDecimalVinAll); + } + 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); + } + } + } + } + }); + //查询该申请已认款金额总数 + subscriptionMoneyAll = finSelectedReceivablesDetailedVos.stream().map(FinSelectedReceivablesDetailedVo::getSubscriptionMoney).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add); + } + //查询该申请所有的款项明细 + finSelectedReceivablesDetailedVos = finSelectedReceivablesDetailedService.fetchByAuditState(sid, 3); + //与收款金额作比较:更新认款状态 1未认款/2部分认款/3已认款 + confirmation.setPaymentState(confirmation.getCollectionMoney().compareTo(subscriptionMoneyAll) <= 0 ? 3 : subscriptionMoneyAll.compareTo(BigDecimal.ZERO) == 0 ? 1 : 2); + //更新收款申请的余额以及审核状态 + BigDecimal balanceBigDecimal = confirmation.getCollectionMoney().subtract(subscriptionMoneyAll); + confirmation.setBalance(balanceBigDecimal); + confirmation.setAuditState(3); + //查询当前登录人信息并更新审核人和审核时间 + ResultBean userVoResultBean = sysUserFeign.fetchBySid(userSid); + if (userVoResultBean.getData() != null) { + confirmation.setConfirmName(userVoResultBean.getData().getName()); + } + confirmation.setConfirmDate(DateUtil.today()); + confirmation.setConfirmNameSid(userSid); + baseMapper.updateById(confirmation); + //删除临时表的数据 + ResultBean deleteResult = baseVehicleTempstateFeign.delByBusSid(sid); + return rb.success().setMsg("款项确认成功"); + } + + //组装客户推送 + private BdCustomer createBdCustomer(String useOrgSid, String name, String mobile, String customerSid, String collSid) { + BdCustomer bdCustomer = new BdCustomer(); + ResultBean resultBean = sysOrganizationFeign.fetchBySid(useOrgSid); + if (resultBean.getSuccess()) { + SysOrganizationVo vo = resultBean.getData(); + if (vo != null) { + bdCustomer.setTOrgIds(vo.getOrgCode()); + } + } + String fname = name + mobile; + bdCustomer.setFName(fname); + String code = ""; + if (StringUtils.isNotBlank(customerSid)) {//存在客户sid + //根据客户sid查询客户的编码 + ResultBean crmCustomerTempVoResultBean = crmCustomerTempFeign.fetchSid(customerSid); + if (crmCustomerTempVoResultBean.getData() != null) { + code = crmCustomerTempVoResultBean.getData().getCustomerNo(); + } + } else { + //简易订单-订金收取 + code = getPrefix(collSid, name, mobile); + } + bdCustomer.setFNumber(code); + return bdCustomer; + } + + /** + * 组装数据并调用检查金蝶中的客户信息 + * + * @param payTypeKey 1全款,2贷款 + * @return + */ + public String createCustomerQuery(int payTypeKey, FinSelectedReceivablesDetailedVo vv, String orgCode) { + CustomerQuery customerQuery = new CustomerQuery(); + //根据销售类型是全款还是贷款推送金蝶客户的信息 + if (payTypeKey == 1) {//全款 + //客户编码:买卖合同编号,客户名称:客户名称+买卖合同编号,orgCode:当前分公司code + customerQuery.setCustomerNo(vv.getContractNo()); + customerQuery.setCustomerName(vv.getCustomerName() + vv.getContractNo()); + customerQuery.setOrgCode(orgCode); + + } else {//贷款 + //根据销售订单车辆sid查询临时号码 + String customerNo = ""; + FinUncollectedReceivablesDetailed finUncollectedReceivablesDetailed = finUncollectedReceivablesDetailedService.fetchBySid(vv.getReceivablesSid()); + ResultBean resultBean = busSalesOrderVehicleFeign.details(finUncollectedReceivablesDetailed.getBusVinSid()); + if (resultBean.getData() != null) { + customerNo = resultBean.getData().getTemporaryNo(); + } + //第一种:不确定车架号:客户编码:买卖合同编号0x,客户名称:客户名称+买卖合同编号0x,orgCode:当前分公司code + if (vv.getVIN().length() < 8) { + customerQuery.setCustomerNo(customerNo); + customerQuery.setCustomerName(vv.getCustomerName() + customerQuery.getCustomerNo()); + customerQuery.setOrgCode(orgCode); + + } else {//第二种:确定车架号:客户编码:买卖合同编号0x,客户名称:客户名称+车架号,orgCode:当前分公司code + //查询销售订单中客户的临时编号 + customerQuery.setCustomerNo(customerNo); + customerQuery.setCustomerName(vv.getCustomerName() + vv.getVIN()); + customerQuery.setOrgCode(orgCode); + } + } + ResultBean customerResultBean = crmCustomerTempFeign.checkCustomerOrUpdate(customerQuery); + log.info("推送客户{}", customerResultBean); + return customerResultBean.getData(); } private BdCustomer createBdCustomer1(String useOrgSid, String name, String contractNo, String collSid, String vinNo) { @@ -2734,7 +3477,7 @@ public class FinCollectionConfirmationService extends MybatisBaseService finSelectedReceivablesDetailedVos = finSelectedReceivablesDetailedService.fetchByAuditState(sid, 1); diff --git a/anrui-terminal/anrui-terminal-api/src/main/java/com/yxt/anrui/terminal/api/autoservice/retrieval/DeliveredDetailsVo.java b/anrui-terminal/anrui-terminal-api/src/main/java/com/yxt/anrui/terminal/api/autoservice/retrieval/DeliveredDetailsVo.java index 766ee41367..8ba678662b 100644 --- a/anrui-terminal/anrui-terminal-api/src/main/java/com/yxt/anrui/terminal/api/autoservice/retrieval/DeliveredDetailsVo.java +++ b/anrui-terminal/anrui-terminal-api/src/main/java/com/yxt/anrui/terminal/api/autoservice/retrieval/DeliveredDetailsVo.java @@ -92,12 +92,6 @@ public class DeliveredDetailsVo implements Vo { private String sid; @ApiModelProperty("orgPath") private String orgPath; - - /* private String applyName; - private String applySid; - private String applyDeptSid; - private String staffUserSid; - private String applyDept;*/ @ApiModelProperty("车辆集合") private List carList = new ArrayList<>(); @ApiModelProperty("剩余") @@ -112,4 +106,6 @@ public class DeliveredDetailsVo implements Vo { @ApiModelProperty("销售订单sid") private String busSalesOrderSid; + + private boolean showLoanUser; }