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

public enum CardVaultodyStatusEnum {
    TRANSACTION_REQUEST("TRANSACTION_REQUEST","交易请求已创建"),
    TRANSACTION_APPROVED("TRANSACTION_APPROVED", "交易请求已被审批通过"),
    TRANSACTION_REJECTED("TRANSACTION_REJECTED", "交易请求被拒绝"),
    TRANSACTION_BROADCASTED("TRANSACTION_BROADCASTED", "交易已广播到区块链网络"),
    OUTGOING_MINED("OUTGOING_MINED", "向外发起的交易已成功上链（被区块打包）"),
    OUTGOING_MINED_WITH_ERRORS("OUTGOING_MINED_WITH_ERRORS", "交易已上链，但执行失败（业务逻辑错误）"),
    OUTGOING_FAILED("OUTGOING_FAILED", "向外发起的交易彻底失败（未上链）"),
    INCOMING_MINED_TX("INCOMING_MINED_TX", "原生代币交易（如 ETH、BTC 等主网币转账）"),
    INCOMING_CONFIRMED_COIN_TX("INCOMING_CONFIRMED_COIN_TX", "原生代币入账已确认"),
    INCOMING_CONFIRMED_INTERNAL_TX("INCOMING_CONFIRMED_INTERNAL_TX", "内部交易入账已确认");

    private final String code;
    private final String description;

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

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }


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

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