From 309ee07859f04f40d252f3a9c45a4618ebab8ef7 Mon Sep 17 00:00:00 2001 From: gaowdong Date: Fri, 25 Apr 2025 09:07:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/canteen/core/order/domain/OrderInfo.java | 6 ------ .../core/order/domain/param/ShopOrderAddParam.java | 5 +---- .../order/service/impl/OrderInfoServiceImpl.java | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/OrderInfo.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/OrderInfo.java index e1bac1a..b99139d 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/OrderInfo.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/OrderInfo.java @@ -189,8 +189,6 @@ public class OrderInfo extends BaseEntity orderInfo.setDeviceSn(StringUtils.defaultString(orderInfoAddParam.getDeviceSn(), StringUtils.EMPTY)); orderInfo.setDeviceNum(StringUtils.defaultString(orderInfoAddParam.getDeviceNum(), StringUtils.EMPTY)); orderInfo.setUserId(param.getUserId()); - orderInfo.setPayableAmount(param.getPayableAmount()); - orderInfo.setRealAmount(param.getRealAmount()); orderInfo.setSourceType(param.getSourceType()); orderInfo.setCreateBy(SecurityUtils.getUsername()); orderInfo.setCreateTime(DateUtils.getNowDate()); @@ -210,7 +208,6 @@ public class OrderInfo extends BaseEntity orderInfo.setOrderState(OrderStateEnum.WAIT_PLACE.getKey()); orderInfo.setOrderRefundState(OrderRefundStateEnum.UN_REFUND.getKey()); orderInfo.setDeductionType(DeductionTypeEnum.PAY_PLACE.getKey()); - orderInfo.setPayType(param.getPayType()); orderInfo.setPayChannel(PayChannelEnum.ACC.getKey()); orderInfo.setPayState(PayStateEnum.PAY_INPROCESS.getKey()); orderInfo.setDeliveryAmount(BigDecimal.ZERO); @@ -286,14 +283,11 @@ public class OrderInfo extends BaseEntity orderInfo.setDeviceNum(StringUtils.defaultString(orderInfoAddParam.getDeviceNum(), StringUtils.EMPTY)); orderInfo.setIdentityVerification(orderInfoAddParam.getIdentityVerification()); orderInfo.setUserId(param.getUserId()); - orderInfo.setPayableAmount(param.getPayableAmount()); - orderInfo.setRealAmount(param.getRealAmount()); orderInfo.setSourceType(param.getSourceType()); orderInfo.setCreateBy(SecurityUtils.getUsername()); orderInfo.setCreateTime(DateUtils.getNowDate()); orderInfo.setUpdateBy(SecurityUtils.getUsername()); orderInfo.setUpdateTime(DateUtils.getNowDate()); - orderInfo.setPayType(param.getPayType()); Long canteenId = orderInfoAddParam.getCanteenId(); orderInfo.setCanteenId(Objects.isNull(canteenId) ? -1 : canteenId); Long stallId = orderInfoAddParam.getStallId(); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/ShopOrderAddParam.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/ShopOrderAddParam.java index a866650..8839bfd 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/ShopOrderAddParam.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/ShopOrderAddParam.java @@ -62,8 +62,6 @@ public class ShopOrderAddParam { orderInfo.setDeviceSn(StringUtils.defaultString(orderInfoAddParam.getDeviceSn(), StringUtils.EMPTY)); orderInfo.setDeviceNum(StringUtils.defaultString(orderInfoAddParam.getDeviceNum(), StringUtils.EMPTY)); orderInfo.setUserId(param.getUserId()); - orderInfo.setPayableAmount(param.getPayableAmount()); - orderInfo.setRealAmount(param.getRealAmount()); orderInfo.setSourceType(param.getSourceType()); orderInfo.setCreateBy(SecurityUtils.getUsername()); orderInfo.setCreateTime(DateUtils.getNowDate()); @@ -76,7 +74,6 @@ public class ShopOrderAddParam { orderInfo.setOrderState(OrderStateEnum.WAIT_PLACE.getKey()); orderInfo.setOrderRefundState(OrderRefundStateEnum.UN_REFUND.getKey()); orderInfo.setDeductionType(DeductionTypeEnum.PAY_PLACE.getKey()); - orderInfo.setPayType(param.getPayType()); orderInfo.setPayChannel(PayChannelEnum.ACC.getKey()); orderInfo.setPayState(PayStateEnum.PAY_INPROCESS.getKey()); orderInfo.setDeliveryAmount(BigDecimal.ZERO); @@ -86,7 +83,7 @@ public class ShopOrderAddParam { orderInfo.setOrderTime(DateUtils.getNowDate()); orderInfo.setExternalPayAmount(BigDecimal.ZERO); orderInfo.setRefundAmount(BigDecimal.ZERO); - orderInfo.setPayableAmount(param.getRealAmount()); + orderInfo.setPayableAmount(param.getPayableAmount()); orderInfo.setDiscountsAmount(BigDecimal.ZERO); orderInfo.setRealAmount(param.getRealAmount()); orderInfo.setAccountPayAmount(param.getRealAmount()); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderInfoServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderInfoServiceImpl.java index 5e01466..d38546c 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderInfoServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderInfoServiceImpl.java @@ -139,6 +139,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(orderAddParam.getUserId()); accInfoService.checkAccStatus(accInfoVO); List canteenOrderInfoList = new OrderInfo().of(orderAddParam); + checkOrdersTotalAmount(canteenOrderInfoList, orderAddParam.getRealAmount()); List orderInfoList = orderBusiness.orderPlaceHandler(canteenOrderInfoList); orderPay(orderInfoList); return 1; @@ -154,6 +155,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(orderAddParam.getUserId()); accInfoService.checkAccStatus(accInfoVO); List canteenOrderInfoList = new OrderInfo().of(orderAddParam); + checkOrdersTotalAmount(canteenOrderInfoList, orderAddParam.getRealAmount()); List orderInfoList = orderBusiness.orderPlaceHandler(canteenOrderInfoList); orderPay(orderInfoList); return 1; @@ -291,6 +293,18 @@ public class OrderInfoServiceImpl implements IOrderInfoService return orderPayDTO; } + private void checkOrdersTotalAmount(List orderInfoList ,BigDecimal totalAmountParam) { + BigDecimal totalAmount = BigDecimal.ZERO; + if(CollUtil.isNotEmpty(orderInfoList)) { + totalAmount = orderInfoList.stream() + .map(OrderInfo::getRealAmount) + .reduce(BigDecimal.ZERO, BigDecimal::add); + } + if(totalAmount.compareTo(totalAmountParam) != 0) { + throw new ServiceException("订单金额有误"); + } + } + /** * 修改订单