提交 cffdb210 作者: 沈振路

复用时替换获客链接的查询接口

上级 46ff7f38
...@@ -63,4 +63,21 @@ public interface MaterialCommonMapper { ...@@ -63,4 +63,21 @@ public interface MaterialCommonMapper {
*/ */
String getStoreTypeNameByAppId(@Param("appId") String appId); String getStoreTypeNameByAppId(@Param("appId") String appId);
/**
* 获取指定公众号的指定获客链接数量
* @param appointAuthId 指定公众号Id
* @param appointReferral 指定获客链接
* @return 数量
*/
Integer getAppointAuthIdAndAppointReferralCount(@Param("appointAuthId") Long appointAuthId, @Param("appointReferral") String appointReferral);
/**
* 获取指定公众号的获客链接列表
* @param targetAuthId 指定公众号
* @return 获客链接列表
*/
List<String> getAcquisitionLinkList(@Param("targetAuthId") Long targetAuthId);
} }
package com.yaoyaozw.customer.service;
public interface CompanyAcquisitionLinkService {
/**
* 校验链接是否是源公众号的获客链接,如果是的,查找目标公众号的链接,并返回(如果不是获客链接,则会返回原链接,如果是,但找不到目标公众号的获客链接,则返回空)
* @param sourceReferral 原链接
* @param sourceAuthId 原公众号
* @param targetAuthId 目标公众号
* @return 链接
*/
String checkAndSearchTargetReferral(String sourceReferral, Long sourceAuthId, Long targetAuthId);
}
package com.yaoyaozw.customer.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.yaoyaozw.customer.mapper.MaterialCommonMapper;
import com.yaoyaozw.customer.service.CompanyAcquisitionLinkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Slf4j
@Service
public class CompanyAcquisitionLinkServiceImpl implements CompanyAcquisitionLinkService {
@Resource
private MaterialCommonMapper materialCommonMapper;
@Override
public String checkAndSearchTargetReferral(String sourceReferral, Long sourceAuthId, Long targetAuthId) {
// 查询 sourceReferral 这个链接是不是获客链接,如果不是,直接返回原链接
Integer count = materialCommonMapper.getAppointAuthIdAndAppointReferralCount(sourceAuthId, sourceReferral);
if (count == null || count == 0) {
return sourceReferral;
}
// 原链接是获客链接,查询目标公众号的获客链接
List<String> acquisitionLinkList = materialCommonMapper.getAcquisitionLinkList(targetAuthId);
if (CollectionUtil.isEmpty(acquisitionLinkList) || acquisitionLinkList.size() > 1) {
return null;
}
return acquisitionLinkList.get(0);
}
}
...@@ -63,4 +63,27 @@ ...@@ -63,4 +63,27 @@
where a.appid = #{appId} where a.appid = #{appId}
limit 1 limit 1
</select> </select>
<select id="getAcquisitionLinkList" resultType="java.lang.String">
SELECT
DISTINCT a.link_url
FROM company_acquisition_link a
LEFT JOIN authorizer_info ai ON ai.appid = a.auth_app_id
WHERE ai.id = #{targetAuthId}
AND a.`status` = 1
AND a.is_deleted = 0
</select>
<select id="getAppointAuthIdAndAppointReferralCount" resultType="java.lang.Integer">
SELECT count(1) FROM company_acquisition_link a
LEFT JOIN authorizer_info ai ON a.auth_app_id = ai.appid
WHERE a.link_url = #{appointReferral} AND ai.id = #{appointAuthId}
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论