|
@@ -23,6 +23,7 @@ import com.cyksj.model.request.corp.CorpXmlOutMessage;
|
|
|
import com.cyksj.model.response.ExternalContact;
|
|
import com.cyksj.model.response.ExternalContact;
|
|
|
import com.cyksj.model.response.FollowedUser;
|
|
import com.cyksj.model.response.FollowedUser;
|
|
|
import com.cyksj.model.response.corp.CorpExternalContactInfo;
|
|
import com.cyksj.model.response.corp.CorpExternalContactInfo;
|
|
|
|
|
+import com.cyksj.model.response.corp.CorpUserExternalTagGroupInfo;
|
|
|
import com.cyksj.model.response.corp.CorpUserExternalTagGroupList;
|
|
import com.cyksj.model.response.corp.CorpUserExternalTagGroupList;
|
|
|
import com.cyksj.service.corp.WxCorpOps;
|
|
import com.cyksj.service.corp.WxCorpOps;
|
|
|
import com.cyksj.service.corp.msg.CorpEventActionService;
|
|
import com.cyksj.service.corp.msg.CorpEventActionService;
|
|
@@ -102,13 +103,19 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
if (corpUserInfo == null) {
|
|
if (corpUserInfo == null) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
- //2.客户添加成员信息
|
|
|
|
|
- List<FollowedUser> followedUsers = externalContact.getFollowedUsers();
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
THREAD_POOL.execute(()->{
|
|
THREAD_POOL.execute(()->{
|
|
|
|
|
+ //2.客户添加成员信息
|
|
|
|
|
+ List<FollowedUser> followedUsers = externalContact.getFollowedUsers();
|
|
|
//保存企微用户
|
|
//保存企微用户
|
|
|
CorpUser corpUser = saveOrUpdateCorpUser(message, corpUserInfo, followedUsers);
|
|
CorpUser corpUser = saveOrUpdateCorpUser(message, corpUserInfo, followedUsers);
|
|
|
-
|
|
|
|
|
|
|
+ if (StrUtil.equals(message.getState(), Constant.DY_CS_CODE_KEY)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ followedUsers = wxCorpOps.getExternalContact(message.getToUserName(), message.getExternalUserId()).getFollowedUsers();
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
CorpUserAuth corpUserAuth = corpUserAuthMapper.selectOne(Wrappers.lambdaQuery(CorpUserAuth.class).eq(CorpUserAuth::getExternalUserid, corpUserInfo.getExternalUserId()).eq(CorpUserAuth::getWxCorpId, wxCorpApp.getId()));
|
|
CorpUserAuth corpUserAuth = corpUserAuthMapper.selectOne(Wrappers.lambdaQuery(CorpUserAuth.class).eq(CorpUserAuth::getExternalUserid, corpUserInfo.getExternalUserId()).eq(CorpUserAuth::getWxCorpId, wxCorpApp.getId()));
|
|
|
if (corpUserAuth == null) {
|
|
if (corpUserAuth == null) {
|
|
|
corpUserAuth = new CorpUserAuth();
|
|
corpUserAuth = new CorpUserAuth();
|
|
@@ -420,12 +427,27 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
corpUser.setState(message.getState());
|
|
corpUser.setState(message.getState());
|
|
|
//打标签
|
|
//打标签
|
|
|
if (StrUtil.equals(message.getState(), Constant.DY_CS_CODE_KEY) && CollUtil.isNotEmpty(followedUsers)) {
|
|
if (StrUtil.equals(message.getState(), Constant.DY_CS_CODE_KEY) && CollUtil.isNotEmpty(followedUsers)) {
|
|
|
- followedUsers.forEach(follow -> {
|
|
|
|
|
|
|
+ //查询对应标签是否存在
|
|
|
|
|
+ CorpTag corpTag = corpTagMapper.selectOne(Wrappers.lambdaQuery(CorpTag.class)
|
|
|
|
|
+ .eq(CorpTag::getName, Constant.DY_CS_CODE_KEY).last("limit 1"));
|
|
|
|
|
+ if (corpTag == null) {
|
|
|
try {
|
|
try {
|
|
|
- wxCorpOps.markTag(corpUserInfo.getExternalUserId(), follow.getUserId(), new String[]{Constant.DY_CS_CODE_KEY}, null);
|
|
|
|
|
|
|
+ corpTag = addCorpTag(Constant.DY_CS_CODE_KEY, Constant.DY_CS_CODE_KEY, message.getToUserName());
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if (corpTag != null) {
|
|
|
|
|
+ List<String> dy_tag = List.of(corpTag.getTagId());
|
|
|
|
|
+ followedUsers.forEach(follow -> {
|
|
|
|
|
+ if (!Constant.DY_CUS.contains(follow.getUserId())) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ wxCorpOps.markTag(corpUserInfo.getExternalUserId(), follow.getUserId(), dy_tag.toArray(new String[dy_tag.size()]), null);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//新增修改客户信息
|
|
//新增修改客户信息
|
|
@@ -450,4 +472,32 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
}
|
|
}
|
|
|
return corpUser;
|
|
return corpUser;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public CorpTag addCorpTag(String tagGroupName, String tagName, String corpId) throws Exception {
|
|
|
|
|
+ CorpUserExternalTagGroupInfo tagGroupInfoReq = new CorpUserExternalTagGroupInfo();
|
|
|
|
|
+ CorpUserExternalTagGroupInfo.TagGroup group = new CorpUserExternalTagGroupInfo.TagGroup();
|
|
|
|
|
+ CorpUserExternalTagGroupInfo.Tag tag = new CorpUserExternalTagGroupInfo.Tag();
|
|
|
|
|
+ tag.setName(tagName);
|
|
|
|
|
+ group.setTag(List.of(tag));
|
|
|
|
|
+ group.setGroupName(tagGroupName);
|
|
|
|
|
+ tagGroupInfoReq.setTagGroup(group);
|
|
|
|
|
+ CorpUserExternalTagGroupInfo corpUserExternalTagGroupInfo = wxCorpOps.addCorpTag(tagGroupInfoReq, corpId);
|
|
|
|
|
+ CorpUserExternalTagGroupInfo.TagGroup tagGroup = corpUserExternalTagGroupInfo.getTagGroup();
|
|
|
|
|
+ List<CorpUserExternalTagGroupInfo.Tag> tagList = tagGroup.getTag();
|
|
|
|
|
+ for (CorpUserExternalTagGroupInfo.Tag save_tag : tagList) {
|
|
|
|
|
+ if (StrUtil.equals(tagName, save_tag.getName())) {
|
|
|
|
|
+ CorpTag corpTag = new CorpTag();
|
|
|
|
|
+ corpTag.setGroupId(tagGroup.getGroupId());
|
|
|
|
|
+ corpTag.setGroupName(tagGroup.getGroupName());
|
|
|
|
|
+ corpTag.setType(1);
|
|
|
|
|
+
|
|
|
|
|
+ corpTag.setTagId(save_tag.getId());
|
|
|
|
|
+ corpTag.setName(save_tag.getName());
|
|
|
|
|
+ corpTagMapper.insert(corpTag);
|
|
|
|
|
+ return corpTag;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|