package com.ruoyi.bst.pay.domain.enums;

import com.ruoyi.bst.order.service.impl.OrderPayHandler;
import com.ruoyi.bst.pay.interfaces.PayHandler;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author wjh
 * 2025/3/26
 */
@Getter
@AllArgsConstructor
public enum PayBstType {
    ORDER("1", "订单", OrderPayHandler.class);

    private final String type;
    private final String msg;
    private final Class<? extends PayHandler> payHandler;   // 支付回调处理器

    public static PayBstType parse(String type) {
        for (PayBstType value : PayBstType.values()) {
            if (value.getType().equals(type)) {
                return value;
            }
        }
        return null;
    }

    public static List<String> asList(PayBstType ...types) {
        return Arrays.stream(types).map(PayBstType::getType).collect(Collectors.toList());
    }
}
