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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 支付状态：待支付、成功、失败、关闭（关单/撤销）。
 *
 * @author jeesharp
 * @since 2026-05-09
 */
@Getter
@AllArgsConstructor
public enum PayRecordStatusEnum {

    /**
     * 待支付
     */
    PENDING(0, "待支付"),

    /**
     * 支付成功
     */
    SUCCESS(1, "成功"),

    /**
     * 支付失败
     */
    FAILED(2, "失败"),

    /**
     * 已关闭
     */
    CLOSED(3, "已关闭");

    private final Integer value;
    private final String desc;

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

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