package com.ruoyi.common.enums;

public enum ECardPayStatus {
    refund(-2, "已退费"),
    payFailed(-1, "支付失败"),
    payInvalid(0, "无效"),
    unpaid(1, "未支付"),
    paid(2, "已支付");

    private Integer value;
    private String remark;

    private ECardPayStatus(Integer value, String remark) {
        this.value = value;
        this.remark = remark;
    }

    public Integer getValue() {
        return value;
    }

    public String getRemark() {
        return remark;
    }

    public static ECardPayStatus getByValue(String value) {
        for (ECardPayStatus o : ECardPayStatus.values()) {
            if (o.getValue().equals(value)) {
                return o;
            }
        }
        return null;
    }

    public static Boolean isSuccess(Object value) {
        if (value instanceof String) {
            return paid.name().equalsIgnoreCase(String.valueOf(value));
        }else if (value instanceof Integer) {
            return paid.getValue()==Integer.parseInt(String.valueOf(value));
        }
        return false;
    }

    public static Boolean isFaild(Object value) {
        if (value instanceof String) {
            return payFailed.name().equalsIgnoreCase(String.valueOf(value));
        }else if (value instanceof Integer) {
            return payFailed.getValue()==Integer.parseInt(String.valueOf(value));
        }
        return false;
    }

    public static Boolean isUnPaid(Object value) {
        if (value instanceof String) {
            return unpaid.name().equalsIgnoreCase(String.valueOf(value));
        }else if (value instanceof Integer) {
            return unpaid.getValue()==Integer.parseInt(String.valueOf(value));
        }
        return false;
    }
}
