From a301432a87b659416306ffa2ea23ed00db824c80 Mon Sep 17 00:00:00 2001 From: lele0521 Date: Mon, 27 May 2024 08:53:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=98=AF=E5=90=A6=E5=8F=AF=E4=BB=A5=E5=94=AE?= =?UTF-8?q?=E5=90=8E=E6=8E=A5=E5=8F=A3=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/common/enums/PromotionTypeEnum.java | 28 +++++++++++++++---- .../order/order/entity/dos/OrderItem.java | 2 +- .../entity/enums/OrderPromotionTypeEnum.java | 24 ++++++++++++++-- .../order/order/entity/vo/OrderSimpleVO.java | 4 +-- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/enums/PromotionTypeEnum.java b/framework/src/main/java/cn/lili/common/enums/PromotionTypeEnum.java index 626b127f0..62db4cde4 100644 --- a/framework/src/main/java/cn/lili/common/enums/PromotionTypeEnum.java +++ b/framework/src/main/java/cn/lili/common/enums/PromotionTypeEnum.java @@ -1,6 +1,9 @@ package cn.lili.common.enums; +import cn.lili.common.utils.StringUtils; + +import java.util.Arrays; import java.util.EnumSet; /** @@ -55,12 +58,27 @@ public enum PromotionTypeEnum { } /** - * 判断订单类型是否可售后 - * POINTS\KANJIA 三种促销类型的订单不可进行售后 - * @return true 不可售后 false 可售后 + * 判断促销类型是否有效 + * @param typeEnumValue + * @return */ - public static boolean isAfterSale(String promotionType) { + public static boolean isValid(String typeEnumValue) { + if (StringUtils.isBlank(typeEnumValue)) { + return false; + } + return Arrays.stream(PromotionTypeEnum.values()).anyMatch(c -> c.name().equals(typeEnumValue)); + } + + /** + * 判断订单类型是否可售后 + * POINTS\KANJIA 两种促销类型的订单不可进行售后 + * @return true 可售后 false 不可售后 + */ + public static boolean isCanAfterSale(String promotionType) { + if (!isValid(promotionType)) { + return true; + } EnumSet noAfterSale = EnumSet.of(PromotionTypeEnum.KANJIA, PromotionTypeEnum.POINTS_GOODS); - return noAfterSale.contains(PromotionTypeEnum.valueOf(promotionType)); + return !noAfterSale.contains(PromotionTypeEnum.valueOf(promotionType)); } } diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/OrderItem.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/OrderItem.java index b13c01c7d..dd0e187ec 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/OrderItem.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/OrderItem.java @@ -189,7 +189,7 @@ public class OrderItem extends BaseEntity { } public String getAfterSaleStatus() { - if (PromotionTypeEnum.isAfterSale(this.getPromotionType())) { + if (!PromotionTypeEnum.isCanAfterSale(this.promotionType)) { return OrderItemAfterSaleStatusEnum.EXPIRED.name(); } return afterSaleStatus; diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderPromotionTypeEnum.java b/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderPromotionTypeEnum.java index 13c124eb5..18dd5956d 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderPromotionTypeEnum.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderPromotionTypeEnum.java @@ -1,5 +1,8 @@ package cn.lili.modules.order.order.entity.enums; +import cn.lili.common.utils.StringUtils; + +import java.util.Arrays; import java.util.EnumSet; /** @@ -31,13 +34,28 @@ public enum OrderPromotionTypeEnum { */ KANJIA; + /** + * 判断促销类型是否有效 + * @param typeEnumValue + * @return + */ + public static boolean isValid(String typeEnumValue) { + if (StringUtils.isBlank(typeEnumValue)) { + return false; + } + return Arrays.stream(OrderPromotionTypeEnum.values()).anyMatch(c -> c.name().equals(typeEnumValue)); + } + /** * 判断订单类型是否可售后 * GIFT\POINTS\KANJIA 三种促销类型的订单不可进行售后 - * @return true 不可售后 false 可售后 + * @return true 可售后 false 不可售后 */ - public static boolean isAfterSale(String orderPromotionType) { + public static boolean isCanAfterSale(String orderPromotionType) { + if (!isValid(orderPromotionType)) { + return true; + } EnumSet noAfterSale = EnumSet.of(OrderPromotionTypeEnum.GIFT, OrderPromotionTypeEnum.POINTS, OrderPromotionTypeEnum.KANJIA); - return noAfterSale.contains(OrderPromotionTypeEnum.valueOf(orderPromotionType)); + return !noAfterSale.contains(OrderPromotionTypeEnum.valueOf(orderPromotionType)); } } diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderSimpleVO.java b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderSimpleVO.java index 4ba0fdddd..affd62408 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderSimpleVO.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderSimpleVO.java @@ -188,7 +188,7 @@ public class OrderSimpleVO { orderItemVO.setImage(groupImages.split(",")[i]); } if (CharSequenceUtil.isNotEmpty(groupAfterSaleStatus) && groupAfterSaleStatus.split(",").length == groupGoodsId.split(",").length) { - if (OrderPromotionTypeEnum.isAfterSale(this.orderPromotionType)) { + if (!OrderPromotionTypeEnum.isCanAfterSale(this.orderPromotionType)) { orderItemVO.setAfterSaleStatus(OrderItemAfterSaleStatusEnum.EXPIRED.name()); } else { orderItemVO.setAfterSaleStatus(groupAfterSaleStatus.split(",")[i]); @@ -222,7 +222,7 @@ public class OrderSimpleVO { public String getGroupAfterSaleStatus() { // 不可售后的订单类型集合 - if (OrderPromotionTypeEnum.isAfterSale(this.orderPromotionType)) { + if (!OrderPromotionTypeEnum.isCanAfterSale(this.orderPromotionType)) { return OrderItemAfterSaleStatusEnum.EXPIRED.name(); } return groupAfterSaleStatus;