From aa69391136a0e533dae060a6ecaa134b588c921e Mon Sep 17 00:00:00 2001 From: aike <17730485278@139.com> Date: Fri, 10 Oct 2025 10:45:14 +0800 Subject: [PATCH 1/4] =?UTF-8?q?demand:=20=20=20TMS=E7=B3=BB=E7=BB=9F=20-?= =?UTF-8?q?=20=E8=BF=90=E8=BE=93=E7=AE=A1=E7=90=86=20-=20=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=BC=8F=E7=BB=84=E6=89=B9=E6=AC=A1=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=95=B0=E9=87=8F=E8=AE=A1=E7=AE=97=E4=B8=8D?= =?UTF-8?q?=E5=87=86=E7=A1=AE=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96=20=20=20?= =?UTF-8?q?=20TMS=E7=B3=BB=E7=BB=9F=20-=20=E6=9C=88=E7=BB=93=E8=B4=A6?= =?UTF-8?q?=E5=8D=95=E6=A0=B8=E9=94=80=20-=20=E6=92=A4=E9=94=80=E6=94=B6?= =?UTF-8?q?=E6=AC=BE=E5=8A=9F=E8=83=BD=20=E6=92=A4=E9=94=80=E5=90=8E=20?= =?UTF-8?q?=E8=B4=A2=E5=8A=A1=E5=BC=80=E7=A5=A8=E5=A4=84=E7=90=86-?= =?UTF-8?q?=E5=B7=B2=E5=BC=80=E7=A5=A8=20=E6=94=B6=E6=AC=BE=E9=87=91?= =?UTF-8?q?=E9=A2=9D=20=E6=95=B0=E5=80=BC=E6=9C=AA=E5=AE=9E=E6=96=BD?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit committer: heyu --- .../impl/EmisSettlePayRecordServiceImpl.java | 67 ++++++++++++++++++- .../mapper/EmisSettlePayRelMapper.xml | 43 ++++++++---- .../EmisTmsSiteBatchMissStatisticsMapper.xml | 22 +++--- 3 files changed, 105 insertions(+), 27 deletions(-) diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettlePayRecordServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettlePayRecordServiceImpl.java index bd5674035..9adde5c62 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettlePayRecordServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettlePayRecordServiceImpl.java @@ -613,8 +613,71 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I // 删除收款记录 emisSettlePayRecordMapper.deleteEmisSettlePayRecordById(id); - // 重新计算账单收款 - emisSettleBillService.reCalcSettleBillPayStatus(payRecordOld.getSettleBillNo()); + // 重新计算账单收款(账单号可能为逗号分隔的多个) + if (StringUtils.isNotBlank(payRecordOld.getSettleBillNo())) { + List settleBillNos = Arrays.stream(payRecordOld.getSettleBillNo().split(",")) + .map(String::trim) + .filter(org.apache.commons.lang3.StringUtils::isNotBlank) + .distinct() + .collect(Collectors.toList()); + for (String settleBillNo : settleBillNos) { + emisSettleBillService.reCalcSettleBillPayStatus(settleBillNo); + } + } + + // 重新计算对应发票的已收金额与付款状态 + // 规则:发票新的已收金额 = 发票历史已收金额 - 本次(payId)对应的金额汇总 + // 1) 查询本次收款的运单收款明细(包含applySeqNo) + EmisSettlePayRel query = new EmisSettlePayRel(); + query.setPayId(payRecordOld.getPayId()); + List thisPayRelList = emisSettlePayRelMapper.selectEmisSettlePayRelList(query); + if (!CollectionUtils.isEmpty(thisPayRelList)) { + // 2) 按applySeqNo分组汇总本次金额 + Map revokeAmountByApplySeqNo = thisPayRelList.stream() + .filter(rel -> StringUtils.isNotBlank(rel.getApplySeqNo())) + .collect(Collectors.groupingBy(EmisSettlePayRel::getApplySeqNo, + Collectors.mapping(EmisSettlePayRel::getPayMoney, + Collectors.reducing(BigDecimal.ZERO, v -> v == null ? BigDecimal.ZERO : v, + BigDecimal::add)))); + + // 3) 对每个发票applySeqNo执行:历史已收金额 - 本次金额,重算状态 + for (Map.Entry entry : revokeAmountByApplySeqNo.entrySet()) { + String applySeqNo = entry.getKey(); + BigDecimal revokeAmount = entry.getValue() == null ? BigDecimal.ZERO : entry.getValue(); + + EmisSettleInvoiceRecord invoiceRecord = emisSettleInvoiceRecordMapper + .selectInvoiceRecordByApplySeqNo(applySeqNo); + if (invoiceRecord == null) { + continue; + } + + BigDecimal historyReced = invoiceRecord.getRecedMoney() == null ? BigDecimal.ZERO + : invoiceRecord.getRecedMoney(); + BigDecimal applyMoney = invoiceRecord.getApplyMoney() == null ? BigDecimal.ZERO + : invoiceRecord.getApplyMoney(); + + // 新的已收金额 = 历史已收金额 - 本次撤销金额,且不小于0 + BigDecimal newReced = historyReced.subtract(revokeAmount); + if (newReced.compareTo(BigDecimal.ZERO) < 0) { + newReced = BigDecimal.ZERO; + } + + String paymentStatus; + if (newReced.compareTo(BigDecimal.ZERO) == 0) { + paymentStatus = "0"; // 未付款 + } else if (newReced.compareTo(applyMoney) >= 0) { + paymentStatus = "1"; // 已付款 + } else { + paymentStatus = "2"; // 部分付款 + } + + EmisSettleInvoiceRecord upd = new EmisSettleInvoiceRecord(); + upd.setId(invoiceRecord.getId()); + upd.setRecedMoney(newReced); + upd.setPaymentStatus(paymentStatus); + emisSettleInvoiceRecordMapper.updateEmisSettleInvoiceRecord(upd); + } + } return 1; } diff --git a/emis-biz/src/main/resources/mapper/EmisSettlePayRelMapper.xml b/emis-biz/src/main/resources/mapper/EmisSettlePayRelMapper.xml index 2d6236661..0332500af 100644 --- a/emis-biz/src/main/resources/mapper/EmisSettlePayRelMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisSettlePayRelMapper.xml @@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -20,26 +21,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, pay_id, bill_no, pay_money, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_settle_pay_rel + select a.id, + a.pay_id, + a.bill_no, + a.pay_money, + a.del_flag, + a.create_by, + a.create_time, + a.update_by, + a.update_time, + a.create_site, + a.update_site, + r.apply_seq_no + from emis_settle_pay_rel a + left join emis_settle_pay_invoice_rel r + on r.pay_id = a.pay_id and r.del_flag = '0' From fae230d502e7193313800053b64abb515445d1b3 Mon Sep 17 00:00:00 2001 From: aike <17730485278@139.com> Date: Fri, 10 Oct 2025 15:49:42 +0800 Subject: [PATCH 3/4] =?UTF-8?q?demand:=20=20=20=20=20=20TMS=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=20-=20=E5=AE=A2=E6=88=B7=E8=B4=A6=E5=8D=95=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20-=20=E6=9C=88=E7=BB=93=E8=B4=A6=E5=8D=95=E6=A0=B8?= =?UTF-8?q?=E9=94=80=20-=20=E8=BF=90=E5=8D=95=E6=94=B6=E6=AC=BE=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E6=9F=A5=E8=AF=A2=E9=87=8D=E5=A4=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit committer: heyu --- .../mapper/EmisSettlePayRelMapper.xml | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/emis-biz/src/main/resources/mapper/EmisSettlePayRelMapper.xml b/emis-biz/src/main/resources/mapper/EmisSettlePayRelMapper.xml index 5c581f0ee..675fd9e78 100644 --- a/emis-biz/src/main/resources/mapper/EmisSettlePayRelMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisSettlePayRelMapper.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -32,16 +32,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" a.update_time, a.create_site, a.update_site, - (select r.apply_seq_no - from emis_settle_pay_invoice_rel r - where r.pay_id = a.pay_id and r.del_flag = '0' - limit 1) as apply_seq_no + ( + select r.apply_seq_no + from emis_settle_invoice_rel r + where r.bill_no = a.bill_no + and r.del_flag = '0' + and exists ( + select 1 from emis_settle_pay_invoice_rel p + where p.apply_seq_no = r.apply_seq_no + and p.pay_id = a.pay_id + and p.del_flag = '0' + ) + limit 1 + ) as apply_seq_no from emis_settle_pay_rel a - + - + insert into emis_settle_pay_rel @@ -164,4 +173,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} - \ No newline at end of file + From 20a9c5a5e727ac09abba905e7240c476904a399f Mon Sep 17 00:00:00 2001 From: aike <17730485278@139.com> Date: Fri, 10 Oct 2025 16:14:07 +0800 Subject: [PATCH 4/4] =?UTF-8?q?demand:=20=20=20=20=20=20TMS=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=20-=20=E5=AE=A2=E6=88=B7=E8=B4=A6=E5=8D=95=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20-=20=E6=94=B6=E6=AC=BE=E6=98=8E=E7=BB=86=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=20-=20=E5=BC=80=E7=A5=A8=E9=87=91=E9=A2=9D=E3=80=81?= =?UTF-8?q?=E5=BC=80=E7=A5=A8=E7=8A=B6=E6=80=81=E5=8F=96=E5=80=BC=E4=B8=8D?= =?UTF-8?q?=E5=87=86=E7=A1=AE=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit committer: heyu --- .../mapper/EmisSettlePayRecordMapper.xml | 56 ++++++++++++++++++- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml b/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml index fd041a8a1..4307ba44b 100644 --- a/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml @@ -655,7 +655,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"