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 CheckCodeTypeEnum implements IntArrayValuable {
    Voucher_No(0, "凭证码"),
    Order_No(1, "订单号"),
    Card_No(2, "证件号"),
    Voucher_Base(3, "子票"),
    Other(4, "其他");

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

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

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

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

}