fix: 付款申请同步组织编码与币种改为取自关联合同并调整默认推送配置
This commit is contained in:
+33
-14
@@ -31,7 +31,9 @@ import org.springblade.core.tool.jackson.JsonUtil;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.cache.DictBizCache;
|
||||
import org.springblade.system.cache.SysCache;
|
||||
import org.springblade.system.pojo.entity.DictBiz;
|
||||
import org.springblade.system.pojo.entity.Dept;
|
||||
import org.springblade.thirdparty.bfi.pojo.dto.BfiPayApplySaveDTO;
|
||||
import org.springblade.thirdparty.bfi.pojo.dto.BfiPayApplySaveEntryDTO;
|
||||
import org.springblade.thirdparty.bfi.pojo.vo.BfiBillSaveResultItemVO;
|
||||
@@ -122,17 +124,13 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
private final TemporaryCreditLimitMapper temporaryCreditLimitMapper;
|
||||
private final IFormalSettlementService formalSettlementService;
|
||||
private final IBfiService bfiService;
|
||||
@Value("${thirdParty.bfi.payApply.srcSys:TMS}")
|
||||
@Value("${thirdParty.bfi.payApply.srcSys:WLTMS}")
|
||||
private String bfiPayApplySrcSys;
|
||||
@Value("${thirdParty.bfi.payApply.billtype:ap_payapply_BT_S}")
|
||||
@Value("${thirdParty.bfi.payApply.billtype:ap_payapply_oth_BT_S}")
|
||||
private String bfiPayApplyBilltype;
|
||||
@Value("${thirdParty.bfi.payApply.orgNumber:}")
|
||||
private String bfiPayApplyOrgNumber;
|
||||
@Value("${thirdParty.bfi.payApply.currency:CNY}")
|
||||
private String bfiPayApplyCurrency;
|
||||
@Value("${thirdParty.bfi.payApply.exratetable:01}")
|
||||
private String bfiPayApplyExratetable;
|
||||
@Value("${thirdParty.bfi.payApply.srcType:TMS付款申请}")
|
||||
@Value("${thirdParty.bfi.payApply.srcType:0KzXs}")
|
||||
private String bfiPayApplySrcType;
|
||||
|
||||
@Override
|
||||
@@ -378,21 +376,23 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
* @return 金蝶付款申请单id
|
||||
*/
|
||||
private String pushBfiPayApply(PaymentApplication entity) {
|
||||
if (Func.isBlank(bfiPayApplyOrgNumber)) throw new ServiceException("推送金蝶付款申请失败,请配置thirdParty.bfi.payApply.orgNumber");
|
||||
ContractManage contract = requireContract(entity);
|
||||
String orgNumber = bfiOrgNumber(contract);
|
||||
String currency = bfiCurrency(contract);
|
||||
String applyDateText = (entity.getApplyDate() == null ? LocalDate.now() : entity.getApplyDate()).format(DateTimeFormatter.BASIC_ISO_DATE);
|
||||
BigDecimal applyAmount = money(entity.getAppliedAmount()).setScale(2, RoundingMode.HALF_UP);
|
||||
BfiPayApplySaveDTO param = new BfiPayApplySaveDTO();
|
||||
param.setAwrpSrcCode(entity.getPaymentNo());
|
||||
param.setAwrpSrcSys(bfiPayApplySrcSys);
|
||||
param.setSettleorgNumber(bfiPayApplyOrgNumber);
|
||||
param.setSettleorgNumber(orgNumber);
|
||||
param.setBilltypeNumber(bfiPayApplyBilltype);
|
||||
param.setApplydate(applyDateText);
|
||||
param.setApplyorgNumber(bfiPayApplyOrgNumber);
|
||||
param.setPayorgNumber(bfiPayApplyOrgNumber);
|
||||
param.setPurorgNumber(bfiPayApplyOrgNumber);
|
||||
param.setApplyorgNumber(orgNumber);
|
||||
param.setPayorgNumber(orgNumber);
|
||||
// param.setPurorgNumber(orgNumber);
|
||||
param.setApplycause(bfiApplyCause(entity.getPaymentType()));
|
||||
param.setPaycurrencyNumber(bfiPayApplyCurrency);
|
||||
param.setSettlecurrencyNumber(bfiPayApplyCurrency);
|
||||
param.setPaycurrencyNumber(currency);
|
||||
param.setSettlecurrencyNumber(currency);
|
||||
param.setAwrpSrcType(bfiPayApplySrcType);
|
||||
param.setExratetableNumber(bfiPayApplyExratetable);
|
||||
param.setExratedate(applyDateText);
|
||||
@@ -431,6 +431,25 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
updateById(entity);
|
||||
}
|
||||
|
||||
private ContractManage requireContract(PaymentApplication entity) {
|
||||
if (entity.getContractId() == null) throw new ServiceException("推送金蝶付款申请失败,付款申请未关联合同");
|
||||
ContractManage contract = contractManageMapper.selectById(entity.getContractId());
|
||||
if (contract == null || Objects.equals(contract.getIsDeleted(), 1)) throw new ServiceException("推送金蝶付款申请失败,关联合同不存在");
|
||||
return contract;
|
||||
}
|
||||
|
||||
private String bfiOrgNumber(ContractManage contract) {
|
||||
Dept dept = contract.getOrganizationId() == null ? null : SysCache.getDept(contract.getOrganizationId());
|
||||
String orgNumber = dept == null || Func.isBlank(dept.getDeptCode()) ? contract.getOrganizationName() : dept.getDeptCode();
|
||||
if (Func.isBlank(orgNumber)) throw new ServiceException("推送金蝶付款申请失败,合同所属组织编码不能为空");
|
||||
return orgNumber;
|
||||
}
|
||||
|
||||
private String bfiCurrency(ContractManage contract) {
|
||||
if (Func.isBlank(contract.getSettlementCurrency())) throw new ServiceException("推送金蝶付款申请失败,合同结算币种不能为空");
|
||||
return contract.getSettlementCurrency();
|
||||
}
|
||||
|
||||
private String bfiApplyCause(String paymentType) {
|
||||
return switch (paymentType == null ? "" : paymentType) {
|
||||
case "project_advance" -> "项目预付款申请";
|
||||
|
||||
+5
-5
@@ -52,7 +52,7 @@ public class BfiPayApplySaveDTO implements Serializable {
|
||||
@JsonProperty("awrp_src_sys")
|
||||
private String awrpSrcSys;
|
||||
/**
|
||||
* 结算组织.编码
|
||||
* 结算组织.编码 传组织编码
|
||||
*/
|
||||
@JsonProperty("settleorg_number")
|
||||
private String settleorgNumber;
|
||||
@@ -66,17 +66,17 @@ public class BfiPayApplySaveDTO implements Serializable {
|
||||
*/
|
||||
private String applydate;
|
||||
/**
|
||||
* 申请组织.编码
|
||||
* 申请组织.编码 传组织编码
|
||||
*/
|
||||
@JsonProperty("applyorg_number")
|
||||
private String applyorgNumber;
|
||||
/**
|
||||
* 付款组织.编码
|
||||
* 付款组织.编码 传组织编码
|
||||
*/
|
||||
@JsonProperty("payorg_number")
|
||||
private String payorgNumber;
|
||||
/**
|
||||
* 采购组织.编码
|
||||
* 采购组织.编码 传组织编码
|
||||
*/
|
||||
@JsonProperty("purorg_number")
|
||||
private String purorgNumber;
|
||||
@@ -105,7 +105,7 @@ public class BfiPayApplySaveDTO implements Serializable {
|
||||
@JsonProperty("settlecurrency_number")
|
||||
private String settlecurrencyNumber;
|
||||
/**
|
||||
* 外部单据类型
|
||||
* 外部单据类型 0KzXs
|
||||
*/
|
||||
@JsonProperty("awrp_src_type")
|
||||
private String awrpSrcType;
|
||||
|
||||
@@ -130,12 +130,12 @@ TMS 付款申请审核通过
|
||||
| 接口字段 | 含义 | 来源 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| awrp_src_code | 来源单据号(防重键) | `paymentNo` | 付款申请单号 |
|
||||
| awrp_src_sys | 外部系统编号(防重键) | 配置 `payApply.srcSys` | 默认 `TMS` |
|
||||
| settleorg_number / applyorg_number / payorg_number / purorg_number | 结算/申请/付款/采购组织编码 | 配置 `payApply.orgNumber` | 金蝶公司编码,必填 |
|
||||
| billtype_number | 单据类型编码 | 配置 `payApply.billtype` | 默认 `ap_payapply_BT_S` 采购付款申请 |
|
||||
| awrp_src_sys | 外部系统编号(防重键) | 配置 `payApply.srcSys` | 默认 `WLTMS` |
|
||||
| settleorg_number / applyorg_number / payorg_number / purorg_number | 结算/申请/付款/采购组织编码 | 合同所属组织 | `organizationId` → 组织编码 `deptCode`,为空回退组织名称;缺失报错 |
|
||||
| billtype_number | 单据类型编码 | 配置 `payApply.billtype` | 默认 `ap_payapply_oth_BT_S` 其他付款申请 |
|
||||
| applydate | 申请日期 | `applyDate` | yyyy-MM-dd,空取当天 |
|
||||
| applycause | 请款事由 | paymentType 映射 | 见 5.1 |
|
||||
| paycurrency_number / settlecurrency_number | 付款/结算币种 | 配置 `payApply.currency` | 默认 `CNY` |
|
||||
| paycurrency_number / settlecurrency_number | 付款/结算币种 | 合同结算币种 `settlementCurrency` | 缺失报错 |
|
||||
| awrp_src_type | 外部单据类型 | 配置 `payApply.srcType` | 默认 `TMS付款申请` |
|
||||
| exratetable_number | 汇率表编码 | 配置 `payApply.exratetable` | 默认 `01` |
|
||||
| exratedate | 汇率日期 | 同 applydate | yyyy-MM-dd |
|
||||
@@ -160,6 +160,8 @@ TMS 付款申请审核通过
|
||||
|
||||
未传的可选字段:purdept_number、awrp_department_number、e_duedate、e_settlementtype_number、e_costcenter_number、awrp_src_con_eno、awrp_splb_number。
|
||||
|
||||
> 前置校验:推送前按 `contractId` 加载合同,未关联合同、合同不存在、所属组织编码为空、结算币种为空时,同步失败并标记 `kingdeeStatus = failed`。
|
||||
|
||||
---
|
||||
|
||||
## 5. 字典与枚举对应关系
|
||||
@@ -206,13 +208,13 @@ TMS 付款申请审核通过
|
||||
| --- | --- | --- | --- |
|
||||
| thirdParty.bfi.baseUrl | BFI_BASE_URL | — | 星瀚网关地址(已有) |
|
||||
| thirdParty.bfi.clientId / clientSecret / username / accountId | BFI_* | — | OAuth2 凭证(已有) |
|
||||
| thirdParty.bfi.payApply.srcSys | BFI_PAY_APPLY_SRC_SYS | TMS | 外部系统编号(防重键) |
|
||||
| thirdParty.bfi.payApply.billtype | BFI_PAY_APPLY_BILLTYPE | ap_payapply_BT_S | 单据类型编码 |
|
||||
| thirdParty.bfi.payApply.orgNumber | BFI_PAY_APPLY_ORG_NUMBER | 空(**必配**) | 金蝶公司编码,未配置同步报错 |
|
||||
| thirdParty.bfi.payApply.currency | BFI_PAY_APPLY_CURRENCY | CNY | 币种编码 |
|
||||
| thirdParty.bfi.payApply.srcSys | BFI_PAY_APPLY_SRC_SYS | WLTMS | 外部系统编号(防重键) |
|
||||
| thirdParty.bfi.payApply.billtype | BFI_PAY_APPLY_BILLTYPE | ap_payapply_oth_BT_S | 单据类型编码(其他付款申请) |
|
||||
| thirdParty.bfi.payApply.exratetable | BFI_PAY_APPLY_EXRATE_TABLE | 01 | 汇率表编码 |
|
||||
| thirdParty.bfi.payApply.srcType | BFI_PAY_APPLY_SRC_TYPE | TMS付款申请 | 外部单据类型 |
|
||||
|
||||
> 组织编码与币种不走配置:分别取自付款申请关联合同的所属组织(`blade_contract_manage.organization_id` → 组织编码,为空回退组织名称)与结算币种(`settlement_currency`)。
|
||||
|
||||
---
|
||||
|
||||
## 7. 异常处理与批量语义
|
||||
|
||||
@@ -132,17 +132,14 @@ thirdParty:
|
||||
# 付款申请推送配置(A103-3 付款申请保存)
|
||||
payApply:
|
||||
# 外部系统编号,与来源单据号共同防重
|
||||
srcSys: ${BFI_PAY_APPLY_SRC_SYS:TMS}
|
||||
srcSys: ${BFI_PAY_APPLY_SRC_SYS:WLTMS}
|
||||
# 单据类型编码:ap_payapply_BT_S 采购付款申请、ap_payapply_oth_BT_S 其他付款申请
|
||||
billtype: ${BFI_PAY_APPLY_BILLTYPE:ap_payapply_BT_S}
|
||||
# 结算/申请/付款/采购组织编码(金蝶公司编码)
|
||||
orgNumber: ${BFI_PAY_APPLY_ORG_NUMBER:}
|
||||
# 付款及结算币种编码
|
||||
currency: ${BFI_PAY_APPLY_CURRENCY:CNY}
|
||||
billtype: ${BFI_PAY_APPLY_BILLTYPE:ap_payapply_oth_BT_S}
|
||||
# 组织编码、币种取自付款申请关联合同的所属组织与结算币种
|
||||
# 汇率表编码
|
||||
exratetable: ${BFI_PAY_APPLY_EXRATE_TABLE:01}
|
||||
# 外部单据类型
|
||||
srcType: ${BFI_PAY_APPLY_SRC_TYPE:TMS付款申请}
|
||||
srcType: ${BFI_PAY_APPLY_SRC_TYPE:0KzXs}
|
||||
|
||||
#百度OCR配置,API Key和Secret Key请通过环境变量注入
|
||||
baidu:
|
||||
|
||||
@@ -104,17 +104,14 @@ thirdParty:
|
||||
# 付款申请推送配置(A103-3 付款申请保存)
|
||||
payApply:
|
||||
# 外部系统编号,与来源单据号共同防重
|
||||
srcSys: ${BFI_PAY_APPLY_SRC_SYS:TMS}
|
||||
srcSys: ${BFI_PAY_APPLY_SRC_SYS:WLTMS}
|
||||
# 单据类型编码:ap_payapply_BT_S 采购付款申请、ap_payapply_oth_BT_S 其他付款申请
|
||||
billtype: ${BFI_PAY_APPLY_BILLTYPE:ap_payapply_BT_S}
|
||||
# 结算/申请/付款/采购组织编码(金蝶公司编码)
|
||||
orgNumber: ${BFI_PAY_APPLY_ORG_NUMBER:}
|
||||
# 付款及结算币种编码
|
||||
currency: ${BFI_PAY_APPLY_CURRENCY:CNY}
|
||||
billtype: ${BFI_PAY_APPLY_BILLTYPE:ap_payapply_oth_BT_S}
|
||||
# 组织编码、币种取自付款申请关联合同的所属组织与结算币种
|
||||
# 汇率表编码
|
||||
exratetable: ${BFI_PAY_APPLY_EXRATE_TABLE:01}
|
||||
# 外部单据类型
|
||||
srcType: ${BFI_PAY_APPLY_SRC_TYPE:TMS付款申请}
|
||||
srcType: ${BFI_PAY_APPLY_SRC_TYPE:0KzXs}
|
||||
|
||||
#百度OCR配置,API Key和Secret Key请通过环境变量注入
|
||||
baidu:
|
||||
|
||||
@@ -35,14 +35,11 @@ thirdParty:
|
||||
# 付款申请推送配置(A103-3 付款申请保存)
|
||||
payApply:
|
||||
# 外部系统编号,与来源单据号共同防重
|
||||
srcSys: ${BFI_PAY_APPLY_SRC_SYS:TMS}
|
||||
srcSys: ${BFI_PAY_APPLY_SRC_SYS:WLTMS}
|
||||
# 单据类型编码:ap_payapply_BT_S 采购付款申请、ap_payapply_oth_BT_S 其他付款申请
|
||||
billtype: ${BFI_PAY_APPLY_BILLTYPE:ap_payapply_BT_S}
|
||||
# 结算/申请/付款/采购组织编码(金蝶公司编码)
|
||||
orgNumber: ${BFI_PAY_APPLY_ORG_NUMBER:}
|
||||
# 付款及结算币种编码
|
||||
currency: ${BFI_PAY_APPLY_CURRENCY:CNY}
|
||||
billtype: ${BFI_PAY_APPLY_BILLTYPE:ap_payapply_oth_BT_S}
|
||||
# 组织编码、币种取自付款申请关联合同的所属组织与结算币种
|
||||
# 汇率表编码
|
||||
exratetable: ${BFI_PAY_APPLY_EXRATE_TABLE:01}
|
||||
# 外部单据类型
|
||||
srcType: ${BFI_PAY_APPLY_SRC_TYPE:TMS付款申请}
|
||||
srcType: ${BFI_PAY_APPLY_SRC_TYPE:0KzXs}
|
||||
|
||||
Reference in New Issue
Block a user