package com.ruoyi.payment.domain.enums; /** * 订单状态枚举 * * @author ruoyi */ public enum OrderStatus { /** 初始化 */ INIT("INIT", "初始化"), /** 待支付 */ PENDING("PENDING", "待支付"), /** 支付成功 */ SUCCEEDED("SUCCEEDED", "支付成功"), /** 支付失败 */ FAILED("FAILED", "支付失败"), /** 已关闭 */ CANCELED("CANCELED", "已关闭"), /** 已过期 */ EXPIRED("EXPIRED", "已过期"); private final String code; private final String desc; OrderStatus(String code, String desc) { this.code = code; this.desc = desc; } public String getCode() { return code; } public String getDesc() { return desc; } public static OrderStatus fromCode(String code) { for (OrderStatus status : values()) { if (status.code.equals(code)) { return status; } } throw new IllegalArgumentException("未知的订单状态: " + code); } }