package com.sonic.frog.enums;

import lombok.Getter;

import java.math.BigDecimal;

@Getter
public enum HeartbeatLevelEnum {
    LEVEL_1(1, new BigDecimal("0.1"), "ACQUAINTANCE", "Initial acquaintance","Lv.1"),
    LEVEL_2(2, new BigDecimal("0.3"), "ACQUAINTANCE", "Initial acquaintance","Lv.2"),
    LEVEL_3(3, new BigDecimal("0.5"), "FRIEND", "Friend","Lv.3"),
    LEVEL_4(4, new BigDecimal("1"), "FRIEND", "Friend","Lv.4"),
    LEVEL_5(5, new BigDecimal("2"), "FLIRT", "Flirt","Lv.5"),
    LEVEL_6(6, new BigDecimal("3"), "FLIRT", "Flirt","Lv.6"),
    LEVEL_7(7, new BigDecimal("4"), "LOVE", "Love","Lv.7"),
    LEVEL_8(8, new BigDecimal("5"), "LOVE", "Love","Lv.8"),
    LEVEL_9(9, new BigDecimal("6"), "MARRIAGE", "Marriage","Lv.9"),
    LEVEL_10(10, new BigDecimal("7"), "MARRIAGE", "Marriage","Lv.10"),
    ;

    /**
     * 对应等级数字num
     */
    private final int num;
    /**
     * 对应等级24小时未聊天需要扣除的心动值
     */
    private BigDecimal subtractHeartbeatVal;

    /**
     * 关系阶段代码
     */
    private String relationStage;
    /**
     * 关系阶段名称
     */
    private String relationStageName;

    /**
     * 对应的等级名称
     */
    private String levelName;

    HeartbeatLevelEnum(int num, BigDecimal subtractHeartbeatVal, String relationStage, String relationStageName, String levelName) {
        this.num = num;
        this.subtractHeartbeatVal = subtractHeartbeatVal;
        this.relationStage = relationStage;
        this.relationStageName = relationStageName;
        this.levelName = levelName;
    }

    /**
     * 判断是否升级
     *
     * @param oldLevel
     * @param newLevel
     * @return
     */
    public static Boolean isUpgrade(HeartbeatLevelEnum oldLevel, HeartbeatLevelEnum newLevel) {
        if (oldLevel == null && newLevel != null) {
            return true;
        } else if (oldLevel != null && newLevel != null && newLevel.num > oldLevel.num) {
            return true;
        }
        return false;
    }


    /**
     * 判断是否降级
     *
     * @param oldLevel
     * @param newLevel
     * @return
     */
    public static Boolean isDowngrade(HeartbeatLevelEnum oldLevel, HeartbeatLevelEnum newLevel) {
        if (oldLevel != null && newLevel == null) {
            return true;
        } else if (oldLevel != null && newLevel != null && newLevel.num < oldLevel.num) {
            return true;
        }
        return false;
    }

}
