package cn.freemud.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 订单特殊类型
 * @Auther: yong.huang
 * @Date: 2018/12/29 15:58
 * @Description:
 */
@Getter
@AllArgsConstructor
public enum OrderMarketType {
    ORDER((byte)1, "普通订单"),
    GROUPB((byte)2, "拼团订单"),
    SEC_KILL((byte)3, "秒杀订单"),
    COLLAGE((byte)4, "拼单订单")
    ;

    private byte index;
    private String name;

    public static final String API_DESC = "销售类型或营销活动类型 1:普通订单 2:拼团订单 3:秒杀订单 4:拼单订单";

    public static OrderMarketType getByIndex(byte index) {
        return Arrays.stream(OrderMarketType.values())
                .filter(e -> e.getIndex() == index)
                .findFirst()
                .orElseGet(() -> ORDER);
    }
}
