:fix: 修复付款申请草稿重存时结算关联唯一索引冲突(逻辑删除残留旧行,改物理删除)
This commit is contained in:
+11
@@ -1,10 +1,21 @@
|
|||||||
package org.springblade.transport.mapper;
|
package org.springblade.transport.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Delete;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springblade.transport.pojo.entity.PaymentApplicationSettlement;
|
import org.springblade.transport.pojo.entity.PaymentApplicationSettlement;
|
||||||
|
|
||||||
/** 付款申请关联正式结算单 Mapper。 */
|
/** 付款申请关联正式结算单 Mapper。 */
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface PaymentApplicationSettlementMapper extends BaseMapper<PaymentApplicationSettlement> {
|
public interface PaymentApplicationSettlementMapper extends BaseMapper<PaymentApplicationSettlement> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按付款申请主键物理删除关联记录(表存在不含逻辑删除字段的关系唯一索引,重存前必须物理清理)
|
||||||
|
*
|
||||||
|
* @param paymentApplicationId 付款申请主键
|
||||||
|
* @return 删除行数
|
||||||
|
*/
|
||||||
|
@Delete("DELETE FROM blade_payment_application_settlement WHERE payment_application_id = #{paymentApplicationId}")
|
||||||
|
int deleteByPaymentApplicationId(@Param("paymentApplicationId") Long paymentApplicationId);
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-3
@@ -325,7 +325,7 @@ private final CustomerReceiptAccountMapper receiptAccountMapper;
|
|||||||
validateProjectAdvanceContract(entity);
|
validateProjectAdvanceContract(entity);
|
||||||
validateSelectedBill(entity, false);
|
validateSelectedBill(entity, false);
|
||||||
validateQuota(entity);
|
validateQuota(entity);
|
||||||
// HCS 提交同步校验(事务内查询类同步,D15/R2-Q3):C101-1 风险(黑名单阻断)+ C106-1 额度(超额转特批)
|
// HCS 提交同步校验(事务内查询类同步,D15/R2-Q3):C101-1 风险(收款方外部客商高风险/黑名单须特批附件并标记待特批)+ C106-1 额度(超额转特批)
|
||||||
hcsCreditCheckSupport.checkOnSubmit(entity);
|
hcsCreditCheckSupport.checkOnSubmit(entity);
|
||||||
entity.setApprovalStatus(TransportBusiConstant.REVIEWING);
|
entity.setApprovalStatus(TransportBusiConstant.REVIEWING);
|
||||||
entity.setCurrentNode("财务审核");
|
entity.setCurrentNode("财务审核");
|
||||||
@@ -388,6 +388,12 @@ private final CustomerReceiptAccountMapper receiptAccountMapper;
|
|||||||
public String doSyncKingdee(Long id, KingdeeSyncContext context) {
|
public String doSyncKingdee(Long id, KingdeeSyncContext context) {
|
||||||
PaymentApplication entity = lockedPayment(id);
|
PaymentApplication entity = lockedPayment(id);
|
||||||
if (!TransportBusiConstant.APPROVED.equals(entity.getApprovalStatus())) throw new ServiceException("仅审批通过的付款申请允许生成金蝶单据");
|
if (!TransportBusiConstant.APPROVED.equals(entity.getApprovalStatus())) throw new ServiceException("仅审批通过的付款申请允许生成金蝶单据");
|
||||||
|
// 高风险/黑名单客商付款特批门禁:待特批/特批审核中(挂起"特批审核")禁止推送金蝶,
|
||||||
|
// 特批通过(合规 paymentLegal/result 回调恢复"审批通过")后放行
|
||||||
|
if (entity.getHcsSpecStatus() != null && List.of(HcsSyncConstant.SPEC_STATUS_NEED, HcsSyncConstant.SPEC_STATUS_PUSHING,
|
||||||
|
HcsSyncConstant.SPEC_STATUS_PROCESSING).contains(entity.getHcsSpecStatus())) {
|
||||||
|
throw new ServiceException("收款方客商为高风险/黑名单,付款特批审核中(" + entity.getCurrentNode() + "),特批完成后方可推送金蝶");
|
||||||
|
}
|
||||||
if (KingdeeBfiConstant.KINGDEE_STATUS_SYNCED.equals(entity.getKingdeeStatus())
|
if (KingdeeBfiConstant.KINGDEE_STATUS_SYNCED.equals(entity.getKingdeeStatus())
|
||||||
|| KingdeeBfiConstant.KINGDEE_STATUS_PAYING.equals(entity.getKingdeeStatus())
|
|| KingdeeBfiConstant.KINGDEE_STATUS_PAYING.equals(entity.getKingdeeStatus())
|
||||||
|| KingdeeBfiConstant.KINGDEE_STATUS_PAID.equals(entity.getKingdeeStatus())
|
|| KingdeeBfiConstant.KINGDEE_STATUS_PAID.equals(entity.getKingdeeStatus())
|
||||||
@@ -1505,8 +1511,8 @@ private final CustomerReceiptAccountMapper receiptAccountMapper;
|
|||||||
|
|
||||||
private void saveSettlementRelations(PaymentApplication entity, List<FormalSettlement> settlements) {
|
private void saveSettlementRelations(PaymentApplication entity, List<FormalSettlement> settlements) {
|
||||||
if (settlements.isEmpty()) return;
|
if (settlements.isEmpty()) return;
|
||||||
settlementRelationMapper.delete(Wrappers.<PaymentApplicationSettlement>lambdaQuery()
|
// 关系唯一索引不含 is_deleted,逻辑删除会残留旧行导致重存冲突,此处必须物理删除
|
||||||
.eq(PaymentApplicationSettlement::getPaymentApplicationId, entity.getId()));
|
settlementRelationMapper.deleteByPaymentApplicationId(entity.getId());
|
||||||
BigDecimal totalBase = settlements.stream().map(item -> money(item.getSettlementAmount()).subtract(
|
BigDecimal totalBase = settlements.stream().map(item -> money(item.getSettlementAmount()).subtract(
|
||||||
cumulativeFormalSettlementApplied(item.getId(), entity.getId())).max(BigDecimal.ZERO))
|
cumulativeFormalSettlementApplied(item.getId(), entity.getId())).max(BigDecimal.ZERO))
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
|||||||
Reference in New Issue
Block a user