package com.ruoyi.common.enums;

import lombok.Getter;

@Getter
public enum MemberDiscountEnum {
    NEW_PARENTS(1, 0.95),
    ORDINARY_MEMBER(2, 0.90),
    SILVER_MEMBER(3, 0.88),
    GOLD_MEMBER(4, 0.85);

    private final Integer level;
    private final double discount;

    private MemberDiscountEnum(Integer level, double discount) {
        this.level = level;
        this.discount = discount;
    }
    public static double getDisCount(Integer level) {
        for (MemberDiscountEnum memberLevel : values()) {
            if (memberLevel.getLevel().equals(level)) {
                return memberLevel.getDiscount();
            }
        }
        return 0.95;
    }

    public static Integer getLevel(double discount) {
        for (MemberDiscountEnum memberLevel : values()) {
            if (memberLevel.getDiscount() ==  discount) {
                return memberLevel.getLevel();
            }
        }
        return 1;
    }
}
