package com.ywt.mg.domain.models.enums;

/**
 * 订单状态：1-未支付；2-已支付/待检测；4-已完成；8-已取消；16-已退款
 */
public enum NatOrderStatusEnum {
    UNKNOWN("", 0),
    UNPAID("未支付", 1),
    PAID("待检测", 2),
    FINISHED("已完成", 4),
    CANCELED("已取消", 8),
    REFUNDED("已退款", 16),
    ;

    private final String displayName;

    private final int value;

    NatOrderStatusEnum(String displayName, int value) {
        this.displayName = displayName;
        this.value = value;
    }

    public String getDisplayName() {
        return displayName;
    }

    public int getValue() {
        return value;
    }

    public static NatOrderStatusEnum valueOf(int value) {
        for (NatOrderStatusEnum e : NatOrderStatusEnum.values()) {
            if ((value & e.getValue()) == e.getValue() && value < 2 * e.getValue()) {
                return e;
            }
        }
        return UNKNOWN;
    }
}
