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

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.ss.account.domain.enums.AccountType;
import lombok.AllArgsConstructor;
import lombok.Getter;
import nonapi.io.github.classgraph.utils.LogNode;

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

/**
 * 支付方式（打款方式）
 * @author 辉
 * 2024/3/12
 */
@Getter
@AllArgsConstructor
public enum TransactionBillPayType {

    WECHAT(1L, "微信支付", AccountType.WECHAT),
    ALI(2L, "支付宝", AccountType.ALIPAY),
    BANK(3L, "银行卡", AccountType.BANK_CARD),
    BALANCE(4L, "余额支付", null),
    TL_WX(5L, "通联微信支付", null),
    TM_WX(6L, "太米微信支付", null);

    private final Long type;
    private final String name;
    private final AccountType accountType;

    public static TransactionBillPayType parse(Long type) {
        for (TransactionBillPayType value : TransactionBillPayType.values()) {
            if (Objects.equals(value.getType(), type)) {
                return value;
            }
        }
        throw new ServiceException("不存在值为" + type + "的支付方式（打款方式）");
    }

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

    /**
     * 微信支付列表
     */
    public static List<Long> wxList() {
        return asList(WECHAT, TL_WX, TM_WX);
    }
}
