|
|
@@ -2,10 +2,13 @@ package com.fs.newAdv.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fs.newAdv.constant.AdvConfigConstant;
|
|
|
import com.fs.newAdv.domain.Lead;
|
|
|
+import com.fs.newAdv.dto.res.AdvConfigRes;
|
|
|
import com.fs.newAdv.enums.SystemEventTypeEnum;
|
|
|
import com.fs.newAdv.event.ConversionEventPublisher;
|
|
|
import com.fs.newAdv.mapper.LeadMapper;
|
|
|
@@ -13,6 +16,7 @@ import com.fs.newAdv.service.ILeadService;
|
|
|
import com.fs.qw.domain.QwExternalContact;
|
|
|
import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
import com.fs.qw.service.IQwExternalContactService;
|
|
|
+import com.fs.system.service.ISysConfigService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
@@ -40,6 +44,10 @@ public class LeadServiceImpl extends ServiceImpl<LeadMapper, Lead> implements IL
|
|
|
@Autowired
|
|
|
private QwExternalContactMapper qwExternalContactMapper;
|
|
|
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService sysConfigService;
|
|
|
+
|
|
|
@Override
|
|
|
public Lead getByTraceId(String traceId) {
|
|
|
List<Lead> list = this.list(new LambdaQueryWrapper<Lead>()
|
|
|
@@ -80,7 +88,9 @@ public class LeadServiceImpl extends ServiceImpl<LeadMapper, Lead> implements IL
|
|
|
} else if (StrUtil.isNotEmpty(name)) {
|
|
|
last.eq(Lead::getWeiChatName, name);
|
|
|
}
|
|
|
- last.eq(Lead::getAddContactQw, 0).last("LIMIT 1");
|
|
|
+ last.eq(Lead::getAddContactQw, 0);
|
|
|
+ last.eq(Lead::getStatus, 0);
|
|
|
+ last.orderByDesc(Lead::getCreateTime).last("LIMIT 1");
|
|
|
// 末次归因逻辑
|
|
|
Lead lead = this.getOne(last);
|
|
|
if (lead != null) {
|
|
|
@@ -88,15 +98,34 @@ public class LeadServiceImpl extends ServiceImpl<LeadMapper, Lead> implements IL
|
|
|
lead.setAddContactQw(1);
|
|
|
lead.setCorpId(corpId);
|
|
|
this.updateById(lead);
|
|
|
- if (ObjectUtil.isNotEmpty(lead.getLandingPageTs()) && lead.getLandingPageTs().toLocalDate().isEqual(LocalDate.now())) {
|
|
|
+
|
|
|
+ // 判断去重逻辑是否开启
|
|
|
+ if (this.isStatusByPhone(lead.getPhone())) {
|
|
|
+ log.info("用户加群线索信息已转化:{} {}", lead.getTraceId(), lead.getPhone());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否当日加群
|
|
|
+ if (ObjectUtil.isNotEmpty(lead.getLandingPageTs())
|
|
|
+ && lead.getLandingPageTs().toLocalDate().isEqual(LocalDate.now())
|
|
|
+ ) {
|
|
|
// 当日加群事件回调
|
|
|
conversionEventPublisher.publishConversionEvent(lead.getTraceId(), SystemEventTypeEnum.GROUP_TODAY);
|
|
|
}
|
|
|
} else {
|
|
|
log.info("用户加群线索信息不存在:{}", name);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
+ private Boolean isStatusByPhone(String phone) {
|
|
|
+ AdvConfigRes bean = JSONUtil.toBean(sysConfigService.selectConfigByKey(AdvConfigConstant.ADV_CONFIG), AdvConfigRes.class);
|
|
|
+ if (bean.getRepeatPostbackSettings().getFilter().equals(1) && bean.getRepeatPostbackSettings().getMethod().equals(2)) {
|
|
|
+ return !this.list(new LambdaQueryWrapper<Lead>()
|
|
|
+ .eq(Lead::getPhone, phone)
|
|
|
+ .eq(Lead::getStatus, 1)).isEmpty();
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -146,6 +175,7 @@ public class LeadServiceImpl extends ServiceImpl<LeadMapper, Lead> implements IL
|
|
|
} else if (StrUtil.isNotEmpty(qwExternalContact.getName())) {
|
|
|
last.eq(Lead::getWeiChatName, qwExternalContact.getName());
|
|
|
}
|
|
|
+ last.eq(Lead::getStatus, 0);
|
|
|
last.eq(Lead::getAddContactQwGroup, 0).last("LIMIT 1");
|
|
|
// 末次归因逻辑
|
|
|
Lead lead = this.getOne(last);
|
|
|
@@ -158,6 +188,13 @@ public class LeadServiceImpl extends ServiceImpl<LeadMapper, Lead> implements IL
|
|
|
temp.setId(qwExternalContact.getId());
|
|
|
temp.setTraceId(lead.getTraceId());
|
|
|
qwExternalContactMapper.updateById(temp);
|
|
|
+
|
|
|
+ // 判断去重逻辑是否开启
|
|
|
+ if (this.isStatusByPhone(lead.getPhone())) {
|
|
|
+ log.info("用户加微线索信息已转化:{} {}", lead.getTraceId(), lead.getPhone());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (ObjectUtil.isNotEmpty(lead.getLandingPageTs()) && lead.getLandingPageTs().toLocalDate().isEqual(LocalDate.now())) {
|
|
|
// 当日加微事件回调
|
|
|
conversionEventPublisher.publishConversionEvent(lead.getTraceId(), SystemEventTypeEnum.WEI_CHAT_TODAY);
|