package com.ruoyi.ss.payBill.domain.enums;

import com.ruoyi.ss.payBill.interfaces.AfterPay;
import com.ruoyi.ss.payBill.interfaces.AfterRefund;
import com.ruoyi.ss.transactionBill.service.impl.RechargeDepositAfterPay;
import com.ruoyi.ss.transactionBill.service.impl.RechargePayHandler;
import lombok.AllArgsConstructor;
import lombok.Getter;

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

/**
 * @author wjh
 * 2024/7/24
 */
@Getter
@AllArgsConstructor
public enum PayBillBstType {

    MONTH_BILL("1", "月费账单", null, null),
    ELECTRICITY_RECHARGE("2", "电量充值订单", null, null),
    RECHARGE_ORDER("4", "充值订单", RechargePayHandler.class, RechargePayHandler.class),
    RECHARGE_ORDER_DEPOSIT("5", "充值订单押金", RechargeDepositAfterPay.class, null);

    private final String type;
    private final String msg;
    private final Class<? extends AfterPay> afterPay;   // 支付回调处理器
    private final Class<? extends AfterRefund> afterRefund; // 退款回调处理器

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

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