|
|
@@ -137,6 +137,8 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
|
|
|
private final CorpCustomerAcquistionCallbackMapper corpCustomerAcquistionCallbackMapper;
|
|
|
|
|
|
+ private final CorpFollowMapper corpFollowMapper;
|
|
|
+
|
|
|
private static final String DEFAULT_MSG = "您好,欢迎加入银河录像局";
|
|
|
|
|
|
/**
|
|
|
@@ -593,6 +595,30 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public CorpXmlOutMessage creatOrUpdateFollowUser(CorpXmlMessage message) throws Exception {
|
|
|
+ //corpId
|
|
|
+ String corpId = message.getToUserName();
|
|
|
+ //成员id
|
|
|
+ String userId = message.getUserId();
|
|
|
+
|
|
|
+ Long wxCorpId = WeChatCorpFactory.getCorpConfigStrategy(corpId).getId();
|
|
|
+ CorpFollow corpFollow = corpFollowMapper.selectOne(Wrappers.lambdaQuery(CorpFollow.class).eq(CorpFollow::getWxCorpId, wxCorpId).eq(CorpFollow::getUserid, userId));
|
|
|
+ CorpUserInfo userInfo = wxCorpOps.getFollowUser(corpId, userId);
|
|
|
+ if (corpFollow == null) {
|
|
|
+ corpFollow = new CorpFollow();
|
|
|
+ BeanUtil.copyProperties(userInfo, corpFollow);
|
|
|
+ corpFollow.setWxCorpId(wxCorpId);
|
|
|
+ corpFollowMapper.insert(corpFollow);
|
|
|
+ //同步客户列表
|
|
|
+ getCorpUserInfo(corpId, corpFollow.getUserid());
|
|
|
+ } else {
|
|
|
+ BeanUtil.copyProperties(userInfo, corpFollow);
|
|
|
+ corpFollowMapper.updateById(corpFollow);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改客户成员关系,客户标签
|
|
|
*/
|
|
|
@@ -1227,4 +1253,46 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
}
|
|
|
return corpWelcomeTemplate;
|
|
|
}
|
|
|
+
|
|
|
+ public void getCorpUserInfo(String corpId, String userId) {
|
|
|
+ THREAD_POOL.execute(() -> {
|
|
|
+ List<String> externalList = null;
|
|
|
+ try {
|
|
|
+ externalList = wxCorpOps.listExternalContacts(corpId, userId);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (externalList.size() > 1000) {
|
|
|
+ List<List<String>> lists = StringUtil.averageAssign(externalList, 5);
|
|
|
+ for (List<String> list : lists) {
|
|
|
+ THREAD_POOL.execute(() -> {
|
|
|
+ for (String externalUserid : list) {
|
|
|
+ try {
|
|
|
+ log.info("同步客户数据 corpId:{},externalUserid:{}", corpId, externalUserid);
|
|
|
+ //尝试添加客户
|
|
|
+ CorpXmlMessage message = new CorpXmlMessage();
|
|
|
+ message.setToUserName(corpId);
|
|
|
+ message.setExternalUserId(externalUserid);
|
|
|
+ addExternalContact(message, null);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (String externalUserid : externalList) {
|
|
|
+ try {
|
|
|
+ //尝试添加客户
|
|
|
+ CorpXmlMessage message = new CorpXmlMessage();
|
|
|
+ message.setToUserName(corpId);
|
|
|
+ message.setExternalUserId(externalUserid);
|
|
|
+ addExternalContact(message, null);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|