From f11f249f804f82abdaeb2f561fd833d2c0386a28 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Thu, 10 Jun 2021 00:28:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/pay/WechatPayController.java | 16 +++++++- .../java/com/hai/common/utils/HttpsUtils.java | 41 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java index 8310971e..8b48c744 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java @@ -17,6 +17,7 @@ import com.hai.model.ResponseData; import com.hai.model.WxSharingOrderRequestModel; import com.hai.model.WxSharingReceiversVO; import com.hai.service.HighProfitSharingRecordService; +import com.hai.service.TelApiService; import com.hai.service.pay.NotifyService; import com.hai.service.pay.PayRecordService; import com.wechat.pay.contrib.apache.httpclient.util.PemUtil; @@ -68,6 +69,8 @@ public class WechatPayController { @Resource private WechatPayUtil wechatPayUtil; + @Resource + private TelApiService telApiService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @@ -176,6 +179,17 @@ public class WechatPayController { + body + "\n"; } - + @RequestMapping(value = "/telApi", method = RequestMethod.GET) + @ApiOperation(value = "电话查询") + @ResponseBody + public ResponseData addLedgerReceiver(@RequestParam(value = "tel", required = true) String tel) { + try { + JSONObject jsonObject = telApiService.outApiTel(tel); + return ResponseMsgUtil.success(jsonObject); + } catch (Exception e) { + log.error("WechatPayController --> wechatNotify() error!", e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java b/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java index 8697b14b..d2a894c2 100644 --- a/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java +++ b/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java @@ -126,6 +126,47 @@ public class HttpsUtils { return null; } + public static JSONObject doGet(String url, Map params , Map headers) { + String apiUrl = url; + StringBuffer param = new StringBuffer(); + int i = 0; + for (String key : params.keySet()) { + if (i == 0) + param.append("?"); + else + param.append("&"); + param.append(key).append("=").append(params.get(key)); + i++; + } + apiUrl += param; + String result = null; + HttpClient httpClient = null; + try { + + if (apiUrl.startsWith("https")) { + httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) + .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); + } else { + httpClient = HttpClients.createDefault(); + } + + HttpGet httpGet = new HttpGet(apiUrl); + for (Map.Entry e : headers.entrySet()) { + httpGet.addHeader(e.getKey(), e.getValue()); + } + HttpResponse response = httpClient.execute(httpGet); + HttpEntity entity = response.getEntity(); + if (entity != null) { + InputStream instream = entity.getContent(); + result = IOUtils.toString(instream, "UTF-8"); + } + return JSON.parseObject(result); + } catch (Exception e) { + log.error(e.getMessage(),e); + } + return null; + } + public static JSONObject doWxGet(String url, Map params) { String apiUrl = url; StringBuffer param = new StringBuffer();