From 9173fc069bc66f3e41c9e49c790e63fce059aa4c Mon Sep 17 00:00:00 2001 From: aike <17730485278@139.com> Date: Wed, 17 Sep 2025 15:42:49 +0800 Subject: [PATCH] =?UTF-8?q?demand:=20=20TMS=E7=B3=BB=E7=BB=9F=E8=B4=A2?= =?UTF-8?q?=E5=8A=A1=E9=94=80=E8=B4=A6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit committer: heyu --- .../impl/EmisWriteoffApplyServiceImpl.java | 99 ++++++++++--------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWriteoffApplyServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWriteoffApplyServiceImpl.java index 332ec2ffe..cdb6bccfd 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWriteoffApplyServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWriteoffApplyServiceImpl.java @@ -1134,15 +1134,17 @@ public class EmisWriteoffApplyServiceImpl extends EmisBaseService implements IEm String applyManName = StringUtils.hasText(apply.getApplyManName()) ? apply.getApplyManName() : apply.getApplyManCode(); - // 获取操作人姓名 + // 获取操作人姓名 - 通过当前登录账号获取 String operatorName = ""; - if ("centerPass".equals(actionType) || "centerReject".equals(actionType)) { - operatorName = StringUtils.hasText(apply.getCenterConfirmManName()) ? apply.getCenterConfirmManName() - : apply.getCenterConfirmManCode(); - } else if ("headquartersReject".equals(actionType)) { - operatorName = StringUtils.hasText(apply.getHeadquartersConfirmManName()) - ? apply.getHeadquartersConfirmManName() - : apply.getHeadquartersConfirmManCode(); + try { + SysUser currentUser = getCurrentUser(); + if (currentUser != null) { + operatorName = StringUtils.hasText(currentUser.getEmpName()) ? currentUser.getEmpName() + : currentUser.getEmpCode(); + } + } catch (Exception e) { + log.warn("获取当前登录用户信息失败,使用默认操作人", e); + operatorName = "系统"; } // 构建通知内容 @@ -1214,57 +1216,56 @@ public class EmisWriteoffApplyServiceImpl extends EmisBaseService implements IEm continue; } - // 计算该运单的总申请金额 - BigDecimal totalApplyMoney = waybillDetails.stream() - .map(detail -> detail.getApplyMoney() != null ? detail.getApplyMoney() : BigDecimal.ZERO) - .reduce(BigDecimal.ZERO, BigDecimal::add); - - // 计算该运单的总已收金额 - BigDecimal totalReceivedMoney = waybillDetails.stream() - .map(detail -> detail.getEmisSettleSubBill() != null - && detail.getEmisSettleSubBill().getRecedMoney() != null - ? detail.getEmisSettleSubBill().getRecedMoney() - : BigDecimal.ZERO) - .reduce(BigDecimal.ZERO, BigDecimal::add); - // 获取运单运费 BigDecimal waybillFreight = firstDetail.getEmisWaybill().getFreight() != null ? firstDetail.getEmisWaybill().getFreight() : BigDecimal.ZERO; - // 更新运单付款状态 - EmisWaybill updateWaybill = new EmisWaybill(); - updateWaybill.setBillCode(billCode); + // 对每个运单明细单独计算并更新付款状态 + for (EmisWriteoffApplyDetail detail : waybillDetails) { + // 计算该明细的申请金额 + BigDecimal applyMoney = detail.getApplyMoney() != null ? detail.getApplyMoney() + : BigDecimal.ZERO; - if (isPass) { - // 审核通过:申请金额 + 已收金额 与运单金额比较 - BigDecimal totalAmount = totalApplyMoney.add(totalReceivedMoney); - if (totalAmount.compareTo(BigDecimal.ZERO) == 0) { - updateWaybill.setPaymentStatus("0"); // 未付款 - } else if (totalAmount.compareTo(waybillFreight) >= 0) { - updateWaybill.setPaymentStatus("1"); // 已付款 + // 计算该明细的已收金额 + BigDecimal receivedMoney = detail.getEmisSettleSubBill() != null + && detail.getEmisSettleSubBill().getRecedMoney() != null + ? detail.getEmisSettleSubBill().getRecedMoney() + : BigDecimal.ZERO; + + // 更新运单付款状态 + EmisWaybill updateWaybill = new EmisWaybill(); + updateWaybill.setBillCode(billCode); + + if (isPass) { + // 审核通过:申请金额 + 已收金额 与运单金额比较 + BigDecimal totalAmount = applyMoney.add(receivedMoney); + if (totalAmount.compareTo(BigDecimal.ZERO) == 0) { + updateWaybill.setPaymentStatus("0"); // 未付款 + } else if (totalAmount.compareTo(waybillFreight) >= 0) { + updateWaybill.setPaymentStatus("1"); // 已付款 + } else { + updateWaybill.setPaymentStatus("2"); // 部分付款 + } } else { - updateWaybill.setPaymentStatus("2"); // 部分付款 - } - } else { - // 审核驳回:申请金额 + 已收金额 与运单金额比较 - BigDecimal totalAmount = totalReceivedMoney; // 驳回时只考虑已收金额 - if (totalAmount.compareTo(BigDecimal.ZERO) == 0) { - updateWaybill.setPaymentStatus("0"); // 未付款 - } else if (totalAmount.compareTo(waybillFreight) >= 0) { - updateWaybill.setPaymentStatus("1"); // 已付款 - } else { - updateWaybill.setPaymentStatus("2"); // 部分付款 + // 审核驳回:只考虑已收金额与运单金额比较 + if (receivedMoney.compareTo(BigDecimal.ZERO) == 0) { + updateWaybill.setPaymentStatus("0"); // 未付款 + } else if (receivedMoney.compareTo(waybillFreight) >= 0) { + updateWaybill.setPaymentStatus("1"); // 已付款 + } else { + updateWaybill.setPaymentStatus("2"); // 部分付款 + } } + + // 更新运单付款状态 + emisWaybillMapper.updatePayedStatus(updateWaybill); + + log.info("运单付款状态更新成功,运单号: {}, 明细ID: {}, 付款状态: {}, 申请金额: {}, 已收金额: {}, 运单运费: {}", + billCode, detail.getId(), updateWaybill.getPaymentStatus(), applyMoney, receivedMoney, + waybillFreight); } - // 更新运单付款状态 - emisWaybillMapper.updatePayedStatus(updateWaybill); - - log.info("运单付款状态更新成功,运单号: {}, 付款状态: {}, 申请金额: {}, 已收金额: {}, 运单运费: {}", - billCode, updateWaybill.getPaymentStatus(), totalApplyMoney, totalReceivedMoney, - waybillFreight); - } catch (Exception e) { log.error("更新运单付款状态失败,运单号: {}", billCode, e); // 继续处理其他运单,不抛出异常