package com.yc.ship.module.trade.enums;


import com.yc.ship.framework.common.core.IntArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.Optional;


/**
 * 核销对象类型
 */
@RequiredArgsConstructor
@Getter
public enum CheckTargetTypeEnum implements IntArrayValuable {
    Voucher(0, "门票"),
    Order(  1, "订单"),
    Voucher_Base(2, "子票"),
    Card_No(3, "证件号");

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

    /**
     * 类型值
     */
    private final Integer type;
    /**
     * 类型名
     */
    private final String name;

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

    public static String getName(Integer type) {
        Optional<CheckTargetTypeEnum> first = Arrays.stream(values()).filter(item -> item.type.equals(type)).findFirst();
        if (first.isPresent()) {
            return first.get().getName();
        }
        return "";
    }

}