package com.czg.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 台桌状态枚举
 *
 * @author Administrator
 */

@Getter
public enum ShopTableStatusEnum {
    // 未绑定
    UNBOUND("unbound", "未绑定"),
    // 空闲
    IDLE("idle", "空闲"),
    // 点餐中
    ORDERING("ordering", "点餐中"),
    // 未结账
    UNSETTLED("unsettled", "未结账"),
    // 支付中
    PAYING("paying", "支付中"),
    // 已结账 (待清台)
    SETTLED("settled", "已结账 (待清台)"),
    // 关台
    CLOSED("closed", "关台"),
    // 预定
    SUBSCRIBE("subscribe", "预定"),
    ;
    private final String value;
    private final String msg;

    // 静态代码块，在类加载时执行，用于初始化映射关系
    private static final Map<String, String> VALUE_MSG_MAP = new HashMap<>();

    static {
        for (ShopTableStatusEnum status : ShopTableStatusEnum.values()) {
            VALUE_MSG_MAP.put(status.getValue(), status.getMsg());
        }
    }

    ShopTableStatusEnum(String value, String msg) {
        this.value = value;
        this.msg = msg;
    }

    public boolean equalsVal(String val) {
        return val.equals(value);
    }


    public static String getMsgByValue(String value) {
        if (StrUtil.isBlank(value)) {
            return "";
        }
        return VALUE_MSG_MAP.get(value);
    }
}
