package com.ff.base.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * xjpay支付状态
 *
 * @author liukang
 * @date 2024/10/22
 */
@Getter
@AllArgsConstructor
public enum XjPayStatus {

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

    private final Integer status;
    private final Integer code;
    private final String info;

    /**
     * 按code查找状态
     *
     * @param code 代码
     * @return {@link String }
     */
    public static Integer findStatusByCode(Integer code) {
        Optional<Integer> system = Stream.of(XjPayStatus.values())
                .filter(fyPayStatus -> fyPayStatus.getCode().equals(code))
                .map(XjPayStatus::getStatus)
                .findFirst();
        return system.orElse(null);
    }
}
