From 13d9bee30cabf98ecbe279ec46fec0554e46653b Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Wed, 19 Mar 2025 14:20:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=9F=A5=E8=AF=A2=E8=B6=85=E5=B8=82?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hard/service/impl/order/HardCarServiceImpl.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardCarServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardCarServiceImpl.java index edf39b7e5..61fef4b58 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardCarServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardCarServiceImpl.java @@ -34,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -165,8 +166,15 @@ public class HardCarServiceImpl extends ServiceImpl ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> { Integer price = getSupermarket(spu); - int itemTotalPrice = v.getProductCount() * price; - supermarketTotalPrice.addAndGet(itemTotalPrice); + if (ObjectUtil.isNotEmpty(v.getProductCount()) && !ObjectUtil.equals(v.getProductCount(), 0)) { + int itemTotalPrice = v.getProductCount() * price; + supermarketTotalPrice.addAndGet(itemTotalPrice); + } + if (ObjectUtil.isNotEmpty(v.getProductWeight()) && !ObjectUtil.equals(v.getProductWeight(), 0)) { + // 向上取整 + int itemTotalPrice = v.getProductWeight().multiply(BigDecimal.valueOf(price)).setScale(0, RoundingMode.CEILING).intValue(); + supermarketTotalPrice.addAndGet(itemTotalPrice); + } }); } yield supermarketTotalPrice.get(); @@ -301,6 +309,7 @@ public class HardCarServiceImpl extends ServiceImpl