package com.jeesharp.business.modules.member.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 连续签到里程碑额外积分（在基础分之上叠加，按最高满足档计算）。
 *
 * @author jeesharp
 * @since 2026-05-08
 */
@Getter
@AllArgsConstructor
public enum MemberSignInStreakBonusEnum {

    /**
     * 连续满 7 天及以上
     */
    STREAK_7(7, 90),

    /**
     * 连续满 5 天及以上
     */
    STREAK_5(5, 50),

    /**
     * 连续满 3 天及以上
     */
    STREAK_3(3, 10);

    private final int minContinuousDays;
    private final int bonusPoints;

    /**
     * 根据连续天数解析额外积分
     */
    public static int resolveBonusPoints(Integer continuousDays) {
        if (continuousDays == null || continuousDays <= 0) {
            return 0;
        }
        for (MemberSignInStreakBonusEnum e : values()) {
            if (continuousDays >= e.getMinContinuousDays()) {
                return e.getBonusPoints();
            }
        }
        return 0;
    }
}
