Commit 95f66962 authored by 李健华's avatar 李健华

Merge branch 'feature/enterprise_token-2022-03-31' into 'master'

获取企业微信token更改为从消息中心获取

See merge request !58
parents 6d2502a3 08be6010
...@@ -193,7 +193,7 @@ public class UserRegisterServiceImpl implements IUserRegisterService { ...@@ -193,7 +193,7 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
@Override @Override
public User register(String phoneNo, Long channelId, Long registerFrom, String appChannel, Long btRegisterChannelId, String dimension) { public User register(String phoneNo, Long channelId, Long registerFrom, String appChannel, Long btRegisterChannelId, String dimension) {
// deregisterCheck(phoneNo); deregisterCheck(phoneNo);
UserRegisterParam userRegisterParam = UserRegisterParam.builder() UserRegisterParam userRegisterParam = UserRegisterParam.builder()
.registerFrom(registerFrom) .registerFrom(registerFrom)
......
...@@ -68,6 +68,8 @@ public class WechatFollowServiceImpl implements IWechatFollowService { ...@@ -68,6 +68,8 @@ public class WechatFollowServiceImpl implements IWechatFollowService {
private String customerInfoListBatchUrl; private String customerInfoListBatchUrl;
// 消息中心
private String msgEnterpriseToken;
@Resource @Resource
...@@ -80,6 +82,9 @@ public class WechatFollowServiceImpl implements IWechatFollowService { ...@@ -80,6 +82,9 @@ public class WechatFollowServiceImpl implements IWechatFollowService {
@Qualifier("stringRedisTemplate") @Qualifier("stringRedisTemplate")
private RedisTemplate<String, String> redisTemplate; private RedisTemplate<String, String> redisTemplate;
@Value("${mo-msg.http}")
private String msgCenter;
@Resource @Resource
private ApplicationEventPublisher applicationEventPublisher; private ApplicationEventPublisher applicationEventPublisher;
...@@ -110,6 +115,9 @@ public class WechatFollowServiceImpl implements IWechatFollowService { ...@@ -110,6 +115,9 @@ public class WechatFollowServiceImpl implements IWechatFollowService {
//批量获取客户详情 //批量获取客户详情
customerInfoListBatchUrl = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/batch/get_by_user?access_token=%s"; customerInfoListBatchUrl = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/batch/get_by_user?access_token=%s";
// 消息中心获取企业微信Token
msgEnterpriseToken = String.format("%s/middle_office/token/enterprise?corpId=%s", msgCenter, corpid);
} }
@Override @Override
...@@ -189,14 +197,16 @@ public class WechatFollowServiceImpl implements IWechatFollowService { ...@@ -189,14 +197,16 @@ public class WechatFollowServiceImpl implements IWechatFollowService {
private JsonResult executeEnterpriseFollowStatus(String s, String period) { private JsonResult executeEnterpriseFollowStatus(String s, String period) {
try { try {
String response = httpService.get(qyAccessTokenUrl); // String response = httpService.get(qyAccessTokenUrl);
String response = httpService.get(msgEnterpriseToken);
if (StringUtils.isEmpty(response)) { if (StringUtils.isEmpty(response)) {
log.info("请求消息中心企业微信Token为空---{}", response);
return null; return null;
} }
AccessTokenResponse accessTokenResponse = JSONObject.parseObject(response, Map<String, Object> tokenReponseMap = JSONObject.parseObject(response, Map.class);
AccessTokenResponse.class); String token = tokenReponseMap.get("data").toString();
if (accessTokenResponse.getAccessToken() != null) { if (token != null && !"".equals(token)) {
String deparmentList = String.format(departmentUserListUrl, accessTokenResponse.getAccessToken(), departmentId); String deparmentList = String.format(departmentUserListUrl, token, departmentId);
String departmentRep = httpService.get(deparmentList); String departmentRep = httpService.get(deparmentList);
DepartmentListResponse departmentListResponse = JSONObject.parseObject(departmentRep, DepartmentListResponse.class); DepartmentListResponse departmentListResponse = JSONObject.parseObject(departmentRep, DepartmentListResponse.class);
if (!departmentListResponse.getUserlist().isEmpty()) { if (!departmentListResponse.getUserlist().isEmpty()) {
...@@ -204,7 +214,7 @@ public class WechatFollowServiceImpl implements IWechatFollowService { ...@@ -204,7 +214,7 @@ public class WechatFollowServiceImpl implements IWechatFollowService {
System.out.println(userIdList); System.out.println(userIdList);
if (!userIdList.isEmpty()) { if (!userIdList.isEmpty()) {
// 批量查询客户详情 // 批量查询客户详情
batchQueryCustomerDetailInfo2(accessTokenResponse.getAccessToken(), userIdList, "", period); batchQueryCustomerDetailInfo2(token, userIdList, "", period);
} }
} }
} }
......
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