Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
ee47fc32
提交
ee47fc32
authored
10月 17, 2022
作者:
沈振路
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
延时客服-图文-finish
上级
42445d1d
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
151 行增加
和
59 行删除
+151
-59
CustomerServiceCommonAsyncComponent.java
...tomer/components/CustomerServiceCommonAsyncComponent.java
+85
-45
CustomerDelaySaveDTO.java
.../yaoyaozw/customer/dto/customer/CustomerDelaySaveDTO.java
+3
-0
CustomerGraphicsDelay.java
...a/com/yaoyaozw/customer/entity/CustomerGraphicsDelay.java
+11
-0
CustomerGraphicsDelayMapper.java
...yaoyaozw/customer/mapper/CustomerGraphicsDelayMapper.java
+4
-3
CustomerGraphicsDelayServiceImpl.java
...stomer/service/impl/CustomerGraphicsDelayServiceImpl.java
+32
-10
CustomerDelayGraphicsDetailVO.java
...w/customer/vo/customer/CustomerDelayGraphicsDetailVO.java
+11
-0
CustomerMessageDetailVO.java
...aoyaozw/customer/vo/customer/CustomerMessageDetailVO.java
+1
-1
CustomerGraphicsDelayMapper.xml
src/main/resources/mapper/CustomerGraphicsDelayMapper.xml
+4
-0
没有找到文件。
src/main/java/com/yaoyaozw/customer/components/CustomerServiceCommonAsyncComponent.java
浏览文件 @
ee47fc32
...
...
@@ -69,11 +69,9 @@ public class CustomerServiceCommonAsyncComponent {
private
CustomerGraphicsMapper
customerGraphicsMapper
;
@Autowired
private
KanbanCommonMapper
kanbanCommonMapper
;
@Autowired
private
CustomerGraphicsDelayMapper
customerGraphicsDelayMapper
;
private
CustomerGraphicsDelayService
graphicsDelayService
;
public
void
setGraphicsDelayService
(
CustomerGraphicsDelayService
graphicsDelayService
)
{
this
.
graphicsDelayService
=
graphicsDelayService
;
}
@Async
(
"myExecutor"
)
public
void
addMatchUserIntoPackage
(
Long
packageId
,
Boolean
needRemove
)
{
...
...
@@ -173,10 +171,8 @@ public class CustomerServiceCommonAsyncComponent {
// 遍历客服素材进行处理
for
(
CustomerGraphicsDelay
sourceGraphics
:
sourceCustomerList
)
{
generateDelayExtend
Link
(
dateStr
,
sourceGraphics
,
targetAuthInfo
);
dispatchCustomerDelay
Link
(
dateStr
,
sourceGraphics
,
targetAuthInfo
);
}
}
...
...
@@ -343,81 +339,125 @@ public class CustomerServiceCommonAsyncComponent {
* 以下是延时客服 的方法
*/
private
void
generateDelayExtendLink
(
String
dateStr
,
CustomerGraphicsDelay
sourceGraphics
,
AuthorizerInfo
targetAuthInfo
)
{
List
<
ReferralEntity
>
targetReferralEntityList
=
new
ArrayList
<>();
private
void
dispatchCustomerDelayLink
(
String
dateStr
,
CustomerGraphicsDelay
sourceGraphics
,
AuthorizerInfo
targetAuthInfo
)
{
// 新建新主体
CustomerGraphicsDelay
targetCustomerGraphics
=
new
CustomerGraphicsDelay
();
List
<
ReferralEntity
>
targetReferralEntityList
=
new
ArrayList
<>();
BeanUtil
.
copyProperties
(
sourceGraphics
,
targetCustomerGraphics
);
long
mainId
=
snowflakeComponent
.
snowflakeId
();
targetCustomerGraphics
.
setId
(
mainId
);
// 遍历链接数据进行处理
targetCustomerGraphics
.
setAuthorizerInfo
(
targetAuthInfo
);
targetCustomerGraphics
.
setAppId
(
targetAuthInfo
.
getAppid
());
List
<
ReferralEntity
>
sourceReferralList
=
sourceGraphics
.
getBelongReferralList
();
for
(
ReferralEntity
sourceReferralEntity
:
sourceReferralList
)
{
Integer
postSort
=
sourceGraphics
.
getPostSort
();
// 遍历处理客服链接
for
(
ReferralEntity
sourceReferralEntity
:
sourceReferralList
)
{
// 生成新的链接数据
ReferralEntity
targetReferralEntity
=
new
ReferralEntity
();
BeanUtil
.
copyProperties
(
sourceReferralEntity
,
targetReferralEntity
);
// 重新生成链接主键id
targetReferralEntity
.
setId
(
snowflakeComponent
.
snowflakeId
());
targetReferralEntity
.
setMaterialGraphicsId
(
mainId
);
targetReferralEntity
.
setAccountId
(
targetAuthInfo
.
getAccountId
());
targetReferralEntity
.
setStoreTypeName
(
targetAuthInfo
.
getStoreTypeName
());
try
{
// 获取链接
AuthInfoVO
authInfoVo
=
new
AuthInfoVO
();
authInfoVo
.
putPropertyValue
(
targetAuthInfo
);
getCopyReferral
(
dateStr
,
authInfoVo
,
targetReferralEntity
);
targetCustomerGraphics
.
setSourceUrl
(
targetReferralEntity
.
getReferral
());
}
catch
(
Exception
e
)
{
LOCAL_LOG
.
warn
(
"公众号: {} 获取链接异常: {}"
,
targetAuthInfo
.
getNickName
(),
e
.
getMessage
());
String
name
=
CustomerCommonConstant
.
getLinkNameModel
(
targetReferralEntity
.
getNewsType
());
if
(
StringUtils
.
isNotBlank
(
name
))
{
name
=
name
+
"-"
+
postSort
;
if
(
ObjectUtil
.
isNotNull
(
targetReferralEntity
.
getSort
()))
{
name
=
name
+
"-"
+
targetReferralEntity
.
getSort
();
}
targetReferralEntity
.
setName
(
name
);
}
Integer
newsType
=
sourceReferralEntity
.
getNewsType
();
// 调用获取链接方法
if
(
newsType
.
equals
(
CustomerCommonConstant
.
BOOK_NEWS_TYPE
))
{
// 是推广链接
generateDelayExtendLink
(
dateStr
,
targetReferralEntity
,
targetAuthInfo
);
}
else
if
(
newsType
.
equals
(
CustomerCommonConstant
.
ACTIVITY_NEWS_TYPE
))
{
// 是活动链接
generateDelayActivityLink
(
dateStr
,
targetReferralEntity
,
targetAuthInfo
);
}
else
if
(
newsType
.
equals
(
CustomerCommonConstant
.
USUAL_LINK_NEWS_TYPE
))
{
// 常用链接
}
else
{
LOCAL_LOG
.
info
(
"newsType: {}, 不需要获取链接"
,
newsType
);
}
targetReferralEntityList
.
add
(
targetReferralEntity
);
// 图文主表只有一个素材链接,文本主表不需要存素材链接
targetCustomerGraphics
.
setSourceUrl
(
targetReferralEntity
.
getReferral
());
}
targetCustomerGraphics
.
setSendStatus
(
CustomerCommonConstant
.
SEND_STATUS_LINK_FINISH
);
LOCAL_LOG
.
info
(
"保存主体数据, 主体id: {}"
,
mainId
);
graphicsDelayService
.
save
(
targetCustomerGraphics
);
customerGraphicsDelayMapper
.
insert
(
targetCustomerGraphics
);
LOCAL_LOG
.
info
(
"准备保存, 共生成链接数据 : {} 条"
,
targetReferralEntityList
.
size
());
referralEntityService
.
saveBatch
(
targetReferralEntityList
);
}
private
void
generateDelayActivityLink
(
String
dateStr
,
CustomerGraphicsDelay
sourceGraphics
,
AuthorizerInfo
targetAuthInfo
)
{
List
<
ReferralEntity
>
targetReferralEntityList
=
new
ArrayList
<>();
// 新建新主体
CustomerGraphicsDelay
targetCustomerGraphics
=
new
CustomerGraphicsDelay
();
long
mainId
=
snowflakeComponent
.
snowflakeId
();
targetCustomerGraphics
.
setId
(
mainId
);
private
void
generateDelayExtendLink
(
String
dateStr
,
ReferralEntity
targetReferralEntity
,
AuthorizerInfo
targetAuthInfo
)
{
// 遍历链接数据进行处理
List
<
ReferralEntity
>
sourceReferralList
=
sourceGraphics
.
getBelongReferralList
();
for
(
ReferralEntity
sourceReferralEntity
:
sourceReferralList
)
{
try
{
// 获取链接
AuthInfoVO
authInfoVo
=
new
AuthInfoVO
();
authInfoVo
.
putPropertyValue
(
targetAuthInfo
);
getCopyReferral
(
dateStr
,
authInfoVo
,
targetReferralEntity
);
}
catch
(
Exception
e
)
{
LOCAL_LOG
.
warn
(
"公众号: {} 获取链接异常: {}"
,
targetAuthInfo
.
getNickName
(),
e
.
getMessage
());
}
}
ReferralEntity
targetReferralEntity
=
new
ReferralEntity
();
BeanUtil
.
copyProperties
(
sourceReferralEntity
,
targetReferralEntity
);
private
void
generateDelayActivityLink
(
String
dateStr
,
ReferralEntity
targetReferralEntity
,
AuthorizerInfo
targetAuthInfo
)
{
String
storeType
=
targetReferralEntity
.
getStoreType
();
boolean
isLegal
=
true
;
String
configId
=
null
;
String
activityContent
=
targetReferralEntity
.
getRechargeAmount
().
stripTrailingZeros
().
toPlainString
()
+
"送"
+
targetReferralEntity
.
getGiftAmount
();
// 阳光、掌中云 需要获取configId
if
(
storeType
.
equals
(
CustomerCommonConstant
.
STORE_NAME_YANG_GUANG
)
||
storeType
.
equals
(
CustomerCommonConstant
.
STORE_NAME_ZHANG_ZHONG_YUN
))
{
R
activityConfig
=
referralFeignClient
.
getActivityConfig
(
targetReferralEntity
.
getRechargeAmount
().
stripTrailingZeros
().
toPlainString
(),
storeType
,
null
);
// 获取资源配置列表
Map
<
String
,
Object
>
data
=
activityConfig
.
getData
();
JSONArray
configList
=
JSONUtil
.
parseArray
(
data
.
get
(
"configList"
));
List
<
CommonOptionResponseVO
>
activityConfigList
=
JSONUtil
.
toList
(
configList
,
CommonOptionResponseVO
.
class
);
if
(!
CollectionUtil
.
isEmpty
(
activityConfigList
))
{
// 转换config
Map
<
String
,
String
>
configMap
=
activityConfigList
.
stream
().
collect
(
Collectors
.
toMap
(
key
->
key
.
getLabel
().
replaceAll
(
"[^(0-9.送)]"
,
""
),
CommonOptionResponseVO:
:
getValue
,
(
o1
,
o2
)
->
o2
));
configId
=
configMap
.
get
(
activityContent
);
LOCAL_LOG
.
info
(
"活动内容: {} 获取到configId: {}"
,
activityContent
,
configId
);
if
(
ObjectUtil
.
isNull
(
configId
))
{
isLegal
=
false
;
}
}
else
{
isLegal
=
false
;
LOCAL_LOG
.
info
(
"无法获取资源配置"
);
}
}
targetReferralEntity
.
setConfigId
(
configId
);
String
tempId
=
CustomerStoreTemplateEnum
.
getTempId
(
storeType
);
targetReferralEntity
.
setTemplateId
(
tempId
);
if
(
isLegal
)
{
// 重新生成链接主键id
targetReferralEntity
.
setId
(
snowflakeComponent
.
snowflakeId
());
targetReferralEntity
.
setMaterialGraphicsId
(
mainId
);
targetReferralEntity
.
setAccountId
(
targetAuthInfo
.
getAccountId
());
targetReferralEntity
.
setStoreTypeName
(
targetAuthInfo
.
getStoreTypeName
());
try
{
// 获取链接
AuthInfoVO
authInfoVo
=
new
AuthInfoVO
();
authInfoVo
.
putPropertyValue
(
targetAuthInfo
);
getCopyReferral
(
dateStr
,
authInfoVo
,
targetReferralEntity
);
targetCustomerGraphics
.
setSourceUrl
(
targetReferralEntity
.
getReferral
());
}
catch
(
Exception
e
)
{
LOCAL_LOG
.
warn
(
"公众号: {} 获取链接异常: {}"
,
targetAuthInfo
.
getNickName
(),
e
.
getMessage
());
targetReferralEntity
.
setReferral
(
"error"
);
}
targetReferralEntityList
.
add
(
targetReferralEntity
);
}
targetCustomerGraphics
.
setSendStatus
(
CustomerCommonConstant
.
SEND_STATUS_LINK_FINISH
);
LOCAL_LOG
.
info
(
"保存主体数据, 主体id: {}"
,
mainId
);
graphicsDelayService
.
save
(
targetCustomerGraphics
);
LOCAL_LOG
.
info
(
"准备保存, 共生成链接数据 : {} 条"
,
targetReferralEntityList
.
size
());
referralEntityService
.
saveBatch
(
targetReferralEntityList
);
}
...
...
@@ -430,7 +470,7 @@ public class CustomerServiceCommonAsyncComponent {
/**
* 以下是公有方法
*/
p
rivate
void
getCopyReferral
(
String
dateStr
,
AuthInfoVO
authInfoVo
,
ReferralEntity
referralEntity
)
{
p
ublic
void
getCopyReferral
(
String
dateStr
,
AuthInfoVO
authInfoVo
,
ReferralEntity
referralEntity
)
{
referralEntity
.
setStoreType
(
authInfoVo
.
getStoreType
());
// 非常用链接类型的name需要处理
String
name
=
referralEntity
.
getName
();
...
...
src/main/java/com/yaoyaozw/customer/dto/customer/CustomerDelaySaveDTO.java
浏览文件 @
ee47fc32
...
...
@@ -41,6 +41,9 @@ public class CustomerDelaySaveDTO implements Serializable {
@ApiModelProperty
(
"发文间隔时间"
)
private
Long
timeInterval
;
@ApiModelProperty
(
"已支付、未支付"
)
private
Integer
isPay
;
@ApiModelProperty
(
"消息内容实体"
)
private
CustomerReferralDTO
customerReferralDto
;
...
...
src/main/java/com/yaoyaozw/customer/entity/CustomerGraphicsDelay.java
浏览文件 @
ee47fc32
...
...
@@ -44,6 +44,11 @@ public class CustomerGraphicsDelay implements Serializable {
@TableField
(
value
=
"extend_title"
)
private
String
extendTitle
;
/**
* 封面图片地址
*/
@TableField
(
value
=
"cover_url"
)
private
String
coverUrl
;
/**
* 文本内容
...
...
@@ -64,6 +69,12 @@ public class CustomerGraphicsDelay implements Serializable {
private
String
sourceUrl
;
/**
* 是否支付
*/
@TableField
(
value
=
"is_pay"
)
private
Integer
isPay
;
/**
* 是否是历史遗留
*/
@TableField
(
value
=
"is_history"
)
...
...
src/main/java/com/yaoyaozw/customer/mapper/CustomerGraphicsDelayMapper.java
浏览文件 @
ee47fc32
...
...
@@ -47,12 +47,13 @@ public interface CustomerGraphicsDelayMapper extends BaseMapper<CustomerGraphics
/**
* 让时间间隔列表
*
* @param keyword 关键词
* @param keyword
关键词
* @param keywordList 关键词拆分
* @param storeType 书城
* @param storeType 书城
* @param appId 需要排除的公众号appId
* @return {@link List}<{@link AuthInfoVO}>
*/
List
<
AuthInfoVO
>
getAuthList
(
@Param
(
"keyword"
)
String
keyword
,
@Param
(
"keywordList"
)
List
<
String
>
keywordList
,
@Param
(
"storeType"
)
String
storeType
);
List
<
AuthInfoVO
>
getAuthList
(
@Param
(
"keyword"
)
String
keyword
,
@Param
(
"keywordList"
)
List
<
String
>
keywordList
,
@Param
(
"storeType"
)
String
storeType
,
@Param
(
"appId"
)
String
appId
);
/**
* 让时间间隔列表
...
...
src/main/java/com/yaoyaozw/customer/service/impl/CustomerGraphicsDelayServiceImpl.java
浏览文件 @
ee47fc32
...
...
@@ -36,6 +36,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
...
...
@@ -78,7 +79,6 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
BaseResult
insertCustomerDelay
(
CustomerDelaySaveDTO
saveDto
)
{
CustomerGraphicsDelay
customerGraphicsDelay
=
new
CustomerGraphicsDelay
();
...
...
@@ -92,23 +92,45 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
}
customerGraphicsDelay
.
setSendStatus
(
CustomerCommonConstant
.
SEND_STATUS_LINK_GETTING
);
localLog
.
info
(
"生成referral数据"
);
ReferralEntity
referralEntity
=
new
ReferralEntity
();
BeanUtil
.
copyProperties
(
saveDto
.
getCustomerReferralDto
(),
referralEntity
);
referralEntity
.
setMaterialGraphicsId
(
customerGraphicsDelay
.
getId
());
// 非自定义获取链接
if
(!
referralEntity
.
getNewsType
().
equals
(-
1
))
{
try
{
localLog
.
info
(
"准备获取链接"
);
String
linkNameModel
=
CustomerCommonConstant
.
getLinkNameModel
(
referralEntity
.
getNewsType
());
localLog
.
info
(
"获取链接name模板: {}"
,
linkNameModel
);
referralEntity
.
setName
(
linkNameModel
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy/MM/dd"
);
String
dateStr
=
dateFormat
.
format
(
new
Date
());
AuthorizerInfo
authorizerInfo
=
authorizerInfoService
.
getOne
(
new
QueryWrapper
<
AuthorizerInfo
>().
eq
(
"appid"
,
saveDto
.
getAppId
()));
AuthInfoVO
authInfoVO
=
new
AuthInfoVO
();
authInfoVO
.
putPropertyValue
(
authorizerInfo
);
commonAsyncComponent
.
getCopyReferral
(
dateStr
,
authInfoVO
,
referralEntity
);
customerGraphicsDelay
.
setSendStatus
(
CustomerCommonConstant
.
SEND_STATUS_LINK_FINISH
);
localLog
.
info
(
"链接获取完成"
);
}
catch
(
Exception
e
)
{
localLog
.
info
(
"获取链接异常"
);
return
new
BaseResult
().
error
(
"获取链接异常"
);
}
}
customerGraphicsDelay
.
setSourceUrl
(
referralEntity
.
getReferral
());
boolean
mainResult
=
super
.
saveOrUpdate
(
customerGraphicsDelay
);
if
(!
mainResult
)
{
localLog
.
info
(
"主体数据生成异常"
);
return
new
BaseResult
().
error
(
"新增/更新 主体数据异常"
);
}
localLog
.
info
(
"生成referral数据"
);
ReferralEntity
referralEntity
=
new
ReferralEntity
();
referralEntity
.
setMaterialGraphicsId
(
customerGraphicsDelay
.
getId
());
BeanUtil
.
copyProperties
(
referralEntity
,
saveDto
.
getCustomerReferralDto
());
boolean
referralResult
=
referralEntityService
.
saveOrUpdate
(
referralEntity
);
if
(!
referralResult
)
{
localLog
.
info
(
"referral数据生成异常, 回滚事务"
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
new
BaseResult
().
error
(
"新增/更新 链接数据异常"
);
}
// TODO: 2022/10/14 生成链接
return
new
BaseResult
().
success
();
}
...
...
@@ -221,7 +243,7 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
keyword
=
null
;
}
List
<
AuthInfoVO
>
authList
=
super
.
baseMapper
.
getAuthList
(
keyword
,
keywordList
,
storeType
);
List
<
AuthInfoVO
>
authList
=
super
.
baseMapper
.
getAuthList
(
keyword
,
keywordList
,
storeType
,
appId
);
return
new
GenericsResult
<>(
authList
);
}
...
...
src/main/java/com/yaoyaozw/customer/vo/customer/CustomerDelayGraphicsDetailVO.java
浏览文件 @
ee47fc32
...
...
@@ -29,14 +29,25 @@ public class CustomerDelayGraphicsDetailVO implements Serializable {
private
String
type
;
@ApiModelProperty
(
"是否支付 0-否 1-是"
)
@JsonSerialize
(
using
=
ToStringSerializer
.
class
)
private
Integer
isPay
;
@ApiModelProperty
(
"素材图片路径"
)
private
String
coverUrl
;
@ApiModelProperty
(
"推广标题"
)
private
String
extendTitle
;
@ApiModelProperty
(
"素材文本内容"
)
private
String
content
;
@ApiModelProperty
(
"素材文本内容"
)
private
Integer
postSort
;
@ApiModelProperty
(
"时间间隔"
)
@JsonSerialize
(
using
=
ToStringSerializer
.
class
)
private
Long
timeInterval
;
@ApiModelProperty
(
"链接相关内容"
)
private
CustomerReferralDTO
customerReferralDto
;
...
...
src/main/java/com/yaoyaozw/customer/vo/customer/CustomerMessageDetailVO.java
浏览文件 @
ee47fc32
...
...
@@ -31,7 +31,7 @@ public class CustomerMessageDetailVO implements Serializable {
@ApiModelProperty
(
"客服消息类型(图文、文本)"
)
private
String
type
;
@ApiModelProperty
(
"
素材文本内容
"
)
@ApiModelProperty
(
"
推广标题
"
)
private
String
extendTitle
;
@ApiModelProperty
(
"素材图片路径"
)
...
...
src/main/resources/mapper/CustomerGraphicsDelayMapper.xml
浏览文件 @
ee47fc32
...
...
@@ -110,6 +110,9 @@
<if
test=
"storeType != null and storeType != ''"
>
and store_type = #{storeType}
</if>
<if
test=
"appId != null and appId != ''"
>
and appId != #{appId}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论