fix: 修复判断订单是否可以售后接口异常

This commit is contained in:
lele0521 2024-05-27 08:53:43 +08:00
parent 526de18a42
commit a301432a87
4 changed files with 47 additions and 11 deletions

View File

@ -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<PromotionTypeEnum> noAfterSale = EnumSet.of(PromotionTypeEnum.KANJIA, PromotionTypeEnum.POINTS_GOODS);
return noAfterSale.contains(PromotionTypeEnum.valueOf(promotionType));
return !noAfterSale.contains(PromotionTypeEnum.valueOf(promotionType));
}
}

View File

@ -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;

View File

@ -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<OrderPromotionTypeEnum> noAfterSale = EnumSet.of(OrderPromotionTypeEnum.GIFT, OrderPromotionTypeEnum.POINTS, OrderPromotionTypeEnum.KANJIA);
return noAfterSale.contains(OrderPromotionTypeEnum.valueOf(orderPromotionType));
return !noAfterSale.contains(OrderPromotionTypeEnum.valueOf(orderPromotionType));
}
}

View File

@ -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;