Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
9c8bff4d
提交
9c8bff4d
authored
11月 21, 2025
作者:
沈振路
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
客服消息适配文本的小程序文字链【未测试】
上级
1a062c39
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
57 行增加
和
31 行删除
+57
-31
CustomerServiceCommonAsyncComponent.java
...tomer/components/CustomerServiceCommonAsyncComponent.java
+18
-22
CustomerCommonConstant.java
...m/yaoyaozw/customer/constants/CustomerCommonConstant.java
+3
-0
CommonReferralBody.java
...java/com/yaoyaozw/customer/entity/CommonReferralBody.java
+9
-0
CustomerGraphicsTextServiceImpl.java
...ustomer/service/impl/CustomerGraphicsTextServiceImpl.java
+15
-4
WeChatServiceImpl.java
...zw/customer/service/wechat/service/WeChatServiceImpl.java
+12
-5
没有找到文件。
src/main/java/com/yaoyaozw/customer/components/CustomerServiceCommonAsyncComponent.java
浏览文件 @
9c8bff4d
...
@@ -14,7 +14,10 @@ import com.yaoyaozw.customer.constants.CustomerCommonConstant;
...
@@ -14,7 +14,10 @@ import com.yaoyaozw.customer.constants.CustomerCommonConstant;
import
com.yaoyaozw.customer.constants.RabbitCommonNameConstant
;
import
com.yaoyaozw.customer.constants.RabbitCommonNameConstant
;
import
com.yaoyaozw.customer.entity.*
;
import
com.yaoyaozw.customer.entity.*
;
import
com.yaoyaozw.customer.enums.CustomerStoreTemplateEnum
;
import
com.yaoyaozw.customer.enums.CustomerStoreTemplateEnum
;
import
com.yaoyaozw.customer.exception.BaseException
;
import
com.yaoyaozw.customer.factory.MpReferralFactory
;
import
com.yaoyaozw.customer.feigns.ReferralFeignClient
;
import
com.yaoyaozw.customer.feigns.ReferralFeignClient
;
import
com.yaoyaozw.customer.handler.MpReferralHandler
;
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
;
...
@@ -28,6 +31,7 @@ import org.apache.commons.lang3.StringUtils;
...
@@ -28,6 +31,7 @@ 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.core.RabbitTemplate
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
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
;
...
@@ -81,6 +85,8 @@ public class CustomerServiceCommonAsyncComponent {
...
@@ -81,6 +85,8 @@ public class CustomerServiceCommonAsyncComponent {
private
CompanyAcquisitionLinkService
companyAcquisitionLinkService
;
private
CompanyAcquisitionLinkService
companyAcquisitionLinkService
;
@Autowired
@Autowired
private
TencentCustomerUtil
tencentCustomerUtil
;
private
TencentCustomerUtil
tencentCustomerUtil
;
@Resource
private
MpReferralFactory
mpReferralFactory
;
@Async
(
"myExecutor"
)
@Async
(
"myExecutor"
)
...
@@ -701,23 +707,20 @@ public class CustomerServiceCommonAsyncComponent {
...
@@ -701,23 +707,20 @@ public class CustomerServiceCommonAsyncComponent {
}
}
referralEntity
.
setInfoId
(
authInfoVo
.
getId
());
referralEntity
.
setInfoId
(
authInfoVo
.
getId
());
// 判断如果是番茄小程序的话,处理参数
boolean
isMpQuery
=
CUSTOMER_TYPE_VALUE_MINI_PROGRAM
.
equals
(
referralEntity
.
getCustomerMsgType
())
||
StringUtils
.
isNotBlank
(
referralEntity
.
getMpAppId
());
if
(
CustomerCommonConstant
.
STORE_NAME_TOMATO
.
equals
(
authInfoVo
.
getStoreType
())
&&
CUSTOMER_TYPE_VALUE_MINI_PROGRAM
.
equals
(
referralEntity
.
getCustomerMsgType
()))
{
referralEntity
.
setMiniProgramQuery
(
isMpQuery
);
// 番茄小程序
if
(
ACTIVITY_NEWS_TYPE
.
equals
(
referralEntity
.
getNewsType
()))
{
if
(
isMpQuery
)
{
// 活动使用公众号本身的分销商Id
MpReferralHandler
handler
=
mpReferralFactory
.
getHandler
(
authInfoVo
.
getStoreType
());
referralEntity
.
setAccountId
(
authInfoVo
.
getAccountId
());
if
(
handler
==
null
)
{
}
else
{
throw
new
BaseException
(
"不支持小程序发文的书城:"
+
(
StringUtils
.
isNotBlank
(
authInfoVo
.
getStoreTypeName
())
?
authInfoVo
.
getStoreTypeName
()
:
authInfoVo
.
getStoreType
()));
referralEntity
.
setAccountId
(
authInfoVo
.
getExpandDistributorId
());
if
(
BOOK_NEWS_TYPE
.
equals
(
referralEntity
.
getNewsType
()))
{
referralEntity
.
setMediaSource
(
"2"
);
}
}
referralEntity
.
setMiniProgramQuery
(
Boolean
.
TRUE
);
}
}
if
(
STORE_NAME_YUE_WEN_1
.
equals
(
authInfoVo
.
getStoreType
())
&&
CUSTOMER_TYPE_VALUE_MINI_PROGRAM
.
equals
(
referralEntity
.
getCustomerMsgType
()))
{
ReferralEntity
referralResult
=
handler
.
queryMpReferral
(
referralEntity
);
referralEntity
.
setMiniProgramQuery
(
Boolean
.
TRUE
);
if
(
referralResult
!=
null
)
{
// 全量赋值
BeanUtils
.
copyProperties
(
referralResult
,
referralEntity
);
}
}
}
else
{
// LOCAL_LOG.info("获取链接, 参数: {}", referralEntity);
// LOCAL_LOG.info("获取链接, 参数: {}", referralEntity);
R
r
=
referralFeignClient
.
productReferral
(
referralEntity
);
R
r
=
referralFeignClient
.
productReferral
(
referralEntity
);
if
(!
r
.
getCode
().
equals
(
ApiResultConstant
.
SUCCESS_CODE
))
{
if
(!
r
.
getCode
().
equals
(
ApiResultConstant
.
SUCCESS_CODE
))
{
...
@@ -736,13 +739,6 @@ public class CustomerServiceCommonAsyncComponent {
...
@@ -736,13 +739,6 @@ public class CustomerServiceCommonAsyncComponent {
String
referral
=
jsonObject1
.
getString
(
"referral"
);
String
referral
=
jsonObject1
.
getString
(
"referral"
);
referralEntity
.
setPromoteId
(
jsonObject1
.
getString
(
"promoteId"
));
referralEntity
.
setPromoteId
(
jsonObject1
.
getString
(
"promoteId"
));
referralEntity
.
setReferral
(
referral
);
referralEntity
.
setReferral
(
referral
);
if
(
CustomerCommonConstant
.
STORE_NAME_TOMATO
.
equals
(
authInfoVo
.
getStoreType
())
&&
CUSTOMER_TYPE_VALUE_MINI_PROGRAM
.
equals
(
referralEntity
.
getCustomerMsgType
()))
{
// 取链接成功之后,后置处理番茄小程序
suffixHandleTomatoMiniProgram
(
authInfoVo
,
referralEntity
);
}
if
(
STORE_NAME_YUE_WEN_1
.
equals
(
authInfoVo
.
getStoreType
())
&&
CUSTOMER_TYPE_VALUE_MINI_PROGRAM
.
equals
(
referralEntity
.
getCustomerMsgType
()))
{
// 取链接成功之后,后置处理阅文1小程序
suffixHandleYwMiniProgram
(
authInfoVo
,
referralEntity
,
jsonObject1
);
}
}
}
}
...
...
src/main/java/com/yaoyaozw/customer/constants/CustomerCommonConstant.java
浏览文件 @
9c8bff4d
...
@@ -59,9 +59,12 @@ public class CustomerCommonConstant {
...
@@ -59,9 +59,12 @@ public class CustomerCommonConstant {
public
final
static
String
ACTIVITY_NEWS_TYPE_NAME_CONFIG_NAME_MODEL
=
"系统-客服-{newsType}-{accountNickName}-{storeType}-{currentDate}-{configName}"
;
public
final
static
String
ACTIVITY_NEWS_TYPE_NAME_CONFIG_NAME_MODEL
=
"系统-客服-{newsType}-{accountNickName}-{storeType}-{currentDate}-{configName}"
;
public
final
static
String
CUSTOMER_TEXT_LINK_TEMPLATE
=
"<a href=\"{url}-\" style='color: blue'>{content}</a>"
;
public
final
static
String
CUSTOMER_TEXT_LINK_TEMPLATE
=
"<a href=\"{url}-\" style='color: blue'>{content}</a>"
;
public
final
static
String
CUSTOMER_TEXT_MINI_PROGRAM_TEMPLATE
=
"<a href=\"#\" data-miniprogram-appid=\"{mpAppId}\" data-miniprogram-path=\"{mpPath}\">点击跳小程序</a>"
;
public
final
static
String
CUSTOMER_TEXT_URL_PLACEHOLDER
=
"{url}-"
;
public
final
static
String
CUSTOMER_TEXT_URL_PLACEHOLDER
=
"{url}-"
;
public
final
static
String
CUSTOMER_TEXT_CONTENT_PLACEHOLDER
=
"{content}"
;
public
final
static
String
CUSTOMER_TEXT_CONTENT_PLACEHOLDER
=
"{content}"
;
public
final
static
String
CUSTOMER_TEXT_MP_APPID_PLACEHOLDER
=
"{mpAppId}"
;
public
final
static
String
CUSTOMER_TEXT_MP_PATH_PLACEHOLDER
=
"{mpPath}"
;
public
final
static
String
H5_STYLE_CODE
=
" style='color: blue'"
;
public
final
static
String
H5_STYLE_CODE
=
" style='color: blue'"
;
public
final
static
Integer
USUAL_LINK_NEWS_TYPE
=
3
;
public
final
static
Integer
USUAL_LINK_NEWS_TYPE
=
3
;
...
...
src/main/java/com/yaoyaozw/customer/entity/CommonReferralBody.java
浏览文件 @
9c8bff4d
...
@@ -103,6 +103,15 @@ public class CommonReferralBody implements Serializable {
...
@@ -103,6 +103,15 @@ public class CommonReferralBody implements Serializable {
private
String
h5Content
;
private
String
h5Content
;
private
String
mpTitle
;
private
String
mpAppId
;
private
String
mpPath
;
private
String
mediaId
;
public
Date
getStartTime
()
{
public
Date
getStartTime
()
{
if
(
CollectionUtil
.
isNotEmpty
(
this
.
dateList
))
{
if
(
CollectionUtil
.
isNotEmpty
(
this
.
dateList
))
{
return
dateList
.
get
(
0
);
return
dateList
.
get
(
0
);
...
...
src/main/java/com/yaoyaozw/customer/service/impl/CustomerGraphicsTextServiceImpl.java
浏览文件 @
9c8bff4d
...
@@ -29,6 +29,8 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
...
@@ -29,6 +29,8 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
static
com
.
yaoyaozw
.
customer
.
constants
.
CustomerCommonConstant
.
REMOTE_LINK_NEWS_TYPE_LIST
;
/**
/**
* @author darker
* @author darker
* @date 2022/10/12 11:49
* @date 2022/10/12 11:49
...
@@ -74,6 +76,11 @@ public class CustomerGraphicsTextServiceImpl extends ServiceImpl<CustomerGraphic
...
@@ -74,6 +76,11 @@ public class CustomerGraphicsTextServiceImpl extends ServiceImpl<CustomerGraphic
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
GenericsResult
<
CustomerMessageTextDetailVO
>
insertCustomerContent
(
CommonReferralBody
referralDto
)
{
public
GenericsResult
<
CustomerMessageTextDetailVO
>
insertCustomerContent
(
CommonReferralBody
referralDto
)
{
// 预处理小程序信息
if
(
StringUtils
.
isNotBlank
(
referralDto
.
getMpAppId
())
&&
!
REMOTE_LINK_NEWS_TYPE_LIST
.
contains
(
referralDto
.
getNewsType
()))
{
// 判断是不是确实符合小程序类型:(newsType 只有书籍、活动、常用链接 支持小程序)
return
new
GenericsResult
<>(
false
,
"当前链接类型不支持发送小程序"
);
}
// 处理活动数据
// 处理活动数据
ReferralEntity
referralEntity
=
new
ReferralEntity
();
ReferralEntity
referralEntity
=
new
ReferralEntity
();
...
@@ -119,10 +126,14 @@ public class CustomerGraphicsTextServiceImpl extends ServiceImpl<CustomerGraphic
...
@@ -119,10 +126,14 @@ public class CustomerGraphicsTextServiceImpl extends ServiceImpl<CustomerGraphic
// 设置主键id和h5代码段
// 设置主键id和h5代码段
customerContentVO
.
setId
(
item
.
getId
());
customerContentVO
.
setId
(
item
.
getId
());
String
context
=
null
;
String
context
=
null
;
if
(
CustomerCommonConstant
.
REPLACE_LINK_NEWS_TYPE_LIST
.
contains
(
item
.
getNewsType
())
||
CustomerCommonConstant
.
ACQUISITION_LINK_NEWS_TYPE
.
equals
(
item
.
getNewsType
()))
{
if
(
StringUtils
.
isNotBlank
(
item
.
getMpAppId
()))
{
// 小程序链接:这里的mpAppId会在保存的时候通过占位符填入,待生成的时候,匹配具体appId
context
=
CustomerCommonConstant
.
CUSTOMER_TEXT_MINI_PROGRAM_TEMPLATE
.
replace
(
CustomerCommonConstant
.
CUSTOMER_TEXT_CONTENT_PLACEHOLDER
,
item
.
getTextContent
());
}
else
if
(
CustomerCommonConstant
.
REPLACE_LINK_NEWS_TYPE_LIST
.
contains
(
item
.
getNewsType
())
||
CustomerCommonConstant
.
ACQUISITION_LINK_NEWS_TYPE
.
equals
(
item
.
getNewsType
()))
{
// 非小程序链接
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
);
}
else
if
(
CustomerCommonConstant
.
COMMON_NEWS_TYPE_LIST
.
contains
(
item
.
getNewsType
())){
}
else
if
(
CustomerCommonConstant
.
COMMON_NEWS_TYPE_LIST
.
contains
(
item
.
getNewsType
())){
// 纯文本或者获客链接
// 纯文本或者获客链接
context
=
item
.
getTextContent
();
context
=
item
.
getTextContent
();
...
@@ -144,7 +155,7 @@ public class CustomerGraphicsTextServiceImpl extends ServiceImpl<CustomerGraphic
...
@@ -144,7 +155,7 @@ public class CustomerGraphicsTextServiceImpl extends ServiceImpl<CustomerGraphic
contentList
.
add
(
customerContentVO
);
contentList
.
add
(
customerContentVO
);
// 统计referralSize
// 统计referralSize
if
(
CustomerCommonConstant
.
REMOTE_LINK_NEWS_TYPE_LIST
.
contains
(
item
.
getNewsType
())
||
CustomerCommonConstant
.
ACQUISITION_LINK_NEWS_TYPE
.
equals
(
item
.
getNewsType
()))
{
if
(
REMOTE_LINK_NEWS_TYPE_LIST
.
contains
(
item
.
getNewsType
())
||
CustomerCommonConstant
.
ACQUISITION_LINK_NEWS_TYPE
.
equals
(
item
.
getNewsType
()))
{
replaceLinkTypeNum
+=
1
;
replaceLinkTypeNum
+=
1
;
}
}
idx
+=
1
;
idx
+=
1
;
...
...
src/main/java/com/yaoyaozw/customer/service/wechat/service/WeChatServiceImpl.java
浏览文件 @
9c8bff4d
...
@@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
...
@@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.web.util.UriComponentsBuilder
;
import
org.springframework.web.util.UriComponentsBuilder
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.*
;
import
java.util.concurrent.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Slf4j
@Slf4j
...
@@ -215,12 +216,14 @@ public class WeChatServiceImpl implements WeChatService{
...
@@ -215,12 +216,14 @@ public class WeChatServiceImpl implements WeChatService{
private
WeChatCustomerRequestEntity
buildCustomerRequest
(
CustomerGraphics
customerGraphics
,
List
<
ReferralEntityVo
>
urlList
){
private
WeChatCustomerRequestEntity
buildCustomerRequest
(
CustomerGraphics
customerGraphics
,
List
<
ReferralEntityVo
>
urlList
){
//类型判断
//类型判断
if
(
CUSTOMER_TEXT
.
equals
(
customerGraphics
.
getType
())){
if
(
CUSTOMER_TEXT
.
equals
(
customerGraphics
.
getType
())){
if
(
StringUtils
.
isNotBlank
(
customerGraphics
.
getContent
())
&&
customerGraphics
.
getContent
().
contains
(
CustomerCommonConstant
.
CUSTOMER_TEXT_URL_PLACEHOLDER
)
&&
CollectionUtil
.
isEmpty
(
urlList
))
{
if
(
StringUtils
.
isNotBlank
(
customerGraphics
.
getContent
())
&&
(
customerGraphics
.
getContent
().
contains
(
CustomerCommonConstant
.
CUSTOMER_TEXT_URL_PLACEHOLDER
)
||
customerGraphics
.
getContent
().
contains
(
CustomerCommonConstant
.
CUSTOMER_TEXT_MP_PATH_PLACEHOLDER
))
&&
CollectionUtil
.
isEmpty
(
urlList
))
{
// 文本中存在需要替换的链接,但链接列表为空
// 文本中存在需要替换的链接,但链接列表为空
return
null
;
return
null
;
}
}
//文本类客服,需要判断替换链接的个数
//文本类客服,需要判断替换链接的个数
Map
<
Integer
,
String
>
sortReferral
=
urlList
!=
null
&&!
urlList
.
isEmpty
()?
urlList
.
stream
().
collect
(
Collectors
.
toMap
(
ReferralEntityVo:
:
getSort
,
ReferralEntityVo:
:
getReferral
,
(
v1
,
v2
)
->
v2
)):
new
HashMap
<>(
1
);
Map
<
Integer
,
ReferralEntityVo
>
sortReferral
=
urlList
!=
null
&&!
urlList
.
isEmpty
()?
urlList
.
stream
().
collect
(
Collectors
.
toMap
(
ReferralEntityVo:
:
getSort
,
Function
.
identity
()
,
(
v1
,
v2
)
->
v2
)):
new
HashMap
<>(
1
);
// 统计生成完成的非自定义链接的链接数量
// 统计生成完成的非自定义链接的链接数量
int
actualReferralCount
=
urlList
==
null
?
0
:
(
int
)
urlList
.
stream
().
filter
(
v
->
!
StringUtils
.
isAnyBlank
(
v
.
getAppid
(),
v
.
getReferral
())
&&
v
.
getNewsType
()
!=
null
&&
v
.
getNewsType
()
!=
-
1
).
map
(
ReferralEntityVo:
:
getSort
).
distinct
().
count
();
int
actualReferralCount
=
urlList
==
null
?
0
:
(
int
)
urlList
.
stream
().
filter
(
v
->
!
StringUtils
.
isAnyBlank
(
v
.
getAppid
(),
v
.
getReferral
())
&&
v
.
getNewsType
()
!=
null
&&
v
.
getNewsType
()
!=
-
1
).
map
(
ReferralEntityVo:
:
getSort
).
distinct
().
count
();
...
@@ -228,13 +231,17 @@ public class WeChatServiceImpl implements WeChatService{
...
@@ -228,13 +231,17 @@ public class WeChatServiceImpl implements WeChatService{
String
content
=
customerGraphics
.
getContent
();
String
content
=
customerGraphics
.
getContent
();
for
(
Map
.
Entry
<
Integer
,
String
>
replaceReferral
:
sortReferral
.
entrySet
())
{
for
(
Map
.
Entry
<
Integer
,
ReferralEntityVo
>
replaceReferral
:
sortReferral
.
entrySet
())
{
Integer
sort
=
replaceReferral
.
getKey
();
Integer
sort
=
replaceReferral
.
getKey
();
String
url
=
replaceReferral
.
getValue
();
ReferralEntityVo
referralEntityVo
=
replaceReferral
.
getValue
();
String
url
=
referralEntityVo
.
getReferral
();
//替换占位符
//替换占位符
content
=
content
.
replace
(
CustomerCommonConstant
.
CUSTOMER_TEXT_URL_PLACEHOLDER
+
sort
,
url
);
content
=
content
.
replace
(
CustomerCommonConstant
.
CUSTOMER_TEXT_URL_PLACEHOLDER
+
sort
,
url
)
.
replace
(
CustomerCommonConstant
.
CUSTOMER_TEXT_MP_APPID_PLACEHOLDER
,
referralEntityVo
.
getMpAppId
())
.
replace
(
CustomerCommonConstant
.
CUSTOMER_TEXT_MP_PATH_PLACEHOLDER
+
sort
,
referralEntityVo
.
getMpPath
())
;
}
}
return
new
WeChatCustomerRequestEntity
(
CUSTOMER_TEXT
,
content
);
return
new
WeChatCustomerRequestEntity
(
CUSTOMER_TEXT
,
content
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论