package com.seer.teach.pay.enums;

import lombok.Getter;

/**
 * <p>
 * 转账状态枚举
 * </p>
 *
 * @author ZS
 * @since 2025-10-17
 */
@Getter
public enum MerchantWithdrawTransferStatusEnum {

    /**
     * 待转账
     */
    PENDING_TRANSFER(0, "待转账"),

    /**
     * 已发起
     */
    INITIATED(1, "已发起"),

    /**
     * 银行确认
     */
    BANK_CONFIRMED(2, "银行确认"),

    /**
     * 转账失败
     */
    TRANSFER_FAILED(3, "转账失败");

    private final Integer code;
    private final String description;

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

    /**
     * 根据code获取枚举
     *
     * @param code 状态码
     * @return 对应的枚举值，找不到则返回null
     */
    public static MerchantWithdrawTransferStatusEnum fromCode(Integer code) {
        for (MerchantWithdrawTransferStatusEnum status : MerchantWithdrawTransferStatusEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }
}