package com.haha.common.enums;

public enum PaymentMethod {

    CORPORATE("CORPORATE", "对公"),
    PRIVATE("PRIVATE", "对私");

    private final String code;
    private final String description;

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

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static PaymentMethod fromCode(String code) {
        if (code == null) {
            return null;
        }
        for (PaymentMethod paymentMethod : values()) {
            if (paymentMethod.code.equals(code)) {
                return paymentMethod;
            }
        }
        return null;
    }

    public static String getDescription(String code) {
        PaymentMethod paymentMethod = fromCode(code);
        return paymentMethod != null ? paymentMethod.description : "未知";
    }
}
