package com.seer.teach.common.enums;

import lombok.Getter;

/**
 * 支付模式枚举
 */
@Getter
public enum PaymentModeEnum {

    /**
     * 线上支付
     */
    ONLINE(0, "线上支付"),

    /**
     * 线下支付
     */
    OFFLINE(1, "线下支付");

    private final Integer code;
    private final String description;

    PaymentModeEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    public static PaymentModeEnum fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (PaymentModeEnum mode : PaymentModeEnum.values()) {
            if (mode.getCode().equals(code)) {
                return mode;
            }
        }
        return null;
    }

    public static boolean isOnlinePay(Integer code) {
        if (code == null) {
            return false;
        }
    	return ONLINE.getCode().equals(code);
    }
}