'提交代码'

dev-discount
胡锐 4 years ago
parent 0c2d55d5f8
commit ada630b7cb
  1. 4
      hai-cweb/src/test/common/RegionTest.java
  2. 2
      hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java
  3. 2
      hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java
  4. 14
      hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java
  5. 39
      hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java

@ -99,11 +99,11 @@ public class RegionTest {
String sha256 = encodeBySHA256(signature + JSON.toJSONString(bodyMap) + date); String sha256 = encodeBySHA256(signature + JSON.toJSONString(bodyMap) + date);
Map<String,Object> headerMap = new HashMap<>(); Map<String,Object> headerMap = new HashMap<>();
headerMap.put("sign", sha256);
headerMap.put("token", token); headerMap.put("token", token);
headerMap.put("sign", sha256);
headerMap.put("ts", date); headerMap.put("ts", date);
//map2.put("sign", sha256); //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()); //System.out.println(jsonObject.toJSONString());
} }

@ -20,7 +20,7 @@ public class HighCouponSchedule {
private HighUserCouponService highUserCouponService; private HighUserCouponService highUserCouponService;
// @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 // @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
@Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行 // @Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行
public void certification() { public void certification() {
List<HighUserCoupon> userCoupons = highUserCouponService.getOverdueCoupon(); List<HighUserCoupon> userCoupons = highUserCouponService.getOverdueCoupon();
for (HighUserCoupon highUserCoupon : userCoupons) { for (HighUserCoupon highUserCoupon : userCoupons) {

@ -24,7 +24,7 @@ public class HighOrderSchedule {
@Resource @Resource
private HighOrderService highOrderService; private HighOrderService highOrderService;
@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 // @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
public void certification() { public void certification() {
List<HighOrder> orderList = highOrderService.getCloseOrder(); List<HighOrder> orderList = highOrderService.getCloseOrder();

@ -35,12 +35,12 @@ public class SynchronizeCNPC {
tokenMap.put("appId", "jsVpwDoHZfR2rrpjhA"); tokenMap.put("appId", "jsVpwDoHZfR2rrpjhA");
tokenMap.put("appSecret", "R7yJjinikdPhOlTrVgmdS7cblWMMOf99zEJkfPgaTIoDtKGlX51JKueLV725a6S4"); tokenMap.put("appSecret", "R7yJjinikdPhOlTrVgmdS7cblWMMOf99zEJkfPgaTIoDtKGlX51JKueLV725a6S4");
JSONObject jsonObject = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/api/open/merchant/token", JSON.toJSONString(tokenMap)); 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) { if (jsonObject != null && jsonObject.getBoolean("success") == true) {
JSONObject data = jsonObject.getJSONObject("data"); JSONObject data = jsonObject.getJSONObject("data");
String token = data.getString("token"); String token = data.getString("token");
Map<String, Object> bodyMap = new HashMap<>(); Map<String,Object> bodyMap = new HashMap<>();
bodyMap.put("appId", "jsVpwDoHZfR2rrpjhA"); bodyMap.put("appId", "jsVpwDoHZfR2rrpjhA");
bodyMap.put("pageNo", 1); bodyMap.put("pageNo", 1);
bodyMap.put("pageSize", 10); bodyMap.put("pageSize", 10);
@ -50,14 +50,16 @@ public class SynchronizeCNPC {
String signature = "hAFO76ZqXmIqosNw3PTAP4wxGJTN7MPawSU0QFDzzNioLjKMEaVFDlNKRIQX6n0DgyoVMy170T0b13P8uUTAQsbk9UNRPFO5i0fWp1hHOhNdaaQ2BdC0WXQz5QQ5epyK"; String signature = "hAFO76ZqXmIqosNw3PTAP4wxGJTN7MPawSU0QFDzzNioLjKMEaVFDlNKRIQX6n0DgyoVMy170T0b13P8uUTAQsbk9UNRPFO5i0fWp1hHOhNdaaQ2BdC0WXQz5QQ5epyK";
Long date = new Date().getTime(); Long date = new Date().getTime();
String sha256 = encodeBySHA256(signature + JSON.toJSONString(bodyMap) + date); String sha256 = encodeBySHA256(signature + JSON.toJSONString(bodyMap) + date);
Map<String, Object> headerMap = new HashMap<>(); Map<String,Object> headerMap = new HashMap<>();
headerMap.put("sign", sha256);
headerMap.put("token", token); headerMap.put("token", token);
headerMap.put("sign", sha256);
headerMap.put("ts", date); 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());
} }
} }

@ -303,6 +303,45 @@ public class HttpsUtils {
return null; 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安全连接 * 创建SSL安全连接
* *

Loading…
Cancel
Save