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 18c80de43..9b90acb63 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 @@ -133,8 +133,10 @@ public class YxyPrinter 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"); String data = buildOrderPrintData(printInfoDTO, detailList); String voiceJson = "{\"PbizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; @@ -164,8 +166,10 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl { .setPrintTitle(isPre ? "预结算单" : "结算单") .setCount(count) .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()); @@ -261,18 +265,12 @@ public class YxyPrinter 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"; } }