Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
b0acf056
提交
b0acf056
authored
5月 26, 2025
作者:
沈振路
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
链接被替换时发送报警
上级
6abc7608
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
218 行增加
和
0 行删除
+218
-0
WeChatTextDTO.java
src/main/java/com/yaoyaozw/customer/dto/WeChatTextDTO.java
+40
-0
DelayCustomerAcquisitionListener.java
...w/customer/listener/DelayCustomerAcquisitionListener.java
+11
-0
FollowReplyAcquisitionListener.java
...ozw/customer/listener/FollowReplyAcquisitionListener.java
+13
-0
KeywordAcquisitionListener.java
...aoyaozw/customer/listener/KeywordAcquisitionListener.java
+13
-0
HttpClientUtil.java
...main/java/com/yaoyaozw/customer/utils/HttpClientUtil.java
+100
-0
WeChatUtils.java
src/main/java/com/yaoyaozw/customer/utils/WeChatUtils.java
+41
-0
没有找到文件。
src/main/java/com/yaoyaozw/customer/dto/WeChatTextDTO.java
0 → 100644
浏览文件 @
b0acf056
package
com
.
yaoyaozw
.
customer
.
dto
;
import
lombok.Data
;
import
java.util.List
;
/**
* @Author: Dwl
* @Date: 2024/09/09/12:17
* @ClassName: WoComDTO
* @Version: V3.2.0
* @Description: 文本类型请求模型
*/
@Data
public
class
WeChatTextDTO
{
private
static
final
String
TEXT
=
"text"
;
private
String
msgtype
=
TEXT
;
private
Text
text
;
public
WeChatTextDTO
cover
(
String
content
,
List
<
String
>
openList
,
List
<
String
>
openIdList
)
{
WeChatTextDTO
woComTextDTO
=
new
WeChatTextDTO
();
this
.
text
=
new
Text
();
this
.
text
.
setContent
(
content
);
if
(
openList
!=
null
&&
!
openList
.
isEmpty
())
{
this
.
text
.
setMentioned_mobile_list
(
openList
);
}
if
(
openIdList
!=
null
&&
!
openIdList
.
isEmpty
())
{
this
.
text
.
setMentioned_list
(
openIdList
);
}
woComTextDTO
.
setText
(
this
.
text
);
return
woComTextDTO
;
}
@Data
private
static
class
Text
{
private
String
content
;
private
List
<
String
>
mentioned_mobile_list
;
private
List
<
String
>
mentioned_list
;
}
}
src/main/java/com/yaoyaozw/customer/listener/DelayCustomerAcquisitionListener.java
浏览文件 @
b0acf056
...
...
@@ -3,12 +3,14 @@ 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.dto.WeChatTextDTO
;
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
com.yaoyaozw.customer.utils.WeChatUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.context.ApplicationListener
;
...
...
@@ -86,11 +88,20 @@ public class DelayCustomerAcquisitionListener implements ApplicationListener<Acq
updateReferralList
.
add
(
item
);
}
});
boolean
update
=
false
;
if
(
CollectionUtil
.
isNotEmpty
(
updateGraphicsList
))
{
customerGraphicsDelayService
.
updateBatchById
(
updateGraphicsList
);
update
=
true
;
}
if
(
CollectionUtil
.
isNotEmpty
(
updateReferralList
))
{
referralEntityService
.
updateBatchById
(
updateReferralList
);
update
=
true
;
}
if
(
update
)
{
// 发送报警信息
String
msg
=
"【延时客服-获客链接替换】公众号:"
+
authorizerInfo
.
getAppid
()
+
" 获客链接:"
+
fromPath
+
" 已被替换为:"
+
toPath
;
WeChatTextDTO
cover
=
new
WeChatTextDTO
().
cover
(
msg
,
null
,
null
);
WeChatUtils
.
sendErrorMessage
(
cover
,
"9934244e-9694-4a0c-95dd-ddd6ca4bd959"
);
}
}
...
...
src/main/java/com/yaoyaozw/customer/listener/FollowReplyAcquisitionListener.java
浏览文件 @
b0acf056
...
...
@@ -3,6 +3,7 @@ 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.dto.WeChatTextDTO
;
import
com.yaoyaozw.customer.entity.AuthorizerInfo
;
import
com.yaoyaozw.customer.entity.CustomerFollowReply
;
import
com.yaoyaozw.customer.entity.ReferralEntity
;
...
...
@@ -10,6 +11,7 @@ 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
com.yaoyaozw.customer.utils.WeChatUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.context.ApplicationListener
;
...
...
@@ -89,14 +91,25 @@ public class FollowReplyAcquisitionListener implements ApplicationListener<Acqui
updateReferralList
.
add
(
item
);
}
});
boolean
update
=
false
;
if
(
CollectionUtil
.
isNotEmpty
(
updateGraphicsList
))
{
customerFollowReplyService
.
updateBatchById
(
updateGraphicsList
);
update
=
true
;
}
if
(
CollectionUtil
.
isNotEmpty
(
updateReferralList
))
{
referralEntityService
.
updateBatchById
(
updateReferralList
);
update
=
true
;
}
// 刷新缓存数据
customerFollowReplyService
.
putMaterialToRedis
(
authorizerInfo
.
getAppid
(),
null
);
if
(
update
)
{
// 发送报警信息
String
msg
=
"【关回-获客链接替换】公众号:"
+
authorizerInfo
.
getAppid
()
+
" 获客链接:"
+
fromPath
+
" 已被替换为:"
+
toPath
;
WeChatTextDTO
cover
=
new
WeChatTextDTO
().
cover
(
msg
,
null
,
null
);
WeChatUtils
.
sendErrorMessage
(
cover
,
"9934244e-9694-4a0c-95dd-ddd6ca4bd959"
);
}
}
}
src/main/java/com/yaoyaozw/customer/listener/KeywordAcquisitionListener.java
浏览文件 @
b0acf056
...
...
@@ -3,6 +3,7 @@ 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.dto.WeChatTextDTO
;
import
com.yaoyaozw.customer.entity.AuthorizerInfo
;
import
com.yaoyaozw.customer.entity.CustomerGraphicsDelay
;
import
com.yaoyaozw.customer.entity.CustomerKeyword
;
...
...
@@ -10,6 +11,7 @@ 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
com.yaoyaozw.customer.utils.WeChatUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.context.ApplicationListener
;
...
...
@@ -88,13 +90,24 @@ public class KeywordAcquisitionListener implements ApplicationListener<Acquisiti
updateReferralList
.
add
(
item
);
}
});
boolean
update
=
false
;
if
(
CollectionUtil
.
isNotEmpty
(
updateGraphicsList
))
{
customerKeywordService
.
updateBatchById
(
updateGraphicsList
);
update
=
true
;
}
if
(
CollectionUtil
.
isNotEmpty
(
updateReferralList
))
{
referralEntityService
.
updateBatchById
(
updateReferralList
);
update
=
true
;
}
// 刷新缓存数据
customerKeywordService
.
putMaterialToRedis
(
authorizerInfo
.
getAppid
());
if
(
update
)
{
// 发送报警信息
String
msg
=
"【关键词-获客链接替换】公众号:"
+
authorizerInfo
.
getAppid
()
+
" 获客链接:"
+
fromPath
+
" 已被替换为:"
+
toPath
;
WeChatTextDTO
cover
=
new
WeChatTextDTO
().
cover
(
msg
,
null
,
null
);
WeChatUtils
.
sendErrorMessage
(
cover
,
"9934244e-9694-4a0c-95dd-ddd6ca4bd959"
);
}
}
}
src/main/java/com/yaoyaozw/customer/utils/HttpClientUtil.java
浏览文件 @
b0acf056
package
com
.
yaoyaozw
.
customer
.
utils
;
import
cn.hutool.core.lang.UUID
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.HttpStatus
;
...
...
@@ -593,4 +595,102 @@ public class HttpClientUtil {
}
return
result
.
toString
();
}
public
static
<
T
>
T
allElementPost
(
String
url
,
String
json
,
Map
<
String
,
String
>
urlParams
,
Map
<
String
,
String
>
headers
,
Class
<
T
>
responseClass
)
{
// 创建Httpclient对象
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpResponse
httpResponse
=
null
;
String
resultString
=
""
;
try
{
// 创建uri
URIBuilder
builder
=
new
URIBuilder
(
url
);
if
(
urlParams
!=
null
)
{
for
(
Map
.
Entry
<
String
,
String
>
param
:
urlParams
.
entrySet
())
{
builder
.
addParameter
(
param
.
getKey
(),
param
.
getValue
());
}
}
URI
uri
=
builder
.
build
();
//创建post方法连接实例,在post方法中传入待连接地址
HttpPost
httpPost
=
new
HttpPost
(
uri
);
if
(
headers
!=
null
)
{
// 设置请求头
for
(
Map
.
Entry
<
String
,
String
>
head
:
headers
.
entrySet
())
{
httpPost
.
addHeader
(
head
.
getKey
(),
head
.
getValue
());
}
}
// 创建请求内容
if
(
json
!=
null
)
{
StringEntity
entity
=
new
StringEntity
(
json
,
ContentType
.
APPLICATION_JSON
);
httpPost
.
setEntity
(
entity
);
}
// 执行http请求
httpResponse
=
httpClient
.
execute
(
httpPost
);
resultString
=
EntityUtils
.
toString
(
httpResponse
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
httpResponse
!=
null
)
{
try
{
httpResponse
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
if
(
StringUtils
.
isNotEmpty
(
resultString
)
&&
responseClass
!=
null
)
{
return
JSONUtil
.
toBean
(
resultString
,
responseClass
);
}
return
null
;
}
public
static
<
T
>
T
allElementGet
(
String
url
,
Map
<
String
,
String
>
urlParams
,
Map
<
String
,
String
>
headers
,
Class
<
T
>
responseClass
)
{
// 创建Httpclient对象
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpResponse
httpResponse
=
null
;
String
resultString
=
""
;
try
{
// 创建uri
URIBuilder
builder
=
new
URIBuilder
(
url
);
if
(
urlParams
!=
null
)
{
for
(
Map
.
Entry
<
String
,
String
>
param
:
urlParams
.
entrySet
())
{
builder
.
addParameter
(
param
.
getKey
(),
param
.
getValue
());
}
}
URI
uri
=
builder
.
build
();
//创建post方法连接实例,在post方法中传入待连接地址
HttpGet
httpGet
=
new
HttpGet
(
uri
);
if
(
headers
!=
null
)
{
// 设置请求头
for
(
Map
.
Entry
<
String
,
String
>
head
:
headers
.
entrySet
())
{
httpGet
.
addHeader
(
head
.
getKey
(),
head
.
getValue
());
}
}
// 执行http请求
httpResponse
=
httpClient
.
execute
(
httpGet
);
resultString
=
EntityUtils
.
toString
(
httpResponse
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
httpResponse
!=
null
)
{
try
{
httpResponse
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
if
(
StringUtils
.
isNotEmpty
(
resultString
)
&&
responseClass
!=
null
)
{
return
JSONUtil
.
toBean
(
resultString
,
responseClass
);
}
return
null
;
}
}
src/main/java/com/yaoyaozw/customer/utils/WeChatUtils.java
0 → 100644
浏览文件 @
b0acf056
package
com
.
yaoyaozw
.
customer
.
utils
;
import
cn.hutool.json.JSONUtil
;
import
com.yaoyaozw.customer.dto.WeChatTextDTO
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @Author: Dwl
* @Date: 2024/09/09/12:10
* @ClassName: WoComUtils
* @Version: V3.2.0
* @Description:
*/
@Slf4j
public
class
WeChatUtils
{
private
static
final
String
WO_COM_API_URL
=
"https://qyapi.weixin.qq.com/cgi-bin/webhook/send"
;
private
static
Map
<
String
,
String
>
getParams
(
String
key
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
"key"
,
key
);
return
headers
;
}
public
static
void
sendErrorMessage
(
String
message
,
String
key
)
{
Map
<
String
,
String
>
params
=
getParams
(
key
);
try
{
String
s
=
HttpClientUtil
.
allElementPost
(
WO_COM_API_URL
,
message
,
params
,
null
,
String
.
class
);
log
.
info
(
"sendErrorMessage response: {}"
,
s
);
}
catch
(
Exception
e
)
{
log
.
error
(
"sendErrorMessage error: {}"
,
e
.
getMessage
());
}
}
public
static
void
sendErrorMessage
(
WeChatTextDTO
woComDTO
,
String
key
)
{
log
.
info
(
"报警机器人请求参数: {}"
,
JSONUtil
.
toJsonStr
(
woComDTO
));
sendErrorMessage
(
JSONUtil
.
toJsonStr
(
woComDTO
),
key
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论