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 EOrderBusiness {

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

    /**
     * 首购  注册 + 升级
     */
    FIRST_PURCHASE(2, "首购", 0, EnumsPrefixConstants.ORDER_BUSINESS + 2),

    /**
     * 复购 + 嗨粉
     */
    REPURCHASE(3, "复购", 0, EnumsPrefixConstants.ORDER_BUSINESS + 3),

    /**
     * 新零售注册订单
     */
    RETAIL_REGISTER(41, "注册订单", 0, EnumsPrefixConstants.ORDER_BUSINESS + 41),
    /**
     * 新零售升级订单
     */
    RETAIL_UPGRADE(42, "升级订单", 0, EnumsPrefixConstants.ORDER_BUSINESS + 42),
    /**
     * 新零售复购订单
     */
    RETAIL_REPURCHASE(43, "复购订单", 0, EnumsPrefixConstants.ORDER_BUSINESS + 43),
    /**
     * 新零售重消订单
     */
    RETAIL_CONSUME(44, "重消订单", 0, EnumsPrefixConstants.ORDER_BUSINESS + 44),

    ;

    /**
     * 实际值
     */
    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 EOrderBusiness getEnumByValue(int value) {
        for (EOrderBusiness eOrderType : EOrderBusiness.values()) {
            if (eOrderType.getValue() == value) {
                return eOrderType;
            }
        }
        return null;
    }

    /**
     * 根据值，返回订单类型集合
     *
     * @param value
     * @return
     */
    public static List<Integer> getOrderTypeList(Integer value) {
        List<Integer> orderTypeList = new ArrayList<>();
        if (null == value || EOrderBusiness.WHOLE.getValue() == value) {
            orderTypeList.add(EOrderType.RETAIL_REGISTER.getValue());
            orderTypeList.add(EOrderType.RETAIL_UPGRADE.getValue());
            orderTypeList.add(EOrderType.RETAIL_REPURCHASE.getValue());
            orderTypeList.add(EOrderType.RETAIL_CONSUME.getValue());
        } else if (EOrderBusiness.FIRST_PURCHASE.getValue() == value) {
            //首购
            orderTypeList.add(EOrderType.RETAIL_REGISTER.getValue());
            orderTypeList.add(EOrderType.RETAIL_UPGRADE.getValue());
        } else if (EOrderBusiness.REPURCHASE.getValue() == value) {
            //复购
            orderTypeList.add(EOrderType.RETAIL_REPURCHASE.getValue());
            orderTypeList.add(EOrderType.RETAIL_CONSUME.getValue());
        } else if (EOrderBusiness.RETAIL_REGISTER.getValue() == value) {
            // 注册
            orderTypeList.add(EOrderType.RETAIL_REGISTER.getValue());
        } else if (EOrderBusiness.RETAIL_UPGRADE.getValue() == value) {
            // 升级
            orderTypeList.add(EOrderType.RETAIL_UPGRADE.getValue());
        } else if (EOrderBusiness.RETAIL_REPURCHASE.getValue() == value) {
            // 复购
            orderTypeList.add(EOrderType.RETAIL_REPURCHASE.getValue());
        } else if (EOrderBusiness.RETAIL_CONSUME.getValue() == value) {
            // 重消
            orderTypeList.add(EOrderType.RETAIL_CONSUME.getValue());
        }
        return orderTypeList;
    }

}
