|
|
@@ -11,17 +11,14 @@ import com.fs.newAdv.mapper.LeadMapper;
|
|
|
import com.fs.newAdv.service.ILeadService;
|
|
|
import com.fs.qw.domain.QwExternalContact;
|
|
|
import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
-import com.fs.qwApi.domain.QwExternalContactResult;
|
|
|
-import com.fs.qwApi.service.QwApiService;
|
|
|
+import com.fs.qw.service.IQwExternalContactService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
-import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
|
|
|
/**
|
|
|
* 域名管理Service实现类
|
|
|
@@ -36,9 +33,9 @@ public class LeadServiceImpl extends ServiceImpl<LeadMapper, Lead> implements IL
|
|
|
|
|
|
@Autowired
|
|
|
private ConversionEventPublisher conversionEventPublisher;
|
|
|
-
|
|
|
@Autowired
|
|
|
- private QwApiService qwApiService;
|
|
|
+ private IQwExternalContactService qwExternalContactService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private QwExternalContactMapper qwExternalContactMapper;
|
|
|
|
|
|
@@ -61,9 +58,7 @@ public class LeadServiceImpl extends ServiceImpl<LeadMapper, Lead> implements IL
|
|
|
.eq(Lead::getAddContactQw, 0)
|
|
|
.last("LIMIT 1"));
|
|
|
if (lead != null) {
|
|
|
- lead.setCorpId(corpId);
|
|
|
lead.setChatId(chatId);
|
|
|
- lead.setUserId(userId);
|
|
|
lead.setAddContactQw(1);
|
|
|
this.updateById(lead);
|
|
|
|
|
|
@@ -80,65 +75,59 @@ public class LeadServiceImpl extends ServiceImpl<LeadMapper, Lead> implements IL
|
|
|
|
|
|
@Override
|
|
|
@Async
|
|
|
- public CompletableFuture<String> updateAddMemberLead(String externalUserID, String userID, String corpId, String state) {
|
|
|
- QwExternalContactResult externalContactResult = qwApiService.getExternalcontact(externalUserID, corpId);
|
|
|
- String unionid = externalContactResult.getExternal_contact().getUnionid();
|
|
|
+ public void updateAddMemberLead(Long externalId, String unionid) {
|
|
|
+ QwExternalContact qwExternalContact = qwExternalContactService.selectQwExternalContactById(externalId);
|
|
|
+ if (qwExternalContact == null) {
|
|
|
+ log.info("外部联系人信息不存在:{}", externalId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 末次归因逻辑
|
|
|
Lead lead = this.getOne(new LambdaQueryWrapper<Lead>()
|
|
|
.eq(Lead::getUnionid, unionid)
|
|
|
.eq(Lead::getAddContactQwGroup, 0)
|
|
|
.last("LIMIT 1"));
|
|
|
if (lead != null) {
|
|
|
- lead.setExternalUserId(externalUserID);
|
|
|
- lead.setCorpId(corpId);
|
|
|
- lead.setUserId(userID);
|
|
|
+ lead.setExternalId(externalId);
|
|
|
lead.setAddContactQwGroup(1);
|
|
|
this.updateById(lead);
|
|
|
-
|
|
|
// 绑定企微用户线索关系
|
|
|
- QwExternalContact qwExternalContact = qwExternalContactMapper.selectQwExternalByExternalIdAndCompanyIdToIdAndFs(externalUserID, userID, corpId);
|
|
|
- if (qwExternalContact != null){
|
|
|
- QwExternalContact temp = new QwExternalContact();
|
|
|
- temp.setId(qwExternalContact.getId());
|
|
|
- temp.setTraceId(lead.getTraceId());
|
|
|
- qwExternalContactMapper.updateById(temp);
|
|
|
- }else {
|
|
|
- log.info("广告归因企微用户信息不存在:{} {} {} ", externalUserID, userID,corpId);
|
|
|
- }
|
|
|
+ QwExternalContact temp = new QwExternalContact();
|
|
|
+ temp.setId(qwExternalContact.getId());
|
|
|
+ temp.setTraceId(lead.getTraceId());
|
|
|
+ qwExternalContactMapper.updateById(temp);
|
|
|
if (ObjectUtil.isNotEmpty(lead.getLandingPageTs()) && lead.getLandingPageTs().toLocalDate().isEqual(LocalDate.now())) {
|
|
|
// 当日加微事件回调
|
|
|
conversionEventPublisher.publishConversionEvent(lead.getTraceId(), SystemEventTypeEnum.WEI_CHAT_TODAY);
|
|
|
}
|
|
|
- return CompletableFuture.completedFuture(lead.getTraceId());
|
|
|
+
|
|
|
} else {
|
|
|
- log.info("广告归因线索不存在:{} {} {}", externalUserID, userID,corpId);
|
|
|
+ log.info("广告归因线索不存在:{} {}", externalId, unionid);
|
|
|
}
|
|
|
- return CompletableFuture.completedFuture(null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Async
|
|
|
public void weChatAuthorizationLead(String traceId, String unionId, String maOpenId, String phone) {
|
|
|
- try{
|
|
|
- log.info("用户微信授权线索信息:{}", traceId);
|
|
|
- Lead byTraceId = this.getByTraceId(traceId);
|
|
|
- if (byTraceId == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- this.update(new LambdaUpdateWrapper<Lead>()
|
|
|
- .eq(Lead::getTraceId, traceId)
|
|
|
- .set(ObjectUtil.isNotEmpty(unionId),Lead::getUnionid, unionId)
|
|
|
- .set(ObjectUtil.isNotEmpty(phone),Lead::getPhone, phone)
|
|
|
- .set(ObjectUtil.isNotEmpty(maOpenId),Lead::getOpenid, maOpenId)
|
|
|
- .set(Lead::getMiniAuth, 1));
|
|
|
- if (ObjectUtil.isNotEmpty(byTraceId.getLandingPageTs()) && byTraceId.getLandingPageTs().toLocalDate().isEqual(LocalDate.now())) {
|
|
|
- // 微信授权且当日创建事件
|
|
|
- log.info("用户微信授权线索事件回传:{}", traceId);
|
|
|
- conversionEventPublisher.publishConversionEvent(traceId, SystemEventTypeEnum.AUTH_TODAY_CREATE);
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ try {
|
|
|
+ log.info("用户微信授权线索信息:{}", traceId);
|
|
|
+ Lead byTraceId = this.getByTraceId(traceId);
|
|
|
+ if (byTraceId == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.update(new LambdaUpdateWrapper<Lead>()
|
|
|
+ .eq(Lead::getTraceId, traceId)
|
|
|
+ .set(ObjectUtil.isNotEmpty(unionId), Lead::getUnionid, unionId)
|
|
|
+ .set(ObjectUtil.isNotEmpty(phone), Lead::getPhone, phone)
|
|
|
+ .set(ObjectUtil.isNotEmpty(maOpenId), Lead::getOpenid, maOpenId)
|
|
|
+ .set(Lead::getMiniAuth, 1));
|
|
|
+ if (ObjectUtil.isNotEmpty(byTraceId.getLandingPageTs()) && byTraceId.getLandingPageTs().toLocalDate().isEqual(LocalDate.now())) {
|
|
|
+ // 微信授权且当日创建事件
|
|
|
+ log.info("用户微信授权线索事件回传:{}", traceId);
|
|
|
+ conversionEventPublisher.publishConversionEvent(traceId, SystemEventTypeEnum.AUTH_TODAY_CREATE);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -161,7 +150,7 @@ public class LeadServiceImpl extends ServiceImpl<LeadMapper, Lead> implements IL
|
|
|
boolean update = this.update(new LambdaUpdateWrapper<Lead>()
|
|
|
.eq(Lead::getTraceId, traceId)
|
|
|
.set(Lead::getMiniLaunchIndexCount, 1));
|
|
|
- if (!update){
|
|
|
+ if (!update) {
|
|
|
log.error("发起进入小程序失败:{}", traceId);
|
|
|
}
|
|
|
}
|