package com.cool.store.enums.point;

import java.util.Objects;

/**
 * @author zhangchenbiao
 * @FileName: PaymentMethodEnum
 * @Description:付款方式
 * @date 2024-03-26 16:08
 */
public enum PaymentMethodEnum {

    //1.月付 2.季付 3.半年付 4.年付
    PAYMENT_METHOD_1(1, "月付"),
    PAYMENT_METHOD_2(2, "季付"),
    PAYMENT_METHOD_3(3, "半年付"),
    PAYMENT_METHOD_4(4, "年付"),
    ;

    private Integer code;

    private String desc;

    PaymentMethodEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


    public static PaymentMethodEnum getByCode(Integer code) {
        if(Objects.isNull(code)){
            return null;
        }
        for (PaymentMethodEnum paymentMethodEnum : PaymentMethodEnum.values()) {
            if (paymentMethodEnum.getCode().equals(code)) {
                return paymentMethodEnum;
            }
        }
        return null;
    }

}
