Revert "fix: 付款申请发号含逻辑删除占位并勾稽金额校验,防单号复用撞金蝶防重键"

This reverts commit 1c9471df89.
This commit is contained in:
刘泉佳
2026-10-18 14:38:07 +08:00
parent d937915043
commit cc2564c6ee
2 changed files with 1 additions and 32 deletions
@@ -21,23 +21,9 @@ package org.springblade.transport.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springblade.transport.pojo.entity.PaymentApplication;
import java.util.List;
/** 付款申请 Mapper。 @author Chill */
@Mapper
public interface PaymentApplicationMapper extends BaseMapper<PaymentApplication> {
/**
* 按前缀查询单号(含逻辑删除单据):发号占位用,删除后的单号不复用,
* 避免 A103-3/A103-1 推送时防重键(awrp_src_code)撞金蝶已有单据(已提交单据不允许修改)。
*
* @param pattern 单号匹配模式(如 'FKD20261018%')
*/
@Select("SELECT payment_no FROM blade_payment_application WHERE payment_no LIKE #{pattern}")
List<String> selectPaymentNosIncludingDeleted(@Param("pattern") String pattern);
}
@@ -1040,13 +1040,6 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
if (existPayApply == null || existPayApply.getId() == null) {
return null;
}
// 防重键冲突防线:同号但金额不一致,说明金蝶单据并非本单(多为已删除付款申请复用单号残留),禁止错绑
if (existPayApply.getApplyamount() != null
&& money(existPayApply.getApplyamount()).compareTo(money(entity.getAppliedAmount())) != 0) {
throw new ServiceException("付款申请[" + entity.getPaymentNo() + "]勾稽异常:金蝶已存在同号付款申请单"
+ "(金额" + existPayApply.getApplyamount() + "与本单" + money(entity.getAppliedAmount())
+ "不一致,疑似单号复用残留),请财务在金蝶核实作废/删除后重推");
}
String kingdeeBillId = String.valueOf(existPayApply.getId());
if (Func.isNotEmpty(existPayApply.getBillno())) {
entity.setKingdeeBillNo(existPayApply.getBillno());
@@ -2272,17 +2265,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
}
private PaymentApplication existing(Long id) { PaymentApplication entity = getById(id); if (entity == null || Objects.equals(entity.getIsDeleted(), 1)) throw new ServiceException("付款申请不存在"); return entity; }
private PaymentApplication editable(Long id) { PaymentApplication entity = existing(id); if (!List.of(TransportBusiConstant.DRAFT, TransportBusiConstant.RETURNED).contains(entity.getApprovalStatus())) throw new ServiceException("当前状态不可编辑"); return entity; }
private String nextNo() {
String prefix = "FKD" + LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE);
// 单号占用含逻辑删除单据:删除后不复用单号,避免推送时防重键撞金蝶已有单据(已提交单据不允许修改)
int max = this.baseMapper.selectPaymentNosIncludingDeleted(prefix + "%").stream()
.map(no -> no.length() > prefix.length() ? no.substring(prefix.length()) : "")
.filter(no -> no.matches("\\d+"))
.map(Integer::valueOf)
.max(Integer::compareTo)
.orElse(0);
return prefix + String.format("%05d", max + 1);
}
private String nextNo() { String prefix = "FKD" + LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE); return prefix + String.format("%05d", count(Wrappers.<PaymentApplication>lambdaQuery().likeRight(PaymentApplication::getPaymentNo, prefix)) + 1); }
private BigDecimal nonNegative(BigDecimal value, String name) { if (value == null || value.compareTo(BigDecimal.ZERO) < 0) throw new ServiceException(name + "不能小于0"); return value; }
private BigDecimal money(BigDecimal value) { return value == null ? BigDecimal.ZERO : value; }
private String limit(String value, int length) { if (value != null && value.length() > length) throw new ServiceException("备注不能超过" + length + "个字符"); return value; }