Commit 41e8dbbd authored by 李健华's avatar 李健华

每次请求不单独获取access_token

parent 8c768cca
......@@ -189,11 +189,9 @@ public class WechatFollowServiceImpl implements IWechatFollowService {
System.out.println(userIdList);
if (!userIdList.isEmpty()) {
// 批量查询客户详情
batchQueryCustomerDetailInfo(userIdList, "", period);
batchQueryCustomerDetailInfo(accessTokenResponse.getAccessToken(), userIdList, "", period);
}
}
System.out.println(departmentListResponse);
}
} catch (Exception e) {
log.error("同步企业微信数据失败--{}", e.getMessage());
......@@ -203,14 +201,7 @@ public class WechatFollowServiceImpl implements IWechatFollowService {
return null;
}
private JsonResult batchQueryCustomerDetailInfo(List<String> userIdList, String cursor, Integer period) {
String response = httpService.get(qyAccessTokenUrl);
if (StringUtils.isEmpty(response)) {
return null;
}
AccessTokenResponse accessTokenResponse = JSONObject.parseObject(response,
AccessTokenResponse.class);
String accessToken = accessTokenResponse.getAccessToken();
private void batchQueryCustomerDetailInfo(String accessToken, List<String> userIdList, String cursor, Integer period) {
// 查询客户详情
HashMap<String, Object> parameters = new HashMap<>();
parameters.put("userid_list", userIdList);
......@@ -219,6 +210,7 @@ public class WechatFollowServiceImpl implements IWechatFollowService {
String customerInfoUrl = String.format(customerInfoListBatchUrl, accessToken);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> responseEntity = restTemplate.postForEntity(customerInfoUrl, parameters, String.class); //提交的body内容为user对象,请求的返回的body类型为String
log.info("batchQueryCustomerDetailInfo--customerInfoUrl:{}, parameters:{}", customerInfoUrl, parameters);
CustomerListResponse customerListResponse = JSONObject.parseObject(responseEntity.getBody(), CustomerListResponse.class);
if (customerListResponse.getErrcode() == 0) {
// 获取所有unionId
......@@ -235,10 +227,11 @@ public class WechatFollowServiceImpl implements IWechatFollowService {
// 根据unionid 添加现有指定信息
// 判断nextCursor不为空,继续获取更多客户
if (!"".equals(customerListResponse.getNextCursor())) {
batchQueryCustomerDetailInfo(userIdList, customerListResponse.getNextCursor(), period);
batchQueryCustomerDetailInfo(accessToken, userIdList, customerListResponse.getNextCursor(), period);
}
} else {
batchQueryCustomerDetailInfo(accessToken, userIdList, customerListResponse.getNextCursor(), period);
}
return JsonResult.buildSuccessResult();
}
private void initTask() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment