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.List;

/**
 * 伞下直推新增业绩订单类型枚举
 */
@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),

    /**
     * 注册
     */
    REGISTER_ORDER(5, "注册专区", 0, EnumsPrefixConstants.ORDER_BUSINESS + 5),

    /**
     * 升级
     */
    UPGRADE_ORDER(6, "升级专区", 0, EnumsPrefixConstants.ORDER_BUSINESS + 6),

    /**
     * 复购专区
     */
    REPURCHASE_ORDER(7, "复购专区", 0, EnumsPrefixConstants.ORDER_BUSINESS + 7),

//    /**
//     * 嗨粉
//     */
//    FANS_ORDER(8, "海粉专区", 0, EnumsPrefixConstants.ORDER_BUSINESS + 8),
//
//    /**
//     * 福利
//     */
//    WELFARE_ORDER(9, "福利专区", 0, EnumsPrefixConstants.ORDER_BUSINESS + 9),
//    /**
//     * 虚拟订单
//     */
//    FICTITIOUS_ORDER(12, "虚拟订单", 0, EnumsPrefixConstants.ORDER_BUSINESS + 12),
    /**
     * 重销订单
     */
    CONSUME_ORDER(17, "重销订单", 0, EnumsPrefixConstants.ORDER_BUSINESS + 17),
//    /**
//     * 专供专区
//     */
//    WHOLESALE_AREA(18, "专供专区", 0, EnumsPrefixConstants.ORDER_BUSINESS + 18),

    ;

    /**
     * 实际值
     */
    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) {
            //首购 1,2,24,25,20
            orderTypeList.add(EOrderType.REGISTER_ORDER.getValue());
            orderTypeList.add(EOrderType.UPGRADE_ORDER.getValue());
            orderTypeList.add(EOrderType.SPECIAL_REGISTER_ORDER.getValue());
            orderTypeList.add(EOrderType.SPECIAL_UPGRADE_ORDER.getValue());

            //复购 3,26,22,14,12,18,19,7,28,13,27,31,10,40
            orderTypeList.add(EOrderType.REPURCHASE_ORDER.getValue());
            orderTypeList.add(EOrderType.SPECIAL_REPURCHASE_ORDER.getValue());
            orderTypeList.add(EOrderType.CONSUME_ORDER.getValue());
        } else if (EOrderBusiness.FIRST_PURCHASE.getValue() == value) {
            //首购
            orderTypeList.add(EOrderType.REGISTER_ORDER.getValue());
            orderTypeList.add(EOrderType.UPGRADE_ORDER.getValue());
            orderTypeList.add(EOrderType.SPECIAL_REGISTER_ORDER.getValue());
            orderTypeList.add(EOrderType.SPECIAL_UPGRADE_ORDER.getValue());
        } else if (EOrderBusiness.REPURCHASE.getValue() == value) {
            //复购
            orderTypeList.add(EOrderType.REPURCHASE_ORDER.getValue());
            orderTypeList.add(EOrderType.SPECIAL_REPURCHASE_ORDER.getValue());
            orderTypeList.add(EOrderType.CONSUME_ORDER.getValue());
        } else if (EOrderBusiness.REGISTER_ORDER.getValue() == value) {
            //注册专区
            orderTypeList.add(EOrderType.REGISTER_ORDER.getValue());
            orderTypeList.add(EOrderType.SPECIAL_REGISTER_ORDER.getValue());
        } else if (EOrderBusiness.UPGRADE_ORDER.getValue() == value) {
            //升级专区
            orderTypeList.add(EOrderType.UPGRADE_ORDER.getValue());
            orderTypeList.add(EOrderType.SPECIAL_UPGRADE_ORDER.getValue());
        } else if (EOrderBusiness.REPURCHASE_ORDER.getValue() == value) {
            //复购专区 3,26,22,14,12,18,19,28,13
            orderTypeList.add(EOrderType.REPURCHASE_ORDER.getValue());
            orderTypeList.add(EOrderType.SPECIAL_REPURCHASE_ORDER.getValue());
        } else if (EOrderBusiness.CONSUME_ORDER.getValue() == value) {
            //重销订单
            orderTypeList.add(EOrderType.CONSUME_ORDER.getValue());
        }
        return orderTypeList;
    }

}
