From 35e35e5668c5eef86fcac9f033a314d1a0cca0be Mon Sep 17 00:00:00 2001 From: gong <1157756119@qq.com> Date: Sat, 28 Mar 2026 13:35:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A1=E7=AE=97=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E9=87=91=E9=A2=9D4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../czg/service/order/print/FeiPrinter.java | 31 ++++++++++--------- .../czg/service/order/print/YxyPrinter.java | 4 +++ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/cash-service/order-service/src/main/java/com/czg/service/order/print/FeiPrinter.java b/cash-service/order-service/src/main/java/com/czg/service/order/print/FeiPrinter.java index e6090ac86..6ec647016 100644 --- a/cash-service/order-service/src/main/java/com/czg/service/order/print/FeiPrinter.java +++ b/cash-service/order-service/src/main/java/com/czg/service/order/print/FeiPrinter.java @@ -100,8 +100,15 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl { .setBalance(balance).setPayType((ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType())).setIntegral("0") .setOutNumber(orderInfo.getTakeCode()).setPrintTitle("结算单") .setRemark(orderInfo.getRemark()) - // 使用累计的总优惠金额,如果为 null 则用原价减去实付计算 - .setDiscountAmount(calculateDiscountAmount(orderInfo)); + // 使用累计的总优惠金额,null 表示没有优惠 + .setDiscountAmount(orderInfo.getDiscountAllAmount() != null + ? orderInfo.getDiscountAllAmount().toPlainString() + : "0.00"); + + if (orderInfo.getPayAmount() != null && orderInfo.getPayAmount().compareTo(BigDecimal.ZERO) == 0) { + // 设置支付金额为 订单原价-订单优惠金额 + printInfoDTO.setPayAmount(orderInfo.getOriginAmount().subtract(orderInfo.getDiscountAllAmount()).toPlainString()); + } String string = buildOrderPrintData(printInfoDTO, detailList); String o = sendPrintRequest(machine.getAddress(), string, null, printerNum); printMachineLogService.save(orderInfo.getId(), machine, "结算单", string, o); @@ -129,8 +136,10 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl { .setBalance(balance).setPayType((ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType())).setIntegral("0") .setOutNumber(orderInfo.getTakeCode()).setPrintTitle("结算单") .setRemark(orderInfo.getRemark()) - // 使用累计的总优惠金额,如果为 null 则用原价减去实付计算 - .setDiscountAmount(calculateDiscountAmount(orderInfo)); + // 使用累计的总优惠金额,null 表示没有优惠 + .setDiscountAmount(orderInfo.getDiscountAllAmount() != null + ? orderInfo.getDiscountAllAmount().toPlainString() + : "0.00"); printInfoDTO.setPrintTitle(printInfoDTO.getPrintTitle()); if (orderInfo.getSeatNum() != null && orderInfo.getSeatAmount().compareTo(BigDecimal.ZERO) > 0) { printInfoDTO.setSeatNum(orderInfo.getSeatNum().toString()); @@ -252,18 +261,12 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl { } /** - * 计算优惠金额:优先使用 discountAllAmount,如果为 null 则用原价 - 实付计算 + * 计算优惠金额:优先使用 discountAllAmount,如果为 null 则返回 0 */ private String calculateDiscountAmount(OrderInfo orderInfo) { - if (orderInfo.getDiscountAllAmount() != null) { - return orderInfo.getDiscountAllAmount().toPlainString(); - } - // 兜底计算:原价 + 餐位费 + 打包费 - 实付 - BigDecimal originalTotal = orderInfo.getOriginAmount() - .add(orderInfo.getSeatAmount() != null ? orderInfo.getSeatAmount() : BigDecimal.ZERO) - .add(orderInfo.getPackFee() != null ? orderInfo.getPackFee() : BigDecimal.ZERO); - BigDecimal discount = originalTotal.subtract(orderInfo.getPayAmount()); - return discount.compareTo(BigDecimal.ZERO) >= 0 ? discount.toPlainString() : "0.00"; + return orderInfo.getDiscountAllAmount() != null + ? orderInfo.getDiscountAllAmount().toPlainString() + : "0.00"; } } diff --git a/cash-service/order-service/src/main/java/com/czg/service/order/print/YxyPrinter.java b/cash-service/order-service/src/main/java/com/czg/service/order/print/YxyPrinter.java index 9b90acb63..5b4263d3b 100644 --- a/cash-service/order-service/src/main/java/com/czg/service/order/print/YxyPrinter.java +++ b/cash-service/order-service/src/main/java/com/czg/service/order/print/YxyPrinter.java @@ -170,6 +170,10 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl { .setDiscountAmount(orderInfo.getDiscountAllAmount() != null ? orderInfo.getDiscountAllAmount().toPlainString() : "0.00"); + if (isPre) { + // 设置支付金额为 订单原价-订单优惠金额 + printInfoDTO.setPayAmount(orderInfo.getOriginAmount().subtract(orderInfo.getDiscountAllAmount()).toPlainString()); + } printInfoDTO.setPrintTitle(printInfoDTO.getPrintTitle()); if (orderInfo.getSeatNum() != null && orderInfo.getSeatAmount().compareTo(BigDecimal.ZERO) > 0) { printInfoDTO.setSeatNum(orderInfo.getSeatNum().toString());