|
@@ -8,6 +8,7 @@ import com.fs.store.domain.FsPayConfig;
|
|
import com.fs.system.domain.SysConfig;
|
|
import com.fs.system.domain.SysConfig;
|
|
import com.fs.system.mapper.SysConfigMapper;
|
|
import com.fs.system.mapper.SysConfigMapper;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.http.HttpEntity;
|
|
import org.apache.http.HttpEntity;
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
import org.apache.http.client.methods.HttpPost;
|
|
import org.apache.http.client.methods.HttpPost;
|
|
@@ -18,28 +19,39 @@ import org.apache.http.util.EntityUtils;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.lang.reflect.Type;
|
|
import java.lang.reflect.Type;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.TreeMap;
|
|
import java.util.TreeMap;
|
|
|
|
|
|
@SuppressWarnings("all")
|
|
@SuppressWarnings("all")
|
|
|
|
+@Slf4j
|
|
public class PayUtil {
|
|
public class PayUtil {
|
|
|
|
|
|
|
|
|
|
public static String endPayHttp(String url , Map<String,String> map){
|
|
public static String endPayHttp(String url , Map<String,String> map){
|
|
|
|
+ log.info("==> 开始执行 endPayHttp 方法, URL: {}, 请求参数Map: {}", url, map);
|
|
|
|
+
|
|
//获取sign
|
|
//获取sign
|
|
String sign = sign(map);
|
|
String sign = sign(map);
|
|
|
|
+ log.info("--> 生成签名 sign: {}", sign);
|
|
|
|
+
|
|
map.put("sign",sign);
|
|
map.put("sign",sign);
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
String json = gson.toJson(map);
|
|
String json = gson.toJson(map);
|
|
|
|
+ log.info("--> 构造请求体 JSON: {}", json);
|
|
HttpPost httpPost = new HttpPost(url);
|
|
HttpPost httpPost = new HttpPost(url);
|
|
httpPost.setHeader("Content-Type", "application/json");
|
|
httpPost.setHeader("Content-Type", "application/json");
|
|
|
|
+ log.info("--> 设置请求头: {}", Arrays.toString(httpPost.getAllHeaders()));
|
|
|
|
+
|
|
StringEntity requestEntity = new StringEntity(json, "UTF-8");
|
|
StringEntity requestEntity = new StringEntity(json, "UTF-8");
|
|
httpPost.setEntity(requestEntity);
|
|
httpPost.setEntity(requestEntity);
|
|
return sendHttp(httpPost);
|
|
return sendHttp(httpPost);
|
|
}
|
|
}
|
|
|
|
|
|
public static String sendHttp( HttpPost httpPost){
|
|
public static String sendHttp( HttpPost httpPost){
|
|
|
|
+ log.info("==> 开始执行 sendHttp 方法, 请求目标 URL: {}", httpPost.getURI());
|
|
|
|
+
|
|
String responseText=null;
|
|
String responseText=null;
|
|
// 创建HttpClient对象
|
|
// 创建HttpClient对象
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
@@ -63,6 +75,9 @@ public class PayUtil {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ log.info("<== sendHttp 方法执行结束, 返回响应文本: {}", responseText);
|
|
|
|
+
|
|
return responseText;
|
|
return responseText;
|
|
}
|
|
}
|
|
|
|
|