fix: 修复收款流水同步与认领推送问题

This commit is contained in:
刘泉佳
2026-09-28 18:40:05 +08:00
parent 145cb57e00
commit bdae054b0b
2 changed files with 12 additions and 24 deletions
@@ -141,7 +141,7 @@ public final class KingdeeBfiConstant {
public static final String BFI_AR_BILL_SRC_BT = "ar_finarbill";
/** A301-3 认领推送核心单据类型:其他应付(e_corebilltype)。 */
public static final String BFI_CLAIM_CORE_BILL_TYPE = "ApFin_other_BT_S";
public static final String BFI_CLAIM_CORE_BILL_TYPE = "ar_finarbill";
/** A303-1 发票种类:数电发票(普通发票)。 */
public static final String BFI_INVOICE_TYPE_DIGITAL_GENERAL = "10xdp";
@@ -213,10 +213,7 @@ public final class KingdeeBfiConstant {
public static final String BFI_CLAIM_REC_PAY_TYPE = "999";
/** A301-3 认领推送:付款人类型(默认客户 bd_customer,待金蝶确认后如有调整直接改此常量)。 */
public static final String BFI_CLAIM_PAYMENT_TYPE = "999";
/** A301-3 认领推送来源单据编码前缀:SKCL + yyyyMMddHHmmss + 认领id尾号,作 A301-1 回写匹配键。 */
public static final String BFI_CLAIM_SRC_CODE_PREFIX = "SKCL";
public static final String BFI_CLAIM_PAYMENT_TYPE = "bd_customer";
/** 金蝶同步状态:认领结果已推送(A301-3 成功,等待金蝶收款单审核/收款,可继续回写)。 */
public static final String KINGDEE_STATUS_PUSHED = "pushed";
@@ -637,7 +637,10 @@ public class ReceiptFlowServiceImpl extends BaseServiceImpl<KingdeeReceiptFlowMa
if (flow.getBillId() == null) {
throw new ServiceException("认领公告id缺失,请先手动同步金蝶收款流水");
}
String awrpSrcCode = buildClaimSrcCode(claim.getId());
// 来源单据编码:多个结算单号用_拼接
String awrpSrcCode = settlements.stream()
.map(FormalSettlement::getFormalSettlementNo)
.collect(Collectors.joining("_"));
claim.setAwrpSrcCode(awrpSrcCode);
BfiClaimPushDTO param = new BfiClaimPushDTO();
@@ -666,9 +669,9 @@ public class ReceiptFlowServiceImpl extends BaseServiceImpl<KingdeeReceiptFlowMa
if (Func.isNotEmpty(settlement.getKingdeeBillNo())) {
// 结算单已同步金蝶应收单时携带核心单据引用,金蝶按应收单号核销认领金额
// 核心单据类型
entry.setECorebilltype(KingdeeBfiConstant.BFI_CLAIM_CORE_BILL_TYPE);
// entry.setECorebilltype(KingdeeBfiConstant.BFI_CLAIM_CORE_BILL_TYPE);
// 核心单据编号
entry.setECorebillno(settlement.getKingdeeBillNo());
entry.setECorebillno(String.valueOf(settlement.getId()));
}
allocatedTotal = allocatedTotal.add(money(allocationMap.get(settlement.getId())));
entries.add(entry);
@@ -713,18 +716,6 @@ public class ReceiptFlowServiceImpl extends BaseServiceImpl<KingdeeReceiptFlowMa
claim.getId(), Func.isEmpty(kingdeeBillNo) ? "响应未返回" : kingdeeBillNo);
}
/**
* 生成 A301-3 认领推送来源单据编码:SKCL + yyyyMMddHHmmss + 认领id尾号
*
* @param claimId 认领记录id
* @return 来源单据编码
*/
private String buildClaimSrcCode(Long claimId) {
String time = DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(LocalDateTime.now());
String suffix = String.valueOf(claimId);
return KingdeeBfiConstant.BFI_CLAIM_SRC_CODE_PREFIX + time + suffix.substring(Math.max(0, suffix.length() - 6));
}
/**
* A301-2 认领公告 → 收款流水表字段拷贝(仅覆盖金蝶侧来源字段,不覆盖本地认领金额与状态)
*/
@@ -734,10 +725,10 @@ public class ReceiptFlowServiceImpl extends BaseServiceImpl<KingdeeReceiptFlowMa
target.setBillId(source.getId());
// 收款通知单号
target.setReceiptNoticeNo(trimToEmpty(source.getBillno()));
// 付款人名称
target.setPayerName(trimToEmpty(source.getRecviewpayer()));
// 付款人id
target.setPayerId(trimToEmpty(source.getRecpayer()));
// 付款人名称(取自对方户名)
target.setPayerName(trimToEmpty(source.getOppunit()));
// 付款人id(取自对方账号)
target.setPayerId(trimToEmpty(source.getOppbanknumber()));
// 收款人
target.setPayeeName(trimToNull(source.getRecpayee()));
// 收款金额