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 WithdrawStatus {

    /**
     *  1.待出款(未锁定) 2.待出款(已锁定) 3.待三方付款 4.付款失败 5.已拒绝 6.已取消 7.已付款   8.已强制出款
     */
    STATUS_1(1, 1, "待出款(未锁定)"),
    STATUS_2(2, 2, "待出款(已锁定)"),
    STATUS_3(3, 3, "待三方付款"),
    STATUS_4(4, 4, "付款失败"),
    STATUS_5(5, 5, "已拒绝"),
    STATUS_6(6, 6, "已取消"),
    STATUS_7(7, 7, "已付款"),
    STATUS_8(8, 8, "已强制出款");

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