package com.hzs.common.core.enums;

import com.hzs.common.core.constant.EnumsPrefixConstants;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 伞下直推新增业绩订单类型枚举
 *
 * @author hzs
 */
@AllArgsConstructor
@Getter
public enum EOrderUpBusiness {

    /**
     * 全部
     */
    WHOLE(1, "全部", 0, EnumsPrefixConstants.ORDER_UP_BUSINESS + 1),

    /**
     * 首购
     */
    FIRST_PURCHASE(2, "首购", 0, EnumsPrefixConstants.ORDER_UP_BUSINESS + 2),

    /**
     * 复购
     */
    REPURCHASE(3, "复购", 0, EnumsPrefixConstants.ORDER_UP_BUSINESS + 3),


    ;

    /**
     * 实际值
     */
    private final int value;
    /**
     * 显示标签
     */
    private final String label;
    /**
     * 是否启用（0=是,1=否） -- 来源EYesNo
     */
    private final int enable;
    /**
     * 国际化翻译key值
     */
    private final String key;

    /**
     * 根据值，返回枚举
     *
     * @param value
     * @return
     */
    public static EOrderUpBusiness getEnumByValue(int value) {
        for (EOrderUpBusiness eOrderType : EOrderUpBusiness.values()) {
            if (eOrderType.getValue() == value) {
                return eOrderType;
            }
        }
        return null;
    }

    /**
     * 会员前端列表
     */
    private static List<EOrderUpBusiness> apiList;

    /**
     * 获取会员前端列表
     *
     * @return
     */
    public static List<EOrderUpBusiness> getApiList() {
        if (null == apiList) {
            apiList = new ArrayList<>();
            Collections.addAll(apiList, EOrderUpBusiness.values());
        }
        return apiList;
    }

}
