package com.ruoyi.payment.domain.enums; /** * 交易状态枚举 * * @author ruoyi */ public enum TransactionStatus { /** 待支付 */ PENDING("PENDING", "待支付"), /** 支付成功 */ SUCCEEDED("SUCCEEDED", "支付成功"), /** 支付失败 */ FAILED("FAILED", "支付失败"), /** 已取消 */ CANCELED("CANCELED", "已取消"); private final String code; private final String desc; TransactionStatus(String code, String desc) { this.code = code; this.desc = desc; } public String getCode() { return code; } public String getDesc() { return desc; } public static TransactionStatus fromCode(String code) { for (TransactionStatus status : values()) { if (status.code.equals(code)) { return status; } } throw new IllegalArgumentException("未知的交易状态: " + code); } }