fix: 付款申请发号含逻辑删除占位并勾稽金额校验,防单号复用撞金蝶防重键
nextNo 改为含逻辑删除单据取当天最大序号+1,删除后单号不再复用(此前复用同号推送金蝶时按防重键匹配到旧单转更新,报已提交状态下的单据不允许修改);A103-2 勾稽回填前校验金蝶同号单金额与本单一致,不一致拦截并提示财务核实
This commit is contained in:
+14
@@ -21,9 +21,23 @@ 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);
|
||||
|
||||
}
|
||||
|
||||
+18
-1
@@ -1040,6 +1040,13 @@ 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());
|
||||
@@ -2265,7 +2272,17 @@ 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); return prefix + String.format("%05d", count(Wrappers.<PaymentApplication>lambdaQuery().likeRight(PaymentApplication::getPaymentNo, prefix)) + 1); }
|
||||
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 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; }
|
||||
|
||||
Reference in New Issue
Block a user