package com.ruoyi.xq.enums.activity;

import lombok.Getter;

import java.time.LocalDateTime;

@Getter
public enum ActivityShopStatusEnum {
    NO_START(0,"未开启"),
    STARTING(1,"开始中"),
    ENDING(2,"已结束"),
    ;
    private final Integer code;
    private final String text;

    ActivityShopStatusEnum(Integer code, String text) {
        this.code = code;
        this.text = text;
    }

    public static ActivityShopStatusEnum getEnumByTime(LocalDateTime startTime, LocalDateTime endTime){
        if(startTime == null || endTime == null){
            return NO_START;
        }
        LocalDateTime now = LocalDateTime.now();
        if(now.isBefore(startTime)){
            return NO_START;
        }
        if(now.isAfter(endTime)){
            return ENDING;
        }
        return STARTING;
    }
}

