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

/**
 * 卡交易类型枚举
 * @author gao
 * @date 2025/11/4 16:29
 */
public enum CardTransacTypeEnum {
    AUTH("auth", "授权"),
    REFUND("refund", "退款"),
    VERIFICATION("verification", "验证"),
    VOID("Void", "撤销"),
    MAINTAIN_FEE("maintain_fee", "卡费（月费、年费、ATM提现费....）"),
    WITHDRAW("withdraw", "扣款");

    private final String code;
    private final String description;

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

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

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

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