Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
1bc6ce93
提交
1bc6ce93
authored
5月 23, 2025
作者:
沈振路
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
处理公众号延时发文的获客链接替换【未测试】
上级
675e9a07
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
75 行增加
和
0 行删除
+75
-0
DelayCustomerAcquisitionListener.java
...w/customer/listener/DelayCustomerAcquisitionListener.java
+75
-0
没有找到文件。
src/main/java/com/yaoyaozw/customer/listener/DelayCustomerAcquisitionListener.java
浏览文件 @
1bc6ce93
package
com
.
yaoyaozw
.
customer
.
listener
;
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.CustomerGraphicsDelay
;
import
com.yaoyaozw.customer.entity.ReferralEntity
;
import
com.yaoyaozw.customer.event.AcquisitionExceptionEvent
;
import
com.yaoyaozw.customer.service.CustomerGraphicsDelayService
;
import
com.yaoyaozw.customer.service.ReferralEntityService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Slf4j
@Component
public
class
DelayCustomerAcquisitionListener
implements
ApplicationListener
<
AcquisitionExceptionEvent
>
{
@Resource
private
CustomerGraphicsDelayService
customerGraphicsDelayService
;
@Resource
private
ReferralEntityService
referralEntityService
;
@Override
public
void
onApplicationEvent
(
AcquisitionExceptionEvent
acquisitionExceptionEvent
)
{
AcquisitionExceptionHandleParam
source
=
acquisitionExceptionEvent
.
getSource
();
if
(
source
==
null
)
{
return
;
}
AuthorizerInfo
authorizerInfo
=
source
.
getAuthorizerInfo
();
String
fromPath
=
source
.
getFromPath
();
String
toPath
=
source
.
getToPath
();
// 查询这个公众号延时客服用到了 fromPath 的地方,替换成 toPath
List
<
CustomerGraphicsDelay
>
allCustomerGraphicsDelayList
=
customerGraphicsDelayService
.
list
(
new
QueryWrapper
<
CustomerGraphicsDelay
>().
eq
(
"app_id"
,
authorizerInfo
.
getAppid
()));
// 过滤出发送链接是 fromPath 或者发送文本中的跳转链接包含 fromPath 的延时客服配置
List
<
CustomerGraphicsDelay
>
containsFromPathGraphicsList
=
allCustomerGraphicsDelayList
.
stream
().
filter
(
v
->
(
StringUtils
.
isNotBlank
(
v
.
getSourceUrl
())
&&
v
.
getSourceUrl
().
contains
(
fromPath
))
||
(
StringUtils
.
isNotBlank
(
v
.
getContent
())
&&
v
.
getContent
().
contains
(
fromPath
))).
collect
(
Collectors
.
toList
());
if
(
CollectionUtil
.
isEmpty
(
containsFromPathGraphicsList
))
{
return
;
}
List
<
Long
>
graphicsIds
=
containsFromPathGraphicsList
.
stream
().
map
(
CustomerGraphicsDelay:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
ReferralEntity
>
relatedReferralEntityList
=
referralEntityService
.
list
(
new
QueryWrapper
<
ReferralEntity
>().
in
(
ReferralEntity
.
COL_MATERIAL_GRAPHICS_ID
,
graphicsIds
));
List
<
CustomerGraphicsDelay
>
updateGraphicsList
=
new
ArrayList
<>();
List
<
ReferralEntity
>
updateReferralList
=
new
ArrayList
<>();
// 替换 graphics 和 referral 中的 fromPath 为 toPath
allCustomerGraphicsDelayList
.
forEach
(
item
->
{
boolean
update
=
false
;
// 直跳链接
if
(
StringUtils
.
isNotBlank
(
item
.
getSourceUrl
())
&&
item
.
getSourceUrl
().
contains
(
fromPath
))
{
item
.
setSourceUrl
(
item
.
getSourceUrl
().
replaceAll
(
fromPath
,
toPath
));
update
=
true
;
}
// 文本链接
if
(
StringUtils
.
isNotBlank
(
item
.
getContent
())
&&
item
.
getContent
().
contains
(
fromPath
))
{
item
.
setContent
(
item
.
getContent
().
replaceAll
(
fromPath
,
toPath
));
update
=
true
;
}
if
(
update
)
{
updateGraphicsList
.
add
(
item
);
}
});
relatedReferralEntityList
.
forEach
(
item
->
{
boolean
update
=
false
;
// 直跳链接
if
(
StringUtils
.
isNotBlank
(
item
.
getReferral
())
&&
item
.
getReferral
().
contains
(
fromPath
))
{
item
.
setReferral
(
item
.
getReferral
().
replaceAll
(
fromPath
,
toPath
));
update
=
true
;
}
// 文本链接
if
(
StringUtils
.
isNotBlank
(
item
.
getTextContent
())
&&
item
.
getTextContent
().
contains
(
fromPath
))
{
item
.
setTextContent
(
item
.
getTextContent
().
replaceAll
(
fromPath
,
toPath
));
update
=
true
;
}
if
(
update
)
{
updateReferralList
.
add
(
item
);
}
});
if
(
CollectionUtil
.
isNotEmpty
(
updateGraphicsList
))
{
customerGraphicsDelayService
.
updateBatchById
(
updateGraphicsList
);
}
if
(
CollectionUtil
.
isNotEmpty
(
updateReferralList
))
{
referralEntityService
.
updateBatchById
(
updateReferralList
);
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论