Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
a9342289
提交
a9342289
authored
7月 02, 2025
作者:
沈振路
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
客服消息适配“获客链接”newsType类型
上级
8eac6ad5
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
92 行增加
和
9 行删除
+92
-9
CustomerServiceCommonAsyncComponent.java
...tomer/components/CustomerServiceCommonAsyncComponent.java
+89
-8
CustomerCommonConstant.java
...m/yaoyaozw/customer/constants/CustomerCommonConstant.java
+1
-0
CustomerGraphicsTextServiceImpl.java
...ustomer/service/impl/CustomerGraphicsTextServiceImpl.java
+2
-1
没有找到文件。
src/main/java/com/yaoyaozw/customer/components/CustomerServiceCommonAsyncComponent.java
浏览文件 @
a9342289
...
@@ -2,14 +2,12 @@ package com.yaoyaozw.customer.components;
...
@@ -2,14 +2,12 @@ package com.yaoyaozw.customer.components;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.alibaba.fastjson.TypeReference
;
import
com.sun.org.apache.xpath.internal.operations.Bool
;
import
com.yaoyaozw.customer.common.R
;
import
com.yaoyaozw.customer.common.R
;
import
com.yaoyaozw.customer.constants.ApiResultConstant
;
import
com.yaoyaozw.customer.constants.ApiResultConstant
;
import
com.yaoyaozw.customer.constants.CustomerCommonConstant
;
import
com.yaoyaozw.customer.constants.CustomerCommonConstant
;
...
@@ -20,7 +18,6 @@ import com.yaoyaozw.customer.feigns.ReferralFeignClient;
...
@@ -20,7 +18,6 @@ import com.yaoyaozw.customer.feigns.ReferralFeignClient;
import
com.yaoyaozw.customer.mapper.CustomerGraphicsDelayMapper
;
import
com.yaoyaozw.customer.mapper.CustomerGraphicsDelayMapper
;
import
com.yaoyaozw.customer.mapper.CustomerGraphicsMapper
;
import
com.yaoyaozw.customer.mapper.CustomerGraphicsMapper
;
import
com.yaoyaozw.customer.mapper.KanbanCommonMapper
;
import
com.yaoyaozw.customer.mapper.KanbanCommonMapper
;
import
com.yaoyaozw.customer.mapper.MaterialCommonMapper
;
import
com.yaoyaozw.customer.service.*
;
import
com.yaoyaozw.customer.service.*
;
import
com.yaoyaozw.customer.vo.AuthInfoVO
;
import
com.yaoyaozw.customer.vo.AuthInfoVO
;
import
com.yaoyaozw.customer.vo.kanban.CommonOptionResponseVO
;
import
com.yaoyaozw.customer.vo.kanban.CommonOptionResponseVO
;
...
@@ -28,10 +25,8 @@ import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO;
...
@@ -28,10 +25,8 @@ import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -39,7 +34,6 @@ import org.springframework.stereotype.Component;
...
@@ -39,7 +34,6 @@ import org.springframework.stereotype.Component;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -159,8 +153,8 @@ public class CustomerServiceCommonAsyncComponent {
...
@@ -159,8 +153,8 @@ public class CustomerServiceCommonAsyncComponent {
for
(
ReferralEntity
referralEntity
:
referralEntityList
)
{
for
(
ReferralEntity
referralEntity
:
referralEntityList
)
{
// 获取链接
// 获取链接
if
(
CustomerCommonConstant
.
REMOTE_LINK_NEWS_TYPE_LIST
.
contains
(
referralEntity
.
getNewsType
())
)
{
if
(
CustomerCommonConstant
.
REMOTE_LINK_NEWS_TYPE_LIST
.
contains
(
referralEntity
.
getNewsType
())
||
LOCAL_LOG
.
info
(
"异步获取图文客服链接"
);
CustomerCommonConstant
.
ACQUISITION_LINK_NEWS_TYPE
.
equals
(
referralEntity
.
getNewsType
()))
{
getMessageAuthListLink
(
storeGroupMap
,
customerGraphics
,
referralEntity
);
getMessageAuthListLink
(
storeGroupMap
,
customerGraphics
,
referralEntity
);
}
else
{
}
else
{
LOCAL_LOG
.
info
(
"newsType: {}, 不需要获取链接"
,
referralEntity
.
getNewsType
());
LOCAL_LOG
.
info
(
"newsType: {}, 不需要获取链接"
,
referralEntity
.
getNewsType
());
...
@@ -236,6 +230,9 @@ public class CustomerServiceCommonAsyncComponent {
...
@@ -236,6 +230,9 @@ public class CustomerServiceCommonAsyncComponent {
}
else
if
(
CustomerCommonConstant
.
USUAL_LINK_NEWS_TYPE
.
equals
(
newsType
))
{
}
else
if
(
CustomerCommonConstant
.
USUAL_LINK_NEWS_TYPE
.
equals
(
newsType
))
{
// 常用链接
// 常用链接
generateMessageUsualLink
(
storeGroupMap
,
customerReferral
);
generateMessageUsualLink
(
storeGroupMap
,
customerReferral
);
}
else
if
(
CustomerCommonConstant
.
ACQUISITION_LINK_NEWS_TYPE
.
equals
(
newsType
))
{
// 获客链接
generateMessageAcquisitionLink
(
storeGroupMap
,
customerReferral
);
}
}
}
}
...
@@ -389,6 +386,90 @@ public class CustomerServiceCommonAsyncComponent {
...
@@ -389,6 +386,90 @@ public class CustomerServiceCommonAsyncComponent {
});
});
}
}
private
void
generateMessageAcquisitionLink
(
Map
<
String
,
List
<
CrowdPackageUserVO
>>
storeGroupMap
,
ReferralEntity
customerReferral
)
{
LOCAL_LOG
.
info
(
"开始处理获客链接"
);
Map
<
String
,
String
>
storeEntityMap
=
getStoreEntityMap
(
storeGroupMap
.
keySet
());
// 缓存公众号appId对应的获客链接,避免重复查询数据库
Map
<
String
,
String
>
appIdAcquisitionLinkMap
=
new
HashMap
<>();
storeGroupMap
.
forEach
((
storeType
,
userVoList
)
->
{
LOCAL_LOG
.
info
(
"当前处理书城: {}"
,
storeType
);
// 去重提取公众号
Set
<
String
>
accountSet
=
userVoList
.
stream
().
map
(
CrowdPackageUserVO:
:
getAccountId
).
collect
(
Collectors
.
toSet
());
List
<
AuthInfoVO
>
authInfoList
=
customerServiceCommonService
.
getAuthInfoList
(
accountSet
);
// 定义
List
<
ReferralEntity
>
referralEntityList
=
new
ArrayList
<>(
accountSet
.
size
());
for
(
AuthInfoVO
authInfoVo
:
authInfoList
)
{
ReferralEntity
referralEntity
=
new
ReferralEntity
();
BeanUtil
.
copyProperties
(
customerReferral
,
referralEntity
);
// 重新生成链接主键id
referralEntity
.
setId
(
snowflakeComponent
.
snowflakeId
());
referralEntity
.
setAccountId
(
authInfoVo
.
getAccountId
());
referralEntity
.
setStoreTypeName
(
storeEntityMap
.
get
(
storeType
));
try
{
// 获取获客链接
String
acquisitionLink
=
getAcquisitionLinkFromCache
(
authInfoVo
.
getAppId
(),
appIdAcquisitionLinkMap
);
if
(
StringUtils
.
isNotBlank
(
acquisitionLink
))
{
referralEntity
.
setReferral
(
acquisitionLink
);
LOCAL_LOG
.
info
(
"公众号: {} 获取到获客链接: {}"
,
authInfoVo
.
getAccountName
(),
acquisitionLink
);
}
else
{
LOCAL_LOG
.
warn
(
"公众号: {} 未找到可用的获客链接,设置为error"
,
authInfoVo
.
getAccountName
());
referralEntity
.
setReferral
(
CustomerCommonConstant
.
ERROR_LABEL
);
}
}
catch
(
Exception
e
)
{
LOCAL_LOG
.
warn
(
"公众号: {} 获取获客链接异常: {}"
,
authInfoVo
.
getAccountName
(),
e
.
getMessage
());
referralEntity
.
setReferral
(
CustomerCommonConstant
.
ERROR_LABEL
);
}
referralEntityList
.
add
(
referralEntity
);
}
// 批量新增
LOCAL_LOG
.
info
(
"保存书城: {} 的获客链接实体, 数量:{}条"
,
storeType
,
referralEntityList
.
size
());
referralEntityService
.
saveBatch
(
referralEntityList
);
});
}
/**
* 从缓存中获取获客链接,避免重复查询数据库
* @param appId 公众号appId
* @param appIdAcquisitionLinkMap 缓存Map
* @return 获客链接,如果没有则返回null
*/
private
String
getAcquisitionLinkFromCache
(
String
appId
,
Map
<
String
,
String
>
appIdAcquisitionLinkMap
)
{
// 先从缓存中查找
if
(
appIdAcquisitionLinkMap
.
containsKey
(
appId
))
{
return
appIdAcquisitionLinkMap
.
get
(
appId
);
}
// 缓存中没有,查询数据库
try
{
List
<
String
>
acquisitionLinkList
=
companyAcquisitionLinkService
.
getAcquisitionLinksByAppId
(
appId
,
"OPERATE"
);
String
acquisitionLink
=
null
;
if
(
CollectionUtil
.
isNotEmpty
(
acquisitionLinkList
))
{
// 取第一个可用的获客链接
acquisitionLink
=
acquisitionLinkList
.
get
(
0
);
LOCAL_LOG
.
info
(
"公众号: {} 查询到 {} 个可用获客链接,使用第一个: {}"
,
appId
,
acquisitionLinkList
.
size
(),
acquisitionLink
);
}
else
{
LOCAL_LOG
.
warn
(
"公众号: {} 没有找到可用的获客链接"
,
appId
);
}
// 存入缓存(包括null值,避免重复查询)
appIdAcquisitionLinkMap
.
put
(
appId
,
acquisitionLink
);
return
acquisitionLink
;
}
catch
(
Exception
e
)
{
LOCAL_LOG
.
error
(
"查询公众号: {} 的获客链接时发生异常: {}"
,
appId
,
e
.
getMessage
(),
e
);
// 异常情况也存入缓存,避免重复查询
appIdAcquisitionLinkMap
.
put
(
appId
,
null
);
return
null
;
}
}
/**
/**
* 以下是延时客服 的方法
* 以下是延时客服 的方法
*/
*/
...
...
src/main/java/com/yaoyaozw/customer/constants/CustomerCommonConstant.java
浏览文件 @
a9342289
...
@@ -32,6 +32,7 @@ public class CustomerCommonConstant {
...
@@ -32,6 +32,7 @@ public class CustomerCommonConstant {
public
final
static
List
<
Integer
>
REMOTE_LINK_NEWS_TYPE_LIST
=
Arrays
.
asList
(
1
,
2
,
3
);
public
final
static
List
<
Integer
>
REMOTE_LINK_NEWS_TYPE_LIST
=
Arrays
.
asList
(
1
,
2
,
3
);
public
final
static
List
<
Integer
>
COMMON_NEWS_TYPE_LIST
=
Collections
.
singletonList
(
4
);
public
final
static
List
<
Integer
>
COMMON_NEWS_TYPE_LIST
=
Collections
.
singletonList
(
4
);
public
final
static
Integer
ACQUISITION_LINK_NEWS_TYPE
=
-
2
;
public
final
static
String
YW_LINK_LIMIT_REDIS_KEY
=
"YW_REFERRAL"
;
public
final
static
String
YW_LINK_LIMIT_REDIS_KEY
=
"YW_REFERRAL"
;
public
final
static
String
YANG_GUANG_ACCESS_LIMIT_REDIS_KEY
=
"YG_ACCESS_LIMIT_NUM"
;
public
final
static
String
YANG_GUANG_ACCESS_LIMIT_REDIS_KEY
=
"YG_ACCESS_LIMIT_NUM"
;
...
...
src/main/java/com/yaoyaozw/customer/service/impl/CustomerGraphicsTextServiceImpl.java
浏览文件 @
a9342289
...
@@ -123,7 +123,8 @@ public class CustomerGraphicsTextServiceImpl extends ServiceImpl<CustomerGraphic
...
@@ -123,7 +123,8 @@ public class CustomerGraphicsTextServiceImpl extends ServiceImpl<CustomerGraphic
context
=
CustomerCommonConstant
.
CUSTOMER_TEXT_LINK_TEMPLATE
context
=
CustomerCommonConstant
.
CUSTOMER_TEXT_LINK_TEMPLATE
.
replace
(
CustomerCommonConstant
.
CUSTOMER_TEXT_CONTENT_PLACEHOLDER
,
item
.
getTextContent
())
.
replace
(
CustomerCommonConstant
.
CUSTOMER_TEXT_CONTENT_PLACEHOLDER
,
item
.
getTextContent
())
.
replace
(
CustomerCommonConstant
.
CUSTOMER_TEXT_URL_PLACEHOLDER
,
CustomerCommonConstant
.
CUSTOMER_TEXT_URL_PLACEHOLDER
+
idx
);
.
replace
(
CustomerCommonConstant
.
CUSTOMER_TEXT_URL_PLACEHOLDER
,
CustomerCommonConstant
.
CUSTOMER_TEXT_URL_PLACEHOLDER
+
idx
);
}
else
if
(
CustomerCommonConstant
.
COMMON_NEWS_TYPE_LIST
.
contains
(
item
.
getNewsType
())){
}
else
if
(
CustomerCommonConstant
.
COMMON_NEWS_TYPE_LIST
.
contains
(
item
.
getNewsType
())
||
CustomerCommonConstant
.
ACQUISITION_LINK_NEWS_TYPE
.
equals
(
item
.
getNewsType
())){
// 纯文本或者获客链接
context
=
item
.
getTextContent
();
context
=
item
.
getTextContent
();
}
}
if
(
ObjectUtil
.
isNotNull
(
context
))
{
if
(
ObjectUtil
.
isNotNull
(
context
))
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论