From b11b8b9c2bff933fd15f3076761a7a5f6495b6d0 Mon Sep 17 00:00:00 2001 From: "kuang.yife" Date: Wed, 23 Nov 2022 14:16:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=89=8B=E7=BB=AD=E8=B4=B9?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ghy-common/src/main/java/com/ghy/common/utils/AdapayUtils.java | 2 +- .../com/ghy/order/service/impl/OrderDetailServiceImpl.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ghy-common/src/main/java/com/ghy/common/utils/AdapayUtils.java b/ghy-common/src/main/java/com/ghy/common/utils/AdapayUtils.java index 324cce68..0430f5f7 100644 --- a/ghy-common/src/main/java/com/ghy/common/utils/AdapayUtils.java +++ b/ghy-common/src/main/java/com/ghy/common/utils/AdapayUtils.java @@ -50,7 +50,7 @@ public class AdapayUtils { * @return 保留两位小数的String */ public static String bigDecimalToString(BigDecimal b) { - return b.setScale(2, RoundingMode.HALF_UP).toString(); + return b.setScale(2, RoundingMode.CEILING).toString(); } public synchronized static String createOrderNo(AdapayOrderType type) { diff --git a/ghy-order/src/main/java/com/ghy/order/service/impl/OrderDetailServiceImpl.java b/ghy-order/src/main/java/com/ghy/order/service/impl/OrderDetailServiceImpl.java index 33f1121b..b2c832f9 100644 --- a/ghy-order/src/main/java/com/ghy/order/service/impl/OrderDetailServiceImpl.java +++ b/ghy-order/src/main/java/com/ghy/order/service/impl/OrderDetailServiceImpl.java @@ -38,6 +38,7 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.math.BigDecimal; +import java.math.RoundingMode; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; @@ -350,7 +351,7 @@ public class OrderDetailServiceImpl implements OrderDetailService { DivMember feeDivMember = new DivMember("0", AdapayUtils.bigDecimalToString(fee), true); divMembers.add(feeDivMember); - BigDecimal totalMoney = feeAmount.add(fee); + BigDecimal totalMoney = feeAmount.add(fee.setScale(2, RoundingMode.CEILING)); // 扣除交易费用 String sureMoney = AdapayUtils.bigDecimalToString(totalMoney);