back_recharge
jiahuiwen 2022-02-17 19:18:34 +08:00
parent a906ad4712
commit 283439f860
2 changed files with 34 additions and 1 deletions

View File

@ -284,7 +284,13 @@ public class BuyGoodsNewLogic {
jsonObject2.put("_mac", reportBaseBean != null ? reportBaseBean.getNetwork_s() : "");
jsonObject.put("context", jsonObject2);
String result = HttpPool.doPost(DataMessageUtils.restURL, jsonObject);
Map<String, String> params = new HashMap<>();
params.put("appid","e7ba14d6442b0ec225289bc846826092");
params.put("who", user.getPlayerInfoManager().getOpenId());
params.put("context", jsonObject2.toJSONString());
String result = HttpPool.doPost(DataMessageUtils.restURL, params);
// String result = HttpPool.doPost(DataMessageUtils.restURL, jsonObject);
LOGGER.info("onChargeSuccess uid={} REST付费上报={} 参数={}", user.getId(), result, jsonObject.toJSONString());
}
}

View File

@ -99,6 +99,33 @@ public class HttpPool {
}
public static String doPost(String url, Map<String,String> parms) throws IOException {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
List<NameValuePair> nvps =getFromMap(parms);
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
CloseableHttpResponse response2 = httpclient.execute(httpPost);
try {
HttpEntity entity = response2.getEntity();
return EntityUtils.toString(entity);
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
response2.close();
}
}
public static List<NameValuePair> getFromMap(Map<String,String> parms){
List<NameValuePair> nvps = new ArrayList<NameValuePair>(parms.size());
for(Map.Entry<String,String> item : parms.entrySet()){
nvps.add(new BasicNameValuePair(item.getKey(), item.getValue()));
}
return nvps;
}
/**
* Post
* @param url