From 28441b3922e6188f643d145a32c55d4fa285af84 Mon Sep 17 00:00:00 2001
From: wuxw7 <wuxw7@asiainfo.com>
Date: 星期三, 13 六月 2018 00:11:52 +0800
Subject: [PATCH] 日志保存 和 调用链开发
---
java110-core/src/main/java/com/java110/core/factory/DataTransactionFactory.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/java110-core/src/main/java/com/java110/core/factory/DataTransactionFactory.java b/java110-core/src/main/java/com/java110/core/factory/DataTransactionFactory.java
index ef66a70..1cc15b0 100644
--- a/java110-core/src/main/java/com/java110/core/factory/DataTransactionFactory.java
+++ b/java110-core/src/main/java/com/java110/core/factory/DataTransactionFactory.java
@@ -3,6 +3,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.JSONPath;
import com.java110.common.constant.MappingConstant;
import com.java110.common.constant.OrderTypeCdConstant;
import com.java110.common.constant.ResponseConstant;
@@ -52,6 +53,54 @@
}
/**
+ * 涓氬姟鏄惁閮芥垚鍔熶簡
+ * @param response true 鎴愬姛 false 澶辫触
+ * @return
+ */
+ public static boolean isSuccessBusiness(JSONObject response){
+ Object obj = JSONPath.eval(response,"$.orders.response.code");
+
+ if(obj != null && obj instanceof String && ResponseConstant.RESULT_CODE_SUCCESS.equals(obj.toString())){
+ Object businessObj = JSONPath.eval(response,"$.business");
+ if(businessObj == null){
+ return true;
+ }
+
+ if(businessObj instanceof JSONObject){
+ JSONObject businessJson = (JSONObject) businessObj;
+ if(!businessJson.containsKey("response")){ //杩欓噷杩斿洖鍗忚閿欒锛屾垜浠涓烘槸鎴愬姛
+ return true;
+ }
+ if(businessJson.getJSONObject("response").containsKey("code")
+ && ResponseConstant.RESULT_CODE_SUCCESS.equals(businessJson.getJSONObject("response").getString("code"))){
+ return true;
+ }
+ }
+
+ if(businessObj instanceof JSONArray){
+ JSONArray businessJsons = (JSONArray) businessObj;
+ if(businessJsons == null || businessJsons.size() == 0){
+ return true;
+ }
+ JSONObject businessJson = null;
+ for (int businessIndex = 0;businessIndex < businessJsons.size();businessIndex++) {
+ businessJson = businessJsons.getJSONObject(businessIndex);
+ if (!businessJson.containsKey("response")) { //杩欓噷杩斿洖鍗忚閿欒锛屾垜浠涓烘槸鎴愬姛
+ continue;
+ }
+ if (businessJson.getJSONObject("response").containsKey("code")
+ && !ResponseConstant.RESULT_CODE_SUCCESS.equals(businessJson.getJSONObject("response").getString("code"))) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
* 杩斿洖妯℃澘 鍙湁Order淇℃伅
* @param transactionId
* @param code
--
Gitblit v1.8.0