package com.crm.rely.backend.core.constant;

/**
 * 审批状态枚举
 * @author gao
 * @date 2025/11/4 16:29
 */
public enum CardStatusTypeEnum {
    UN_ACTIVATE("unactivate","未激活"),
    WAIT_PROCESS("wait_process", "待处理"),
    PROCESSING("processing", "处理中"),
    SUCCESS("success", "成功"),
    FAIL("fail", "失败"),
    CANCEL("cancel","销卡");

    private final String code;
    private final String description;

    CardStatusTypeEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }


    public static CardStatusTypeEnum fromCode(String code) {
        if (code == null) {
            return null;
        }
        for (CardStatusTypeEnum statusType : values()) {
            if (statusType.getCode().equals(code)) {
                return statusType;
            }
        }
        return null;
    }

    public static String matchCode(String code) {
        CardStatusTypeEnum statusTypeEnum = fromCode(code);
        return statusTypeEnum != null ? statusTypeEnum.getDescription() : "";
    }
}
