|
|
@@ -1,6 +1,7 @@
|
|
|
package com.fs.newAdv.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
@@ -61,23 +62,27 @@ public class LeadServiceImpl extends ServiceImpl<LeadMapper, Lead> implements IL
|
|
|
|
|
|
@Override
|
|
|
@Async
|
|
|
- public void updateGroupAddMemberLead(String userId, String chatId, String corpId, String unionid) {
|
|
|
+ public void updateGroupAddMemberLead(String name, String chatId, String corpId, String unionid) {
|
|
|
+ LambdaQueryWrapper<Lead> last = new LambdaQueryWrapper<Lead>();
|
|
|
+ if (StrUtil.isNotEmpty(unionid)) {
|
|
|
+ last.eq(Lead::getUnionid, unionid);
|
|
|
+ } else if (StrUtil.isNotEmpty(name)) {
|
|
|
+ last.eq(Lead::getWeiChatName, name);
|
|
|
+ }
|
|
|
+ last.eq(Lead::getAddContactQw, 0).last("LIMIT 1");
|
|
|
// 末次归因逻辑
|
|
|
- Lead lead = this.getOne(new LambdaQueryWrapper<Lead>()
|
|
|
- .eq(Lead::getUnionid, unionid)
|
|
|
- .eq(Lead::getAddContactQw, 0)
|
|
|
- .last("LIMIT 1"));
|
|
|
+ Lead lead = this.getOne(last);
|
|
|
if (lead != null) {
|
|
|
lead.setChatId(chatId);
|
|
|
lead.setAddContactQw(1);
|
|
|
+ lead.setCorpId(corpId);
|
|
|
this.updateById(lead);
|
|
|
-
|
|
|
if (ObjectUtil.isNotEmpty(lead.getLandingPageTs()) && lead.getLandingPageTs().toLocalDate().isEqual(LocalDate.now())) {
|
|
|
// 当日加群事件回调
|
|
|
conversionEventPublisher.publishConversionEvent(lead.getTraceId(), SystemEventTypeEnum.GROUP_TODAY);
|
|
|
}
|
|
|
} else {
|
|
|
- log.info("用户加群线索信息不存在:{}", userId);
|
|
|
+ log.info("用户加群线索信息不存在:{}", name);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -91,13 +96,32 @@ public class LeadServiceImpl extends ServiceImpl<LeadMapper, Lead> implements IL
|
|
|
log.info("外部联系人信息不存在:{}", externalId);
|
|
|
return;
|
|
|
}
|
|
|
+ qwExternalContact.setUnionid(unionid);
|
|
|
+ this.updateAddMemberLead(qwExternalContact);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateAddMemberLead(String externalUserID, String userID, String corpId, String State) {
|
|
|
+ QwExternalContact qwExternalContact = qwExternalContactMapper.selectQwExternalByExternalIdAndCompanyIdToIdAndFs(externalUserID, userID, corpId);
|
|
|
+ if (qwExternalContact == null) {
|
|
|
+ log.info("外部联系人信息不存在:{} {} {}", externalUserID, userID, corpId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.updateAddMemberLead(qwExternalContact);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateAddMemberLead(QwExternalContact qwExternalContact) {
|
|
|
+ LambdaQueryWrapper<Lead> last = new LambdaQueryWrapper<Lead>();
|
|
|
+ if (StrUtil.isNotEmpty(qwExternalContact.getUnionid())) {
|
|
|
+ last.eq(Lead::getUnionid, qwExternalContact.getUnionid());
|
|
|
+ } else if (StrUtil.isNotEmpty(qwExternalContact.getName())) {
|
|
|
+ last.eq(Lead::getWeiChatName, qwExternalContact.getName());
|
|
|
+ }
|
|
|
+ last.eq(Lead::getAddContactQwGroup, 0).last("LIMIT 1");
|
|
|
// 末次归因逻辑
|
|
|
- Lead lead = this.getOne(new LambdaQueryWrapper<Lead>()
|
|
|
- .eq(Lead::getUnionid, unionid)
|
|
|
- .eq(Lead::getAddContactQwGroup, 0)
|
|
|
- .last("LIMIT 1"));
|
|
|
+ Lead lead = this.getOne(last);
|
|
|
if (lead != null) {
|
|
|
- lead.setExternalId(externalId);
|
|
|
+ lead.setExternalId(qwExternalContact.getId());
|
|
|
lead.setAddContactQwGroup(1);
|
|
|
this.updateById(lead);
|
|
|
// 绑定企微用户线索关系
|
|
|
@@ -111,7 +135,7 @@ public class LeadServiceImpl extends ServiceImpl<LeadMapper, Lead> implements IL
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- log.info("广告归因线索不存在:{} {}", externalId, unionid);
|
|
|
+ log.info("广告归因线索不存在:{}", qwExternalContact);
|
|
|
}
|
|
|
}
|
|
|
|