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;