package com.neusoft.smart.pos.payment.service;

import com.alibaba.fastjson.JSON;
import com.neusoft.smart.pos.constants.DictionaryConstant;
import com.neusoft.smart.pos.dto.payment.request.*;
import com.neusoft.smart.pos.dto.payment.response.*;
import com.neusoft.smart.pos.framework.exception.BusinessCommonException;
import com.neusoft.smart.pos.framework.utils.*;
import com.neusoft.smart.pos.payment.constants.PaymentConstants;
import com.neusoft.smart.pos.payment.constants.PaymentErrorCode;
import com.neusoft.smart.pos.payment.persistent.domain.PayOrder;
import com.neusoft.smart.pos.payment.persistent.ext.domain.ThirdPlatformInitFacePay;
import com.neusoft.smart.pos.payment.repository.*;
import com.neusoft.smart.pos.payment.utils.LogUtils;
import lombok.val;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


@Service("payService")
public class PayService {

    private final static Logger logger = LoggerFactory.getLogger(PayService.class);

	@Autowired
    private MchPayChannelRepository mchPayChannelRepository;

    @Autowired
    private PayOrderRepository payOrderRepository;

    @Autowired
    private PayTypeDictRepository payTypeDictRepository;

    @Autowired
    private MchPayInfoRepository mchPayInfoRepository;

    /**
     * 第三方支付单生成方法
     * @return
     */
    public PostGenerateOrderResponse createPayOrder(PostGenerateOrderRequest payOrderRequest) {
        logger.info("enter createPayOrder");
        //1.根据商户号查询商户信息
        val mchPayInfo = mchPayInfoRepository.queryMchPayInfoByMcode(payOrderRequest.getMcode(),DictionaryConstant.PAYMENT_MCH_STATUS_SHTG.getCode());
        if(null == mchPayInfo){
            throw new BusinessCommonException(PaymentErrorCode.MCH_INFO_NOT_EXIST);
        }
        logger.info("createPayOrder::11111");

        //2.校验签名信息
        if(!SignUtils.isSignatureValid(MapBeanUtils.beanToMap(payOrderRequest),mchPayInfo.getSecretKey())){
            throw new BusinessCommonException(PaymentErrorCode.SIGN_VALID_ERROR);
        }
        logger.info("createPayOrder::22222");

        //3.校验订单失效时间是否合法，订单失效时间至少与当前时间间隔5分钟,如何为空则默认设置为2小时
        if(StringUtils.isEmpty(payOrderRequest.getTimeExpire())){
            String localDateTime = LocalDateTimeUtils.convertLocalDateTimeToString(LocalDateTimeUtils.plusMinutes(LocalDateTimeUtils.getNow(), PaymentConstants.DEFAULT_TIME_EXPIRE),LocalDateTimeUtils.SIMPLE_DATETIME_FORMAT);
            payOrderRequest.setTimeExpire(localDateTime);
        }else{
            val betweenMinutes = LocalDateTimeUtils.betweenNowMinutes(LocalDateTimeUtils.convertStringToLocalDateTime(payOrderRequest.getTimeExpire(),LocalDateTimeUtils.SIMPLE_DATETIME_FORMAT));
            if(betweenMinutes < 5){
                throw new BusinessCommonException(PaymentErrorCode.MCH_ORDER_TIME_EXPIRE_TOO_SHORT);
            }
        }
        logger.info("createPayOrder::33333");

        //4.整理支付平台预付单信息
        val tradeId = IdGenerateUtils.generateTradeId();    //当前时间毫秒数+5位随机数
        val payOrder = payOrderDataHandle(tradeId,payOrderRequest);

        logger.info("createPayOrder::44444:Mcode="+payOrder.getMcode()+",PayType="+payOrder.getPayType());
        //5.校验支付成功回调url
        val mchPayChannel = mchPayChannelRepository.queryMchPayChannelByMcodeWithBlob(payOrder.getMcode(),payOrder.getPayType());
        if(null == mchPayChannel){
            throw new BusinessCommonException(PaymentErrorCode.MCH_THIRD_PLATFORM_NOT_CONFIG);
        }
        logger.info("createPayOrder::55555");

        //6.生成第三方支付平台预付单信息
        if(StringUtils.isEmpty(mchPayChannel.getNotifyUrl()) && StringUtils.isEmpty(payOrder.getNotifyUrl())){
            throw new BusinessCommonException(PaymentErrorCode.MCH_NOTIFY_URL_EMPTY);
        }else if(StringUtils.isEmpty(payOrder.getNotifyUrl())){
            payOrder.setNotifyUrl(mchPayChannel.getNotifyUrl());
        }
        logger.info("createPayOrder::66666");
        val payTypeDict = payTypeDictRepository.queryEnablePayTypeDict(payOrder.getPayType());
        //根据BeanName获取spring实现类
        val thirdPayRepository = SpringUtils.getBean(payTypeDict.getBeanName(),IThirdPayRepository.class);
        val thirdPlatformOrder = thirdPayRepository.createPayOrderToThirdPlatform(payOrder,mchPayChannel,payTypeDict);

        logger.info("createPayOrder::77777");
        //7.根据第三方平台预付单信息更新支付平台预付单信息
        payOrder.setOuterOrderNumber(thirdPlatformOrder.getOuterOrderNumber());
        payOrder.setCodeUrl(thirdPlatformOrder.getOuterCodeUrl());
//        payOrder.setOrderStatus(thirdPlatformOrder.getPayStatus());
        payOrderRepository.createPayOrder(payOrder);
        logger.info("createPayOrder::88888");

        // added by cy start 如果付款状态为已付款，更新数据库
        if(thirdPlatformOrder.getPayStatus().equals(DictionaryConstant.PAY_STATUS_YFK.getCode())) {
            payOrder.setPayStatus(DictionaryConstant.PAY_STATUS_YFK.getCode());
            payOrderRepository.updatePayOrder(payOrder.getMcode(),payOrder.getTradeId(),payOrder.getmOrderNumber(),payOrder);
        }
        // added by cy end

        //8.整理返回数据并记录相关日志，异常信息可不记录日志，在日志文件中可查看
        val postGenerateOrderResponse = new PostGenerateOrderResponse(thirdPlatformOrder.getMcode(),payOrderRequest.getPayType(),thirdPlatformOrder.getOuterCodeUrl(),payOrderRequest.getTimeExpire(),tradeId,thirdPlatformOrder.getOuterOrderNumber(),thirdPlatformOrder.getMOrderNumber(),thirdPlatformOrder.getPayStatus());
        val sign = SignUtils.generateSign(MapBeanUtils.beanToMap(postGenerateOrderResponse),mchPayInfo.getSecretKey());
        postGenerateOrderResponse.setSign(sign);
        LogUtils.saveMchPaymentTradeLog(thirdPlatformOrder.getMcode(),thirdPlatformOrder.getMOrderNumber(),payOrder.getPayType(),LogUtils.LOG_DESCRIPTION_DDSC,JSON.toJSONString(postGenerateOrderResponse), JSON.toJSONString(payOrderRequest),DictionaryConstant.PAYMENT_REQUEST_TYPE_BD.getCode());
        return postGenerateOrderResponse;
    }

    /**
     * 生成聚合平台预付单信息
     * @param tradeId
     * @param payOrderRequest
     */
    private PayOrder payOrderDataHandle(String tradeId, PostGenerateOrderRequest payOrderRequest){
        //1.查询业务订单是否已经生成
        val payOrderTemp = payOrderRepository.queryPayOrder(payOrderRequest.getMcode(),payOrderRequest.getOrderNumber(),payOrderRequest.getPayType());
        if(null != payOrderTemp){
            throw new BusinessCommonException(PaymentErrorCode.MCH_ORDER_REPEAT);
        }
        //2.整理订单数据
        val payOrder = new PayOrder();
        BeanUtils.copyProperties(payOrderRequest,payOrder);
        payOrder.setmOrderNumber(payOrderRequest.getOrderNumber());
        payOrder.setTradeId(tradeId);
        payOrder.setPayIp(payOrderRequest.getIp());
        return payOrder;
    }

    /**
     * 订单信息查询使用方法
     * @param queryOrderRequest
     * @return
     */
    public PostQueryOrderResponse queryOrder(PostQueryOrderRequest queryOrderRequest){
        //1.查询商户号信息
        val mchPayInfo = mchPayInfoRepository.queryMchPayInfoByMcode(queryOrderRequest.getMcode(),DictionaryConstant.PAYMENT_MCH_STATUS_SHTG.getCode());
        if(null == mchPayInfo){
            throw new BusinessCommonException(PaymentErrorCode.MCH_INFO_NOT_EXIST);
        }

        //2.校验签名信息
        if(!SignUtils.isSignatureValid(MapBeanUtils.beanToMap(queryOrderRequest),mchPayInfo.getSecretKey())){
            throw new BusinessCommonException(PaymentErrorCode.SIGN_VALID_ERROR);
        }
        //3.查询聚合支付平台预付单信息
        val payOrder = payOrderRepository.queryPayOrder(queryOrderRequest.getMcode(),queryOrderRequest.getOrderNumber(),queryOrderRequest.getPayType());

        //4.查询第三方支付平台预付单信息
        val mchPayChannel = mchPayChannelRepository.queryMchPayChannelByMcodeWithBlob(queryOrderRequest.getMcode(),queryOrderRequest.getPayType());
        val payTypeDict = payTypeDictRepository.queryEnablePayTypeDict(queryOrderRequest.getPayType());
        val thirdPayRepository = SpringUtils.getBean(payTypeDict.getBeanName(),IThirdPayRepository.class);
        val thirdPlatformQueryOrder = thirdPayRepository.queryPayOrderFromThirdPlatform(payOrder,mchPayChannel);


        //5.判断订单状态是否有变化,更新聚合平台订单状态
        val payOrderTemp = new PayOrder();
//        payOrderTemp.setOrderStatus(thirdPlatformQueryOrder.getTradeStatus());
        if(thirdPlatformQueryOrder.getTradeStatus().equals(DictionaryConstant.PAYMENT_ORDER_STATUS_YZF.getCode())){
            payOrderTemp.setPayStatus(DictionaryConstant.PAY_STATUS_YFK.getCode());
            payOrderTemp.setPayTime(LocalDateTimeUtils.convertLocalDateTimeToDate(LocalDateTimeUtils.convertStringToLocalDateTime(thirdPlatformQueryOrder.getTimeEnd(),LocalDateTimeUtils.SIMPLE_DATETIME_FORMAT)));
            payOrderRepository.updatePayOrder(payOrder.getMcode(),payOrder.getTradeId(),payOrder.getmOrderNumber(),payOrderTemp);
        }

        //6.返回数据信息
        val postQueryOrderResponse = new PostQueryOrderResponse(thirdPlatformQueryOrder.getMcode(),queryOrderRequest.getPayType(),payOrder.getCodeUrl(),payOrder.getTimeExpire(),payOrder.getTradeId(),thirdPlatformQueryOrder.getOuterTradeNumber(),thirdPlatformQueryOrder.getMOrderNumber(),thirdPlatformQueryOrder.getTradeStatus());
        val sign = SignUtils.generateSign(MapBeanUtils.beanToMap(postQueryOrderResponse),mchPayInfo.getSecretKey());
        postQueryOrderResponse.setSign(sign);
        LogUtils.saveMchPaymentTradeLog(thirdPlatformQueryOrder.getMcode(),thirdPlatformQueryOrder.getMOrderNumber(),queryOrderRequest.getPayType(),LogUtils.LOG_DESCRIPTION_DDCS,JSON.toJSONString(postQueryOrderResponse), JSON.toJSONString(queryOrderRequest),DictionaryConstant.PAYMENT_REQUEST_TYPE_BD.getCode());
        return postQueryOrderResponse;
    }

    /**
     * 订单信息取消使用方法
     * @param cannelOrderRequest
     * @return
     */
    public PostCancelOrderResponse cancelOrder(PostCancelOrderRequest cannelOrderRequest){
        //1.查询商户号信息
        val mchPayInfo = mchPayInfoRepository.queryMchPayInfoByMcode(cannelOrderRequest.getMcode(),DictionaryConstant.PAYMENT_MCH_STATUS_SHTG.getCode());
        if(null == mchPayInfo){
            throw new BusinessCommonException(PaymentErrorCode.MCH_INFO_NOT_EXIST);
        }

        //2.校验签名信息
        if(!SignUtils.isSignatureValid(MapBeanUtils.beanToMap(cannelOrderRequest),mchPayInfo.getSecretKey())){
            throw new BusinessCommonException(PaymentErrorCode.SIGN_VALID_ERROR);
        }

        //3.查询业务订单下的所有预付单信息
        val payOrders = payOrderRepository.queryPayOrder(cannelOrderRequest.getMcode(),cannelOrderRequest.getOrderNumber());
        if(null != payOrders && payOrders.size() > 0){
            //遍历预付单列表，进行订单取消
            for(PayOrder payOrder:payOrders){
                val mchPayChannel = mchPayChannelRepository.queryMchPayChannelByMcodeWithBlob(cannelOrderRequest.getMcode(),payOrder.getPayType());
                val payTypeDict = payTypeDictRepository.queryEnablePayTypeDict(payOrder.getPayType());
                //3.1 发送取消订单请求
                val thirdPayRepository = SpringUtils.getBean(payTypeDict.getBeanName(),IThirdPayRepository.class);
                val thirdPlatformQueryOrder = thirdPayRepository.cannelPayOrderFromThirdPlatform(payOrder,mchPayChannel);
                //3.2 更新订单状态
                if(("1").equals(thirdPlatformQueryOrder.getCancelStatus())){
                    payOrderRepository.cancelPayOrder(payOrder.getMcode(),payOrder.getmOrderNumber(),payOrder.getPayType());
                }
            }
        }
        //3.查询第三方支付平台预付单信息
        val cancelOrderResponse = new PostCancelOrderResponse(cannelOrderRequest.getMcode(),cannelOrderRequest.getOrderNumber(),"1");
        val sign = SignUtils.generateSign(MapBeanUtils.beanToMap(cancelOrderResponse),mchPayInfo.getSecretKey());
        cancelOrderResponse.setSign(sign);
        LogUtils.saveMchPaymentTradeLog(cannelOrderRequest.getMcode(),cannelOrderRequest.getOrderNumber(),"",LogUtils.LOG_DESCRIPTION_DDQX,JSON.toJSONString(cancelOrderResponse), JSON.toJSONString(cannelOrderRequest),DictionaryConstant.PAYMENT_REQUEST_TYPE_BD.getCode());
        return cancelOrderResponse;
    }

    /**
     * 订单信息申请退款使用方法
     * @param refundOrderRequest
     * @return
     */
    public PostRefundOrderResponse refundOrder(PostRefundOrderRequest refundOrderRequest){
        //1.查询商户号信息
        val mchPayInfo = mchPayInfoRepository.queryMchPayInfoByMcode(refundOrderRequest.getMcode(),DictionaryConstant.PAYMENT_MCH_STATUS_SHTG.getCode());
        if(null == mchPayInfo){
            throw new BusinessCommonException(PaymentErrorCode.MCH_INFO_NOT_EXIST);
        }

        //2.校验签名信息
        if(!SignUtils.isSignatureValid(MapBeanUtils.beanToMap(refundOrderRequest),mchPayInfo.getSecretKey())){
            throw new BusinessCommonException(PaymentErrorCode.SIGN_VALID_ERROR);
        }

        //3.查询业务订单下的所有预付单信息
        val payOrder = payOrderRepository.queryPayOrder(refundOrderRequest.getMcode(),refundOrderRequest.getOrderNumber(),refundOrderRequest.getPayType());
        if(null == payOrder){
            throw new BusinessCommonException(PaymentErrorCode.MCH_ORDER_NOT_EXIST);
        }
        val mchPayChannel = mchPayChannelRepository.queryMchPayChannelByMcodeWithBlob(refundOrderRequest.getMcode(),payOrder.getPayType());
        val payTypeDict = payTypeDictRepository.queryEnablePayTypeDict(payOrder.getPayType());
//        payOrder.setPayInfoJsonString(refundOrderRequest.getThirdPartyInfoJsonString());

        //3.1 发送退款申请请求
        val thirdPayRepository = SpringUtils.getBean(payTypeDict.getBeanName(),IThirdPayRepository.class);
        val thirdPlatformRefundOrder = thirdPayRepository.refundPayOrderFromThirdPlatform(payOrder,refundOrderRequest.getRefundNumber(),refundOrderRequest.getRefundAmount(),mchPayChannel,payTypeDict);
        //3.2 更新订单状态,并生成聚合支付平台退款单信息
        if(("1").equals(thirdPlatformRefundOrder.getRefundStatus())){
            String refundNotifyUrl = refundOrderRequest.getRefundNotifyUrl();
            if(StringUtils.isEmpty(refundNotifyUrl)){
                refundNotifyUrl = mchPayChannel.getRefundNotifyUrl();
            }
            if(refundOrderRequest.getPayType().equals(DictionaryConstant.PAYMENT_PAY_TYPE_ZFBSM.getCode())
                    || refundOrderRequest.getPayType().equals(DictionaryConstant.PAY_TYPE_DISCOUNT.getCode())
                    || refundOrderRequest.getPayType().equals(DictionaryConstant.PAY_TYPE_FM_COUPON.getCode())){
                //支付宝申请退款后直接退款完成
                payOrderRepository.refundPayOrder(payOrder,refundOrderRequest.getRefundNumber(),refundOrderRequest.getRefundAmount(),thirdPlatformRefundOrder.getThirdRefundNumber(),refundNotifyUrl,DictionaryConstant.ORDER_STATUS_YTK.getCode());
            }else{
                //其它方式申请退款，退款状态为退款中
                payOrderRepository.refundPayOrder(payOrder,refundOrderRequest.getRefundNumber(),refundOrderRequest.getRefundAmount(),thirdPlatformRefundOrder.getThirdRefundNumber(),refundNotifyUrl,DictionaryConstant.ORDER_STATUS_TKZ.getCode());
            }
        }

        //4.整理返回数据
        val refundOrderResponse = new PostRefundOrderResponse();
        BeanUtils.copyProperties(refundOrderRequest,refundOrderResponse);
        BeanUtils.copyProperties(thirdPlatformRefundOrder,refundOrderResponse);
        val sign = SignUtils.generateSign(MapBeanUtils.beanToMap(refundOrderResponse),mchPayInfo.getSecretKey());
        refundOrderResponse.setSign(sign);
        LogUtils.saveMchPaymentTradeLog(refundOrderResponse.getMcode(),refundOrderResponse.getOrderNumber(),refundOrderRequest.getPayType(),LogUtils.LOG_DESCRIPTION_SQTK,JSON.toJSONString(refundOrderResponse), JSON.toJSONString(refundOrderRequest),DictionaryConstant.PAYMENT_REQUEST_TYPE_BD.getCode());
        return refundOrderResponse;
    }

    /**
     * 订单信息撤销使用方法
     * @param reverseOrderRequest
     * @return
     */
    public PostReverseOrderResponse reverseOrder(PostReverseOrderRequest reverseOrderRequest){
        //1.查询商户号信息
        val mchPayInfo = mchPayInfoRepository.queryMchPayInfoByMcode(reverseOrderRequest.getMcode(),DictionaryConstant.PAYMENT_MCH_STATUS_SHTG.getCode());
        if(null == mchPayInfo){
            throw new BusinessCommonException(PaymentErrorCode.MCH_INFO_NOT_EXIST);
        }

        //2.校验签名信息
        if(!SignUtils.isSignatureValid(MapBeanUtils.beanToMap(reverseOrderRequest),mchPayInfo.getSecretKey())){
            throw new BusinessCommonException(PaymentErrorCode.SIGN_VALID_ERROR);
        }

        //3.查询业务订单下的所有预付单信息
        val payOrders = payOrderRepository.queryPayOrder(reverseOrderRequest.getMcode(),reverseOrderRequest.getOrderNumber());
        if(null != payOrders && payOrders.size() > 0){
            //遍历预付单列表，进行订单取消
            for(PayOrder payOrder:payOrders){
                val mchPayChannel = mchPayChannelRepository.queryMchPayChannelByMcodeWithBlob(reverseOrderRequest.getMcode(),payOrder.getPayType());
                val payTypeDict = payTypeDictRepository.queryEnablePayTypeDict(payOrder.getPayType());
                //3.1 发送撤销订单请求
                val thirdPayRepository = SpringUtils.getBean(payTypeDict.getBeanName(),IThirdPayRepository.class);
                val thirdPlatformReverseOrder = thirdPayRepository.reversePayOrderFromThirdPlatform(payOrder,reverseOrderRequest.getOrderNumber(),mchPayChannel);
                //3.2 更新订单状态
                if(("2").equals(thirdPlatformReverseOrder.getReverseStatus())){
                    payOrderRepository.cancelPayOrder(payOrder.getMcode(),payOrder.getmOrderNumber(),payOrder.getPayType());
                }
            }
        }
        //3.查询第三方支付平台预付单信息
        val reverseOrderResponse = new PostReverseOrderResponse(reverseOrderRequest.getMcode(),reverseOrderRequest.getOrderNumber(),"2");
        val sign = SignUtils.generateSign(MapBeanUtils.beanToMap(reverseOrderResponse),mchPayInfo.getSecretKey());
        reverseOrderResponse.setSign(sign);
        LogUtils.saveMchPaymentTradeLog(reverseOrderResponse.getMcode(),reverseOrderResponse.getOrderNumber(),"",LogUtils.LOG_DESCRIPTION_DDQX,JSON.toJSONString(reverseOrderResponse), JSON.toJSONString(reverseOrderResponse),DictionaryConstant.PAYMENT_REQUEST_TYPE_BD.getCode());
        return reverseOrderResponse;
    }
    
    /**
     * 人脸支付初始化使用方法
     * @param initFacePayRequest
     * @return
     */
    public PostInitFacePayResponse initFacePay(PostInitFacePayRequest initFacePayRequest){
        //1.查询商户号信息
        val mchPayInfo = mchPayInfoRepository.queryMchPayInfoByMcode(initFacePayRequest.getMcode(),DictionaryConstant.PAYMENT_MCH_STATUS_SHTG.getCode());
        if(null == mchPayInfo){
            throw new BusinessCommonException(PaymentErrorCode.MCH_INFO_NOT_EXIST);
        }
        
        //2.校验签名信息
        if(!SignUtils.isSignatureValid(MapBeanUtils.beanToMap(initFacePayRequest),mchPayInfo.getSecretKey())){
            throw new BusinessCommonException(PaymentErrorCode.SIGN_VALID_ERROR);
        }
    
        val mchPayChannel = mchPayChannelRepository.queryMchPayChannelByMcodeWithBlob(initFacePayRequest.getMcode(),initFacePayRequest.getPayType());
        val payTypeDict = payTypeDictRepository.queryEnablePayTypeDict(initFacePayRequest.getPayType());
        val thirdFacePayRepository = SpringUtils.getBean(payTypeDict.getBeanName(),IThirdFacePayRepository.class);
        ThirdPlatformInitFacePay thirdPlatformInitFacePay = new ThirdPlatformInitFacePay();
        if(!StringUtils.isEmpty(initFacePayRequest.getFaceType())&&initFacePayRequest.getFaceType().equals("1")){
            //刷脸支付
            thirdPlatformInitFacePay = thirdFacePayRepository.initFacePay(initFacePayRequest,mchPayChannel,payTypeDict);
        }else{
            //刷脸生活
            //设置业务类型默认值
            if(StringUtils.isEmpty(initFacePayRequest.getBizType())){
//            1，表明1：1身份核验场景（姓名＋身份证号）
//            2，表明1：N刷脸搜索， 支付宝UID入库
//            3，表明1：N刷脸搜索， 支付宝手机号入库
//            4，表明1：1身份核验场景（手机号）
                initFacePayRequest.setBizType("4");
            }
            thirdPlatformInitFacePay = thirdFacePayRepository.initFaceLive(initFacePayRequest,mchPayChannel,payTypeDict);
            
        }
        
        //3.查询第三方支付平台预付单信息
        val initFacePayResponseResponse = new PostInitFacePayResponse();
        initFacePayResponseResponse.setZimId(thirdPlatformInitFacePay.getZimId());
        initFacePayResponseResponse.setZimInitClientData(thirdPlatformInitFacePay.getZimInitClientData());
        initFacePayResponseResponse.setInitStatus(thirdPlatformInitFacePay.getInitStatus());
        initFacePayResponseResponse.setAuthinfo(thirdPlatformInitFacePay.getAuthinfo());
        initFacePayResponseResponse.setExpiresIn(thirdPlatformInitFacePay.getExpiresIn());
        val sign = SignUtils.generateSign(MapBeanUtils.beanToMap(initFacePayResponseResponse),mchPayInfo.getSecretKey());
        initFacePayResponseResponse.setSign(sign);
        LogUtils.saveMchPaymentTradeLog(initFacePayResponseResponse.getMcode(),"",initFacePayRequest.getPayType(),LogUtils.LOG_DESCRIPTION_RLCSH,JSON.toJSONString(initFacePayResponseResponse), JSON.toJSONString(initFacePayRequest),DictionaryConstant.PAYMENT_REQUEST_TYPE_BD.getCode());
        return initFacePayResponseResponse;
    }
    
}
