|
|
@@ -1,6 +1,7 @@
|
|
|
package com.cyksj.service.corp.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
@@ -19,10 +20,10 @@ import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.request.corp.Attachments;
|
|
|
import com.cyksj.model.request.corp.CorpXmlMessage;
|
|
|
import com.cyksj.model.request.corp.CorpXmlOutMessage;
|
|
|
-import com.cyksj.model.response.corp.CorpExternalContactInfo;
|
|
|
-import com.cyksj.model.response.corp.CorpUserExternalTagGroupList;
|
|
|
import com.cyksj.model.response.ExternalContact;
|
|
|
import com.cyksj.model.response.FollowedUser;
|
|
|
+import com.cyksj.model.response.corp.CorpExternalContactInfo;
|
|
|
+import com.cyksj.model.response.corp.CorpUserExternalTagGroupList;
|
|
|
import com.cyksj.service.corp.WxCorpOps;
|
|
|
import com.cyksj.service.corp.msg.CorpEventActionService;
|
|
|
import com.cyksj.service.mange.coupon.CouponCommonService;
|
|
|
@@ -101,9 +102,12 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
if (corpUserInfo == null) {
|
|
|
return null;
|
|
|
}
|
|
|
+ //2.客户添加成员信息
|
|
|
+ List<FollowedUser> followedUsers = externalContact.getFollowedUsers();
|
|
|
+
|
|
|
THREAD_POOL.execute(()->{
|
|
|
//保存企微用户
|
|
|
- CorpUser corpUser = saveOrUpdateCorpUser(message, corpUserInfo);
|
|
|
+ CorpUser corpUser = saveOrUpdateCorpUser(message, corpUserInfo, followedUsers);
|
|
|
|
|
|
CorpUserAuth corpUserAuth = corpUserAuthMapper.selectOne(Wrappers.lambdaQuery(CorpUserAuth.class).eq(CorpUserAuth::getExternalUserid, corpUserInfo.getExternalUserId()).eq(CorpUserAuth::getWxCorpId, wxCorpApp.getId()));
|
|
|
if (corpUserAuth == null) {
|
|
|
@@ -114,8 +118,6 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
corpUserAuthMapper.insert(corpUserAuth);
|
|
|
}
|
|
|
|
|
|
- //2.客户添加成员信息
|
|
|
- List<FollowedUser> followedUsers = externalContact.getFollowedUsers();
|
|
|
|
|
|
Set<String> relationFollowUserIds = relationMapper.selectList(Wrappers.lambdaQuery(CorpUserFollowRelation.class)
|
|
|
.select(CorpUserFollowRelation::getFollowId)
|
|
|
@@ -202,7 +204,7 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
|
|
|
//保存企微用户
|
|
|
if (externalContact.getExternalContact() != null) {
|
|
|
- saveOrUpdateCorpUser(message, externalContact.getExternalContact());
|
|
|
+ saveOrUpdateCorpUser(message, externalContact.getExternalContact(), null);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
@@ -402,7 +404,7 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public CorpUser saveOrUpdateCorpUser(CorpXmlMessage message, ExternalContact corpUserInfo) {
|
|
|
+ public CorpUser saveOrUpdateCorpUser(CorpXmlMessage message, ExternalContact corpUserInfo, List<FollowedUser> followedUsers) {
|
|
|
//查询客户是否存在
|
|
|
CorpUser corpUser = Optional.ofNullable(
|
|
|
corpUserMapper.selectOne(Wrappers.lambdaQuery(CorpUser.class)
|
|
|
@@ -416,6 +418,15 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
corpUser.setType(corpUserInfo.getType());
|
|
|
//扫码来源
|
|
|
corpUser.setState(message.getState());
|
|
|
+ //打标签
|
|
|
+ if (StrUtil.equals(message.getState(), Constant.DY_CS_CODE_KEY) && CollUtil.isNotEmpty(followedUsers)) {
|
|
|
+ followedUsers.forEach(follow -> {
|
|
|
+ try {
|
|
|
+ wxCorpOps.markTag(corpUserInfo.getExternalUserId(), follow.getUserId(), new String[]{Constant.DY_CS_CODE_KEY}, null);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
//新增修改客户信息
|
|
|
if (corpUser.getId() == null) {
|