package com.yonge.toolset.payment.core.util;

import com.yonge.toolset.base.exception.BizException;
import com.yonge.toolset.payment.base.PaymentTemplate;
import com.yonge.toolset.payment.base.enums.OpenEnum;
import com.yonge.toolset.payment.base.enums.PayChannelEnum;

/***
 *
 * @author liweifan
 * @updateTime 2022/5/11 16:04
 */
public class PaywayUtil {
    /***
     * 获取真实的支付方式
     * @author liweifan
     * @param: openType
     * @updateTime 2022/5/11 16:05
     * @return: com.yonge.toolset.payment.base.PaymentTemplate
     */
    public static PaymentTemplate getRealTemplate(OpenEnum openType, PayChannelEnum payChannel) {
        //原生
        if (OpenEnum.ORIGINAL.equals(openType)) {
            //支付宝
            if (PayChannelEnum.ali_app.equals(payChannel)) {
                return (PaymentTemplate) SpringBeansUtil.getBean("originalAliAppTemplate");
            }
            //微信
            if (PayChannelEnum.wx_app.equals(payChannel)) {
                return (PaymentTemplate) SpringBeansUtil.getBean("originalWxAppTemplate");
            }
        } else if (OpenEnum.ADAPAY.equals(openType)) {
            //汇付
            return (PaymentTemplate) SpringBeansUtil.getBean("adapayTemplate");
        }
        throw new BizException("未找到的服务提供方");
    }
}
