package com.hzs.common.core.enums;

import com.hzs.common.core.constant.EnumsPrefixConstants;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 账户状态枚举（会员信息专用钱包状态）
 *
 * @author: hzs
 */
@AllArgsConstructor
@Getter
public enum EMemberAccount {

    /**
     * 正常
     */
    NORMAL(1, 0, "正常", EnumsPrefixConstants.MEMBER_ACCOUNT + 1),

    /**
     * 禁止转账
     */
    PROHIBIT_TRANSFER(2, 1, "禁止转账", EnumsPrefixConstants.MEMBER_ACCOUNT + 2),
    /**
     * 禁止提现
     */
    PROHIBIT_WITHDRAW(3, 1, "禁止提现", EnumsPrefixConstants.MEMBER_ACCOUNT + 3),
    /**
     * 禁止消费
     */
    PROHIBIT_CONSUME(4, 1, "禁止消费", EnumsPrefixConstants.MEMBER_ACCOUNT + 4),
    /**
     * 全网转账
     */
    WHOLE_TRANSFER(5, 1, "全网转账", EnumsPrefixConstants.MEMBER_ACCOUNT + 5),

    ;

    /**
     * 实际值
     */
    private final int value;
    /**
     * 是否
     */
    private final int isYesNo;
    /**
     * 显示标签
     */
    private final String label;
    /**
     * 国际化翻译key值
     */
    private final String key;

    /**
     * 校验状态是否合法
     *
     * @param value
     * @return
     */
    public static boolean checkEnableCode(Integer value) {
        return NORMAL.getValue() == value
                || PROHIBIT_TRANSFER.getValue() == value
                || PROHIBIT_WITHDRAW.getValue() == value
                || PROHIBIT_CONSUME.getValue() == value;
    }

    /**
     * 根据值，返回label
     *
     * @param vale
     * @return
     */
    public static String getLabelByIntValue(int vale) {
        if (NORMAL.getValue() == vale) {
            return NORMAL.getLabel();
        }
        if (PROHIBIT_TRANSFER.getValue() == vale) {
            return PROHIBIT_TRANSFER.getLabel();
        }
        if (PROHIBIT_WITHDRAW.getValue() == vale) {
            return PROHIBIT_WITHDRAW.getLabel();
        }
        if (PROHIBIT_CONSUME.getValue() == vale) {
            return PROHIBIT_CONSUME.getLabel();
        }
        return NORMAL.getLabel();
    }

    /**
     * 根据枚举值获取枚举
     *
     * @param value 枚举值
     * @return
     */
    public static EMemberAccount getEnumByValue(int value) {
        for (EMemberAccount eApproveStatus : EMemberAccount.values()) {
            if (eApproveStatus.getValue() == value) {
                return eApproveStatus;
            }
        }
        return null;
    }


}
