Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
c39cabf2
提交
c39cabf2
authored
3月 16, 2023
作者:
沈振路
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
关回finish
上级
ea246c31
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
126 行增加
和
27 行删除
+126
-27
FollowReplyComponent.java
...om/yaoyaozw/customer/components/FollowReplyComponent.java
+16
-6
CommonReferralBody.java
...java/com/yaoyaozw/customer/entity/CommonReferralBody.java
+3
-0
ReferralEntity.java
...ain/java/com/yaoyaozw/customer/entity/ReferralEntity.java
+3
-0
AuthorizerInfoMapper.java
...va/com/yaoyaozw/customer/mapper/AuthorizerInfoMapper.java
+11
-0
AuthorizerInfoService.java
.../com/yaoyaozw/customer/service/AuthorizerInfoService.java
+8
-0
AuthorizerInfoServiceImpl.java
...aozw/customer/service/impl/AuthorizerInfoServiceImpl.java
+16
-0
CustomerFollowReplyServiceImpl.java
...customer/service/impl/CustomerFollowReplyServiceImpl.java
+37
-20
FollowReplyInfoVO.java
...va/com/yaoyaozw/customer/vo/follow/FollowReplyInfoVO.java
+13
-1
AuthorizerInfoMapper.xml
src/main/resources/mapper/AuthorizerInfoMapper.xml
+19
-0
没有找到文件。
src/main/java/com/yaoyaozw/customer/components/FollowReplyComponent.java
浏览文件 @
c39cabf2
...
...
@@ -110,6 +110,8 @@ public class FollowReplyComponent {
handleReferralName
(
dateStr
,
authInfoVo
.
getAccountName
(),
targetReferral
);
}
doGetReferral
(
targetReferral
);
}
else
if
(
newsType
.
equals
(-
1
))
{
targetReferral
.
setReferral
(
sourceReferral
.
getReferral
());
}
return
targetReferral
;
...
...
@@ -133,7 +135,9 @@ public class FollowReplyComponent {
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy/MM/dd"
);
String
dateStr
=
format
.
format
(
new
Date
());
int
idx
=
1
;
for
(
CustomerFollowReply
sourceMaterial
:
sourceMaterialList
)
{
localLog
.
info
(
"素材处理进度: {}/{}"
,
idx
++,
sourceMaterialList
.
size
());
CustomerFollowReply
entity
=
new
CustomerFollowReply
();
int
status
=
1
;
...
...
@@ -186,7 +190,7 @@ public class FollowReplyComponent {
// 文本, 构造H5
StringBuilder
builder
=
new
StringBuilder
();
for
(
ReferralEntity
referralEntity
:
singleMaterialReferralList
)
{
builder
.
append
(
structH5Line
(
referralEntity
)).
append
(
"\n\n"
);
builder
.
append
(
structH5Line
(
false
,
referralEntity
)).
append
(
"\n\n"
);
}
entity
.
setContent
(
builder
.
toString
().
trim
());
...
...
@@ -219,7 +223,7 @@ public class FollowReplyComponent {
StringBuilder
builder
=
new
StringBuilder
();
for
(
ReferralEntity
referral
:
referralList
)
{
referral
.
setSort
(
idx
);
builder
.
append
(
structH5Line
(
referral
));
builder
.
append
(
structH5Line
(
false
,
referral
));
if
(
idx
<
referralList
.
size
())
{
builder
.
append
(
"\n\n"
);
...
...
@@ -232,24 +236,30 @@ public class FollowReplyComponent {
return
builder
.
toString
();
}
public
void
contractH5ContentBatch
(
List
<
ReferralEntity
>
referralEntityList
)
{
referralEntityList
.
forEach
(
item
->
item
.
setH5Content
(
structH5Line
(
true
,
item
)));
}
/**
* 构造 h5
*
* @param referralEntity 链接实体
* @return {@link String}
*/
private
String
structH5Line
(
ReferralEntity
referralEntity
)
{
private
String
structH5Line
(
Boolean
needStyle
,
ReferralEntity
referralEntity
)
{
Integer
newsType
=
referralEntity
.
getNewsType
();
// 文本类型替换h5链接
String
context
=
null
;
localLog
.
info
(
"referral参数 --> {}"
,
referralEntity
);
if
(
CustomerCommonConstant
.
REPLACE_LINK_NEWS_TYPE_LIST
.
contains
(
newsType
))
{
context
=
CustomerCommonConstant
.
CUSTOMER_TEXT_LINK_TEMPLATE
.
replace
(
CustomerCommonConstant
.
CUSTOMER_TEXT_CONTENT_PLACEHOLDER
,
referralEntity
.
getTextContent
());
context
=
context
.
replace
(
CustomerCommonConstant
.
CUSTOMER_TEXT_URL_PLACEHOLDER
,
referralEntity
.
getReferral
());
if
(!
needStyle
)
{
context
=
context
.
replace
(
CustomerCommonConstant
.
H5_STYLE_CODE
,
""
);
}
}
else
if
(
CustomerCommonConstant
.
COMMON_NEWS_TYPE_LIST
.
contains
(
newsType
)){
context
=
referralEntity
.
getTextContent
();
}
if
(
ObjectUtil
.
isNotNull
(
context
))
{
context
=
context
.
replace
(
CustomerCommonConstant
.
CUSTOMER_TEXT_URL_PLACEHOLDER
,
referralEntity
.
getReferral
());
}
return
context
;
}
...
...
src/main/java/com/yaoyaozw/customer/entity/CommonReferralBody.java
浏览文件 @
c39cabf2
...
...
@@ -39,6 +39,7 @@ public class CommonReferralBody implements Serializable {
private
Long
infoId
;
@ApiModelProperty
(
"链接类型"
)
@JsonSerialize
(
using
=
ToStringSerializer
.
class
)
private
Integer
newsType
;
@ApiModelProperty
(
"链接名"
)
...
...
@@ -97,6 +98,8 @@ public class CommonReferralBody implements Serializable {
@ApiModelProperty
(
value
=
"模板Id"
)
private
String
templateId
;
private
String
h5Content
;
public
Date
getStartTime
()
{
if
(
ObjectUtil
.
isNull
(
this
.
startTime
)
&&
CollectionUtil
.
isNotEmpty
(
this
.
dateList
))
{
return
dateList
.
get
(
0
);
...
...
src/main/java/com/yaoyaozw/customer/entity/ReferralEntity.java
浏览文件 @
c39cabf2
...
...
@@ -209,6 +209,9 @@ public class ReferralEntity implements Serializable {
private
Long
infoId
;
@TableField
(
exist
=
false
)
private
String
h5Content
;
@TableField
(
exist
=
false
)
private
String
accountName
;
public
static
final
String
COL_ID
=
"id"
;
...
...
src/main/java/com/yaoyaozw/customer/mapper/AuthorizerInfoMapper.java
浏览文件 @
c39cabf2
...
...
@@ -3,7 +3,9 @@ package com.yaoyaozw.customer.mapper;
import
com.baomidou.dynamic.datasource.annotation.DS
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yaoyaozw.customer.entity.AuthorizerInfo
;
import
com.yaoyaozw.customer.vo.AuthInfoVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
/**
...
...
@@ -14,4 +16,12 @@ import org.apache.ibatis.annotations.Mapper;
@DS
(
"material"
)
public
interface
AuthorizerInfoMapper
extends
BaseMapper
<
AuthorizerInfo
>
{
/**
* 根据appid获取公众号信息
*
* @param appid appid
* @return {@link AuthInfoVO}
*/
AuthInfoVO
getAuthInfoByAppid
(
@Param
(
"appid"
)
String
appid
);
}
\ No newline at end of file
src/main/java/com/yaoyaozw/customer/service/AuthorizerInfoService.java
浏览文件 @
c39cabf2
...
...
@@ -2,6 +2,7 @@ package com.yaoyaozw.customer.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.yaoyaozw.customer.entity.AuthorizerInfo
;
import
com.yaoyaozw.customer.vo.AuthInfoVO
;
/**
...
...
@@ -12,5 +13,12 @@ import com.yaoyaozw.customer.entity.AuthorizerInfo;
*/
public
interface
AuthorizerInfoService
extends
IService
<
AuthorizerInfo
>
{
/**
* 根据appid获取公众号信息
*
* @param appid appid
* @return {@link AuthInfoVO}
*/
AuthInfoVO
getAuthInfoByAppid
(
String
appid
);
}
src/main/java/com/yaoyaozw/customer/service/impl/AuthorizerInfoServiceImpl.java
浏览文件 @
c39cabf2
...
...
@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
com.yaoyaozw.customer.entity.AuthorizerInfo
;
import
com.yaoyaozw.customer.mapper.AuthorizerInfoMapper
;
import
com.yaoyaozw.customer.service.AuthorizerInfoService
;
import
com.yaoyaozw.customer.vo.AuthInfoVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
...
...
@@ -16,4 +19,17 @@ import org.springframework.stereotype.Service;
@Service
public
class
AuthorizerInfoServiceImpl
extends
ServiceImpl
<
AuthorizerInfoMapper
,
AuthorizerInfo
>
implements
AuthorizerInfoService
{
@Autowired
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
@Override
public
AuthInfoVO
getAuthInfoByAppid
(
String
appid
)
{
AuthInfoVO
authInfo
=
this
.
baseMapper
.
getAuthInfoByAppid
(
appid
);
Object
storeTypeName
=
redisTemplate
.
opsForHash
().
get
(
"STORE_NAME_MAP"
,
authInfo
.
getStoreType
());
if
(
storeTypeName
!=
null
)
{
authInfo
.
setStoreTypeName
(
String
.
valueOf
(
storeTypeName
));
}
return
authInfo
;
}
}
src/main/java/com/yaoyaozw/customer/service/impl/CustomerFollowReplyServiceImpl.java
浏览文件 @
c39cabf2
...
...
@@ -19,6 +19,7 @@ import com.yaoyaozw.customer.entity.CommonReferralBody;
import
com.yaoyaozw.customer.entity.CustomerFollowReply
;
import
com.yaoyaozw.customer.entity.ReferralEntity
;
import
com.yaoyaozw.customer.mapper.CustomerFollowReplyMapper
;
import
com.yaoyaozw.customer.service.AuthorizerInfoService
;
import
com.yaoyaozw.customer.service.CustomerFollowReplyService
;
import
com.yaoyaozw.customer.service.ReferralEntityService
;
import
com.yaoyaozw.customer.utils.TencentCustomerUtil
;
...
...
@@ -34,6 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
...
...
@@ -55,6 +57,8 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
private
FollowReplyComponent
followReplyComponent
;
@Autowired
private
ReferralEntityService
referralEntityService
;
@Autowired
private
AuthorizerInfoService
authorizerInfoService
;
@Override
...
...
@@ -84,7 +88,7 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
if
(
isCreate
)
{
// 新增的id
entity
.
setId
(
snowflakeComponent
.
snowflakeId
());
}
else
if
(
FollowReplyCommonConstant
.
needReferral
(
sourceEntity
.
getType
()))
{
}
else
if
(
!
entity
.
getType
().
equals
(
sourceEntity
.
getType
())
&&
FollowReplyCommonConstant
.
needReferral
(
sourceEntity
.
getType
()))
{
// 如果编辑更换过类型,清除掉referral数据
referralEntityService
.
remove
(
new
QueryWrapper
<
ReferralEntity
>().
eq
(
ReferralEntity
.
COL_MATERIAL_GRAPHICS_ID
,
sourceEntity
.
getId
()));
}
...
...
@@ -109,7 +113,7 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
}
entity
.
setTxMediaUrl
(
uploadResponse
.
getUrl
());
entity
.
setTxMediaId
(
uploadResponse
.
getMedia_id
());
}
else
{
}
else
if
(!
FollowReplyCommonConstant
.
TENCENT_MEDIA_TYPE_TEXT
.
equals
(
entity
.
getType
()))
{
// 获取书城公众号链接(图文)
ReferralEntity
referralEntity
;
try
{
...
...
@@ -161,10 +165,7 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
// 保存主体
this
.
updateById
(
entity
);
JSONArray
referralJsonArray
=
JSONUtil
.
parseArray
(
referralList
);
List
<
CommonReferralBody
>
referralBodyList
=
JSONUtil
.
toList
(
referralJsonArray
,
CommonReferralBody
.
class
);
return
new
GenericsResult
<>(
referralBodyList
);
return
new
GenericsResult
<>(
getReferralBodyFromEntity
(
referralList
));
}
@Override
...
...
@@ -205,11 +206,7 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
entity
.
setContent
(
content
);
// 保存实体
this
.
updateById
(
entity
);
JSONArray
referralJsonArray
=
JSONUtil
.
parseArray
(
referralList
);
List
<
CommonReferralBody
>
referralBodyList
=
JSONUtil
.
toList
(
referralJsonArray
,
CommonReferralBody
.
class
);
return
new
GenericsResult
<>(
referralBodyList
);
return
new
GenericsResult
<>(
getReferralBodyFromEntity
(
referralList
));
}
@Override
...
...
@@ -217,7 +214,8 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
AuthInfoVO
sourceAuth
=
copyDto
.
getSourceAuth
();
List
<
AuthInfoVO
>
targetAuthList
=
copyDto
.
getTargetAuthList
();
localLog
.
info
(
"调用复用, 源公众号: {}, 目标公众号: {}条"
,
sourceAuth
.
getAccountName
(),
targetAuthList
.
size
());
long
copyFlag
=
System
.
currentTimeMillis
();
localLog
.
info
(
"关回复用, 复用批次号: {}, 源公众号: {}, 目标公众号: {}条"
,
copyFlag
,
sourceAuth
.
getAccountName
(),
targetAuthList
.
size
());
List
<
CustomerFollowReply
>
sourceMaterialList
=
getSourceMaterialList
(
sourceAuth
.
getAppId
());
if
(
CollectionUtil
.
isEmpty
(
sourceMaterialList
))
{
return
new
BaseResult
().
error
(
"源公众号找不到素材"
);
...
...
@@ -226,7 +224,9 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
removeOriginMaterialList
(
targetAuthList
);
List
<
String
>
errorAuthList
=
null
;
int
idx
=
1
;
for
(
AuthInfoVO
targetAuth
:
targetAuthList
)
{
localLog
.
info
(
"批次号: {}, 公众号处理进度: {}/{}"
,
copyFlag
,
idx
++,
targetAuthList
.
size
());
// 调用复用
FollowReplyCopyResultVO
result
=
followReplyComponent
.
copyMaterialToTarget
(
targetAuth
,
sourceMaterialList
);
if
(
result
.
getHasError
())
{
...
...
@@ -234,13 +234,21 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
errorAuthList
=
new
ArrayList
<>();
}
errorAuthList
.
add
(
targetAuth
.
getAccountName
());
}
else
{
if
(
CollectionUtil
.
isNotEmpty
(
result
.
getMaterialList
()))
{
this
.
saveBatch
(
result
.
getMaterialList
());
}
if
(
CollectionUtil
.
isNotEmpty
(
result
.
getReferralEntityList
()))
{
referralEntityService
.
saveBatch
(
result
.
getReferralEntityList
());
}
}
}
if
(
CollectionUtil
.
isNotEmpty
(
errorAuthList
))
{
return
new
BaseResult
().
error
(
"部分成功; 复用异常公众号: "
+
errorAuthList
);
}
return
new
BaseResult
().
success
();
return
new
BaseResult
().
success
(
"复用完成"
);
}
@Override
...
...
@@ -256,9 +264,7 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
if
(
FollowReplyCommonConstant
.
TENCENT_MEDIA_TYPE_TEXT
.
equals
(
entity
.
getType
()))
{
// 文本类型
List
<
ReferralEntity
>
referralList
=
referralEntityService
.
list
(
new
QueryWrapper
<
ReferralEntity
>().
eq
(
ReferralEntity
.
COL_MATERIAL_GRAPHICS_ID
,
id
).
orderByAsc
(
"sort"
));
JSONArray
referralJsonArray
=
JSONUtil
.
parseArray
(
referralList
);
List
<
CommonReferralBody
>
referralBodyList
=
JSONUtil
.
toList
(
referralJsonArray
,
CommonReferralBody
.
class
);
infoVo
.
setTextBodyList
(
referralBodyList
);
infoVo
.
setTextBodyList
(
getReferralBodyFromEntity
(
referralList
));
}
else
if
(
FollowReplyCommonConstant
.
TENCENT_MEDIA_TYPE_NEWS
.
equals
(
entity
.
getType
()))
{
try
{
// 设置图文类型的链接数据
...
...
@@ -272,12 +278,21 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
return
new
GenericsResult
<>(
false
,
"获取图文链接实体异常"
);
}
}
}
// 根据appid获取公众号信息
AuthInfoVO
authInfo
=
authorizerInfoService
.
getAuthInfoByAppid
(
infoVo
.
getAppid
());
if
(
ObjectUtil
.
isNull
(
authInfo
))
{
return
new
GenericsResult
<>(
false
,
"无法获取公众号信息"
);
}
infoVo
.
setAuthInfo
(
authInfo
);
return
new
GenericsResult
<>(
infoVo
);
}
private
List
<
CommonReferralBody
>
getReferralBodyFromEntity
(
List
<
ReferralEntity
>
referralList
)
{
followReplyComponent
.
contractH5ContentBatch
(
referralList
);
JSONArray
referralJsonArray
=
JSONUtil
.
parseArray
(
referralList
);
return
JSONUtil
.
toList
(
referralJsonArray
,
CommonReferralBody
.
class
);
}
private
List
<
CustomerFollowReply
>
getSourceMaterialList
(
String
appid
)
{
List
<
CustomerFollowReply
>
sourceMaterialList
=
this
.
list
(
new
QueryWrapper
<
CustomerFollowReply
>().
eq
(
"appid"
,
appid
));
...
...
@@ -288,14 +303,16 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
localLog
.
info
(
"获取到源公众号素材: {}条"
,
sourceMaterialList
.
size
());
// 获取链接
List
<
Long
>
materialIdList
=
sourceMaterialList
.
stream
().
map
(
CustomerFollowReply:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
ReferralEntity
>
referralEntityList
=
referralEntityService
.
list
(
new
QueryWrapper
<
ReferralEntity
>().
eq
(
ReferralEntity
.
COL_MATERIAL_GRAPHICS_ID
,
materialIdList
));
List
<
ReferralEntity
>
referralEntityList
=
referralEntityService
.
list
(
new
QueryWrapper
<
ReferralEntity
>().
in
(
ReferralEntity
.
COL_MATERIAL_GRAPHICS_ID
,
materialIdList
));
localLog
.
info
(
"获取到源公众号链接数据: {}条"
,
referralEntityList
.
size
());
Map
<
Long
,
List
<
ReferralEntity
>>
referralMap
=
referralEntityList
.
stream
().
collect
(
Collectors
.
groupingBy
(
ReferralEntity:
:
getMaterialGraphicsId
));
// 分配referral
for
(
CustomerFollowReply
sourceEntity
:
sourceMaterialList
)
{
sourceEntity
.
setReferralEntityList
(
referralMap
.
get
(
sourceEntity
.
getId
()));
List
<
ReferralEntity
>
referralEntities
=
referralMap
.
get
(
sourceEntity
.
getId
());
referralEntities
=
referralEntities
.
stream
().
sorted
(
Comparator
.
comparingInt
(
ReferralEntity:
:
getSort
)).
collect
(
Collectors
.
toList
());
sourceEntity
.
setReferralEntityList
(
referralEntities
);
}
return
sourceMaterialList
;
...
...
src/main/java/com/yaoyaozw/customer/vo/follow/FollowReplyInfoVO.java
浏览文件 @
c39cabf2
package
com
.
yaoyaozw
.
customer
.
vo
.
follow
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
com.fasterxml.jackson.databind.ser.std.ToStringSerializer
;
import
com.yaoyaozw.customer.entity.CommonReferralBody
;
import
com.yaoyaozw.customer.vo.AuthInfoVO
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
@@ -22,7 +25,7 @@ public class FollowReplyInfoVO implements Serializable {
private
String
name
;
private
Integer
type
;
private
String
type
;
private
String
originMediaUrl
;
...
...
@@ -32,8 +35,17 @@ public class FollowReplyInfoVO implements Serializable {
private
Integer
sort
;
private
AuthInfoVO
authInfo
;
private
CommonReferralBody
referralBody
;
private
List
<
CommonReferralBody
>
textBodyList
;
public
CommonReferralBody
getReferralBody
()
{
return
ObjectUtil
.
isNull
(
referralBody
)
?
new
CommonReferralBody
()
:
referralBody
;
}
public
List
<
CommonReferralBody
>
getTextBodyList
()
{
return
textBodyList
==
null
?
new
ArrayList
<>(
4
)
:
textBodyList
;
}
}
src/main/resources/mapper/AuthorizerInfoMapper.xml
0 → 100644
浏览文件 @
c39cabf2
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.yaoyaozw.customer.mapper.AuthorizerInfoMapper"
>
<select
id=
"getAuthInfoByAppid"
resultType=
"com.yaoyaozw.customer.vo.AuthInfoVO"
>
select
id,
appid as appId,
account_id as accountId,
nick_name as accountName,
store_type as storeType
from authorizer_info
where appid = #{appid}
</select>
</mapper>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论