Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
7c9da8b7
提交
7c9da8b7
authored
5月 27, 2025
作者:
沈振路
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
关回多图文替换获客链接
上级
3f0d92ba
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
55 行增加
和
25 行删除
+55
-25
FollowReplyAcquisitionListener.java
...ozw/customer/listener/FollowReplyAcquisitionListener.java
+45
-21
CustomerFollowReplyMultiNewsService.java
...customer/service/CustomerFollowReplyMultiNewsService.java
+2
-0
CustomerFollowReplyMultiNewsServiceImpl.java
...service/impl/CustomerFollowReplyMultiNewsServiceImpl.java
+8
-4
没有找到文件。
src/main/java/com/yaoyaozw/customer/listener/FollowReplyAcquisitionListener.java
浏览文件 @
7c9da8b7
...
...
@@ -2,12 +2,15 @@ package com.yaoyaozw.customer.listener;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.yaoyaozw.customer.constants.CustomerMaterialConstant
;
import
com.yaoyaozw.customer.dto.AcquisitionExceptionHandleParam
;
import
com.yaoyaozw.customer.dto.WeChatTextDTO
;
import
com.yaoyaozw.customer.entity.AuthorizerInfo
;
import
com.yaoyaozw.customer.entity.CustomerFollowReply
;
import
com.yaoyaozw.customer.entity.CustomerFollowReplyMultiNews
;
import
com.yaoyaozw.customer.entity.ReferralEntity
;
import
com.yaoyaozw.customer.event.AcquisitionExceptionEvent
;
import
com.yaoyaozw.customer.service.CustomerFollowReplyMultiNewsService
;
import
com.yaoyaozw.customer.service.CustomerFollowReplyService
;
import
com.yaoyaozw.customer.service.CustomerFollowReplyService
;
import
com.yaoyaozw.customer.service.ReferralEntityService
;
...
...
@@ -31,6 +34,8 @@ public class FollowReplyAcquisitionListener implements ApplicationListener<Acqui
@Resource
private
CustomerFollowReplyService
customerFollowReplyService
;
@Resource
private
CustomerFollowReplyMultiNewsService
customerFollowReplyMultiNewsService
;
@Resource
private
ReferralEntityService
referralEntityService
;
...
...
@@ -49,18 +54,22 @@ public class FollowReplyAcquisitionListener implements ApplicationListener<Acqui
// 过滤出发送链接是 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
))
{
log
.
info
(
"公众号:{} 暂无使用获客链接:{} 的关回配置"
,
authorizerInfo
.
getAppid
(),
fromPath
);
return
;
// 多图文
List
<
Long
>
multiNewsReplyIds
=
allCustomerFollowReplyList
.
stream
().
filter
(
v
->
CustomerMaterialConstant
.
TENCENT_MEDIA_TYPE_MULTI_NEWS
.
equals
(
v
.
getType
())).
map
(
CustomerFollowReply:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
CustomerFollowReplyMultiNews
>
customerFollowReplyMultiNewsList
=
new
ArrayList
<>();
if
(
CollectionUtil
.
isNotEmpty
(
multiNewsReplyIds
))
{
customerFollowReplyMultiNewsList
=
customerFollowReplyMultiNewsService
.
list
(
new
QueryWrapper
<
CustomerFollowReplyMultiNews
>().
in
(
"reply_id"
,
multiNewsReplyIds
));
}
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
<>();
// 查询链接配置
List
<
Long
>
graphicsIds
=
containsFromPathGraphicsList
.
stream
().
map
(
CustomerFollowReply:
:
getId
).
collect
(
Collectors
.
toList
());
customerFollowReplyMultiNewsList
.
forEach
(
v
->
graphicsIds
.
add
(
v
.
getId
()));
List
<
ReferralEntity
>
relatedReferralEntityList
=
new
ArrayList
<>();
if
(
CollectionUtil
.
isNotEmpty
(
graphicsIds
))
{
relatedReferralEntityList
=
referralEntityService
.
list
(
new
QueryWrapper
<
ReferralEntity
>().
in
(
ReferralEntity
.
COL_MATERIAL_GRAPHICS_ID
,
graphicsIds
));
}
// 替换 graphics 和 referral 中的 fromPath 为 toPath
allCustomerFollowReplyList
.
forEach
(
item
->
{
List
<
CustomerFollowReply
>
updateGraphicsList
=
allCustomerFollowReplyList
.
stream
().
filter
(
item
->
{
boolean
update
=
false
;
// 直跳链接
if
(
StringUtils
.
isNotBlank
(
item
.
getSourceUrl
())
&&
item
.
getSourceUrl
().
contains
(
fromPath
))
{
...
...
@@ -72,11 +81,19 @@ public class FollowReplyAcquisitionListener implements ApplicationListener<Acqui
item
.
setContent
(
item
.
getContent
().
replaceAll
(
fromPath
,
toPath
));
update
=
true
;
}
if
(
update
)
{
updateGraphicsList
.
add
(
item
);
return
update
;
}).
collect
(
Collectors
.
toList
());
List
<
CustomerFollowReplyMultiNews
>
updateMultiNewsList
=
customerFollowReplyMultiNewsList
.
stream
().
filter
(
item
->
{
boolean
update
=
false
;
if
(
StringUtils
.
isNotBlank
(
item
.
getLinkUrl
())
&&
item
.
getLinkUrl
().
contains
(
fromPath
))
{
item
.
setLinkUrl
(
item
.
getLinkUrl
().
replaceAll
(
fromPath
,
toPath
));
update
=
true
;
}
});
relatedReferralEntityList
.
forEach
(
item
->
{
return
update
;
}).
collect
(
Collectors
.
toList
());
List
<
ReferralEntity
>
updateReferralList
=
relatedReferralEntityList
.
stream
().
filter
(
item
->
{
boolean
update
=
false
;
// 直跳链接
if
(
StringUtils
.
isNotBlank
(
item
.
getReferral
())
&&
item
.
getReferral
().
contains
(
fromPath
))
{
...
...
@@ -88,28 +105,35 @@ public class FollowReplyAcquisitionListener implements ApplicationListener<Acqui
item
.
setTextContent
(
item
.
getTextContent
().
replaceAll
(
fromPath
,
toPath
));
update
=
true
;
}
if
(
update
)
{
updateReferralList
.
add
(
item
);
}
});
return
update
;
}).
collect
(
Collectors
.
toList
()
);
// 执行更新
boolean
update
=
false
;
if
(
CollectionUtil
.
isNotEmpty
(
updateGraphicsList
))
{
// 更新主配置
customerFollowReplyService
.
updateBatchById
(
updateGraphicsList
);
update
=
true
;
customerFollowReplyService
.
putMaterialToRedis
(
authorizerInfo
.
getAppid
(),
null
);
}
if
(
CollectionUtil
.
isNotEmpty
(
updateMultiNewsList
))
{
// 更新多图文配置
customerFollowReplyMultiNewsService
.
updateBatchById
(
updateMultiNewsList
);
update
=
true
;
customerFollowReplyMultiNewsService
.
putMaterialToRedis
(
authorizerInfo
.
getAppid
(),
customerFollowReplyMultiNewsList
);
}
if
(
CollectionUtil
.
isNotEmpty
(
updateReferralList
))
{
// 更新链接配置
referralEntityService
.
updateBatchById
(
updateReferralList
);
update
=
true
;
}
// 刷新缓存数据
customerFollowReplyService
.
putMaterialToRedis
(
authorizerInfo
.
getAppid
(),
null
);
if
(
update
)
{
// 发送报警信息
String
msg
=
"【关回-获客链接替换】公众号:"
+
authorizerInfo
.
getNickName
()
+
" 获客链接:"
+
fromPath
+
" 已被替换为:"
+
toPath
;
WeChatTextDTO
cover
=
new
WeChatTextDTO
().
cover
(
msg
,
null
,
null
);
WeChatUtils
.
sendErrorMessage
(
cover
,
"9934244e-9694-4a0c-95dd-ddd6ca4bd959"
);
}
else
{
log
.
info
(
"公众号:{} 暂无使用获客链接:{} 的关回配置"
,
authorizerInfo
.
getAppid
(),
fromPath
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"公众号:{} 关回链接从:{} 替换为:{} 异常:{}"
,
source
.
getAuthorizerInfo
().
getNickName
(),
source
.
getFromPath
(),
source
.
getToPath
(),
e
.
getMessage
(),
e
);
...
...
src/main/java/com/yaoyaozw/customer/service/CustomerFollowReplyMultiNewsService.java
浏览文件 @
7c9da8b7
...
...
@@ -21,4 +21,6 @@ public interface CustomerFollowReplyMultiNewsService extends IService<CustomerFo
*/
void
saveFollowReplyMultiNews
(
Long
replyId
,
AuthInfoVO
accountEntity
,
List
<
FollowReplyMultiNewsCreateDTO
>
multiNewsList
);
void
putMaterialToRedis
(
String
appId
,
List
<?
extends
CustomerFollowReplyMultiNews
>
entityList
);
}
src/main/java/com/yaoyaozw/customer/service/impl/CustomerFollowReplyMultiNewsServiceImpl.java
浏览文件 @
7c9da8b7
...
...
@@ -11,7 +11,6 @@ import com.yaoyaozw.customer.constants.CustomerMaterialConstant;
import
com.yaoyaozw.customer.dto.follow.FollowReplyMultiNewsCreateDTO
;
import
com.yaoyaozw.customer.dto.follow.NewsMessageReplyEntity
;
import
com.yaoyaozw.customer.entity.CommonReferralBody
;
import
com.yaoyaozw.customer.entity.CustomerFollowReply
;
import
com.yaoyaozw.customer.entity.CustomerFollowReplyMultiNews
;
import
com.yaoyaozw.customer.entity.ReferralEntity
;
import
com.yaoyaozw.customer.mapper.CustomerFollowReplyMultiNewsMapper
;
...
...
@@ -88,10 +87,15 @@ public class CustomerFollowReplyMultiNewsServiceImpl extends ServiceImpl<Custome
referralEntityList
.
add
(
referralEntity
);
}
localLog
.
info
(
"generate multi news size {}, referral entity size {}"
,
entityList
.
size
(),
referralEntityList
.
size
());
// 将这些多图文信息转换到缓存
List
<
NewsMessageReplyEntity
>
cacheEntityList
=
JSONUtil
.
toList
(
JSONUtil
.
parseArray
(
multiNewsList
),
NewsMessageReplyEntity
.
class
);
redisTemplate
.
opsForHash
().
put
(
CustomerMaterialConstant
.
FOLLOW_REPLY_MULTI_NEWS_CACHE_KEY
,
accountEntity
.
getAppId
(),
JSONUtil
.
toJsonStr
(
cacheEntityList
));
putMaterialToRedis
(
accountEntity
.
getAppId
(),
multiNewsList
);
this
.
saveBatch
(
entityList
);
referralEntityService
.
saveBatch
(
referralEntityList
);
}
@Override
public
void
putMaterialToRedis
(
String
appId
,
List
<?
extends
CustomerFollowReplyMultiNews
>
entityList
)
{
// 将这些多图文信息转换到缓存
List
<
NewsMessageReplyEntity
>
cacheEntityList
=
JSONUtil
.
toList
(
JSONUtil
.
parseArray
(
entityList
),
NewsMessageReplyEntity
.
class
);
redisTemplate
.
opsForHash
().
put
(
CustomerMaterialConstant
.
FOLLOW_REPLY_MULTI_NEWS_CACHE_KEY
,
appId
,
JSONUtil
.
toJsonStr
(
cacheEntityList
));
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论