package com.jeequan.jeepay.core.model.params;

import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.model.params.alipay.AlipayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.allinpay.AllinpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.bcmpay.BcmpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.cloudpay.CloudpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.demomockpay.DemomockpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.dgpay.DgpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.easypay.EasypayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.epspay.EpspayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.fbpay.FbpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.fuioupay.FuioupayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.hkpay.HkpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.hmpay.HmpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.hnapay.HnapayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.icbcpay.IcbcpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.kdbpay.KdbpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.kqpay.KqpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.leshuapay.LeshuapayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.lklpay.LklpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.lklspay.LklspayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.mbpay.MbpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.pfpay.PfpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.pmpay.PmpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.ruipay.RyxpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.sftpay.SftpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.shengpay.ShengpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.sqbpay.SqbpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.sxfpay.SxfpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.terpay.TerpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.umhspay.UmhspayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.umpay.UmpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.utmpay.UtmpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.wxpay.WxpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.ysf.YsfpayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.yspay.YspayIsvsubMchParams;
import com.jeequan.jeepay.core.model.params.zftpay.ZftpayIsvsubMchParams;
import com.jeequan.jeepay.core.utils.JeepayKit;

/*
 * 抽象类 特约商户参数定义
 *
 * @author terrfly
 *
 * @date 2021/6/8 16:33
 */
public abstract class IsvsubMchParams {

    public static IsvsubMchParams factory(String ifCode, String paramsStr){

        ifCode = JeepayKit.getIfCodeOrigin(ifCode);

        if(CS.IF_CODE.WXPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, WxpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.ALIPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, AlipayIsvsubMchParams.class);
        }else if(CS.IF_CODE.YSFPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, YsfpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.SHENGPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, ShengpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.ZFTPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, ZftpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.SFTPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, SftpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.HMPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, HmpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.FUIOUPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, FuioupayIsvsubMchParams.class);
        }else if(CS.IF_CODE.LKLPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, LklpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.LKLSPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, LklspayIsvsubMchParams.class);
        }else if(CS.IF_CODE.FBPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, FbpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.DGPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, DgpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.PFPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, PfpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.UTMPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, UtmpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.SQBPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, SqbpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.YSPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, YspayIsvsubMchParams.class);
        }else if(CS.IF_CODE.RYXPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, RyxpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.ALLINPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, AllinpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.MBPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, MbpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.TERPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, TerpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.PMPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, PmpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.UMPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, UmpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.CLOUDPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, CloudpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.HKPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, HkpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.HNAPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, HnapayIsvsubMchParams.class);
        }else if(CS.IF_CODE.BCMPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, BcmpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.ICBCPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, IcbcpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.EASYPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, EasypayIsvsubMchParams.class);
        }else if(CS.IF_CODE.LESHUAPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, LeshuapayIsvsubMchParams.class);
        }else if(CS.IF_CODE.ALIAQF.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, AlipayIsvsubMchParams.class);
        }else if(CS.IF_CODE.SXFPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, SxfpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.EPSPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, EpspayIsvsubMchParams.class);
        }else if(CS.IF_CODE.DEMOMOCKPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, DemomockpayIsvsubMchParams.class);
        } else if (CS.IF_CODE.UMHSPAY.equals(ifCode)) {
            return JSONObject.parseObject(paramsStr, UmhspayIsvsubMchParams.class);
        } else if (CS.IF_CODE.KDBPAY.equals(ifCode)) {
            return JSONObject.parseObject(paramsStr, KdbpayIsvsubMchParams.class);
        }else if(CS.IF_CODE.KQPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, KqpayIsvsubMchParams.class);
        }
        return null;
    }

    /**
     *  用于对账单下载，根据支付参数配置  获取渠道唯一 子商户号
     *  渠道是通过服务商下属子商户下载对账单时，需添加对应渠道商户号的获取
     */
    public static String getChannelMchNo(String ifCode, IsvsubMchParams isvsubMchParams){

        ifCode = JeepayKit.getIfCodeOrigin(ifCode);

        if (isvsubMchParams == null) {
            return null;
        }else if(CS.IF_CODE.ALIPAY.equals(ifCode)){
            return ((AlipayIsvsubMchParams) isvsubMchParams).getAppAuthToken();
        }
        return null;
    }
}
