Bläddra i källkod

fix 客服活码 动态标签标记

zoujiajian 2 år sedan
förälder
incheckning
6ce67f5ef8

+ 2 - 0
netflix-common/src/main/java/com/cyksj/common/constant/Constant.java

@@ -173,4 +173,6 @@ public interface Constant {
 	 * 人民币符号
 	 */
 	String CN_CYS = "¥";
+
+	String DY_CS_CODE_KEY = "抖音免费设备";
 }

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/CorpFollowConfig.java

@@ -23,4 +23,6 @@ public class CorpFollowConfig extends BaseEntity{
 	private String configId;
 
 	private String qrCode;
+
+	private String remark;
 }

+ 9 - 0
netflix-dao/src/main/java/com/cyksj/model/request/corp/CorpFollowContact.java

@@ -22,16 +22,25 @@ public class CorpFollowContact {
 	 */
 	private Integer scene;
 
+	/**
+	 * 在小程序中联系时使用的控件样式,详见附表
+	 */
 	private Integer style;
 
 	private String remark;
 
+	/**
+	 * 外部客户添加时是否无需验证,默认为true
+	 */
 	private boolean skip_verify;
 
 	private String state;
 
 	private List<String> user;
 
+	/**
+	 * 使用该联系方式的部门id列表,只在type为2时有效
+	 */
 	private List<Integer> party;
 
 	private boolean is_temp;

+ 18 - 7
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpEventActionServiceImpl.java

@@ -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) {

+ 1 - 0
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowDynamicConfigServiceImpl.java

@@ -38,6 +38,7 @@ public class CorpFollowDynamicConfigServiceImpl implements CorpFollowDynamicConf
 			corpFollowConfig.setFollowId(followId);
 			corpFollowConfig.setQrCode(jsonObject.getStr("qr_code"));
 			corpFollowConfig.setConfigId(jsonObject.getStr("config_id"));
+			corpFollowConfig.setRemark(corpFollowContact.getRemark());
 			corpFollowConfigMapper.insert(corpFollowConfig);
 		});
 		return body;