package com.cool.store.enums.close;

/**
 * @Author suzhuhong
 * @Date 2025/9/22 18:57
 * @Version 1.0
 */
public enum CloseStoreStatusEnum {
    // 督导审批中
    UNDER_APPROVAL(1, "审批中"),
    // 大区老总审批中
    MANAGER_UNDER_APPROVAL(2, "审批中"),
    REVIEW_NOT_APPROVED(5, "审批拒绝"),
    CANCELED(10, "已取消"),
    CLOSING(15, "闭店中"),
    COMPLETED(20, "已完成"),

    ;
    private Integer closeStoreStatus;

    private String closeStoreStatusName;


    CloseStoreStatusEnum(Integer closeStoreStatus, String closeStoreStatusName) {
        this.closeStoreStatus = closeStoreStatus;
        this.closeStoreStatusName = closeStoreStatusName;
    }

    public Integer getCloseStoreStatus() {
        return closeStoreStatus;
    }

    public String getCloseStoreStatusName() {
        return closeStoreStatusName;
    }

    public static CloseStoreStatusEnum getByCloseStoreStatus(Integer closeStoreStatus){
        for (CloseStoreStatusEnum value : CloseStoreStatusEnum.values()) {
            if (value.getCloseStoreStatus().equals(closeStoreStatus)){
                return value;
            }
        }
        return null;
    }

    public static String getNameByStatus(Integer closeStoreStatus) {
        for (CloseStoreStatusEnum value : CloseStoreStatusEnum.values()) {
            if (value.getCloseStoreStatus().equals(closeStoreStatus)){
                return value.getCloseStoreStatusName();
            }
        }
        return null;
    }

    /**
     * 获取下一个审批通过状态
     * @param status 审批状态
     * @return 审批状态
     */
    public static Integer getNextPassStatus(Integer status) {
        CloseStoreStatusEnum currentStatus = getByCloseStoreStatus(status);
        if (currentStatus == null) {
            throw new IllegalArgumentException("闭店申请状态为空");
        }
        switch (currentStatus) {
            case UNDER_APPROVAL:
                return MANAGER_UNDER_APPROVAL.getCloseStoreStatus();
            case MANAGER_UNDER_APPROVAL:
                return CLOSING.getCloseStoreStatus();
            case CLOSING:
                return COMPLETED.getCloseStoreStatus();
            default:
                return null;
        }
    }

    public static boolean isApprove(Integer status) {
        return CloseStoreStatusEnum.UNDER_APPROVAL.getCloseStoreStatus().equals(status)
                || CloseStoreStatusEnum.MANAGER_UNDER_APPROVAL.getCloseStoreStatus().equals(status);
    }
}
