From b9f90ea07147db51d8af77a36caa802656110e34 Mon Sep 17 00:00:00 2001 From: luluyuyu <3305167204@qq.com> Date: Sat, 14 Dec 2024 20:39:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat=EF=BC=9A=E6=8B=89=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/service/impl/OrderServiceImpl.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java index 5a0cf37c..92e043d0 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java @@ -6,6 +6,7 @@ package com.skyeye.order.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; @@ -106,6 +107,9 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl @Override public void createPrepose(Order order) { + if (order == null&& ObjUtil.isEmpty(order)) { + throw new CustomException("订单对象不能为空"); + } // 订单编号 Map business = BeanUtil.beanToMap(order); String oddNumber = iCodeRuleService.getNextCodeByClassName(getClass().getName(), business); @@ -137,6 +141,9 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl private void checkAndSetItemCouponUse(Order order) {// 子单的优惠券操作 List orderItemList = order.getOrderItemList(); + if (orderItemList == null || orderItemList.isEmpty()) { + throw new CustomException("订单子项列表不能为空"); + } // 设置商品信息、商品规格信息和优惠券信息 List normsIdList = orderItemList.stream().map(OrderItem::getNormsId).collect(Collectors.toList()); List> normsListMap = iShopMaterialNormsService.queryShopMaterialByNormsIdList(Joiner.on(CommonCharConstants.COMMA_MARK).join(normsIdList)); @@ -179,6 +186,9 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl return; } CouponUse couponUse = couponUseService.selectById(couponUseId);//优惠券信息 + if (couponUse == null) { + throw new CustomException("优惠券信息不存在"); + } if (ObjectUtil.isEmpty(couponUse)) { throw new CustomException("优惠券不存在"); } else if (couponUse.getState() != CouponUseState.UNUSED.getKey()) { @@ -209,6 +219,9 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl } private void setOrderAndOrderItem(CouponUse couponUse, Order order, OrderItem targetOrderItem) { + if (targetOrderItem == null) { + throw new CustomException("目标订单子项不能为空"); + } if (Objects.equals(couponUse.getDiscountType(), PromotionDiscountType.PERCENT.getKey())) {// 百分比折扣 for (OrderItem item : order.getOrderItemList()) {// 找到目标子单 if (item.getNormsId().equals(targetOrderItem.getNormsId())) { @@ -418,7 +431,7 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl @Override public void updateOrderToPayState(InputObject inputObject, OutputObject outputObject) { String orderId = inputObject.getParams().get("id").toString(); - // 获取订单当前状态 + //获取订单当前状态 Order order = selectById(orderId); Integer state = order.getState(); if(ShopOrderState.UNSUBMIT.getKey()==state|| From 56b60966265a4c959ccd8d58b4bfc0f0b5064b24 Mon Sep 17 00:00:00 2001 From: luluyuyu <3305167204@qq.com> Date: Sat, 14 Dec 2024 21:09:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat=EF=BC=9A=E4=BF=AE=E6=94=B9=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=AE=A2=E5=8D=95=E6=97=B6=E7=A9=BA=E6=8C=87=E9=92=88?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/skyeye/order/service/impl/OrderServiceImpl.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java index a7dc6ff8..c7d68241 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java @@ -191,9 +191,6 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl return; } CouponUse couponUse = couponUseService.selectById(couponUseId);//优惠券信息 - if (couponUse == null) { - throw new CustomException("优惠券信息不存在"); - } if (ObjectUtil.isEmpty(couponUse)) { throw new CustomException("优惠券不存在"); } else if (couponUse.getState() != CouponUseState.UNUSED.getKey()) {