package com.ff.base.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;

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

/**
 * 充值订单支付状态
 *
 * @author liukang
 * @date 2024/11/22
 */
@Getter
@AllArgsConstructor
public enum ChargeOrderPayStatus {

    STATUS_0(0, 0, "待支付"),
    STATUS_1(1, 1, "支付超时"),
    STATUS_2(2, 2, "补单审核中"),
    STATUS_3(3, 3, "支付成功"),
    STATUS_4(4, 4, "支付失败");

    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(ChargeOrderPayStatus.values())
                .filter(fyPayStatus -> fyPayStatus.getCode().equals(code))
                .map(ChargeOrderPayStatus::getStatus)
                .findFirst();
        return system.orElse(null);
    }
}
