package com.tzy.framework.pay.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.tzy.common.utils.StringUtils;
import com.tzy.common.utils.http.HttpClientUtil;
import com.tzy.framework.pay.config.PayConfig;
import com.tzy.framework.pay.dto.*;
import com.tzy.framework.pay.service.*;
import com.tzy.framework.util.RandomUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 支付
 */
@Slf4j
@Service("paymentManagerServiceImpl")
public class PaymentServiceImpl<T> extends PaymentBaseService implements PaymentService<T> {

    @Override
    public T initPayConfigs(String payWay, Class<T> tClass){
        return JSONObject.parseObject(sysBaseService.getAppMenuByCode(payWay),tClass);
    }

    /**
     * 预加载支付配置
     * @return
     */
    @PostConstruct
    public void initDefaultPayConfig(){
        PayConfig payConfig1 = payConfig;
        log.debug(" 加载支付配置 payConfig {} ",payConfig);
        //System.out.println("--------");
    }

    /**
     * 统一下单
     * 调用不同的支付方式
     * @param paymentRequestDto
     */
    @Override
    public ResultMap unifiedOrder(PaymentRequestDto paymentRequestDto){
        if(null != paymentRequestDto)
        {
            return unifiedOrderNew(paymentRequestDto);
        }
        return ResultMap.error(-1,"下单失败");
    }

    /**
     * 查询订单
     * 调用不同的支付方式
     * @param payWay
     * @param orderNo
     */
    @Override
    public PaymentInfoResponseDto queryPaymentOrder(String payWay, String orderNo){
        if(StringUtils.isNotEmpty(payWay)){
            return queryPaymentOrderNew(payWay, orderNo);
        }
        return PaymentInfoResponseDto.error(-1, "下单失败");
    }

    /**
     * 退款
     * 调用不同的支付方式
     * @param payWay
     * @param orderNo
     * @param refundAmount
     * @param refundMsg
     * @return
     */
    @Deprecated
    @Override
    public ResultMap refund(String payWay, String orderNo, BigDecimal orderPrice, BigDecimal refundAmount,String refundMsg){
        if(StringUtils.isNotEmpty(payWay)){
            return refundNew(payWay, orderNo, orderPrice, refundAmount, refundMsg);
        }
        return  ResultMap.error(-1, "下单失败");
    }

    /**
     * 关闭订单
     * @param payWay
     * @param orderNo
     * @return
     */
    @Override
    public ResultMap close(String payWay, String orderNo){
        if(StringUtils.isNotEmpty(payWay)){
            return closeNew(payWay, orderNo);
        }
        return ResultMap.error(-1, "下单失败");
    }

    /**
     * 查询退款订单
     * @param payWay
     * @param tradeNo
     * @param refundNo
     * @return
     */
    @Override
    public ResultMap refundQuery(String payWay,String tradeNo ,String refundNo){
        if(StringUtils.isNotEmpty(payWay)){
            RefundRequestDto refundRequestDto = new RefundRequestDto();
            refundRequestDto.setPayWay(payWay);
            refundRequestDto.setTradeNo(tradeNo);
            refundRequestDto.setPayWay(refundNo);
            return refundQueryNew(refundRequestDto);
        }
        return ResultMap.error(-1, "下单失败");
    }

    /**
     * 查询订单
     * @param paymentRequestDto
     * @return
     */
    @Override
    public PaymentInfoResponseDto queryPaymentOrder(PaymentRequestDto paymentRequestDto) {
        if(null != paymentRequestDto){
            return queryPaymentOrderNew(paymentRequestDto);
        }
        return PaymentInfoResponseDto.error(-1, "下单失败");
    }
    @Deprecated
    @Override
    public ResultMap close(PaymentRequestDto paymentRequestDto) {
        if(null != paymentRequestDto){
            return closeNew(paymentRequestDto);
        }
        return ResultMap.error(-1, "下单失败");
    }
    @Deprecated
    @Override
    public ResultMap refund(RefundRequestDto refundRequestDto) {
        if(null != refundRequestDto){
            return refundNew(refundRequestDto);
        }
        return ResultMap.error(-1, "下单失败");
    }

    @Override
    public ResultMap refundQuery(RefundRequestDto refundRequestDto) {
        if(null != refundRequestDto){
            return refundQueryNew(refundRequestDto);
        }
        return ResultMap.error(-1, "下单失败");
    }

    /*********************新支付逻辑*******************/

    //获取银行列表
    public ResultMap getBankList(PaymentRequestDto paymentRequestDto){
        ResultMap resultMap = new ResultMap();
        try {
            String paymentType = paymentRequestDto.getPayWay();
            paymentRequestDto.setPayConfig(initPayConfig(paymentType));
            if (paymentType.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
                resultMap = baoFooBankPayService.getBankList(paymentRequestDto);
            } else {
                resultMap = ResultMap.error(-1, "不支持手机银行支付");
            }
        }catch (Exception e){
            e.printStackTrace();
            resultMap = ResultMap.error(-1, "下单失败");
        }
        return resultMap;
    }

    public ResultMap readPay(PaymentRequestDto paymentRequestDto){
        ResultMap resultMap = new ResultMap();
        try {
            String paymentType = paymentRequestDto.getPayWay();
            paymentRequestDto.setPayConfig(initPayConfig(paymentType));
            if (paymentType.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
                resultMap = bankService.ReadyPay(paymentRequestDto);
                resultMap.put("payWay","agreement");
            } else {
                Map<String ,String> header = new HashMap<>();
                header.put("Content-Type","application/json");
                //调用接口进行下单
                String readPayResult = HttpClientUtil.httpRequest(readPayUrl, "POST", JSONObject.toJSONString(paymentRequestDto), header);
                log.info(" 调用支付服务预下单 ",readPayResult);
//                resultMap = ResultMap.error(-1, "不支持该类型");
                resultMap = JSONObject.parseObject(readPayResult, ResultMap.class);
            }
        }catch (Exception e){
            e.printStackTrace();
            resultMap = ResultMap.error(-1, "下单失败");
        }
        return resultMap;
    }
    public ResultMap confirmPay(PaymentRequestDto paymentRequestDto){
        ResultMap resultMap = new ResultMap();
        try {
            String paymentType = paymentRequestDto.getPayWay();
            paymentRequestDto.setPayConfig(initPayConfig(paymentType));
            if (paymentType.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
                resultMap = bankService.ConfirmPay(paymentRequestDto);
            } else {
                resultMap = ResultMap.error(-1, "不支持该类型");
            }
        }catch (Exception e){
            e.printStackTrace();
            resultMap = ResultMap.error(-1, "下单失败");
        }
        return resultMap;
    }
    /**
     * 统一下单
     * 调用不同的支付方式
     * @param paymentRequestDto
     */
    @Override
    public ResultMap unifiedOrderNew(PaymentRequestDto paymentRequestDto){
        ResultMap resultMap = new ResultMap();
        try{
            RechargeUserInfoDto rechargeUserInfoDto = paymentRequestDto.getRechargeUserInfoDto();
            if( null != rechargeUserInfoDto && rechargeUserInfoDto.isCheckUserAuth()
                    && ( StringUtils.isEmpty(rechargeUserInfoDto.getUserName())
                    || StringUtils.isEmpty(rechargeUserInfoDto.getCertificateNo()))){
                //如果需要进行身份信息验证
                return ResultMap.error(100401, "请用户先进行身份验证！");
            }
            String paymentType = paymentRequestDto.getPayWay();
            /*if(null != paymentRequestDto.getMerchantId()){
                //如果有商家id
                MerchantDto merchantDto = sysBaseService.selectMerchantInfo(paymentRequestDto.getMerchantId());
                if(null != merchantDto && StringUtils.isNotEmpty( merchantDto.getPay_config())){
                    String[] split = merchantDto.getPay_config().split(",");
                    paymentType = split[0];
                    paymentRequestDto.setPayWay(paymentType);
                }
            }*/
            paymentRequestDto.setPayConfig(initPayConfig(paymentType));
            paymentRequestDto.setAppid(payConfig.getAppidByPayType(paymentType));
            //判断是否是直连 【默认备用为直连】
            if(paymentType.contains("alipay-spare")){
                paymentType = "alipay";
            }else if(paymentType.contains("wxpay-spare")){
                paymentType = "wxpay";
            }else
            if(paymentType.contains("alipay-web-spare")){
                paymentType = "alipay";
            }
            int payWay = 0;
            if (paymentType.contains("wxpay-hm")) { //杉德-微信
                resultMap = hmPayService.tradeCreateNew(paymentRequestDto);
                payWay = 3;
            } else if (paymentType.contains("alipay-hm")) { //杉德-支付宝
                resultMap = hmPayService.tradeCreateNew(paymentRequestDto);
                payWay = 4;
            } else if (paymentType.contains("alipay-applet-qm")) { //全民-支付宝调小程序
                resultMap = qmPayService.tradeCreateNew(paymentRequestDto);
                JSONObject appPayRequest = (JSONObject) resultMap.get("appPayRequest");
                appPayRequest.put("appScheme", "hobbystocks");
                resultMap.put("appPayRequest", appPayRequest);
                payWay = 7;
            } else if (paymentType.contains("alipay-qme1")) { //全民支付宝-易一
                paymentRequestDto.setPaySubWay("ALI_LITE_FACE");//⽀付宝⼩程序⾯对⾯
                resultMap = qme1PayService.tradeCreate(paymentRequestDto);
                payWay = 10;
            } else if (paymentType.contains("wxpay-main-bf")) { //宝付-微信-主扫
                resultMap = bfPayService.tradeCreateNew(paymentRequestDto);
                payWay = 9;
            } else if (paymentType.contains("alipay-main-bf")) { //宝付-支付宝-主扫
                resultMap = bfPayService.tradeCreateNew(paymentRequestDto);
                payWay = 10;
            } else if (paymentType.contains("uac-main-bf")) { //宝付-云闪付-主扫
                resultMap = bfPayService.tradeCreateNew(paymentRequestDto);
                payWay = 11;
            } else if (paymentType.contains("alipay-main-bof")) { //宝付-支付宝-主扫-bofoo
                paymentRequestDto.setPaySubWay(PayConstants.BFPAY_ALIPAY_NATIVE);
                resultMap = baoFooPayService.unifiedOrder(paymentRequestDto);
                payWay = 10;
            } else if (paymentType.contains("uac-main-bof")) { //宝付-云闪付-主扫-bofoo
                paymentRequestDto.setPaySubWay(PayConstants.BFPAY_QUICK_PASS_NATIVEE);
                resultMap = baoFooPayService.unifiedOrder(paymentRequestDto);
                payWay = 11;
            } else if (paymentType.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
                resultMap = baoFooBankPayService.unifiedOrder(paymentRequestDto);
                payWay = 18;
            } else if (paymentType.contains("recharge-alipay-baofoo")) { //宝付-钱包支付宝主扫支付-baofoo
                paymentRequestDto.setPaySubWay("ALIPAY_NATIVE");//支付包主扫
                resultMap = baofooRechargePayService.payment(paymentRequestDto);
                payWay = 10;
            } else if (paymentType.contains("recharge-bank-baofoo")) { //宝付-钱包余额银行卡支付-baofoo
//                paymentRequestDto.setPaySubWay("CARD");//银行卡支付
                resultMap = baofooRechargePayService.paymentSplitApi(paymentRequestDto);
                resultMap.put("payWay","webview");
                payWay = -1;
            } else if (paymentType.contains("alipay-qm-h5")) { //全民-支付宝h5
                resultMap = qmH5PayService.tradeCreateNew(paymentRequestDto);
                JSONObject qmH5PayRequest = (JSONObject) resultMap.get("appPayRequest");
                resultMap.put("qmH5PayRequest", qmH5PayRequest);
                payWay = 12;
            } else if (paymentType.contains("uac-qm-h5")) { //全民-云闪付h5
                resultMap = qmH5PayService.tradeCreateNew(paymentRequestDto);
                JSONObject uacH5PayRequest = (JSONObject) resultMap.get("appPayRequest");
                resultMap.put("qmUacH5Request", uacH5PayRequest);
                payWay = 13;
            } else if (paymentType.contains("wxpay-qm-h5")) { //全民-支付宝h5
                resultMap = qmH5PayService.tradeCreateNew(paymentRequestDto);
                JSONObject qmH5PayRequest = (JSONObject) resultMap.get("appPayRequest");
                resultMap.put("qmH5PayRequest", qmH5PayRequest);
                payWay = 15;
            } else if (paymentType.contains("uac-qm")) { //全民-云闪付
                resultMap = qmPayService.tradeCreateNew(paymentRequestDto);
                JSONObject uacPayRequest = (JSONObject) resultMap.get("appPayRequest");
                uacPayRequest.put("appScheme", "hobbystocks");
                resultMap.put("appPayRequest", uacPayRequest);
                payWay = 8;
            } else if (paymentType.contains("wxpay-qm")) { //全民-微信
                resultMap = qmPayService.tradeCreateNew(paymentRequestDto);
                payWay = 5;
            } else if (paymentType.contains("alipay-qm")) { //全民-支付宝
                resultMap = qmPayService.tradeCreateNew(paymentRequestDto);
                payWay = 6;
            } else if (paymentType.contains("alipay-hf") ) { //汇付-支付宝
                paymentRequestDto.setPayWay("alipay");
                resultMap = hfPayService.tradeCreate(paymentRequestDto);//需要在启动服务时加载配置，后续修改
                payWay = 14;
            } else if (paymentType.contains("alipay-web-spare") ) { //支付宝
                resultMap = alipayApiService.unifiedOrderNew(paymentRequestDto);
                paymentType = (String) resultMap.getOrDefault("paySubType", "alipay");
                payWay = 14;
            } else if ("wxpay".equals(paymentType)) { //微信
                resultMap = wxPayService.unifiedOrderNew(paymentRequestDto);
                paymentType = (String) resultMap.getOrDefault("paySubType", "wxpay");
                payWay = 1;
            } else if ("alipay".equals(paymentType)) { //支付宝
                resultMap = alipayApiService.unifiedOrderNew(paymentRequestDto);
                paymentType = (String) resultMap.getOrDefault("paySubType", "alipay");
                payWay = 2;
            } else {
                payWay = 0;
                paymentType = "";
                resultMap = ResultMap.error(-1, "未找到支付类型");
            }
            if(payWay > -1) resultMap.put("payWay", payWay);
            resultMap.put("paymentSubType", paymentType);
        }catch (Exception e){
            e.printStackTrace();
            resultMap = ResultMap.error(-1, "下单失败");
        }
        return resultMap;
    }

    /**
     * 查询订单
     * 调用不同的支付方式
     * @param payWay
     * @param orderNo
     */
    @Override
    public PaymentInfoResponseDto queryPaymentOrderNew(String payWay, String orderNo){
        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
        try{
            String appid = payConfig.getAppidByPayType(payWay);
            PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
            paymentRequestDto.setPayWay(payWay);
            paymentRequestDto.setAppid(appid);
            paymentRequestDto.setOrderNo(orderNo);
            //
            try{
                return queryPost(paymentRequestDto);
            }catch (Exception e){
                log.warn(" 不是新支付模块通道【查询订单】 ");
            }
            paymentRequestDto.setPayConfig(initPayConfig(payWay));//从数据库加载数据
            if (payWay.contains("wxpay-hm")) { //杉德-微信
                paymentInfoResponseDto = hmPayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("alipay-hm")) { //杉德-支付宝
                paymentInfoResponseDto = hmPayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("alipay-applet-qm")) { //全民-支付宝调小程序
                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("alipay-qme1")) { //全民支付宝-易一
                paymentRequestDto.setPaySubWay("ALI_LITE_FACE");//⽀付宝⼩程序⾯对⾯
                paymentInfoResponseDto = qme1PayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("uac-qm")) { //全民-云闪付
                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("wxpay-main-bf")) { //宝付-微信-主扫
                paymentInfoResponseDto = bfPayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("alipay-main-bf")) { //宝付-支付宝-主扫
                paymentInfoResponseDto = bfPayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("uac-main-bf")) { //宝付-云闪付-主扫
                paymentInfoResponseDto = bfPayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("alipay-qm-h5")) { //全民-h5
                paymentInfoResponseDto = qmH5PayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("uac-qm-h5")) { //全民-h5
                paymentInfoResponseDto = qmH5PayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("wxpay-qm")) { //全民-微信
                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("alipay-qm")) { //全民-支付宝
                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("alipay-hf")) { //汇付-支付宝
                paymentInfoResponseDto = hfPayService.queryOrder(appid, payWay, orderNo);//暂时不能优化， 需要找到解决办法
            } else if (payWay.contains("alipay-web-spare") ) { //支付宝
                paymentInfoResponseDto = alipayApiService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("alipay-main-bof")) { //宝付-支付宝-主扫-bofoo
                paymentInfoResponseDto = baoFooPayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("uac-main-bof")) { //宝付-云闪付-主扫-bofoo
                paymentInfoResponseDto = baoFooPayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
                paymentInfoResponseDto = baoFooBankPayService.queryOrder(paymentRequestDto);
            }else if (payWay.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
                paymentInfoResponseDto = bofooAgreementService.QueryOrder(paymentRequestDto);
            } else if (payWay.contains("recharge-alipay-baofoo")) { //宝付-钱包支付宝主扫支付-baofoo
                ResultMap resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
                if((boolean)resultMap.get("state")){
                    paymentInfoResponseDto.setOrderNo(paymentRequestDto.getOrderNo());
                    paymentInfoResponseDto.setPayWay(paymentRequestDto.getPayWay());
                    paymentInfoResponseDto.setPaymentNo(String.valueOf(resultMap.get("paymentNo")));
                    paymentInfoResponseDto.setPaymentPrice(new BigDecimal(String.valueOf(resultMap.get("paymentPrice"))));
                    paymentInfoResponseDto.setActualPayment(new BigDecimal(String.valueOf(resultMap.get("actualPayment"))));
                    paymentInfoResponseDto.setPaymentSuccessTime((Date) resultMap.get("paymentSuccessTime"));
                }else{
                    paymentInfoResponseDto = PaymentInfoResponseDto.error((Integer) resultMap.get("code"), String.valueOf(resultMap.get("msg")));
                }
            } else if (payWay.contains("recharge-bank-baofoo")) { //宝付-钱包余额银行卡支付-baofoo
                ResultMap resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
                if((boolean)resultMap.get("state")){
                    paymentInfoResponseDto.setOrderNo(paymentRequestDto.getOrderNo());
                    paymentInfoResponseDto.setPayWay(paymentRequestDto.getPayWay());
                    paymentInfoResponseDto.setPaymentNo(String.valueOf(resultMap.get("paymentNo")));
                    paymentInfoResponseDto.setPaymentPrice(new BigDecimal(String.valueOf(resultMap.get("paymentPrice"))));
                    paymentInfoResponseDto.setActualPayment(new BigDecimal(String.valueOf(resultMap.get("actualPayment"))));
                    paymentInfoResponseDto.setPaymentSuccessTime((Date) resultMap.get("paymentSuccessTime"));
                }else{
                    paymentInfoResponseDto = PaymentInfoResponseDto.error((Integer) resultMap.get("code"), String.valueOf(resultMap.get("msg")));
                }
            } else  if ("wxpay".equals(payWay)) { //微信
                paymentInfoResponseDto = wxPayService.queryOrder(paymentRequestDto);
            } else if ("alipay".equals(payWay)) { //支付宝
                paymentInfoResponseDto = alipayApiService.queryOrder(paymentRequestDto);
            } else {
                paymentInfoResponseDto = paymentInfoResponseDto.error(-1, "未找到支付类型");
            }
        }catch (Exception e){
            e.printStackTrace();
            paymentInfoResponseDto = paymentInfoResponseDto.error(-1, "下单失败");
        }
        return paymentInfoResponseDto;
    }

    /**
     * 退款
     * 调用不同的支付方式
     * @param payWay
     * @param orderNo
     * @param refundAmount
     * @param refundMsg
     * @return
     */
    @Override
    @Deprecated
    public ResultMap refundNew(String payWay, String orderNo, BigDecimal orderPrice, BigDecimal refundAmount,String refundMsg){
        ResultMap resultMap = new ResultMap();
//        Map<String, Object> refundParam = new HashMap<>();
        RefundRequestDto refundRequestDto = new RefundRequestDto();
        refundRequestDto.setRefundNo(RandomUtil.getRandom(RandomUtil.REFUND_NO));
        refundRequestDto.setOrderNo(orderNo);
        refundRequestDto.setPayWay(payWay);
        refundRequestDto.setOrderPrice(orderPrice);
        refundRequestDto.setRefundAmount(refundAmount);
        refundRequestDto.setRefundMsg(refundMsg);
        refundRequestDto.setTradeNo(orderNo);
        refundRequestDto.setPayConfig(initPayConfig(payWay));
        try{
            String appid = payConfig.getAppidByPayType(payWay);
            if (payWay.contains("wxpay-hm") ) { //杉德-微信
//                refundParam.put("totalAmount", refundAmount);
//                refundParam.put("orderNo", orderNo);
//                refundParam.put("refund_request_no", RandomUtil.getRandom(RandomUtil.REFUND_NO));
//                refundParam.put("refundMsg", refundMsg);
                resultMap = hmPayService.refundOrder(refundRequestDto);
            } else if (payWay.contains("alipay-hm" )) { //杉德-支付宝
//                refundParam.put("totalAmount", refundAmount);
//                refundParam.put("orderNo", orderNo);
//                refundParam.put("refund_request_no", RandomUtil.getRandom(RandomUtil.REFUND_NO));
//                refundParam.put("refundMsg", refundMsg);
                resultMap = hmPayService.refundOrder(refundRequestDto);
            } else if (payWay.contains("alipay-applet-qm" )) { //全民-支付宝调小程序
                resultMap = qmPayService.refund(refundRequestDto);
            } else if (payWay.contains("wxpay-main-bf" )) { //宝付-微信-主扫
                resultMap = bfPayService.refund(refundRequestDto);
            } else if (payWay.contains("alipay-main-bf" )) { //宝付-支付宝-主扫
                resultMap = bfPayService.refund(refundRequestDto);
            } else if (payWay.contains("uac-main-bf" )) { //宝付-云闪付-主扫
                resultMap = bfPayService.refund(refundRequestDto);
            } else if (payWay.contains("alipay-qm-h5" )) { //全民-h5
                resultMap = qmH5PayService.refund(refundRequestDto);
            } else if (payWay.contains("uac-qm-h5" )) { //全民-h5
                resultMap = qmH5PayService.refund(refundRequestDto);
            } else if (payWay.contains("alipay-qme1")) { //全民支付宝-易一
                resultMap = qme1PayService.refund(refundRequestDto);
            } else if (payWay.contains("wxpay-qm" )) { //全民-微信
                resultMap = qmPayService.refund(refundRequestDto);
            } else if (payWay.contains("alipay-qm" )) { //全民-支付宝
                resultMap = qmPayService.refund(refundRequestDto);
            } else if (payWay.contains("uac-qm" )) { //全民-云闪付
                resultMap = qmPayService.refund(refundRequestDto);
            } else if (payWay.contains("alipay-hf" )) { //汇付-支付宝
                resultMap = hfPayService.refund(refundRequestDto);
            } else if (payWay.contains("alipay-web-spare") ) { //支付宝
                resultMap = alipayApiService.aliRefundNotify(refundRequestDto);
            } else if (payWay.contains("alipay-main-bof")) { //宝付-支付宝-主扫-bofoo
                resultMap = baoFooPayService.refund(refundRequestDto);
            } else if (payWay.contains("uac-main-bof")) { //宝付-云闪付-主扫-bofoo
                resultMap = baoFooPayService.refund(refundRequestDto);
            } else if (payWay.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
                resultMap = baoFooBankPayService.refund(refundRequestDto);
            }else if (payWay.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
                resultMap = bofooAgreementService.OrderRefund(refundRequestDto);
            }else if (payWay.contains("recharge-alipay-baofoo")) { //宝付-钱包支付宝主扫支付-baofoo
                resultMap = baofooRechargePayService.profitShareRefundApply(refundRequestDto);
            }else if (payWay.contains("recharge-bank-baofoo")) { //宝付-钱包余额银行卡支付-baofoo
                resultMap = baofooRechargePayService.profitShareRefundApply(refundRequestDto);
            } else if ("wxpay".equals(payWay)) { //微信
                resultMap = wxPayService.wxRefund(refundRequestDto);
            } else if ("alipay".equals(payWay)) { //支付宝
                resultMap = alipayApiService.aliRefundNotify(refundRequestDto);
            } else {
                resultMap = resultMap.error(-1, "未找到支付类型");
            }
        }catch (Exception e){
            e.printStackTrace();
            resultMap = resultMap.error(-1, "下单失败");
        }
        return resultMap;
    }

    /**
     * 关闭订单
     * @param payWay
     * @param orderNo
     * @return
     */
    @Override
    public ResultMap closeNew(String payWay, String orderNo){
        ResultMap resultMap = new ResultMap();
        try{
            String appid = payConfig.getAppidByPayType(payWay);
            PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
            paymentRequestDto.setPayWay(payWay);
            paymentRequestDto.setOrderNo(orderNo);
            paymentRequestDto.setPayConfig(initPayConfig(payWay));
            paymentRequestDto.setAppid(payConfig.getAppidByPayType(payWay));
            //杉德-微信
            //杉德-支付宝
            if ("wxpay".equals(payWay)) { //微信
                resultMap = wxPayService.closeOrderNew(appid, orderNo);
            } else if ("alipay".equals(payWay)) { //支付宝
                resultMap = alipayApiService.closeTradeOrderNew(appid, orderNo);
            } else if ("wxpay-hm".equals(payWay)) {
            } else if ("alipay-hm".equals(payWay)) {
            } else if (payWay.contains("alipay-applet-qm" )) { //全民-支付宝调小程序
                resultMap = qmPayService.colseNew(paymentRequestDto);
            } else if ("alipay-qm-h5".equals(payWay)) { //全民-h5
                resultMap = qmH5PayService.colse(appid, payWay, orderNo);
            } else if ("uac-qm-h5".equals(payWay)) { //全民-h5
                resultMap = qmH5PayService.colse(appid, payWay, orderNo);
            } else if ("wxpay-qm".equals(payWay)) { //全民-微信
                resultMap = qmPayService.colse(appid, payWay, orderNo);
            } else if ("alipay-qm".equals(payWay)) { //全民-支付宝
                resultMap = qmPayService.colse(appid, payWay, orderNo);
            } else if (payWay.contains("uac-qm" )) { //全民-云闪付
                resultMap = qmPayService.colseNew(paymentRequestDto);
            } else if ("alipay-hf".equals(payWay)) { //汇付-支付宝
                resultMap = hfPayService.close(paymentRequestDto);
            } else {
                resultMap = resultMap.error(-1, "未找到支付类型");
            }
        }catch (Exception e){
            e.printStackTrace();
            resultMap = resultMap.error(-1, "下单失败");
        }
        return resultMap;
    }

    /**
     * 查询退款订单
     * @param payWay
     * @param tradeNo
     * @param refundNo
     * @return
     */
    @Override
    public ResultMap refundQueryNew(String payWay,String tradeNo ,String refundNo){
        ResultMap resultMap = new ResultMap();
        try{
            String appid = payConfig.getAppidByPayType(payWay);
            RefundRequestDto refundRequestDto = new RefundRequestDto();
            refundRequestDto.setAppid(appid);
            refundRequestDto.setPayWay(payWay);
            refundRequestDto.setRefundNo(refundNo);
            refundRequestDto.setTradeNo(tradeNo);
            refundRequestDto.setMerOrderId(tradeNo);
            refundRequestDto.setPayConfig(initPayConfig(payWay));
            //微信
            //支付宝
            //杉德-微信
            //杉德-支付宝
            if (payWay.contains("wxpay-hm")) {
                resultMap = resultMap.error(-1, "不支持退款查询");
            } else if (payWay.contains("alipay-hm" )) {
                resultMap = resultMap.error(-1, "不支持退款查询");
            } else if (payWay.contains("alipay-applet-qm" )) { //全民-支付宝调小程序
                resultMap = qmPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("wxpay-main-bf" )) { //宝付-微信-主扫
                resultMap = bfPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("alipay-main-bf" )) { //宝付-支付宝-主扫
                resultMap = bfPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("uac-main-bf" )) { //宝付-云闪付-主扫
                resultMap = bfPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("alipay-qm-h5" )) { //全民-h5
                resultMap = qmH5PayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("uac-qm-h5" )) { //全民-h5
                resultMap = qmH5PayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("alipay-qme1")) { //全民支付宝-易一
                resultMap = qme1PayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("wxpay-qm" )) { //全民-微信
                resultMap = qmPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("alipay-qm" )) { //全民-支付宝
                resultMap = qmPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("uac-qm" )) { //全民-云闪付
                resultMap = qmPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("alipay-hf" )) { //汇付-支付宝
                resultMap = hfPayService.queryRefund(refundRequestDto);
            } else if (payWay.contains("alipay-main-bof")) { //宝付-支付宝-主扫-bofoo
                resultMap = baoFooPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("uac-main-bof")) { //宝付-云闪付-主扫-bofoo
                resultMap = baoFooPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
                resultMap = baoFooBankPayService.refundQuery(refundRequestDto);
            }else if (payWay.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
                resultMap = bofooAgreementService.queryRefund(refundRequestDto);
            } else if (payWay.contains("recharge-alipay-baofoo")) { //宝付-钱包支付宝主扫支付-baofoo
                PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
                paymentRequestDto.setPayConfig(refundRequestDto.getPayConfig());
                paymentRequestDto.setOrderNo(refundNo);
                resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("recharge-bank-baofoo")) { //宝付-钱包余额银行卡支付-baofoo
                PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
                paymentRequestDto.setPayConfig(refundRequestDto.getPayConfig());
                paymentRequestDto.setOrderNo(refundNo);
                resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("alipay-web-spare") ) { //支付宝
                resultMap = resultMap.error(-1, "不支持退款查询");
            } else if ("wxpay".equals(payWay)) {
                resultMap = resultMap.error(-1, "不支持退款查询");
            } else if ("alipay".equals(payWay)) {
                resultMap = alipayApiService.queryRefundOrder(refundRequestDto);
//                resultMap = resultMap.error(-1, "不支持退款查询");
            } else {
                resultMap = resultMap.error(-1, "未找到支付类型");
            }
        }catch (Exception e){
            e.printStackTrace();
            resultMap = resultMap.error(-1, "下单失败");
        }
        return resultMap;
    }

    /**
     * 查询订单
     * @param paymentRequestDto
     * @return
     */
    @Override
    public PaymentInfoResponseDto queryPaymentOrderNew(PaymentRequestDto paymentRequestDto) {
        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
        try{
            String payWay = paymentRequestDto.getPayWay();
            paymentRequestDto.setPayConfig(initPayConfig(payWay));//从数据库加载数据
            if (payWay.contains("wxpay-hm")) { //杉德-微信
                paymentInfoResponseDto = hmPayService.queryOrder(paymentRequestDto);
            } else if ("alipay-hm".equals(payWay)) { //杉德-支付宝
                paymentInfoResponseDto = hmPayService.queryOrder(paymentRequestDto);
            } else if ("alipay-applet-qm".equals(payWay)) { //全民-支付宝调小程序
                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
            } else if ("wxpay-main-bf".equals(payWay)) { //宝付-微信-主扫
                paymentInfoResponseDto = bfPayService.queryOrder(paymentRequestDto);
            } else if ("alipay-main-bf".equals(payWay)) { //宝付-支付宝-主扫
                paymentInfoResponseDto = bfPayService.queryOrder(paymentRequestDto);
            } else if ("uac-main-bf".equals(payWay)) { //宝付-云闪付-主扫
                paymentInfoResponseDto = bfPayService.queryOrder(paymentRequestDto);
            } else if ("alipay-qm-h5".equals(payWay)) { //全民-h5
                paymentInfoResponseDto = qmH5PayService.queryOrder(paymentRequestDto);
            } else if ("uac-qm-h5".equals(payWay)) { //全民-h5
                paymentInfoResponseDto = qmH5PayService.queryOrder(paymentRequestDto);
            } else if ("wxpay-qm".equals(payWay)) { //全民-微信
                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
            } else if ("alipay-qm".equals(payWay)) { //全民-支付宝
                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
            } else if ("uac-qm".equals(payWay)) { //全民-云闪付
                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("alipay-web-spare") ) { //支付宝
                paymentInfoResponseDto = alipayApiService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("alipay-main-bof")) { //宝付-支付宝-主扫-bofoo
                paymentInfoResponseDto = baoFooPayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("uac-main-bof")) { //宝付-云闪付-主扫-bofoo
                paymentInfoResponseDto = baoFooPayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
                paymentInfoResponseDto = baoFooBankPayService.queryOrder(paymentRequestDto);
            }else if (payWay.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
                paymentInfoResponseDto = bofooAgreementService.QueryOrder(paymentRequestDto);
            } else if (payWay.contains("recharge-alipay-baofoo")) { //宝付-钱包支付宝主扫支付-baofoo
                ResultMap resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
                if((boolean)resultMap.get("state")){
                    paymentInfoResponseDto.setOrderNo(paymentRequestDto.getOrderNo());
                    paymentInfoResponseDto.setPayWay(paymentRequestDto.getPayWay());
                    paymentInfoResponseDto.setPaymentNo(String.valueOf(resultMap.get("paymentNo")));
                    paymentInfoResponseDto.setPaymentPrice(new BigDecimal(String.valueOf(resultMap.get("paymentPrice"))));
                    paymentInfoResponseDto.setActualPayment(new BigDecimal(String.valueOf(resultMap.get("actualPayment"))));
                    paymentInfoResponseDto.setPaymentSuccessTime((Date) resultMap.get("paymentSuccessTime"));
                }else{
                    paymentInfoResponseDto = PaymentInfoResponseDto.error((Integer) resultMap.get("code"), String.valueOf(resultMap.get("msg")));
                }
            } else if (payWay.contains("recharge-bank-baofoo")) { //宝付-钱包余额银行卡支付-baofoo
                ResultMap resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
                if((boolean)resultMap.get("state")){
                    paymentInfoResponseDto.setOrderNo(paymentRequestDto.getOrderNo());
                    paymentInfoResponseDto.setPayWay(paymentRequestDto.getPayWay());
                    paymentInfoResponseDto.setPaymentNo(String.valueOf(resultMap.get("paymentNo")));
                    paymentInfoResponseDto.setPaymentPrice(new BigDecimal(String.valueOf(resultMap.get("paymentPrice"))));
                    paymentInfoResponseDto.setActualPayment(new BigDecimal(String.valueOf(resultMap.get("actualPayment"))));
                    paymentInfoResponseDto.setPaymentSuccessTime((Date) resultMap.get("paymentSuccessTime"));
                }else{
                    paymentInfoResponseDto = PaymentInfoResponseDto.error((Integer) resultMap.get("code"), String.valueOf(resultMap.get("msg")));
                }
            } else  if ("wxpay".equals(payWay)) { //微信
                paymentInfoResponseDto = wxPayService.queryOrder(paymentRequestDto);
            } else if ("alipay".equals(payWay)) { //支付宝
                paymentInfoResponseDto = alipayApiService.queryOrder(paymentRequestDto);
            } else{
                paymentInfoResponseDto = paymentInfoResponseDto.error(-1, "未找到支付类型");
            }
        }catch (Exception e){
            e.printStackTrace();
            paymentInfoResponseDto = paymentInfoResponseDto.error(-1, "下单失败");
        }
        return paymentInfoResponseDto;
    }

    @Override
    public ResultMap closeNew(PaymentRequestDto paymentRequestDto) {
        ResultMap resultMap = new ResultMap();
        try{
            String payWay = paymentRequestDto.getPayWay();
            String orderNo = paymentRequestDto.getOrderNo();
            String appid = paymentRequestDto.getAppid();
            switch (payWay) {
                case "wxpay": //微信
                    resultMap = wxPayService.closeOrderNew(appid,orderNo);
                    break;
                case "alipay": //支付宝
                    resultMap = alipayApiService.closeTradeOrderNew(appid,orderNo);
                    break;
                case "wxpay-hm": //杉德-微信
                    break;
                case "alipay-hm": //杉德-支付宝
                    break;
                case "uac-qm1": //全民-云闪付
                    resultMap = qmPayService.colse(appid,payWay, orderNo);
                    break;
                case "uac-qm2": //全民-云闪付
                    resultMap = qmPayService.colse(appid,payWay, orderNo);
                    break;
                case "alipay-applet-qm": //全民-支付宝调小程序
                    resultMap = qmPayService.colse(appid,payWay, orderNo);
                    break;
                case "alipay-qm-h5": //全民-h5
                    resultMap = qmH5PayService.colse(appid,payWay, orderNo);
                    break;
                case "wxpay-qm": //全民-微信
                    resultMap = qmPayService.colse(appid,payWay, orderNo);
                    break;
                case "alipay-qm": //全民-支付宝
                    resultMap = qmPayService.colse(appid,payWay, orderNo);
                    break;
                case "uac-qm": //全民-云闪付
                    resultMap = qmPayService.colse(appid,payWay, orderNo);
                    break;
                default:
                    resultMap = resultMap.error(-1,"未找到支付类型");
                    break;
            }
        }catch (Exception e){
            e.printStackTrace();
            resultMap = resultMap.error(-1, "下单失败");
        }
        return resultMap;
    }

    @Override
    public ResultMap refundNew(RefundRequestDto refundRequestDto) {
        ResultMap resultMap = new ResultMap();
        Map<String, Object> refundParam = new HashMap<>();
        try{
            String payWay = refundRequestDto.getPayWay();
            refundRequestDto.setPayConfig(initPayConfig(refundRequestDto.getPayWay()));
            refundRequestDto.setRefundNo(RandomUtil.getRandom(RandomUtil.REFUND_NO));
            refundRequestDto.setTradeNo(StringUtils.isNotEmpty(refundRequestDto.getTradeNo())? refundRequestDto.getTradeNo() : refundRequestDto.getOrderNo());
            //
            try{
                return refundPost(refundRequestDto);
            }catch (Exception e){
                log.warn(" 不是新支付模块通道【退款】 ");
            }

            if (payWay.contains("wxpay-hm") ) { //杉德-微信
//                refundParam.put("totalAmount", refundAmount);
//                refundParam.put("orderNo", orderNo);
//                refundParam.put("refund_request_no", RandomUtil.getRandom(RandomUtil.REFUND_NO));
//                refundParam.put("refundMsg", refundMsg);
                resultMap = hmPayService.refundOrder(refundRequestDto);
            } else if (payWay.contains("alipay-hm" )) { //杉德-支付宝
//                refundParam.put("totalAmount", refundAmount);
//                refundParam.put("orderNo", orderNo);
//                refundParam.put("refund_request_no", RandomUtil.getRandom(RandomUtil.REFUND_NO));
//                refundParam.put("refundMsg", refundMsg);
                resultMap = hmPayService.refundOrder(refundRequestDto);
            } else if (payWay.contains("wxpay-qm" )) { //全民-微信
                resultMap = qmPayService.refund(refundRequestDto);
            } else if (payWay.contains("alipay-qm" )) { //全民-支付宝
                resultMap = qmPayService.refund(refundRequestDto);
            } else if (payWay.contains("uac-qm" )) { //全民-云闪付
                resultMap = qmPayService.refund(refundRequestDto);
            } else if (payWay.contains("alipay-applet-qm" )) { //全民-支付宝调小程序
                resultMap = qmPayService.refund(refundRequestDto);
            } else if (payWay.contains("wxpay-main-bf" )) { //宝付-微信-主扫
                resultMap = bfPayService.refund(refundRequestDto);
            } else if (payWay.contains("alipay-main-bf" )) { //宝付-支付宝-主扫
                resultMap = bfPayService.refund(refundRequestDto);
            } else if (payWay.contains("uac-main-bf" )) { //宝付-云闪付-主扫
                resultMap = bfPayService.refund(refundRequestDto);
            } else if (payWay.contains("alipay-qm-h5" )) { //全民-h5
                resultMap = qmH5PayService.refund(refundRequestDto);
            } else if (payWay.contains("uac-qm-h5" )) { //全民-h5
                resultMap = qmH5PayService.refund(refundRequestDto);
            } else if (payWay.contains("alipay-hf" )) { //汇付-支付宝
                resultMap = hfPayService.refund(refundRequestDto);
            } else if (payWay.contains("alipay-web-spare") ) { //支付宝
                resultMap = alipayApiService.aliRefundNotify(refundRequestDto);
            } else if (payWay.contains("alipay-main-bof")) { //宝付-支付宝-主扫-bofoo
                resultMap = baoFooPayService.refund(refundRequestDto);
            } else if (payWay.contains("uac-main-bof")) { //宝付-云闪付-主扫-bofoo
                resultMap = baoFooPayService.refund(refundRequestDto);
            } else if (payWay.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
                resultMap = baoFooBankPayService.refund(refundRequestDto);
            }else if (payWay.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
                resultMap = bofooAgreementService.OrderRefund(refundRequestDto);
            }else if (payWay.contains("recharge-alipay-baofoo")) { //宝付-钱包支付宝主扫支付-baofoo
                resultMap = baofooRechargePayService.profitShareRefundApply(refundRequestDto);
            }else if (payWay.contains("recharge-bank-baofoo")) { //宝付-钱包余额银行卡支付-baofoo
                resultMap = baofooRechargePayService.profitShareRefundApply(refundRequestDto);
            } else if ("wxpay".equals(payWay)) { //微信
                resultMap = wxPayService.wxRefund(refundRequestDto);
            } else if ("alipay".equals(payWay)) { //支付宝
                resultMap = alipayApiService.aliRefundNotify(refundRequestDto);
            } else {
                resultMap = resultMap.error(-1, "未找到支付类型");
            }
        }catch (Exception e){
            e.printStackTrace();
            resultMap = resultMap.error(-1, "下单失败");
        }
        return resultMap;
    }

    @Override
    public ResultMap refundQueryNew(RefundRequestDto refundRequestDto) {
        ResultMap resultMap = new ResultMap();
        try{
            String payWay = refundRequestDto.getPayWay();
            PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
            refundRequestDto.setPayConfig(initPayConfig(payWay));
            //杉德-微信
            //杉德-支付宝
            if (payWay.contains("wxpay-hm")) {
                resultMap = resultMap.error(-1, "不支持退款查询");
            } else if (payWay.contains("alipay-hm" )) {
                resultMap = resultMap.error(-1, "不支持退款查询");
            } else if (payWay.contains("wxpay-qm" )) { //全民-微信
                resultMap = qmPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("alipay-qm" )) { //全民-支付宝
                resultMap = qmPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("uac-qm" )) { //全民-云闪付
                resultMap = qmPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("alipay-applet-qm" )) { //全民-支付宝调小程序
                resultMap = qmPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("wxpay-main-bf" )) { //宝付-微信-主扫
                resultMap = bfPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("alipay-main-bf" )) { //宝付-支付宝-主扫
                resultMap = bfPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("uac-main-bf" )) { //宝付-云闪付-主扫
                resultMap = bfPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("alipay-main-bof")) { //宝付-支付宝-主扫-bofoo
                resultMap = baoFooPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("uac-main-bof")) { //宝付-云闪付-主扫-bofoo
                resultMap = baoFooPayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
                resultMap = baoFooBankPayService.refundQuery(refundRequestDto);
            }else if (payWay.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
                resultMap = bofooAgreementService.queryRefund(refundRequestDto);
            } else if (payWay.contains("recharge-alipay-baofoo")) { //宝付-钱包支付宝主扫支付-baofoo
                PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
                paymentRequestDto.setPayConfig(refundRequestDto.getPayConfig());
                resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("recharge-bank-baofoo")) { //宝付-钱包余额银行卡支付-baofoo
                PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
                paymentRequestDto.setPayConfig(refundRequestDto.getPayConfig());
                resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
            } else if (payWay.contains("alipay-qm-h5" )) { //全民-h5
                resultMap = qmH5PayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("uac-qm-h5" )) { //全民-h5
                resultMap = qmH5PayService.refundQuery(refundRequestDto);
            } else if (payWay.contains("alipay-hf" )) { //汇付-支付宝
                resultMap = hfPayService.queryRefund(refundRequestDto);
            } else if (payWay.contains("alipay-web-spare") ) { //支付宝
                resultMap = resultMap.error(-1, "不支持退款查询");
            } else if ("wxpay".equals(payWay)) {
                resultMap = resultMap.error(-1, "不支持退款查询");
            } else if ("alipay".equals(payWay)) {
                resultMap = alipayApiService.queryRefundOrder(refundRequestDto);
//                resultMap = resultMap.error(-1, "不支持退款查询");
            } else {
                resultMap = resultMap.error(-1, "未找到支付类型");
            }
        }catch (Exception e){
            e.printStackTrace();
            resultMap = resultMap.error(-1, "下单失败");
        }
        return resultMap;
    }
}
