diff --git a/hai-cweb/src/test/common/RegionTest.java b/hai-cweb/src/test/common/RegionTest.java index e24a80f0..2627d97a 100644 --- a/hai-cweb/src/test/common/RegionTest.java +++ b/hai-cweb/src/test/common/RegionTest.java @@ -99,11 +99,11 @@ public class RegionTest { String sha256 = encodeBySHA256(signature + JSON.toJSONString(bodyMap) + date); Map headerMap = new HashMap<>(); - headerMap.put("sign", sha256); headerMap.put("token", token); + headerMap.put("sign", sha256); headerMap.put("ts", date); //map2.put("sign", sha256); - HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", bodyMap, headerMap); + HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", JSON.toJSONString(bodyMap), token,sha256 ,date); //System.out.println(jsonObject.toJSONString()); } diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java index 387ee4f1..70e689d0 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java @@ -20,7 +20,7 @@ public class HighCouponSchedule { private HighUserCouponService highUserCouponService; // @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 - @Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行 + // @Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行 public void certification() { List userCoupons = highUserCouponService.getOverdueCoupon(); for (HighUserCoupon highUserCoupon : userCoupons) { diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java index 18fd3aef..9f38b305 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java @@ -24,7 +24,7 @@ public class HighOrderSchedule { @Resource private HighOrderService highOrderService; - @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 + // @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 public void certification() { List orderList = highOrderService.getCloseOrder(); diff --git a/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java b/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java index 2ddd87e9..48bbac9f 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java +++ b/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java @@ -35,12 +35,12 @@ public class SynchronizeCNPC { tokenMap.put("appId", "jsVpwDoHZfR2rrpjhA"); tokenMap.put("appSecret", "R7yJjinikdPhOlTrVgmdS7cblWMMOf99zEJkfPgaTIoDtKGlX51JKueLV725a6S4"); JSONObject jsonObject = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/api/open/merchant/token", JSON.toJSONString(tokenMap)); - System.out.println(jsonObject.toJSONString()); + log.error(jsonObject.toJSONString()); if (jsonObject != null && jsonObject.getBoolean("success") == true) { JSONObject data = jsonObject.getJSONObject("data"); String token = data.getString("token"); - Map bodyMap = new HashMap<>(); + Map bodyMap = new HashMap<>(); bodyMap.put("appId", "jsVpwDoHZfR2rrpjhA"); bodyMap.put("pageNo", 1); bodyMap.put("pageSize", 10); @@ -50,14 +50,16 @@ public class SynchronizeCNPC { String signature = "hAFO76ZqXmIqosNw3PTAP4wxGJTN7MPawSU0QFDzzNioLjKMEaVFDlNKRIQX6n0DgyoVMy170T0b13P8uUTAQsbk9UNRPFO5i0fWp1hHOhNdaaQ2BdC0WXQz5QQ5epyK"; - Long date = new Date().getTime(); + Long date = new Date().getTime(); String sha256 = encodeBySHA256(signature + JSON.toJSONString(bodyMap) + date); - Map headerMap = new HashMap<>(); - headerMap.put("sign", sha256); + Map headerMap = new HashMap<>(); headerMap.put("token", token); + headerMap.put("sign", sha256); headerMap.put("ts", date); - log.info(HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", bodyMap, headerMap).toJSONString()); + //map2.put("sign", sha256); + JSONObject object = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", JSON.toJSONString(bodyMap), token, sha256, date); + log.error(object.toJSONString()); } } 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 8c442de3..a9cd8910 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 @@ -303,6 +303,45 @@ public class HttpsUtils { return null; } + public static JSONObject doPost(String apiUrl, String str, String token, String sign, Long ts) { + CloseableHttpClient httpClient = null; + if (apiUrl.startsWith("https")) { + httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) + .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); + } else { + httpClient = HttpClients.createDefault(); + } + String httpStr = null; + CloseableHttpResponse response = null; + + try { + HttpPost httpPost = new HttpPost(apiUrl); + httpPost.setConfig(requestConfig); + httpPost.setHeader("token", token); + httpPost.setHeader("sign", sign); + httpPost.setHeader("ts", ts.toString()); + StringEntity stringEntity = new StringEntity(str, "UTF-8");// 解决中文乱码问题 + stringEntity.setContentEncoding("UTF-8"); + stringEntity.setContentType("application/json"); + httpPost.setEntity(stringEntity); + response = httpClient.execute(httpPost); + HttpEntity entity = response.getEntity(); + httpStr = EntityUtils.toString(entity, "UTF-8"); + return JSON.parseObject(httpStr); + } catch (Exception e) { + log.error(e.getMessage(),e); + } finally { + if (response != null) { + try { + EntityUtils.consume(response.getEntity()); + } catch (IOException e) { + log.error(e.getMessage(),e); + } + } + } + return null; + } + /** * 创建SSL安全连接 *