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

public enum ConsultStatusEnum {
    Paid("已付款", 1),
    Refuse("已退诊", 1 << 1),
    Accept("已接诊", 1 << 2),
    Cancel("已取消", 1 << 3),
    End("已结束", 1 << 4),
    Evaluate("已评价", 1 << 5),
    Refund("已退款", 1 << 6),
    Settlement("已结算", 1 << 7),
    UNKNOWN("",0);

    private final String displayName;

    private final int value;

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

    public String getDisplayName() {
        return displayName;
    }

    public int getValue() {
        return value;
    }

    /**
     * 匹配的时候先匹配后面的，再匹配前面的
     * @param status
     * @return
     */
    public static ConsultStatusEnum getConsultStatusEnum(int status){
        ConsultStatusEnum statusEnum = UNKNOWN;

        if ( (status & Settlement.getValue()) > 0  ){
            statusEnum = Settlement;
        }
        else if ( (status & Refund.getValue()) > 0  ){
            statusEnum = Refund;
        }
        else if ( (status & Evaluate.getValue()) > 0  ){
            statusEnum = Evaluate;
        }
        else if ( (status & End.getValue()) > 0  ){
            statusEnum = End;
        }
        else if ( (status & Cancel.getValue()) > 0 ){
            statusEnum = Cancel;
        }
        else if ( (status & Accept.getValue()) > 0  ){
            statusEnum = Accept;
        }
        else if ( (status & Refuse.getValue()) > 0 ){
            statusEnum = Refuse;
        }
        else if ( (status & Paid.getValue()) > 0 ){
            statusEnum = Paid;
        }
        else {
            statusEnum = UNKNOWN;
        }
        return statusEnum;
    }


}
