package com.jeesharp.business.modules.finance.payrefund.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 支付退款单状态枚举，描述从待发起到渠道终态的生命周期。
 *
 * @author jeesharp
 * @since 2026-06-11
 */
@Getter
@AllArgsConstructor
public enum PayRefundOrderStatusEnum {

    PENDING("PENDING", "待发起"),
    PROCESSING("PROCESSING", "处理中"),
    SUCCESS("SUCCESS", "成功"),
    FAIL("FAIL", "失败"),
    CLOSED("CLOSED", "关闭");

    private final String value;
    private final String desc;

    public static PayRefundOrderStatusEnum fromValue(String value) {
        if (value == null) {
            return null;
        }
        for (PayRefundOrderStatusEnum e : values()) {
            if (e.value.equals(value)) {
                return e;
            }
        }
        return null;
    }

    public static String getDescByValue(String value) {
        PayRefundOrderStatusEnum e = fromValue(value);
        return e != null ? e.getDesc() : "";
    }
}
