Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
99444a2c
提交
99444a2c
authored
11月 12, 2025
作者:
沈振路
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
关键词回复,番茄小程序适配取链接
上级
af2131b7
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
190 行增加
和
7 行删除
+190
-7
CustomerKeywordComponent.java
...aoyaozw/customer/components/CustomerKeywordComponent.java
+106
-4
CustomerKeywordServiceImpl.java
...ozw/customer/service/impl/CustomerKeywordServiceImpl.java
+84
-3
没有找到文件。
src/main/java/com/yaoyaozw/customer/components/CustomerKeywordComponent.java
浏览文件 @
99444a2c
...
@@ -2,6 +2,7 @@ package com.yaoyaozw.customer.components;
...
@@ -2,6 +2,7 @@ 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.util.ObjectUtil
;
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
;
...
@@ -9,10 +10,10 @@ import com.yaoyaozw.customer.common.R;
...
@@ -9,10 +10,10 @@ 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
;
import
com.yaoyaozw.customer.constants.CustomerMaterialConstant
;
import
com.yaoyaozw.customer.constants.CustomerMaterialConstant
;
import
com.yaoyaozw.customer.entity.CommonReferralBody
;
import
com.yaoyaozw.customer.entity.*
;
import
com.yaoyaozw.customer.entity.CustomerKeyword
;
import
com.yaoyaozw.customer.exception.BaseException
;
import
com.yaoyaozw.customer.entity.ReferralEntity
;
import
com.yaoyaozw.customer.feigns.ReferralFeignClient
;
import
com.yaoyaozw.customer.feigns.ReferralFeignClient
;
import
com.yaoyaozw.customer.service.AuthorizerExpandInfoService
;
import
com.yaoyaozw.customer.service.AuthorizerInfoService
;
import
com.yaoyaozw.customer.service.AuthorizerInfoService
;
import
com.yaoyaozw.customer.service.CompanyAcquisitionLinkService
;
import
com.yaoyaozw.customer.service.CompanyAcquisitionLinkService
;
import
com.yaoyaozw.customer.service.ReferralEntityService
;
import
com.yaoyaozw.customer.service.ReferralEntityService
;
...
@@ -32,6 +33,9 @@ import java.util.ArrayList;
...
@@ -32,6 +33,9 @@ import java.util.ArrayList;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
static
com
.
yaoyaozw
.
customer
.
constants
.
CustomerCommonConstant
.*;
import
static
com
.
yaoyaozw
.
customer
.
constants
.
CustomerCommonConstant
.
LANDING_PAGE_VAL
;
/**
/**
* @author darker
* @author darker
* @date 2023/3/14 14:36
* @date 2023/3/14 14:36
...
@@ -51,6 +55,10 @@ public class CustomerKeywordComponent {
...
@@ -51,6 +55,10 @@ public class CustomerKeywordComponent {
private
SnowflakeComponent
snowflakeComponent
;
private
SnowflakeComponent
snowflakeComponent
;
@Resource
@Resource
private
CompanyAcquisitionLinkService
companyAcquisitionLinkService
;
private
CompanyAcquisitionLinkService
companyAcquisitionLinkService
;
@Resource
private
AuthorizerExpandInfoService
authorizerExpandInfoService
;
@Resource
private
AuthorizerInfoService
authorizerInfoService
;
/**
/**
* 获取链接实体
* 获取链接实体
...
@@ -166,7 +174,15 @@ public class CustomerKeywordComponent {
...
@@ -166,7 +174,15 @@ public class CustomerKeywordComponent {
}
}
entity
.
setTxMediaUrl
(
uploadResult
.
getUrl
());
entity
.
setTxMediaUrl
(
uploadResult
.
getUrl
());
entity
.
setTxMediaId
(
uploadResult
.
getMedia_id
());
entity
.
setTxMediaId
(
uploadResult
.
getMedia_id
());
// 需要上传后台的类型不需要处理链接
// 判断需不需要处理小程序
try
{
handleMp
(
dateStr
,
targetAuth
,
entity
,
sourceMaterial
);
finalMaterialList
.
add
(
entity
);
}
catch
(
Exception
e
)
{
status
=
0
;
result
.
setHasError
(
true
);
}
entity
.
setStatus
(
status
);
entity
.
setStatus
(
status
);
finalMaterialList
.
add
(
entity
);
finalMaterialList
.
add
(
entity
);
continue
;
continue
;
...
@@ -219,6 +235,92 @@ public class CustomerKeywordComponent {
...
@@ -219,6 +235,92 @@ public class CustomerKeywordComponent {
}
}
private
void
handleMp
(
String
dateStr
,
AuthInfoVO
targetAuth
,
CustomerKeyword
neoEntity
,
CustomerKeyword
sourceMaterial
)
{
if
(!
CUSTOMER_TYPE_VALUE_MINI_PROGRAM
.
equals
(
neoEntity
.
getType
()))
{
return
;
}
List
<
ReferralEntity
>
referralEntityList
=
sourceMaterial
.
getReferralEntityList
();
if
(
CollectionUtil
.
isEmpty
(
referralEntityList
))
{
// 不具备处理条件
return
;
}
ReferralEntity
sourceReferral
=
referralEntityList
.
get
(
0
);
// 如果参数传入的标题只是在图文上,则延用过来
if
(
StringUtils
.
isBlank
(
neoEntity
.
getMpTitle
())
&&
StringUtils
.
isNotBlank
(
neoEntity
.
getExtendTitle
()))
{
neoEntity
.
setMpTitle
(
neoEntity
.
getExtendTitle
());
}
if
(
StringUtils
.
isBlank
(
neoEntity
.
getMpTitle
()))
{
throw
new
BaseException
(
"无法匹配小程序发文的标题内容"
);
}
// 番茄
// 重新处理 小程序appId、小程序path
String
storeType
;
if
(
StringUtils
.
isNotBlank
(
targetAuth
.
getStoreType
()))
{
storeType
=
targetAuth
.
getStoreType
();
}
else
{
AuthorizerInfo
authorizerInfo
=
authorizerInfoService
.
lambdaQuery
().
eq
(
AuthorizerInfo:
:
getAppid
,
targetAuth
.
getAppId
()).
last
(
"limit 1"
).
one
();
if
(
authorizerInfo
==
null
)
{
throw
new
BaseException
(
"无法获取公众号信息"
);
}
storeType
=
authorizerInfo
.
getStoreType
();
}
if
(!
CustomerCommonConstant
.
STORE_NAME_TOMATO
.
equals
(
storeType
))
{
return
;
}
AuthorizerExpandInfo
authorizerExpandInfo
=
authorizerExpandInfoService
.
lambdaQuery
().
eq
(
AuthorizerExpandInfo:
:
getAuthorizerAppid
,
neoEntity
.
getAppid
()).
last
(
"limit 1"
).
one
();
if
(
authorizerExpandInfo
==
null
)
{
throw
new
BaseException
(
"无法获取公众号"
+
neoEntity
.
getAppid
()
+
"的绑定配置信息"
);
}
// 填入小程序appId
neoEntity
.
setMpAppId
(
authorizerExpandInfo
.
getMpAppid
());
// 重新获取链接
ReferralEntity
targetReferral
=
new
ReferralEntity
();
try
{
BeanUtil
.
copyProperties
(
sourceReferral
,
targetReferral
,
"id"
,
"accountId"
,
"name"
,
"referral"
,
"materialGraphicsId"
,
"infoId"
);
// 为参数设置公众号相关参数
targetReferral
.
setAccountId
(
authorizerExpandInfo
.
getMpDistributorId
());
targetReferral
.
setInfoId
(
targetAuth
.
getId
());
Integer
newsType
=
targetReferral
.
getNewsType
();
if
(
CustomerCommonConstant
.
USUAL_LINK_NEWS_TYPE
.
equals
(
newsType
))
{
// 常用链接延用name
targetReferral
.
setName
(
sourceReferral
.
getName
());
}
else
{
// 书籍、活动 类型, 重新构造name
handleReferralName
(
dateStr
,
targetAuth
.
getAccountName
(),
targetReferral
);
}
doGetReferral
(
targetReferral
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"获取链接异常: "
+
e
.
getMessage
());
}
targetReferral
.
setMaterialGraphicsId
(
neoEntity
.
getId
());
String
referral
=
targetReferral
.
getReferral
();
// 番茄处理小程序常用链接
if
(!
referral
.
contains
(
GET_BOOK_ITEM
))
{
referral
=
referral
+
"&"
+
GET_BOOK_ITEM_VAL
;
}
if
(!
referral
.
contains
(
FROM_APPID
))
{
referral
=
referral
+
"&"
+
FROM_APPID
+
"="
+
authorizerExpandInfo
.
getFlagId
();
}
if
(
CustomerCommonConstant
.
USUAL_LINK_NEWS_TYPE
.
equals
(
targetReferral
.
getNewsType
()))
{
if
(
referral
.
contains
(
"scene=0"
))
{
referral
=
referral
.
replace
(
"scene=0"
,
"scene=1"
);
}
}
else
{
if
(!
referral
.
contains
(
LANDING_PAGE
))
{
referral
=
referral
+
"&"
+
LANDING_PAGE_VAL
;
}
}
targetReferral
.
setReferral
(
referral
);
neoEntity
.
setMpPath
(
referral
);
neoEntity
.
setContent
(
""
);
// 保存链接数据
if
(
ObjectUtil
.
isNull
(
targetReferral
.
getId
()))
{
referralEntityService
.
save
(
targetReferral
);
}
else
{
referralEntityService
.
updateById
(
targetReferral
);
}
}
/**
/**
* 重新排序和保存文本子素材
* 重新排序和保存文本子素材
...
...
src/main/java/com/yaoyaozw/customer/service/impl/CustomerKeywordServiceImpl.java
浏览文件 @
99444a2c
...
@@ -11,14 +11,16 @@ import com.yaoyaozw.customer.common.BaseResult;
...
@@ -11,14 +11,16 @@ import com.yaoyaozw.customer.common.BaseResult;
import
com.yaoyaozw.customer.common.GenericsResult
;
import
com.yaoyaozw.customer.common.GenericsResult
;
import
com.yaoyaozw.customer.components.CustomerKeywordComponent
;
import
com.yaoyaozw.customer.components.CustomerKeywordComponent
;
import
com.yaoyaozw.customer.components.SnowflakeComponent
;
import
com.yaoyaozw.customer.components.SnowflakeComponent
;
import
com.yaoyaozw.customer.constants.CustomerCommonConstant
;
import
com.yaoyaozw.customer.constants.CustomerMaterialConstant
;
import
com.yaoyaozw.customer.constants.CustomerMaterialConstant
;
import
com.yaoyaozw.customer.dto.follow.FollowReplySaveDTO
;
import
com.yaoyaozw.customer.dto.keyword.CustomerKeywordCopyDTO
;
import
com.yaoyaozw.customer.dto.keyword.CustomerKeywordCopyDTO
;
import
com.yaoyaozw.customer.dto.keyword.CustomerKeywordQueryDTO
;
import
com.yaoyaozw.customer.dto.keyword.CustomerKeywordQueryDTO
;
import
com.yaoyaozw.customer.dto.keyword.CustomerKeywordSaveDTO
;
import
com.yaoyaozw.customer.dto.keyword.CustomerKeywordSaveDTO
;
import
com.yaoyaozw.customer.entity.CommonReferralBody
;
import
com.yaoyaozw.customer.entity.*
;
import
com.yaoyaozw.customer.entity.CustomerKeyword
;
import
com.yaoyaozw.customer.exception.BaseException
;
import
com.yaoyaozw.customer.entity.ReferralEntity
;
import
com.yaoyaozw.customer.mapper.CustomerKeywordMapper
;
import
com.yaoyaozw.customer.mapper.CustomerKeywordMapper
;
import
com.yaoyaozw.customer.service.AuthorizerExpandInfoService
;
import
com.yaoyaozw.customer.service.AuthorizerInfoService
;
import
com.yaoyaozw.customer.service.AuthorizerInfoService
;
import
com.yaoyaozw.customer.service.CustomerKeywordService
;
import
com.yaoyaozw.customer.service.CustomerKeywordService
;
import
com.yaoyaozw.customer.service.ReferralEntityService
;
import
com.yaoyaozw.customer.service.ReferralEntityService
;
...
@@ -35,12 +37,16 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -35,12 +37,16 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
static
com
.
yaoyaozw
.
customer
.
constants
.
CustomerCommonConstant
.*;
import
static
com
.
yaoyaozw
.
customer
.
constants
.
CustomerCommonConstant
.
LANDING_PAGE_VAL
;
/**
/**
* @author darker
* @author darker
* @date 2023/3/20 11:09
* @date 2023/3/20 11:09
...
@@ -63,6 +69,10 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe
...
@@ -63,6 +69,10 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe
@Autowired
@Autowired
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
@Resource
private
AuthorizerExpandInfoService
authorizerExpandInfoService
;
@Resource
private
CustomerKeywordComponent
customerKeywordComponent
;
@Override
@Override
...
@@ -124,6 +134,7 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe
...
@@ -124,6 +134,7 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe
}
}
entity
.
setTxMediaUrl
(
uploadResponse
.
getUrl
());
entity
.
setTxMediaUrl
(
uploadResponse
.
getUrl
());
entity
.
setTxMediaId
(
uploadResponse
.
getMedia_id
());
entity
.
setTxMediaId
(
uploadResponse
.
getMedia_id
());
handleMp
(
saveDto
,
entity
);
}
else
if
(!
CustomerMaterialConstant
.
TENCENT_MEDIA_TYPE_TEXT
.
equals
(
entity
.
getType
())){
}
else
if
(!
CustomerMaterialConstant
.
TENCENT_MEDIA_TYPE_TEXT
.
equals
(
entity
.
getType
())){
// 获取书城公众号链接(图文)
// 获取书城公众号链接(图文)
ReferralEntity
referralEntity
;
ReferralEntity
referralEntity
;
...
@@ -152,6 +163,76 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe
...
@@ -152,6 +163,76 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe
return
new
GenericsResult
<>(
String
.
valueOf
(
entity
.
getId
()));
return
new
GenericsResult
<>(
String
.
valueOf
(
entity
.
getId
()));
}
}
private
void
handleMp
(
CustomerKeywordSaveDTO
saveDto
,
CustomerKeyword
entity
)
{
if
(!
CUSTOMER_TYPE_VALUE_MINI_PROGRAM
.
equals
(
entity
.
getType
()))
{
return
;
}
CommonReferralBody
originReferralBody
=
saveDto
.
getReferralBody
();
if
(
originReferralBody
==
null
)
{
// 不具备处理条件
return
;
}
// 如果参数传入的标题只是在图文上,则延用过来
if
(
StringUtils
.
isBlank
(
entity
.
getMpTitle
())
&&
StringUtils
.
isNotBlank
(
entity
.
getExtendTitle
()))
{
entity
.
setMpTitle
(
entity
.
getExtendTitle
());
}
if
(
StringUtils
.
isBlank
(
entity
.
getMpTitle
()))
{
throw
new
BaseException
(
"无法匹配小程序发文的标题内容"
);
}
// 番茄
// 重新处理 小程序appId、小程序path
AuthorizerInfo
authorizerInfo
=
authorizerInfoService
.
lambdaQuery
().
eq
(
AuthorizerInfo:
:
getAppid
,
entity
.
getAppid
()).
last
(
"limit 1"
).
one
();
if
(
authorizerInfo
==
null
)
{
throw
new
BaseException
(
"无法获取公众号信息"
);
}
String
storeType
=
authorizerInfo
.
getStoreType
();
if
(!
CustomerCommonConstant
.
STORE_NAME_TOMATO
.
equals
(
storeType
))
{
return
;
}
AuthorizerExpandInfo
authorizerExpandInfo
=
authorizerExpandInfoService
.
lambdaQuery
().
eq
(
AuthorizerExpandInfo:
:
getAuthorizerAppid
,
entity
.
getAppid
()).
last
(
"limit 1"
).
one
();
if
(
authorizerExpandInfo
==
null
)
{
throw
new
BaseException
(
"无法获取公众号"
+
entity
.
getAppid
()
+
"的绑定配置信息"
);
}
// 填入小程序appId
entity
.
setMpAppId
(
authorizerExpandInfo
.
getMpAppid
());
// 重新获取链接
ReferralEntity
referralEntity
;
try
{
originReferralBody
.
setAccountId
(
authorizerExpandInfo
.
getMpDistributorId
());
referralEntity
=
customerKeywordComponent
.
getCreateReferralEntity
(
originReferralBody
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"获取链接异常: "
+
e
.
getMessage
());
}
referralEntity
.
setMaterialGraphicsId
(
entity
.
getId
());
String
referral
=
referralEntity
.
getReferral
();
// 番茄处理小程序常用链接
if
(!
referral
.
contains
(
GET_BOOK_ITEM
))
{
referral
=
referral
+
"&"
+
GET_BOOK_ITEM_VAL
;
}
if
(!
referral
.
contains
(
FROM_APPID
))
{
referral
=
referral
+
"&"
+
FROM_APPID
+
"="
+
authorizerExpandInfo
.
getFlagId
();
}
if
(
CustomerCommonConstant
.
USUAL_LINK_NEWS_TYPE
.
equals
(
referralEntity
.
getNewsType
()))
{
if
(
referral
.
contains
(
"scene=0"
))
{
referral
=
referral
.
replace
(
"scene=0"
,
"scene=1"
);
}
}
else
{
if
(!
referral
.
contains
(
LANDING_PAGE
))
{
referral
=
referral
+
"&"
+
LANDING_PAGE_VAL
;
}
}
entity
.
setMpPath
(
referral
);
entity
.
setContent
(
""
);
referralEntity
.
setReferral
(
referral
);
// 保存链接数据
if
(
ObjectUtil
.
isNull
(
referralEntity
.
getId
()))
{
referralEntityService
.
save
(
referralEntity
);
}
else
{
referralEntityService
.
updateById
(
referralEntity
);
}
}
@Override
@Override
public
GenericsResult
<
List
<
CommonReferralBody
>>
createTextItem
(
CommonReferralBody
referralBody
)
{
public
GenericsResult
<
List
<
CommonReferralBody
>>
createTextItem
(
CommonReferralBody
referralBody
)
{
CustomerKeyword
entity
=
this
.
getById
(
referralBody
.
getMaterialGraphicsId
());
CustomerKeyword
entity
=
this
.
getById
(
referralBody
.
getMaterialGraphicsId
());
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论