package cn.sikey.hmd.enums;

import cn.hutool.core.util.ArrayUtil;
import cn.sikey.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 支付状态
 */
@AllArgsConstructor
@Getter
public enum PayStatusEnum implements IntArrayValuable {

    TO_BE_PAID(1, "待支付"),
    SUCCESS(2, "成功"),
    FAIL(3, "失败");

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

    /**
     * value
     */
    private final Integer value;
    /**
     * name
     */
    private final String name;

    public static PayStatusEnum valueOf(Integer value) {
        return ArrayUtil.firstMatch(payStatus -> payStatus.getValue().equals(value), PayStatusEnum.values());
    }

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