Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
07770a53
提交
07770a53
authored
5月 23, 2025
作者:
沈振路
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
关回、关键词 替换获客链接监听器【未测试】
上级
cf0a3f4c
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
168 行增加
和
2 行删除
+168
-2
FollowReplyAcquisitionListener.java
...ozw/customer/listener/FollowReplyAcquisitionListener.java
+80
-0
KeywordAcquisitionListener.java
...aoyaozw/customer/listener/KeywordAcquisitionListener.java
+78
-0
CustomerFollowReplyService.java
...yaoyaozw/customer/service/CustomerFollowReplyService.java
+2
-0
CustomerKeywordService.java
...com/yaoyaozw/customer/service/CustomerKeywordService.java
+4
-0
CustomerFollowReplyServiceImpl.java
...customer/service/impl/CustomerFollowReplyServiceImpl.java
+2
-1
CustomerKeywordServiceImpl.java
...ozw/customer/service/impl/CustomerKeywordServiceImpl.java
+2
-1
没有找到文件。
src/main/java/com/yaoyaozw/customer/listener/FollowReplyAcquisitionListener.java
浏览文件 @
07770a53
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.CustomerFollowReply
;
import
com.yaoyaozw.customer.entity.ReferralEntity
;
import
com.yaoyaozw.customer.event.AcquisitionExceptionEvent
;
import
com.yaoyaozw.customer.service.CustomerFollowReplyService
;
import
com.yaoyaozw.customer.service.CustomerFollowReplyService
;
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.data.redis.core.RedisTemplate
;
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
FollowReplyAcquisitionListener
implements
ApplicationListener
<
AcquisitionExceptionEvent
>
{
@Resource
private
CustomerFollowReplyService
customerFollowReplyService
;
@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
<
CustomerFollowReply
>
allCustomerFollowReplyList
=
customerFollowReplyService
.
list
(
new
QueryWrapper
<
CustomerFollowReply
>().
eq
(
"app_id"
,
authorizerInfo
.
getAppid
()));
// 过滤出发送链接是 fromPath 或者发送文本中的跳转链接包含 fromPath 的延时客服配置
List
<
CustomerFollowReply
>
containsFromPathGraphicsList
=
allCustomerFollowReplyList
.
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
(
CustomerFollowReply:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
ReferralEntity
>
relatedReferralEntityList
=
referralEntityService
.
list
(
new
QueryWrapper
<
ReferralEntity
>().
in
(
ReferralEntity
.
COL_MATERIAL_GRAPHICS_ID
,
graphicsIds
));
List
<
CustomerFollowReply
>
updateGraphicsList
=
new
ArrayList
<>();
List
<
ReferralEntity
>
updateReferralList
=
new
ArrayList
<>();
// 替换 graphics 和 referral 中的 fromPath 为 toPath
allCustomerFollowReplyList
.
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
))
{
customerFollowReplyService
.
updateBatchById
(
updateGraphicsList
);
}
if
(
CollectionUtil
.
isNotEmpty
(
updateReferralList
))
{
referralEntityService
.
updateBatchById
(
updateReferralList
);
}
// 刷新缓存数据
customerFollowReplyService
.
putMaterialToRedis
(
authorizerInfo
.
getAppid
(),
null
);
}
}
src/main/java/com/yaoyaozw/customer/listener/KeywordAcquisitionListener.java
浏览文件 @
07770a53
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.CustomerKeyword
;
import
com.yaoyaozw.customer.entity.ReferralEntity
;
import
com.yaoyaozw.customer.event.AcquisitionExceptionEvent
;
import
com.yaoyaozw.customer.service.CustomerKeywordService
;
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.data.redis.core.RedisTemplate
;
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
KeywordAcquisitionListener
implements
ApplicationListener
<
AcquisitionExceptionEvent
>
{
@Resource
private
CustomerKeywordService
customerKeywordService
;
@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
<
CustomerKeyword
>
allCustomerKeywordList
=
customerKeywordService
.
list
(
new
QueryWrapper
<
CustomerKeyword
>().
eq
(
"app_id"
,
authorizerInfo
.
getAppid
()));
// 过滤出发送链接是 fromPath 或者发送文本中的跳转链接包含 fromPath 的延时客服配置
List
<
CustomerKeyword
>
containsFromPathGraphicsList
=
allCustomerKeywordList
.
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
(
CustomerKeyword:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
ReferralEntity
>
relatedReferralEntityList
=
referralEntityService
.
list
(
new
QueryWrapper
<
ReferralEntity
>().
in
(
ReferralEntity
.
COL_MATERIAL_GRAPHICS_ID
,
graphicsIds
));
List
<
CustomerKeyword
>
updateGraphicsList
=
new
ArrayList
<>();
List
<
ReferralEntity
>
updateReferralList
=
new
ArrayList
<>();
// 替换 graphics 和 referral 中的 fromPath 为 toPath
allCustomerKeywordList
.
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
))
{
customerKeywordService
.
updateBatchById
(
updateGraphicsList
);
}
if
(
CollectionUtil
.
isNotEmpty
(
updateReferralList
))
{
referralEntityService
.
updateBatchById
(
updateReferralList
);
}
// 刷新缓存数据
customerKeywordService
.
putMaterialToRedis
(
authorizerInfo
.
getAppid
());
}
}
src/main/java/com/yaoyaozw/customer/service/CustomerFollowReplyService.java
浏览文件 @
07770a53
...
...
@@ -74,4 +74,6 @@ public interface CustomerFollowReplyService extends IService<CustomerFollowReply
* @return {@link GenericsResult}<{@link FollowReplyInfoVO}>
*/
GenericsResult
<
FollowReplyInfoVO
>
getInfo
(
Long
id
);
void
putMaterialToRedis
(
String
appid
,
List
<
CustomerFollowReply
>
entityList
);
}
src/main/java/com/yaoyaozw/customer/service/CustomerKeywordService.java
浏览文件 @
07770a53
...
...
@@ -7,6 +7,7 @@ import com.yaoyaozw.customer.dto.keyword.CustomerKeywordCopyDTO;
import
com.yaoyaozw.customer.dto.keyword.CustomerKeywordQueryDTO
;
import
com.yaoyaozw.customer.dto.keyword.CustomerKeywordSaveDTO
;
import
com.yaoyaozw.customer.entity.CommonReferralBody
;
import
com.yaoyaozw.customer.entity.CustomerFollowReply
;
import
com.yaoyaozw.customer.entity.CustomerKeyword
;
import
com.yaoyaozw.customer.vo.keyword.CustomerKeywordInfoVO
;
import
com.yaoyaozw.customer.vo.keyword.CustomerKeywordListVO
;
...
...
@@ -73,4 +74,7 @@ public interface CustomerKeywordService extends IService<CustomerKeyword> {
* @return {@link BaseResult}
*/
BaseResult
copy
(
CustomerKeywordCopyDTO
copyDto
);
void
putMaterialToRedis
(
String
appid
);
}
src/main/java/com/yaoyaozw/customer/service/impl/CustomerFollowReplyServiceImpl.java
浏览文件 @
07770a53
...
...
@@ -425,7 +425,8 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
return
null
;
}
private
void
putMaterialToRedis
(
String
appid
,
List
<
CustomerFollowReply
>
entityList
)
{
@Override
public
void
putMaterialToRedis
(
String
appid
,
List
<
CustomerFollowReply
>
entityList
)
{
if
(
StringUtils
.
isNotEmpty
(
appid
)
&&
CollectionUtil
.
isEmpty
(
entityList
))
{
// 传参没传实体, 现查
entityList
=
this
.
list
(
new
QueryWrapper
<
CustomerFollowReply
>().
eq
(
"appid"
,
appid
));
...
...
src/main/java/com/yaoyaozw/customer/service/impl/CustomerKeywordServiceImpl.java
浏览文件 @
07770a53
...
...
@@ -382,7 +382,8 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe
return
null
;
}
private
void
putMaterialToRedis
(
String
appid
)
{
@Override
public
void
putMaterialToRedis
(
String
appid
)
{
if
(
StringUtils
.
isNotEmpty
(
appid
))
{
// 传参没传实体, 现查
List
<
CustomerKeyword
>
entityList
=
this
.
list
(
new
QueryWrapper
<
CustomerKeyword
>().
eq
(
"appid"
,
appid
));
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论