package cn.newfeifan.mall.module.trade.enums.delivery;

import cn.newfeifan.mall.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.HashMap;

/**
 * 配送方式枚举
 *
 * @author 非繁源码
 */
@Getter
@AllArgsConstructor
public enum DeliveryTypeEnum implements IntArrayValuable {

    EXPRESS(1, "快递发货"),
    PICK_UP(2, "用户自提"),
    VIRTUAL_PRODUCT(3,"虚拟商品收货")
    ;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryTypeEnum::getType).toArray();

    /**
     * 配送方式
     */
    private final Integer type;
    /**
     * 状态名
     */
    private final String name;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    private static final HashMap<Integer, String> DELIVERY_LIST = new HashMap<>();

    static {
        for (DeliveryTypeEnum applicationEnum : DeliveryTypeEnum.values()) {
            DELIVERY_LIST.put(applicationEnum.getType(), applicationEnum.getName());
        }
    }
    public static String getNameByValue(Integer value) {

        return  DELIVERY_LIST.get(value);

    }




}
