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

/**
 * 远诊会诊订单状态
 */
public enum TreatmentStatusEnum {
    Pending("待付款", 1),
    Paid("已付款", 1 << 1),
    Refunded("已退款", 1 << 2),
    Cancel("已取消", 1 << 3),
    SubmitReport("提交报告", 1 << 4),
    InformPatient("已通知用户", 1 << 5),
    Evaluate("用户已评价", 1 << 6),
    Settlement("已结算", 1 << 7),
    UNKNOWN("",0);

    private final String displayName;

    private final int value;

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

    public String getDisplayName() {
        return displayName;
    }

    public int getValue(){
        return value;
    }

    public static TreatmentStatusEnum valueOf(int value){
        // todo 如果有已退款，优先显示已退款
        if ( (value & Refunded.getValue()) > 0){
            return Refunded;
        }
        if (value == Pending.getValue()){
            return Pending;
        }
        if ( (value & Settlement.getValue()) > 0 && value < 2 * Settlement.value){
            return  Settlement;
        }else if ( (value & Evaluate.getValue()) > 0 && value < 2 * Evaluate.value){
            return  Evaluate;
        }else if ( (value & InformPatient.getValue()) > 0 && value < 2 * InformPatient.value){
            return InformPatient;
        }else if ( (value & SubmitReport.getValue()) > 0 && value < 2 * SubmitReport.value){
            return SubmitReport;
        }else if ( (value & Cancel.getValue()) > 0 && value < 2 * Cancel.value){
            return Cancel;
        }else if ( (value & Paid.getValue()) > 0 && value < 2 * Paid.value){
            return Paid;
        }else {
            return UNKNOWN;
        }
    }


}
