feat: 付款申请金蝶生成即回显预结算预付信息,作废/解锁联动清理
This commit is contained in:
+38
-5
@@ -421,6 +421,8 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
entity.setCurrentProcessor(AuthUtil.getUserName());
|
||||
entity.setRemark(request.getReason() == null ? entity.getRemark() : limit(request.getReason(), 200));
|
||||
updateById(entity);
|
||||
// 联动作废提前建档的预结算预付记录,避免残留记录阻断预结算作废
|
||||
voidPreSettlementAdvance(entity);
|
||||
refreshFormalSettlement(entity);
|
||||
}
|
||||
|
||||
@@ -576,8 +578,9 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
// 真实付款结果改由定时回写任务驱动;联调环境需要模拟时恢复以下注释即可
|
||||
// entity.setPaidAmount(money(entity.getAppliedAmount()).setScale(2, RoundingMode.HALF_UP));
|
||||
// mockPaymentRecords(entity);
|
||||
// syncPreSettlementAdvance(entity);
|
||||
// syncFormalSettlementPayments(entity);
|
||||
// 金蝶付款申请单生成成功:提前联动预结算预付记录(approved/已付0)回显预付信息,付款完成回写时更新为已付款
|
||||
syncPreSettlementAdvance(entity, TransportBusiConstant.APPROVED, money(entity.getPaidAmount()));
|
||||
updateById(entity);
|
||||
log.info("付款申请[{}]同步金蝶完成:kingdeeStatus={},kingdeeBillId={},kingdeeBillNo={}",
|
||||
entity.getPaymentNo(), entity.getKingdeeStatus(), kingdeeBillId, entity.getKingdeeBillNo());
|
||||
@@ -646,6 +649,8 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
.set(PaymentApplication::getKingdeeStatus, KingdeeBfiConstant.KINGDEE_STATUS_FAILED)
|
||||
.set(PaymentApplication::getKingdeeBillId, null)
|
||||
.set(PaymentApplication::getKingdeeBillNo, null));
|
||||
// 金蝶单据已删除/解锁重推:联动作废提前建档的预付记录,重推生成新单后重新建档
|
||||
voidPreSettlementAdvance(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -863,10 +868,15 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
updateById(entity);
|
||||
if (KingdeeBfiConstant.KINGDEE_STATUS_PAID.equals(kingdeeStatus)) {
|
||||
// 付款完成:联动履约付款数据(预结算预付记录、正式结算付款记录)
|
||||
syncPreSettlementAdvance(entity);
|
||||
syncPreSettlementAdvance(entity, "paid", money(entity.getAppliedAmount()));
|
||||
syncFormalSettlementPayments(entity);
|
||||
return true;
|
||||
}
|
||||
// 生成失败单据勾稽确认金蝶已生成(已生成/付款中):与推送成功同语义,提前落预付记录回显预付信息
|
||||
if (KingdeeBfiConstant.KINGDEE_STATUS_SYNCED.equals(kingdeeStatus)
|
||||
|| KingdeeBfiConstant.KINGDEE_STATUS_PAYING.equals(kingdeeStatus)) {
|
||||
syncPreSettlementAdvance(entity, TransportBusiConstant.APPROVED, money(entity.getPaidAmount()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1541,7 +1551,14 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
}
|
||||
}
|
||||
|
||||
private void syncPreSettlementAdvance(PaymentApplication entity) {
|
||||
/**
|
||||
* 付款申请联动预结算预付记录:金蝶付款申请单生成成功(synced)即建档提前回显预付信息,
|
||||
* 付款完成回写(paid)更新为已付款;按付款申请单号幂等,不产生重复记录
|
||||
*
|
||||
* @param billStatus 预付记录状态:approved(已生成待付)/ paid(已付款)
|
||||
* @param paidAmount 已付金额:synced 阶段通常为0,paid 阶段取申请全额
|
||||
*/
|
||||
private void syncPreSettlementAdvance(PaymentApplication entity, String billStatus, BigDecimal paidAmount) {
|
||||
if (entity.getPreSettlementId() == null) return;
|
||||
if (!List.of("progress_advance", "settlement_payment").contains(entity.getPaymentType())) return;
|
||||
PreSettlementAdvance advance = preSettlementAdvanceMapper.selectList(
|
||||
@@ -1566,8 +1583,8 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
advance.setAdvanceNo(entity.getPaymentNo());
|
||||
advance.setAppliedAmount(money(entity.getAppliedAmount()));
|
||||
}
|
||||
advance.setPaidAmount(money(entity.getAppliedAmount()));
|
||||
advance.setBillStatus("paid");
|
||||
advance.setPaidAmount(paidAmount);
|
||||
advance.setBillStatus(billStatus);
|
||||
advance.setKingdeeAdvanceNo(entity.getKingdeeBillNo());
|
||||
if (advance.getId() == null) preSettlementAdvanceMapper.insert(advance);
|
||||
else preSettlementAdvanceMapper.updateById(advance);
|
||||
@@ -1582,6 +1599,22 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
formalSettlementService.refreshPaymentSummariesForPreSettlement(entity.getPreSettlementId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 联动作废付款申请关联的预结算预付记录(付款申请作废、金蝶反审核解锁场景):
|
||||
* 仅清理提前建档的未付记录,已付款记录不联动(付款完成的事实不回退),避免残留记录阻断预结算作废
|
||||
*/
|
||||
private void voidPreSettlementAdvance(PaymentApplication entity) {
|
||||
if (entity.getPreSettlementId() == null) return;
|
||||
if (!List.of("progress_advance", "settlement_payment").contains(entity.getPaymentType())) return;
|
||||
preSettlementAdvanceMapper.update(null, Wrappers.<PreSettlementAdvance>lambdaUpdate()
|
||||
.eq(PreSettlementAdvance::getPreSettlementId, entity.getPreSettlementId())
|
||||
.eq(PreSettlementAdvance::getAdvanceNo, entity.getPaymentNo())
|
||||
.eq(PreSettlementAdvance::getIsDeleted, 0)
|
||||
.ne(PreSettlementAdvance::getBillStatus, "paid")
|
||||
.set(PreSettlementAdvance::getBillStatus, TransportBusiConstant.VOIDED));
|
||||
refreshPreSettlementAdvanceSummary(entity.getPreSettlementId());
|
||||
}
|
||||
|
||||
private BigDecimal findPreSettlementPaid(Long preSettlementId) {
|
||||
return preSettlementAdvanceMapper.selectList(Wrappers.<PreSettlementAdvance>lambdaQuery()
|
||||
.eq(PreSettlementAdvance::getPreSettlementId, preSettlementId)
|
||||
|
||||
Reference in New Issue
Block a user