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

/**
 * 钱包记录类型枚举
 * @author gao
 * @date 2025/11/4 16:29
 */
public enum CardWalletRecordTypeEnum {
    DEPOSIT(1, "提款"),
    WITHDRAW(2, "取款"),
    RECHARGE(3, "卡充值"),
    REFUND(4, "卡退款"),
    MANUAL_IN(5, "手动转入"),
    MANUAL_OUT(6, "手动转出"),
    GLOBAL_DEDUCTION(7, "速汇订单扣款"),
    GLOBAL_REFUND(8, "速汇订单退款"),
    CRYPTO_CURRENCY_TRANSFER(9, "钱包充值"),
    CRYPTO_CURRENCY_TRANSFER_OUT(10, "钱包提现"),
    CRYPTO_CURRENCY_TRANSFER_OUT_REFUND(11, "钱包提现退款");

    private final int code;
    private final String description;

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

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static CardWalletRecordTypeEnum fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (CardWalletRecordTypeEnum type : values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        return null;
    }

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