Bläddra i källkod

新增支付通道

Yangzw 9 månader sedan
förälder
incheckning
fd6461b9c6

+ 17 - 8
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/util/FuiouHttpPoster.java

@@ -10,6 +10,7 @@ import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.List;
 
+import cn.newfeifan.mall.framework.common.exception.ErrorCode;
 import lombok.Setter;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.methods.PostMethod;
@@ -17,6 +18,8 @@ import org.apache.commons.httpclient.methods.StringRequestEntity;
 import org.apache.commons.httpclient.params.HttpMethodParams;
 import org.apache.commons.httpclient.protocol.Protocol;
 
+import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+
 
 /**
  * @author Administrator
@@ -55,7 +58,8 @@ public class FuiouHttpPoster {
 				try {
 					postMethod.setRequestEntity(new StringRequestEntity(body,"application/json","UTF-8"));
 				} catch (UnsupportedEncodingException e) {
-					e.printStackTrace();
+					ErrorCode err = new ErrorCode(1, e.getMessage());
+					throw exception(err);
 				}
 			}
 		});
@@ -119,13 +123,15 @@ public class FuiouHttpPoster {
 				Protocol.unregisterProtocol("https");
 			return responseString;
 		} catch (IOException ex2) {
-			ex2.printStackTrace();
-			System.out.println("报文发送到[" + url + "]失败:" + ex2.getMessage());
-			throw new Exception("报文发送异常");
+			ErrorCode err = new ErrorCode(1, ex2.getMessage());
+//			throw exception(err);
+//			System.out.println("报文发送到[" + url + "]失败:" + ex2.getMessage());
+//			throw new Exception("报文发送异常");
 		} catch (Exception ex) {
-			ex.printStackTrace();
-			System.out.println("报文发送到[" + url + "]失败:" + ex.getMessage());
-			throw new Exception("报文发送异常");
+			ErrorCode err = new ErrorCode(1, ex.getMessage());
+			throw exception(err);
+//			System.out.println("报文发送到[" + url + "]失败:" + ex.getMessage());
+//			throw new Exception("报文发送异常");
 		} finally {
 			try {
 				if(xmlpost != null)
@@ -133,9 +139,12 @@ public class FuiouHttpPoster {
 				if(httpclient != null)
 					httpclient.getHttpConnectionManager().closeIdleConnections(0);
 			} catch (Exception e) {
-				e.printStackTrace();
+				ErrorCode err = new ErrorCode(1, e.getMessage());
+				throw exception(err);
 			}
 		}
+
+		return null;
 	}
 
 	/**