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

import com.alibaba.fastjson.JSON;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.domain.AlipayTradePayModel;
import com.alipay.api.domain.ExtendParams;
import com.alipay.api.request.*;
import com.alipay.api.response.*;
import com.neusoft.smart.pos.constants.DictionaryConstant;
import com.neusoft.smart.pos.dto.payment.request.PostInitFacePayRequest;
import com.neusoft.smart.pos.framework.constants.ApplicationConstants;
import com.neusoft.smart.pos.framework.exception.BusinessCommonException;
import com.neusoft.smart.pos.payment.constants.AliPayConstants;
import com.neusoft.smart.pos.payment.constants.PaymentErrorCode;
import com.neusoft.smart.pos.payment.persistent.ext.domain.*;
import com.neusoft.smart.pos.payment.utils.LogUtils;
import com.neusoft.smart.pos.payorder.persistent.domain.MchPayChannel;
import com.neusoft.smart.pos.payorder.persistent.domain.PayOrder;
import com.neusoft.smart.pos.payorder.persistent.domain.PayTypeDict;
import lombok.val;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * @author tjm
 * @date 2018-02-24 
 * @description 支付管理使用Repository
 */
@Component("aliPayRepository")
public class AliPayRepository implements IThirdPayRepository {

	/**
	 * 创建支付宝支付单使用方法
	 * @param payOrder
	 * @param mchPayChannel
	 * @return
	 */
	@Override
	public String createPayOrderToThirdPlatform(PayOrder payOrder, MchPayChannel mchPayChannel, PayTypeDict payTypeDict){
		//1.处理数据
		AlipayTradePayModel model =  aliPayCreateOrderRequestDataHandle(payOrder,mchPayChannel,payTypeDict);
		//2.请求支付宝预付单生成接口
		AlipayClient alipayClient = new DefaultAlipayClient(AliPayConstants.URL, mchPayChannel.getAppid(), mchPayChannel.getPrivateKey(), AliPayConstants.FORMAT, AliPayConstants.CHARSET, mchPayChannel.getPublicKey(), AliPayConstants.SIGN_TYPE);
		String responseData = "";
		if(StringUtils.isEmpty(payOrder.getScanCode())){
			AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();//创建API对应的request类
			request.setBizModel(model);
			request.setNotifyUrl(payTypeDict.getNotifyUrl());
			try{
				AlipayTradePrecreateResponse response = alipayClient.execute(request);
				responseData = response.getBody();
			}catch (AlipayApiException e){
				e.printStackTrace();
				throw new BusinessCommonException(PaymentErrorCode.ALIPAY_PRECREATE_ERROR);
			}finally {
				//3.记录日志
				LogUtils.savePaymentTradeLog(payOrder.getMcode(),payOrder.getmOrderNumber(), DictionaryConstant.PAYMENT_PAY_TYPE_ZFBSM.getCode(),LogUtils.LOG_DESCRIPTION_DDSC, JSON.toJSONString(model),responseData,DictionaryConstant.PAYMENT_REQUEST_TYPE_ZD.getCode());
			}
		}else{
			AlipayTradePayRequest request = new AlipayTradePayRequest(); //创建API对应的request类
			request.setBizModel(model);
			try{
				AlipayTradePayResponse response = alipayClient.execute(request); //通过alipayClient调用API，获得对应的response类
				responseData = response.getBody();
			}catch (AlipayApiException e){
				e.printStackTrace();
				throw new BusinessCommonException(PaymentErrorCode.ALIPAY_PAY_ERROR);
			}finally {
				//3.记录日志
				LogUtils.savePaymentTradeLog(payOrder.getMcode(),payOrder.getmOrderNumber(), DictionaryConstant.PAYMENT_PAY_TYPE_ZFBSM.getCode(),LogUtils.LOG_DESCRIPTION_DDSC,JSON.toJSONString(model),responseData,DictionaryConstant.PAYMENT_REQUEST_TYPE_ZD.getCode());
			}
		}

		return aliPayCreateOrderResponseDataHandle(payOrder,responseData);
	}

	/**
	 * 支付宝预支付请求数据绑定方法
	 * @param payOrder
	 * @param mchPayChannel
	 * @return
	 */
	private AlipayTradePayModel aliPayCreateOrderRequestDataHandle(PayOrder payOrder, MchPayChannel mchPayChannel,PayTypeDict payTypeDict){
		//请求参数金额是以分为单位，支付宝接口金额是以元为单位，换算成元
		float orderAmount = (float)payOrder.getPayAmount() / 100;
		AlipayTradePayModel model = new AlipayTradePayModel();
		model.setOutTradeNo(payOrder.getmOrderNumber()); // 预授权转支付商户订单号，为新的商户交易流水号；如果重试发起扣款，商户订单号不要变；
		model.setTotalAmount(String.valueOf(orderAmount));
		model.setSubject(payOrder.getDescription());
		if(!StringUtils.isEmpty(payOrder.getStoreId())){
			model.setStoreId(payOrder.getStoreId());
		}
		if(!StringUtils.isEmpty(payOrder.getDeviceId())){
			model.setTerminalId(payOrder.getDeviceId());
		}
		model.setTimeoutExpress("90m");
		JSONObject payInfoJsonObject  = JSONObject.fromObject(payOrder.getRequestDetailInfo());
		try {
			model.setScene("bar_code");
			model.setAuthCode(payInfoJsonObject.getString("scanCode"));
			payOrder.setScanCode(model.getAuthCode());
		} catch (Exception e) {
		}
//		if(!StringUtils.isEmpty(payOrder.getScanCode())){
//			model.setScene("bar_code");
//			model.setAuthCode(payOrder.getScanCode());
//		}
		if(!StringUtils.isEmpty(payOrder.getPid())){
			ExtendParams extendParams = new ExtendParams();
			extendParams.setSysServiceProviderId(payOrder.getPid()); //系统商编号 该参数作为系统商返佣数据提取的依据，请填写系统商签约协议的PID
			model.setExtendParams(extendParams);
		}
		return model;
	}

	/**
	 * 支付宝支付响应数据处理
	 * @param payOrder
	 * @param responseData
	 * @return
	 */
	private String aliPayCreateOrderResponseDataHandle(PayOrder payOrder, String responseData){
		JSONObject resData = JSONObject.fromObject(responseData);
        if (resData.has("alipay_trade_precreate_response")) {
        	JSONObject result = resData.getJSONObject("alipay_trade_precreate_response");
        	if (result.has("code") && !result.getString("code").equals(ApplicationConstants.ALIPAY_SUCC_CODE)){
        		throw new BusinessCommonException(result.getString("code"), result.getString("msg") + "|" + (result.has("sub_code")?result.getString("sub_code"):"") + "|" + (result.has("sub_msg")?result.getString("sub_msg"):""));
        	}
            payOrder.setOuterOrderNumber(result.getString("out_trade_no"));
            payOrder.setCodeUrl(result.getString("qr_code"));
            JSONObject payResponseJsonObject = new JSONObject();
            payResponseJsonObject.put("codeUrl",payOrder.getCodeUrl());
            return payResponseJsonObject.toString();
//        	val thirdPlatformOrder = new ThirdPlatformCreateOrder();
//    		thirdPlatformOrder.setMcode(payOrder.getMcode());
//    		thirdPlatformOrder.setTradeId(payOrder.getTradeId());
//    		thirdPlatformOrder.setMOrderNumber(payOrder.getmOrderNumber());
//    		thirdPlatformOrder.setOuterOrderNumber(result.getString("out_trade_no"));
//    		thirdPlatformOrder.setOuterCodeUrl(result.getString("qr_code"));
//    		return thirdPlatformOrder;
        }else if (resData.has("alipay_trade_pay_response")) {
        	JSONObject result = resData.getJSONObject("alipay_trade_pay_response");
        	if (result.has("code") && !result.getString("code").equals(ApplicationConstants.ALIPAY_SUCC_CODE)){
        		throw new BusinessCommonException(result.getString("code"), result.getString("msg") + "|" + (result.has("sub_code")?result.getString("sub_code"):"") + "|" + (result.has("sub_msg")?result.getString("sub_msg"):""));
        	}
            payOrder.setOuterOrderNumber(result.getString("trade_no"));
            payOrder.setPayStatus(DictionaryConstant.PAY_STATUS_YFK.getCode());
            JSONObject payResponseJsonObject = new JSONObject();
            return payResponseJsonObject.toString();
//        	val thirdPlatformOrder = new ThirdPlatformCreateOrder();
//    		thirdPlatformOrder.setMcode(payOrder.getMcode());
//    		thirdPlatformOrder.setTradeId(payOrder.getTradeId());
//    		thirdPlatformOrder.setMOrderNumber(payOrder.getmOrderNumber());
//    		thirdPlatformOrder.setOuterOrderNumber(result.getString("trade_no"));
//    		thirdPlatformOrder.setPayStatus(DictionaryConstant.PAY_STATUS_YFK.getCode());
//    		return thirdPlatformOrder;
        }else{
        	throw new BusinessCommonException(PaymentErrorCode.ALIPAY_PRECREATE_RESPONSE_ERROR);
        }
		
	}

	/**
	 * 支付宝预付订单查询方法
	 * @param payOrder
	 * @param mchPayChannel
	 * @return
	 */
	public ThirdPlatformQueryOrder queryPayOrderFromThirdPlatform(PayOrder payOrder, MchPayChannel mchPayChannel){
		//1.处理数据
		String queryReqData = aliPayQueryOrderRequestDataHandle(payOrder.getmOrderNumber());
		AlipayClient alipayClient = new DefaultAlipayClient(AliPayConstants.URL, mchPayChannel.getAppid(), mchPayChannel.getPrivateKey(), AliPayConstants.FORMAT, AliPayConstants.CHARSET, mchPayChannel.getPublicKey(), AliPayConstants.SIGN_TYPE);
		AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
		request.setBizContent(queryReqData);
		String responseData = "";
		//2.请求预付单生成接口
		try{
			AlipayTradeQueryResponse response = alipayClient.execute(request);
			responseData = response.getBody();
		}catch (AlipayApiException e){
			throw new BusinessCommonException(PaymentErrorCode.ALIPAY_QUERY_ERROR);
		}finally {
			//3.记录日志
			LogUtils.savePaymentTradeLog(mchPayChannel.getMcode(),payOrder.getmOrderNumber(), DictionaryConstant.PAYMENT_PAY_TYPE_ZFBSM.getCode(),LogUtils.LOG_DESCRIPTION_DDCS,queryReqData,responseData,DictionaryConstant.PAYMENT_REQUEST_TYPE_ZD.getCode());
		}
		return aliPayQueryOrderResponseDataHandle(mchPayChannel.getMcode(),payOrder.getmOrderNumber(),responseData);
	}
	
	/**
	 * 支付宝查询请求数据绑定方法
	 * @return
	 */
	private String aliPayQueryOrderRequestDataHandle(String orderNumber){
		String requestData = "{" +
				"\"out_trade_no\":\"" + orderNumber + "\"}";
		return requestData;
	}

	/**
	 * 支付宝查询响应数据处理
	 * @return
	 */
	private ThirdPlatformQueryOrder aliPayQueryOrderResponseDataHandle(String mcode,String orderNumber, String responseData){
		JSONObject resData = JSONObject.fromObject(responseData);
        if (resData.has("alipay_trade_query_response")) {
        	JSONObject result = resData.getJSONObject("alipay_trade_query_response");
        	if (result.has("code") && !result.getString("code").equals(ApplicationConstants.ALIPAY_SUCC_CODE)){
        		throw new BusinessCommonException(result.getString("code"), result.getString("msg") + "|" + (result.has("sub_code")?result.getString("sub_code"):"") + "|" + (result.has("sub_msg")?result.getString("sub_msg"):""));
        	}
        	val thirdPlatformOrder = new ThirdPlatformQueryOrder();
    		thirdPlatformOrder.setMcode(mcode);
    		thirdPlatformOrder.setMOrderNumber(orderNumber);
    		thirdPlatformOrder.setOuterTradeNumber(result.getString("trade_no")==null?"":result.getString("trade_no"));
    		thirdPlatformOrder.setTradeStatus(getTradeStatus(result.getString("trade_status")));
    		thirdPlatformOrder.setTimeEnd(result.has("send_pay_date")?result.getString("send_pay_date").replaceAll("-", "").replaceAll(":", "").replaceAll(" ", "") : "");
    		return thirdPlatformOrder;
        }else{
        	throw new BusinessCommonException(PaymentErrorCode.ALIPAY_QUERY_RESPONSE_ERROR);
        }
	}

	/**
	 * 根据支付宝交易状态返回支付平台订单状态
	 * @param tradeState
	 * @return
	 */
	private String getTradeStatus(String tradeState){
		String tradeStatus = DictionaryConstant.PAYMENT_ORDER_STATUS_DZF.getCode();
		switch(tradeState){
			case "TRADE_SUCCESS":
				//交易支付成功
				tradeStatus = DictionaryConstant.PAYMENT_ORDER_STATUS_YZF.getCode();
				break;
			case "WAIT_BUYER_PAY":
				//交易创建，等待买家付款
				tradeStatus = DictionaryConstant.PAYMENT_ORDER_STATUS_DZF.getCode();
				break;
			case "TRADE_CLOSED":
				//未付款交易超时关闭，或支付完成后全额退款
				tradeStatus = DictionaryConstant.PAYMENT_ORDER_STATUS_JYGB.getCode();
				break;
			case "TRADE_FINISHED":
				//交易结束，不可退款
				tradeStatus = DictionaryConstant.PAYMENT_ORDER_STATUS_FINISH.getCode();
				break;
		}
		return tradeStatus;
	}

	/**
	 * 支付宝预付订单取消方法
	 * @param payOrder
	 * @param mchPayChannel
	 * @return
	 */
	public ThirdPlatformCancelOrder cannelPayOrderFromThirdPlatform(PayOrder payOrder, MchPayChannel mchPayChannel){
		//1.处理数据
		String ReqData = aliPayQueryOrderRequestDataHandle(payOrder.getmOrderNumber());
		AlipayClient alipayClient = new DefaultAlipayClient(AliPayConstants.URL, mchPayChannel.getAppid(), mchPayChannel.getPrivateKey(), AliPayConstants.FORMAT, AliPayConstants.CHARSET, mchPayChannel.getPublicKey(), AliPayConstants.SIGN_TYPE);
		AlipayTradeCancelRequest request = new AlipayTradeCancelRequest();
		request.setBizContent(ReqData); 
		String responseData = "";
		try{
			AlipayTradeCancelResponse response = alipayClient.execute(request);
			responseData = response.getBody();
		}catch (AlipayApiException e){
			throw new BusinessCommonException(PaymentErrorCode.ALIPAY_CANCEL_ERROR);
		}finally {
			//3.记录日志
			LogUtils.savePaymentTradeLog(mchPayChannel.getMcode(),payOrder.getmOrderNumber(), DictionaryConstant.PAYMENT_PAY_TYPE_ZFBSM.getCode(),LogUtils.LOG_DESCRIPTION_DDQX,ReqData,responseData,DictionaryConstant.PAYMENT_REQUEST_TYPE_ZD.getCode());
		}
		return aliPayCannelOrderResponseDataHandle(mchPayChannel.getMcode(),payOrder.getmOrderNumber(),responseData);
	}

	/**
	 * 支付宝支付订单取消响应数据处理
	 * @return
	 */
	private ThirdPlatformCancelOrder aliPayCannelOrderResponseDataHandle(String mcode,String orderNumber, String responseData){
		JSONObject resData = JSONObject.fromObject(responseData);
        if (resData.has("alipay_trade_cancel_response")) {
        	JSONObject result = resData.getJSONObject("alipay_trade_cancel_response");
        	if (result.has("code") && !result.getString("code").equals(ApplicationConstants.ALIPAY_SUCC_CODE)){
        		throw new BusinessCommonException(result.getString("code"), result.getString("msg") + "|" + (result.has("sub_code")?result.getString("sub_code"):"") + "|" + (result.has("sub_msg")?result.getString("sub_msg"):""));
        	}
        	val thirdPlatformCancelOrder = new ThirdPlatformCancelOrder();
    		thirdPlatformCancelOrder.setMcode(mcode);
    		thirdPlatformCancelOrder.setMOrderNumber(orderNumber);
    		thirdPlatformCancelOrder.setPayType(DictionaryConstant.PAYMENT_PAY_TYPE_ZFBSM.getCode());
    		if(result.getString("retry_flag").equalsIgnoreCase(ApplicationConstants.ALIPAY_RETRY_FLAG)){
    			thirdPlatformCancelOrder.setCancelStatus("0");
    		}else{
    			thirdPlatformCancelOrder.setCancelStatus("1");
    		}
    		return thirdPlatformCancelOrder;
        }else{
        	throw new BusinessCommonException(PaymentErrorCode.ALIPAY_CANCEL_RESPONSE_ERROR);
        }
	}

	/**
	 * 支付宝预付订单退款申请方法
	 * @return
	 */
	@Override
	public ThirdPlatformRefundOrder refundPayOrderFromThirdPlatform(PayOrder payOrder,String refundNumber,Long refundAmount, MchPayChannel mchPayChannel,PayTypeDict payTypeDict){
		//1.处理数据
		String aliPayRefundRequestData =  aliPayRefundOrderRequestDataHandle(payOrder,refundNumber,refundAmount);
		//2.请求支付宝退款接口
		AlipayClient alipayClient = new DefaultAlipayClient(AliPayConstants.URL, mchPayChannel.getAppid(), mchPayChannel.getPrivateKey(), AliPayConstants.FORMAT, AliPayConstants.CHARSET, mchPayChannel.getPublicKey(), AliPayConstants.SIGN_TYPE);
		AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();//创建API对应的request类
		request.setBizContent(aliPayRefundRequestData); //设置业务参数
		String responseData = "";
		try{
			AlipayTradeRefundResponse response = alipayClient.execute(request);//通过alipayClient调用API，获得对应的response类
			responseData = response.getBody();
		}catch (AlipayApiException e){
			throw new BusinessCommonException(PaymentErrorCode.ALIPAY_REFUND_ERROR);
		}finally {
			//3.记录日志
			LogUtils.savePaymentTradeLog(payOrder.getMcode(),payOrder.getmOrderNumber(), DictionaryConstant.PAYMENT_PAY_TYPE_ZFBSM.getCode(),LogUtils.LOG_DESCRIPTION_SQTK,aliPayRefundRequestData,responseData,DictionaryConstant.PAYMENT_REQUEST_TYPE_ZD.getCode());
		}

		return weixinRefundOrderResponseDataHandle(payOrder,responseData);
	}
	
	/**
	 * 支付宝退款请求数据绑定方法
	 * @param payOrder
	 * @return
	 */
	private String aliPayRefundOrderRequestDataHandle(PayOrder payOrder, String refundNumber,Long refundAmount){
		//请求参数金额是以分为单位，支付宝接口金额是以元为单位，换算成元
		float orderAmount = (float)refundAmount / 100;
		String requestData = "{" +
				"    \"out_trade_no\":\"" + payOrder.getmOrderNumber() + "\"," +
				"    \"out_request_no\":\"" + refundNumber + "\"," +
				"    \"refund_amount\":\"" + orderAmount + "\"}";
		return requestData;
	}
	
	/**
	 * 支付宝退款申请响应数据处理
	 * @param payOrder
	 * @param responseData
	 * @return
	 */
	private ThirdPlatformRefundOrder weixinRefundOrderResponseDataHandle(PayOrder payOrder, String responseData){
		JSONObject resData = JSONObject.fromObject(responseData);
        if (resData.has("alipay_trade_refund_response")) {

        	JSONObject result = resData.getJSONObject("alipay_trade_refund_response");
        	if (result.has("code") && !result.getString("code").equals(ApplicationConstants.ALIPAY_SUCC_CODE)&& !result.getString("code").equals("40004")){
        		throw new BusinessCommonException(result.getString("code"), result.getString("msg") + "|" + (result.has("sub_code")?result.getString("sub_code"):"") + "|" + (result.has("sub_msg")?result.getString("sub_msg"):""));
        	}

            val thirdPlatformOrder = new ThirdPlatformRefundOrder();
            thirdPlatformOrder.setMcode(payOrder.getMcode());
            thirdPlatformOrder.setMOrderNumber(payOrder.getmOrderNumber());
            thirdPlatformOrder.setPayType(payOrder.getPayType());
            if(result.getString("code").equals("40004")){
                if(result.has("sub_code")&&result.getString("sub_code").equals("ACQ.TRADE_NOT_EXIST")) {
                    thirdPlatformOrder.setRefundStatus("3");
                }else{
                    thirdPlatformOrder.setRefundStatus("0");
                }
            }else{
                thirdPlatformOrder.setRefundNumber(result.getString("out_trade_no"));
                thirdPlatformOrder.setThirdRefundNumber(result.getString("trade_no"));
                thirdPlatformOrder.setRefundAmount(result.getLong("refund_fee"));
                thirdPlatformOrder.setRefundStatus("2");
            }
    		return thirdPlatformOrder;
        }else{
        	throw new BusinessCommonException(PaymentErrorCode.MCH_ORDER_REFUND_ERROR);
        }

	}

	/**
	 * 预付单撤销使用方法
	 * @return
	 */
	public ThirdPlatformReverseOrder reversePayOrderFromThirdPlatform(PayOrder payOrder, String orderNumber, MchPayChannel mchPayChannel){
		String ReqData = aliPayQueryOrderRequestDataHandle(orderNumber);
		AlipayClient alipayClient = new DefaultAlipayClient(AliPayConstants.URL, mchPayChannel.getAppid(), mchPayChannel.getPrivateKey(), AliPayConstants.FORMAT, AliPayConstants.CHARSET, mchPayChannel.getPublicKey(), AliPayConstants.SIGN_TYPE);
		AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();
		request.setBizContent(ReqData);
		String responseData = "";
		try{
			AlipayTradeCloseResponse response = alipayClient.execute(request);
			responseData = response.getBody();
		}catch (AlipayApiException e){
			throw new BusinessCommonException(PaymentErrorCode.ALIPAY_CLOSE_ERROR);
		}finally {
			//3.记录日志
			LogUtils.savePaymentTradeLog(mchPayChannel.getMcode(),orderNumber, DictionaryConstant.PAYMENT_PAY_TYPE_ZFBSM.getCode(),LogUtils.LOG_DESCRIPTION_DDQX,ReqData,responseData,DictionaryConstant.PAYMENT_REQUEST_TYPE_ZD.getCode());
		}
		return aliPayCloseOrderResponseDataHandle(mchPayChannel.getMcode(),orderNumber,responseData);
	}

	@Override
	public ThirdPlatformInitFacePay initFacePay(PostInitFacePayRequest initFacePayRequest, MchPayChannel mchPayChannel, PayTypeDict payTypeDict) {
		return null;
	}

	@Override
	public ThirdPlatformInitFacePay initFaceLive(PostInitFacePayRequest initFacePayRequest, MchPayChannel mchPayChannel, PayTypeDict payTypeDict) {
		return null;
	}

	@Override
	public boolean IsSupportPartialRefund() {
		return false;
	}

	/**
	 * 支付宝支付订单取消响应数据处理
	 * @return
	 */
	private ThirdPlatformReverseOrder aliPayCloseOrderResponseDataHandle(String mcode,String orderNumber, String responseData){
		JSONObject resData = JSONObject.fromObject(responseData);
        if (resData.has("alipay_trade_close_response")) {
        	JSONObject result = resData.getJSONObject("alipay_trade_close_response");
        	if (result.has("code") && !result.getString("code").equals(ApplicationConstants.ALIPAY_SUCC_CODE)){
        		throw new BusinessCommonException(result.getString("code"), result.getString("msg") + "|" + (result.has("sub_code")?result.getString("sub_code"):"") + "|" + (result.has("sub_msg")?result.getString("sub_msg"):""));
        	}
        	val thirdPlatformReverseOrder = new ThirdPlatformReverseOrder();
        	thirdPlatformReverseOrder.setMcode(mcode);
        	thirdPlatformReverseOrder.setMOrderNumber(orderNumber);
        	thirdPlatformReverseOrder.setPayType(DictionaryConstant.PAYMENT_PAY_TYPE_ZFBSM.getCode());
    		thirdPlatformReverseOrder.setReverseStatus("1");

    		return thirdPlatformReverseOrder;
        }else{
        	throw new BusinessCommonException(PaymentErrorCode.ALIPAY_CLOSE_RESPONSE_ERROR);
        }
	}

}
