package com.seer.teach.common.enums.pay;

import lombok.Getter;

/**
 * 提现申请状态枚举
 */
@Getter
public enum WithdrawalApplyStatusEnum {

    /**
     * 待审核
     */
    PENDING_REVIEW(0, "待审核"),

    /**
     * 审核通过
     */
    APPROVED(1, "审核通过"),

    /**
     * 审核拒绝
     */
    REJECTED(2, "审核拒绝"),

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

    /**
     * 转账中
     */
    TRANSFERRING(4, "转账中"),

    /**
     * 提现完成
     */
    COMPLETED(5, "提现完成"),

    /**
     * 转账失败
     */
    TRANSFER_FAILED(6, "转账失败"),

    /**
     * 已撤销
     */
    REVOKED(7, "已撤销");

    private final int code;
    private final String description;

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

    /**
     * 根据code获取枚举
     * @param code 状态码
     * @return 对应的枚举值
     */
    public static WithdrawalApplyStatusEnum fromCode(int code) {
        for (WithdrawalApplyStatusEnum status : values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的提现申请状态码: " + code);
    }
}