|
|
@@ -575,68 +575,15 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
//外部联系人id
|
|
|
String externalUserId = message.getExternalUserId();
|
|
|
log.info("监听微信客户:{}发起会话事件", externalUserId);
|
|
|
- try {
|
|
|
- //等待3s
|
|
|
- Thread.sleep(3000);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- }
|
|
|
+
|
|
|
//获客链接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::getIsChat, 1)
|
|
|
.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());
|
|
|
- }
|
|
|
- }
|
|
|
- // 是否延后回传都记录,只看是否直接回传.
|
|
|
- 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);
|
|
|
- corpCustomerAcquistionCallback.setStatus(!corpCustomerAcquisitionLinkPopularize.getDelayedPost());
|
|
|
- if (corpCustomerAcquistionCallback.getId() != null) {
|
|
|
- corpCustomerAcquistionCallbackMapper.updateById(corpCustomerAcquistionCallback);
|
|
|
- } else {
|
|
|
- corpCustomerAcquistionCallbackMapper.insert(corpCustomerAcquistionCallback);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ redisService.sSet(RedisService.key.CORP_CUSTOMER_ACQUISTION_START_CHAT_SET.getEnvName(), externalUserId);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
@@ -1229,6 +1176,12 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
|
|
|
corpCustomerAcquistionCallbackMapper.insert(corpCustomerAcquistionCallback);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //是否为对话 回传
|
|
|
+ if (corpCustomerAcquisitionLinkPopularize.getIsChat()) {
|
|
|
+ jsonObject.putOpt("event", corpCustomerAcquisitionLinkPopularize.getAddEvent());
|
|
|
+ redisService.hset(RedisService.key.CORP_CUSTOMER_ACQUISTION_START_CHAT.getEnvName(), unionId, jsonObject.toString(), RedisService.key.CORP_CUSTOMER_ACQUISTION_START_CHAT.getTimeout());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|