|
|
@@ -569,6 +569,72 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public CorpXmlOutMessage customerStartChat(CorpXmlMessage message, Map<String, Object> context) {
|
|
|
+ //微信客户发起会话事件
|
|
|
+ //外部联系人id
|
|
|
+ String externalUserId = message.getExternalUserId();
|
|
|
+ log.info("监听微信客户:{}发起会话事件", externalUserId);
|
|
|
+ //获客链接id
|
|
|
+ String linkId = message.getLinkId();
|
|
|
+ CorpUserAuth corpUserAuth = corpUserAuthMapper.selectOne(Wrappers.lambdaQuery(CorpUserAuth.class)
|
|
|
+ .eq(CorpUserAuth::getExternalUserid, externalUserId).last("limit 1"));
|
|
|
+ String unionId = null;
|
|
|
+ if (corpUserAuth != null) {
|
|
|
+ CorpUser corpUser = corpUserMapper.selectById(corpUserAuth.getCorpUserId());
|
|
|
+ if (corpUser != null) {
|
|
|
+ unionId = corpUser.getUnionid();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StrUtil.isEmpty(unionId)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CorpCustomerAcquisitionLinkPopularize corpCustomerAcquisitionLinkPopularize = corpCustomerAcquisitionLinkPopularizeMapper.selectOne(Wrappers.lambdaQuery(CorpCustomerAcquisitionLinkPopularize.class)
|
|
|
+ .eq(CorpCustomerAcquisitionLinkPopularize::getCustomerAcquistionLinkId, linkId).last("limit 1"));
|
|
|
+ if (corpCustomerAcquisitionLinkPopularize != null) {
|
|
|
+ //callback
|
|
|
+ String callback = null;
|
|
|
+ String params = redisService.getStr(String.format(RedisService.key.CORP_CUSTOMER_ACQUISTION_UNIONID_CLICKID.getName(), unionId));
|
|
|
+ if (StringUtils.isNotBlank(params)) {
|
|
|
+ JSONObject paramsObj = JSONUtil.parseObj(params);
|
|
|
+ callback = paramsObj.getStr("callback");
|
|
|
+ }
|
|
|
+ //如果需要延后主动回传的做持久化.
|
|
|
+ if (StrUtil.isNotBlank(callback)) {
|
|
|
+ log.info("开始回传客户:{}发起会话事件", externalUserId);
|
|
|
+ //如果为加粉则直接回传
|
|
|
+ if (corpCustomerAcquisitionLinkPopularize.getType() == 1) {
|
|
|
+ //如果需要延后主动回传的做持久化.
|
|
|
+ if (!corpCustomerAcquisitionLinkPopularize.getDelayedPost()) {
|
|
|
+ postData(callback, corpCustomerAcquisitionLinkPopularize.getEvent());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //深度转化 前置加粉事件回传.
|
|
|
+ if (StringUtils.isNotBlank(corpCustomerAcquisitionLinkPopularize.getAddEvent())) {
|
|
|
+ postData(callback, corpCustomerAcquisitionLinkPopularize.getAddEvent());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (corpCustomerAcquisitionLinkPopularize.getDelayedPost()) {
|
|
|
+ CorpCustomerAcquistionCallback corpCustomerAcquistionCallback =
|
|
|
+ corpCustomerAcquistionCallbackMapper.selectOne(Wrappers.lambdaQuery(CorpCustomerAcquistionCallback.class).eq(CorpCustomerAcquistionCallback::getCallback, callback).eq(CorpCustomerAcquistionCallback::getUnionId, unionId));
|
|
|
+ if (corpCustomerAcquistionCallback == null) {
|
|
|
+ corpCustomerAcquistionCallback = new CorpCustomerAcquistionCallback();
|
|
|
+ }
|
|
|
+ corpCustomerAcquistionCallback.setCallback(callback);
|
|
|
+ corpCustomerAcquistionCallback.setEvent(corpCustomerAcquisitionLinkPopularize.getEvent());
|
|
|
+ corpCustomerAcquistionCallback.setUnionId(unionId);
|
|
|
+ if (corpCustomerAcquistionCallback.getId() != null) {
|
|
|
+ corpCustomerAcquistionCallbackMapper.updateById(corpCustomerAcquistionCallback);
|
|
|
+ } else {
|
|
|
+ corpCustomerAcquistionCallbackMapper.insert(corpCustomerAcquistionCallback);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改客户成员关系,客户标签
|
|
|
*/
|
|
|
@@ -1124,12 +1190,17 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
if (corpCustomerAcquisitionLinkPopularize.getType() == 1) {
|
|
|
//如果需要延后主动回传的做持久化.
|
|
|
if(!corpCustomerAcquisitionLinkPopularize.getDelayedPost()){
|
|
|
- postData(callback, corpCustomerAcquisitionLinkPopularize.getEvent());
|
|
|
+ if (!corpCustomerAcquisitionLinkPopularize.getIsChat()) {
|
|
|
+ postData(callback, corpCustomerAcquisitionLinkPopularize.getEvent());
|
|
|
+ }
|
|
|
}
|
|
|
}else {
|
|
|
//深度转化 前置加粉事件回传.
|
|
|
- if(StringUtils.isNotBlank(corpCustomerAcquisitionLinkPopularize.getAddEvent())){
|
|
|
- postData(callback, corpCustomerAcquisitionLinkPopularize.getAddEvent());
|
|
|
+ if (StringUtils.isNotBlank(corpCustomerAcquisitionLinkPopularize.getAddEvent())) {
|
|
|
+ //是否是监听客户发起会话事件 false
|
|
|
+ if (!corpCustomerAcquisitionLinkPopularize.getIsChat()) {
|
|
|
+ postData(callback, corpCustomerAcquisitionLinkPopularize.getAddEvent());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//深度回传.
|