package com.hotwj.platform.pay.enums;

import lombok.Getter;

import java.util.Arrays;

@Getter
public enum PayChannelCodeEnum {

    WECHAT_QR("WECHAT_QR", "WECHAT", "QR", 1L, 4L),
    WECHAT_H5("WECHAT_H5", "WECHAT", "H5", 1L, 1L),
    WECHAT_APP("WECHAT_APP", "WECHAT", "APP", 1L, 3L),
    ALIPAY_QR("ALIPAY_QR", "ALIPAY", "QR", 2L, 4L),
    ALIPAY_H5("ALIPAY_H5", "ALIPAY", "H5", 2L, 1L),
    ALIPAY_APP("ALIPAY_APP", "ALIPAY", "APP", 2L, 3L);

    private final String code;
    private final String provider;
    private final String scene;
    private final Long payMethod;
    private final Long payScene;

    PayChannelCodeEnum(String code, String provider, String scene, Long payMethod, Long payScene) {
        this.code = code;
        this.provider = provider;
        this.scene = scene;
        this.payMethod = payMethod;
        this.payScene = payScene;
    }

    public static PayChannelCodeEnum of(String provider, String scene) {
        return Arrays.stream(values())
                .filter(item -> item.provider.equalsIgnoreCase(provider) && item.scene.equalsIgnoreCase(scene))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("不支持的支付方式组合: " + provider + "-" + scene));
    }
}
