From b4d3224898d50b8f1e30b5c8083a520743927282 Mon Sep 17 00:00:00 2001 From: xin <1099200748@qq.com> Date: Mon, 14 Jul 2025 21:08:42 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' into xin --- oying-system/src/main/java/com/oying/modules/message/common/OrderStatusEnum.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-) diff --git a/oying-system/src/main/java/com/oying/modules/message/common/OrderStatusEnum.java b/oying-system/src/main/java/com/oying/modules/message/common/OrderStatusEnum.java new file mode 100644 index 0000000..ea390f5 --- /dev/null +++ b/oying-system/src/main/java/com/oying/modules/message/common/OrderStatusEnum.java @@ -0,0 +1,52 @@ +package com.oying.modules.message.common; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 订单状态枚举 + * + * @author leomon + * @date 2025-05-20 + */ +@Getter +@AllArgsConstructor +public enum OrderStatusEnum { + + ZERO(0, "订单已提交"), + ONE(1, "支付成功"), + TWO(2, "商家已接单"), + THREE(3, "骑手已接单"), + FOUR(4, "商家已备货"), + FIVE(5, "骑手已到店"), + SIX(6, "骑手已取货"), + SEVEN(7, "商品已送达"), + EIGHT(8, "订单已完成"), + NINE(9, "订单已取消"); + + private final Integer key; + private final String value; + + /* ========== 工具方法 ========== */ + + /** 根据 key 获取枚举 */ + public static OrderStatusEnum of(Integer key) { + return key == null ? null : MAP.get(key); + } + + /** 根据 key 获取描述 */ + public static String descOf(Integer key) { + OrderStatusEnum e = of(key); + return e == null ? "" : e.getValue(); + } + + /** 反向映射,提升查找速度 */ + private static final Map<Integer, OrderStatusEnum> MAP = + Arrays.stream(values()) + .collect(Collectors.toMap(OrderStatusEnum::getKey, Function.identity())); +} \ No newline at end of file -- Gitblit v1.9.3