提交 f09760d4 作者: 沈振路

查询可替换获客链接的service方法

上级 9500ece9
......@@ -3,6 +3,7 @@ package com.yaoyaozw.customer.publisher;
import com.yaoyaozw.customer.dto.AcquisitionExceptionHandleParam;
import com.yaoyaozw.customer.entity.AuthorizerInfo;
import com.yaoyaozw.customer.event.AcquisitionExceptionEvent;
import com.yaoyaozw.customer.service.CompanyAcquisitionLinkService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.ApplicationEventPublisher;
......@@ -20,17 +21,25 @@ public class AcquisitionExceptionEventPublisher {
@Resource
private ApplicationEventPublisher applicationEventPublisher;
@Resource
private CompanyAcquisitionLinkService companyAcquisitionLinkService;
public void inspectAndExecute(String linkId) {
if (StringUtils.isBlank(linkId)) {
return;
}
try {
// TODO 查链接Id对应的链接数据
AuthorizerInfo authorizerInfo = null;
String fromPath = null;
// 查链接Id对应的链接数据
AcquisitionExceptionHandleParam replaceAcquisitionEntity = companyAcquisitionLinkService.getReplaceAcquisitionEntityByLinkId(linkId);
if (replaceAcquisitionEntity == null) {
log.warn("链接异常处理异常,链接Id:{},没有对应的可替换链接数据", linkId);
return;
}
AuthorizerInfo authorizerInfo = replaceAcquisitionEntity.getAuthorizerInfo();
String fromPath = replaceAcquisitionEntity.getFromPath();
// 查询可用于替换的链接
String toPath = null;
String toPath = replaceAcquisitionEntity.getToPath();
this.publishAcquisitionExceptionEvent(new AcquisitionExceptionHandleParam(authorizerInfo, fromPath, toPath));
} catch (Exception e) {
......
package com.yaoyaozw.customer.service;
import com.yaoyaozw.customer.dto.AcquisitionExceptionHandleParam;
public interface CompanyAcquisitionLinkService {
/**
......@@ -10,4 +12,11 @@ public interface CompanyAcquisitionLinkService {
*/
String checkAndSearchTargetReferral(String sourceReferral, Long targetAuthId);
/**
* 根据链接Id获取绑定同公众号的其它获客链接列表
* @param linkId 链接Id
* @return 信息
*/
AcquisitionExceptionHandleParam getReplaceAcquisitionEntityByLinkId(String linkId);
}
package com.yaoyaozw.customer.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yaoyaozw.customer.dto.AcquisitionExceptionHandleParam;
import com.yaoyaozw.customer.entity.AuthorizerInfo;
import com.yaoyaozw.customer.entity.CompanyAcquisitionLink;
import com.yaoyaozw.customer.mapper.CompanyAcquisitionLinkMapper;
import com.yaoyaozw.customer.mapper.MaterialCommonMapper;
import com.yaoyaozw.customer.service.AuthorizerInfoService;
import com.yaoyaozw.customer.service.CompanyAcquisitionLinkService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -16,6 +22,10 @@ public class CompanyAcquisitionLinkServiceImpl implements CompanyAcquisitionLink
@Resource
private MaterialCommonMapper materialCommonMapper;
@Resource
private CompanyAcquisitionLinkMapper companyAcquisitionLinkMapper;
@Resource
private AuthorizerInfoService authorizerInfoService;
@Override
public String checkAndSearchTargetReferral(String sourceReferral, Long targetAuthId) {
......@@ -34,4 +44,39 @@ public class CompanyAcquisitionLinkServiceImpl implements CompanyAcquisitionLink
}
return acquisitionLinkList.get(0);
}
@Override
public AcquisitionExceptionHandleParam getReplaceAcquisitionEntityByLinkId(String linkId) {
// 查询链接绑定公众号信息
CompanyAcquisitionLink acquisitionInfo;
try {
acquisitionInfo = companyAcquisitionLinkMapper.getAcquisitionInfoByLinkId(linkId);
} catch (Exception e) {
log.error("获取链接Id:{} 信息异常", linkId, e);
return null;
}
if (acquisitionInfo == null) {
log.error("无法获取链接Id:{} 信息", linkId);
return null;
}
AuthorizerInfo authorizerInfo;
try {
authorizerInfo = authorizerInfoService.getOne(new QueryWrapper<AuthorizerInfo>().eq("appid", acquisitionInfo.getAuthAppId()));
} catch (Exception e) {
log.error("获取公众号信息异常:{}", acquisitionInfo.getAuthAppId(), e);
return null;
}
if (authorizerInfo == null) {
log.error("无法获取公众号信息:{}", acquisitionInfo.getAuthAppId());
return null;
}
// 查询可替换使用的链接列表
List<CompanyAcquisitionLink> availableAcquisitionList = companyAcquisitionLinkMapper.getAvailableAcquisitionListExceptLinkId(acquisitionInfo.getAuthAppId(), linkId);
if (CollectionUtil.isEmpty(availableAcquisitionList)) {
log.error("公众号:{} 无法获取可替换的链接", acquisitionInfo.getAuthAppId());
return null;
}
// TODO: 2025/5/26 排除当天已经轮转过的链接
return new AcquisitionExceptionHandleParam(authorizerInfo, acquisitionInfo.getLinkUrl(), availableAcquisitionList.get(0).getLinkUrl());
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论