merge
This commit is contained in:
@@ -10,20 +10,17 @@ import com.xwbing.util.payWxpay.XmlUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.jdom2.JDOMException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -131,18 +128,9 @@ public class WxPayService {
|
||||
result.setMessage("error response");
|
||||
result.setSuccess(false);
|
||||
}
|
||||
} catch (ClientProtocolException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new PayException(e);
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new PayException(e);
|
||||
} catch (JDOMException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new PayException(e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new PayException(e);
|
||||
throw new PayException("扫码支付异常");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -195,18 +183,9 @@ public class WxPayService {
|
||||
result.setMessage("error response");
|
||||
result.setSuccess(false);
|
||||
}
|
||||
} catch (ClientProtocolException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new PayException(e);
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new PayException(e);
|
||||
} catch (JDOMException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new PayException(e);
|
||||
} catch (Exception e1) {
|
||||
logger.error(e1.getMessage());
|
||||
throw new PayException(e1);
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage());
|
||||
throw new PayException("退款异常");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -254,18 +233,9 @@ public class WxPayService {
|
||||
result.setMessage("error response");
|
||||
result.setSuccess(false);
|
||||
}
|
||||
} catch (ClientProtocolException e) {
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new PayException(e);
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new PayException(e);
|
||||
} catch (JDOMException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new PayException(e);
|
||||
} catch (Exception e1) {
|
||||
logger.error(e1.getMessage());
|
||||
throw new PayException(e1);
|
||||
throw new PayException("查询订单异常");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -316,18 +286,9 @@ public class WxPayService {
|
||||
result.setMessage("error response");
|
||||
result.setSuccess(false);
|
||||
}
|
||||
} catch (ClientProtocolException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new PayException(e);
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new PayException(e);
|
||||
} catch (JDOMException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new PayException(e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new PayException(e);
|
||||
throw new PayException("查询退款异常");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -44,15 +44,14 @@ import java.security.*;
|
||||
*/
|
||||
public class ClientCustomSSL {
|
||||
|
||||
public static CloseableHttpClient getCloseableHttpClient(String mch_id) {
|
||||
public static CloseableHttpClient getCloseableHttpClient(String mchId) {
|
||||
FileInputStream instream = null;
|
||||
KeyStore keyStore = null;
|
||||
try {
|
||||
keyStore = KeyStore.getInstance("PKCS12");
|
||||
String path = ClientCustomSSL.class.getClassLoader().getResource("wx_apiclient_cert.p12")
|
||||
.getPath();
|
||||
String path = ClientCustomSSL.class.getClassLoader().getResource("wx_apiclient_cert.p12").getPath();
|
||||
instream = new FileInputStream(new File(path));
|
||||
keyStore.load(instream, mch_id.toCharArray());
|
||||
keyStore.load(instream, mchId.toCharArray());
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("读取微信证书出错!");
|
||||
} finally {
|
||||
@@ -67,7 +66,7 @@ public class ClientCustomSSL {
|
||||
SSLContext sslcontext = null;
|
||||
try {
|
||||
sslcontext = SSLContexts.custom()
|
||||
.loadKeyMaterial(keyStore, mch_id.toCharArray())
|
||||
.loadKeyMaterial(keyStore, mchId.toCharArray())
|
||||
.build();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.xwbing.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xwbing.exception.BusinessException;
|
||||
import com.xwbing.exception.PayException;
|
||||
import com.xwbing.exception.UtilException;
|
||||
import com.xwbing.util.JsonResult;
|
||||
import org.slf4j.Logger;
|
||||
@@ -64,6 +65,20 @@ public class GlobalExceptionHandler {
|
||||
return JsonResult.toJSONObj(ex.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 线上支付异常
|
||||
*
|
||||
* @param ex
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(value = PayException.class)
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@ResponseBody
|
||||
public JSONObject handlerPayException(PayException ex) {
|
||||
logger.error(ex.getMessage());
|
||||
return JsonResult.toJSONObj(ex.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* CompletableFuture完成结果或任务过程中出现的异常
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user