|
|
@ -2747,6 +2747,808 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl |
|
|
|
return rb.success().setMsg("款项确认成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean cashierConfirmOld(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<SysOrganizationVo> 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()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//销售部门
|
|
|
|
if (StringUtils.isNotBlank(confirmation.getStaffDeptSid())) { |
|
|
|
resultBean = sysOrganizationFeign.fetchBySid(confirmation.getStaffDeptSid()); |
|
|
|
if (resultBean.getSuccess()) { |
|
|
|
SysOrganizationVo vo = resultBean.getData(); |
|
|
|
if (vo != null) { |
|
|
|
arReceivebill.setFSALEDEPTID(vo.getOrgCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
arReceivebill.setFREMARK("付款人:" + confirmation.getPayerName()); |
|
|
|
//物料列表
|
|
|
|
List<ARReceivebill.FRECEIVEBILLENTRY> fEntityList = new ArrayList<>(); |
|
|
|
ARReceivebill.FRECEIVEBILLENTRY freceivebillentry = new ARReceivebill.FRECEIVEBILLENTRY(); |
|
|
|
//推送全款车款
|
|
|
|
List<FinSelectedReceivablesDetailedVo> finSelectedReceivablesDetailedVos1 = finSelectedReceivablesDetailedService.fetchByAuditState1(sid, 1, "车款", "1"); |
|
|
|
List<FinSelectedReceivablesDetailedVo> finSelectedReceivablesDetailedVos1_1_1 = finSelectedReceivablesDetailedService.fetchByAuditState1(sid, 1, "首付款", "1"); |
|
|
|
//推送全款订金
|
|
|
|
List<FinSelectedReceivablesDetailedVo> finSelectedReceivablesDetailedVos2 = finSelectedReceivablesDetailedService.fetchByAuditState1(sid, 1, "订金", "1"); |
|
|
|
|
|
|
|
int carSize = 0; |
|
|
|
//全款推送车款
|
|
|
|
if (finSelectedReceivablesDetailedVos1.size() > 0) { |
|
|
|
List<FinSelectedReceivablesDetailedVo> voListv = finSelectedReceivablesDetailedService.selectDetailsList(sid, 1, "车款"); |
|
|
|
//查询是否含有车架号
|
|
|
|
List<String> 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<SelectCustomerVo> 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<FinSelectedReceivablesDetailedVo> 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<FinSelectedReceivablesDetailedVo> voListv = finSelectedReceivablesDetailedService.selectDetailsList(sid, 1, "首付款及费用"); |
|
|
|
//查询是否含有车架号
|
|
|
|
List<String> 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<SelectCustomerVo> 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<FinSelectedReceivablesDetailedVo> 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<FinSelectedReceivablesDetailedVo> voListv = finSelectedReceivablesDetailedService.selectDetailsList(sid, 1, "订金"); |
|
|
|
//查询是否含有车架号
|
|
|
|
List<String> 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<SelectCustomerVo> 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<FinSelectedReceivablesDetailedVo> 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<FinSelectedReceivablesDetailedVo> 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<FinSelectedReceivablesDetailedVo> 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<FinSelectedReceivablesDetailedVo> 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<FinSelectedReceivablesDetailedVo> 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<FinSelectedReceivablesDetailedVo> voList = finSelectedReceivablesDetailedService.selectListByVin(v.getContractNo(), finUncollectedReceivablesDetailed.getBusVinSid(), 3); |
|
|
|
BigDecimal bigDecimalVinAll = voList.stream().map(FinSelectedReceivablesDetailedVo::getSubscriptionMoney).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
//查询该合同编号下的销售订单的单车成交价
|
|
|
|
ResultBean<CommonContract> commonContractResultBean = commonContractFeign.selectByNo(v.getContractNo()); |
|
|
|
if (commonContractResultBean.getSuccess()) { |
|
|
|
CommonContract commonContract = commonContractResultBean.getData(); |
|
|
|
if (commonContract != null) { |
|
|
|
ResultBean<AppOrderDetailsVo> 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<SolutionsDetailsVo> 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<SysOrganizationVo> 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<SysUserVo> 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(); |
|
|
|