Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
01d603b2
提交
01d603b2
authored
11月 14, 2022
作者:
gh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
定时客服消息使用MQ
上级
e46b30b8
全部展开
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
121 行增加
和
79 行删除
+121
-79
CustomerCommonConstant.java
...m/yaoyaozw/customer/constants/CustomerCommonConstant.java
+2
-0
RabbitCommonNameConstant.java
...yaoyaozw/customer/constants/RabbitCommonNameConstant.java
+15
-1
CustomerMessageTransferDTO.java
...ozw/customer/dto/customer/CustomerMessageTransferDTO.java
+35
-0
CustomerDelayPublishServiceImpl.java
...ustomer/service/impl/CustomerDelayPublishServiceImpl.java
+14
-11
CustomerGraphicsServiceImpl.java
...zw/customer/service/impl/CustomerGraphicsServiceImpl.java
+17
-14
WeChatService.java
...oyaozw/customer/service/wechat/service/WeChatService.java
+2
-2
WeChatServiceImpl.java
...zw/customer/service/wechat/service/WeChatServiceImpl.java
+36
-51
没有找到文件。
src/main/java/com/yaoyaozw/customer/constants/CustomerCommonConstant.java
浏览文件 @
01d603b2
...
...
@@ -63,6 +63,8 @@ public class CustomerCommonConstant {
public
final
static
Integer
SEND_STATUS_ACTIVE
=
9
;
public
final
static
Integer
SEND_STATUS_FINISHED
=
10
;
public
final
static
Integer
SEND_STATUS_LINK_ERROR
=
3
;
public
final
static
Integer
SEND_STATUS_SENT_FAIL
=
4
;
...
...
src/main/java/com/yaoyaozw/customer/constants/RabbitCommonNameConstant.java
浏览文件 @
01d603b2
...
...
@@ -17,13 +17,22 @@ public class RabbitCommonNameConstant {
public
static
final
String
YG_LIMIT_TTL_QUEUE
=
"YG_LIMIT_TTL_QUEUE"
;
public
static
final
String
YG_LIMIT_TTL_ROUTE_KEY
=
"YG_LIMIT"
;
/**
* 2、运营系统交换机
*/
public
static
final
String
CUSTOMER_SERVICE_EXCHANGE
=
"CUSTOMER_SERVICE_EXCHANGE"
;
/**
* 客服消息处理队列
*/
public
static
final
String
CUSTOMER_MESSAGE_ROUTE_KEY
=
"CUSTOMER_MESSAGE_HANDLE"
;
public
static
final
String
CUSTOMER_MESSAGE_QUEUE
=
"CUSTOMER_MESSAGE_HANDLE_QUEUE"
;
/**
*
2
、死信交换机 - 死信队列 - routeKey
*
3
、死信交换机 - 死信队列 - routeKey
*/
public
static
final
String
DEATH_EXCHANGE
=
"DEATH_EXCHANGE"
;
...
...
@@ -33,6 +42,11 @@ public class RabbitCommonNameConstant {
public
static
final
String
YG_LIMIT_DEATH_QUEUE
=
"YG_LIMIT_DEATH_QUEUE"
;
public
static
final
String
YG_LIMIT_DEATH_ROUTE_KEY
=
"YG_LIMIT_DEATH"
;
/**
* 客服消息死信队列
*/
public
static
final
String
CUSTOMER_MESSAGE_DEATH_QUEUE
=
"CUSTOMER_MESSAGE_DEATH_QUEUE"
;
public
static
final
String
CUSTOMER_MESSAGE_DEATH_ROUTE_KEY
=
"CUSTOMER_MESSAGE_DEATH"
;
}
src/main/java/com/yaoyaozw/customer/dto/customer/CustomerMessageTransferDTO.java
0 → 100644
浏览文件 @
01d603b2
package
com
.
yaoyaozw
.
customer
.
dto
.
customer
;
import
com.yaoyaozw.customer.service.wechat.entity.customerRequest.WeChatCustomerRequestEntity
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author wgh
* @date 2022/11/10 14:52
*/
@Data
public
class
CustomerMessageTransferDTO
implements
Serializable
{
/**
* 客服发送请求体
*/
private
WeChatCustomerRequestEntity
customerRequestEntity
;
/**
* 素材id
*/
private
Long
customerGraphicsId
;
/**
* appid
*/
private
String
appid
;
/**
* openid
*/
private
String
openid
;
}
src/main/java/com/yaoyaozw/customer/service/impl/CustomerDelayPublishServiceImpl.java
浏览文件 @
01d603b2
package
com
.
yaoyaozw
.
customer
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO
;
import
com.yaoyaozw.customer.entity.AuthorizerToken
;
import
com.yaoyaozw.customer.service.AuthorizerTokenService
;
import
com.yaoyaozw.customer.service.CustomerGraphicsDelayService
;
import
com.yaoyaozw.customer.service.wechat.service.WeChatService
;
import
com.yaoyaozw.customer.utils.YYZWDateUtil
;
import
com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.*
;
...
...
@@ -31,13 +29,15 @@ import com.yaoyaozw.customer.service.CustomerDelayPublishService;
@Service
public
class
CustomerDelayPublishServiceImpl
extends
ServiceImpl
<
CustomerDelayPublishMapper
,
CustomerDelayPublish
>
implements
CustomerDelayPublishService
{
private
final
static
String
ACCESS_TOKEN_REDIS_KEY
=
"AUTH_ACCESS_TOKEN"
;
private
final
static
Logger
localLog
=
LoggerFactory
.
getLogger
(
CustomerDelayPublishServiceImpl
.
class
);
@Autowired
private
CustomerGraphicsDelayService
customerGraphicsDelayServic
e
;
private
RedisTemplate
<
String
,
Object
>
redisTemplat
e
;
@Autowired
private
AuthorizerTokenService
authorizerToken
Service
;
private
CustomerGraphicsDelayService
customerGraphicsDelay
Service
;
@Autowired
private
WeChatService
weChatService
;
...
...
@@ -71,11 +71,9 @@ public class CustomerDelayPublishServiceImpl extends ServiceImpl<CustomerDelayPu
String
appid
=
userEntry
.
getKey
();
//获取该号token
AuthorizerToken
authorizerToken
=
authorizerTokenService
.
findTokenByAppid
(
appid
);
String
token
=
authorizerToken
.
getAuthorizerAppid
();
Object
tokenObject
=
redisTemplate
.
opsForHash
().
get
(
ACCESS_TOKEN_REDIS_KEY
,
appid
);
//没token过滤
if
(
token
==
null
||
""
.
equals
(
token
)){
continue
;
}
if
(
tokenObject
==
null
||
StringUtils
.
isBlank
(
tokenObject
.
toString
()
)){
continue
;
}
//该号下延时客服
Map
<
Integer
,
List
<
CustomerDelayItemVO
>>
delaySortMap
=
customerMap
.
get
(
appid
);
//所有的用户
...
...
@@ -87,14 +85,19 @@ public class CustomerDelayPublishServiceImpl extends ServiceImpl<CustomerDelayPu
//将所有待用延时客服收集
for
(
CustomerDelayPublish
userPublish
:
userList
)
{
//发送延时客服
futureList
.
add
(
weChatService
.
sendCustomerDelayMessage
(
authorizerToken
,
userPublish
,
delaySortMap
,
needUpdateCustomerDelay
))
;
futureList
.
add
(
weChatService
.
sendCustomerDelayMessage
(
appid
,
tokenObject
.
toString
()
,
userPublish
,
delaySortMap
,
needUpdateCustomerDelay
))
;
}
}
}
List
<
CustomerDelayPublish
>
registerUserEntities
=
new
ArrayList
<>();
//更新下次延时排期
for
(
Future
<
CustomerDelayPublish
>
delayPublishFuture
:
futureList
)
{
try
{
registerUserEntities
.
add
(
delayPublishFuture
.
get
())
;
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
e
.
printStackTrace
();
}
}
if
(!
registerUserEntities
.
isEmpty
()){
...
...
src/main/java/com/yaoyaozw/customer/service/impl/CustomerGraphicsServiceImpl.java
浏览文件 @
01d603b2
...
...
@@ -30,6 +30,7 @@ import com.yaoyaozw.customer.vo.referral.ReferralEntityVo;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
...
...
@@ -57,6 +58,7 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
private
final
static
Logger
LOCAL_LOG
=
LoggerFactory
.
getLogger
(
CustomerGraphicsServiceImpl
.
class
);
@Autowired
private
CrowdPackageConditionMatchService
matchService
;
@Autowired
...
...
@@ -69,8 +71,6 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
private
WeChatService
weChatService
;
@Autowired
private
RegisterUserEntityService
registerUserEntityService
;
@Autowired
private
AuthorizerTokenService
authorizerTokenService
;
@Autowired
private
CrowdPackageConditionService
conditionService
;
...
...
@@ -82,6 +82,7 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
@Autowired
private
CrowdPackageService
crowdPackageService
;
@Override
public
BaseResult
insertCustomerMessage
(
CustomerMessageSaveDTO
saveDto
)
{
...
...
@@ -213,28 +214,32 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
return
new
BaseResult
().
error
(
"更新失败"
);
}
/**
* 发送客服消息
* @param integrationRequestDTO 请求DTO
*/
@Override
public
void
sendCustomerMessage
(
IntegrationRequestDTO
integrationRequestDTO
)
{
Date
requestDate
=
integrationRequestDTO
.
getRequestDate
();
long
currentTimestamp
=
requestDate
.
getTime
();
//获取待发送的开启客服
List
<
CustomerGraphics
>
customerGraphicsList
=
list
(
new
QueryWrapper
<
CustomerGraphics
>().
eq
(
CustomerGraphics
.
COL_POST_TIME
,
requestDate
).
eq
(
CustomerGraphics
.
COL_SEND_STATUS
,
CustomerCommonConstant
.
SEND_STATUS_ACTIVE
));
List
<
CustomerGraphics
>
customerGraphicsList
=
list
(
new
QueryWrapper
<
CustomerGraphics
>().
eq
(
CustomerGraphics
.
COL_POST_TIME
,
requestDate
).
eq
(
CustomerGraphics
.
COL_SEND_STATUS
,
9
));
if
(!
customerGraphicsList
.
isEmpty
()){
List
<
CrowdPackage
>
crowdPackageList
=
crowdPackageService
.
list
();
Map
<
Long
,
CrowdPackage
>
crowdPackageMap
=
crowdPackageList
.
stream
().
collect
(
Collectors
.
toMap
(
CrowdPackage:
:
getId
,
a
->
a
));
if
(!
customerGraphicsList
.
isEmpty
()){
LOCAL_LOG
.
info
(
"start sendCustomerMessage"
);
for
(
CustomerGraphics
customerGraphics
:
customerGraphicsList
)
{
//人群包id
Long
packId
=
customerGraphics
.
getPackId
();
CrowdPackage
crowdPackage
=
crowdPackageMap
.
get
(
packId
);
//活跃时间限制窗口
Long
activeTimeMax
=
crowdPackage
.
getActiveTimeMax
();
Long
activeTimeMin
=
crowdPackage
.
getActiveTimeMin
();
...
...
@@ -243,8 +248,9 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
//1.活跃时间判断,2.用户去重
Map
<
String
,
List
<
CrowdPackageUserVO
>>
appidUserMap
=
userList
.
stream
()
.
filter
(
a
->
a
.
getLastActive
()!=
null
&&(
activeTimeMin
==
null
||(
currentTimestamp
-
a
.
getLastActive
().
getTime
())>=
activeTimeMin
)&&(
activeTimeMax
==
null
||(
currentTimestamp
-
a
.
getLastActive
().
getTime
(
)<
activeTimeMax
)))
.
filter
(
a
->
a
.
getLastActive
()!=
null
&&(
activeTimeMin
==
null
||(
(
currentTimestamp
-
a
.
getLastActive
().
getTime
())>=
activeTimeMin
))&&(
activeTimeMax
==
null
||((
currentTimestamp
-
a
.
getLastActive
().
getTime
()
)<
activeTimeMax
)))
.
collect
(
Collectors
.
groupingBy
(
CrowdPackageUserVO:
:
getAppId
,
Collectors
.
collectingAndThen
(
toCollection
(()
->
new
TreeSet
<>(
Comparator
.
comparing
(
CrowdPackageUserVO:
:
getOpenId
))),
ArrayList:
:
new
)));
//根据客服id找不同公众号的链接,并按appId分组
List
<
ReferralEntityVo
>
referralList
=
referralEntityService
.
findReferralByCustomerGraphicsId
(
customerGraphics
.
getId
());
...
...
@@ -253,21 +259,18 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
for
(
Map
.
Entry
<
String
,
List
<
ReferralEntityVo
>>
referralEntry
:
referralMap
.
entrySet
())
{
String
appid
=
referralEntry
.
getKey
();
//获取token
AuthorizerToken
authorizerToken
=
authorizerTokenService
.
findTokenByAppid
(
appid
);
if
(
authorizerToken
!=
null
&&
authorizerToken
.
getAuthorizerAccessToken
()!=
null
){
//获取该号的链接实体
List
<
ReferralEntityVo
>
referralEntityVo
=
referralMap
.
get
(
appid
);
//获取该号的openid
List
<
CrowdPackageUserVO
>
packageUserVo
=
appidUserMap
.
get
(
appid
);
if
(
referralEntityVo
!=
null
&&!
referralEntity
Vo
.
isEmpty
()){
if
(
referralEntityVo
!=
null
&&!
referralEntityVo
.
isEmpty
()&&
packageUserVo
!=
null
&&!
packageUser
Vo
.
isEmpty
()){
weChatService
.
sendCustomerMessage
(
appid
,
authorizerToken
,
customerGraphics
,
packageUserVo
,
referralEntityVo
);
}
weChatService
.
sendCustomerMessage
(
appid
,
customerGraphics
,
packageUserVo
,
referralEntityVo
);
}
}
//客服状态修改
customerGraphics
.
setSendStatus
(
CustomerCommonConstant
.
SEND_STATUS_FINISHED
);
}
updateBatchById
(
customerGraphicsList
);
LOCAL_LOG
.
info
(
"end sendCustomerMessage"
);
...
...
src/main/java/com/yaoyaozw/customer/service/wechat/service/WeChatService.java
浏览文件 @
01d603b2
...
...
@@ -15,7 +15,7 @@ public interface WeChatService {
/**
* 发送延时客服消息
*/
Future
<
CustomerDelayPublish
>
sendCustomerDelayMessage
(
AuthorizerToken
authorizerT
oken
,
CustomerDelayPublish
user
,
Future
<
CustomerDelayPublish
>
sendCustomerDelayMessage
(
String
appid
,
String
t
oken
,
CustomerDelayPublish
user
,
Map
<
Integer
,
List
<
CustomerDelayItemVO
>>
delaySortMap
,
Set
<
CustomerDelayItemVO
>
needUpdateVoList
);
...
...
@@ -23,7 +23,7 @@ public interface WeChatService {
/**
* 定时发送客服消息
*/
void
sendCustomerMessage
(
String
appid
,
AuthorizerToken
authorizerToken
,
CustomerGraphics
customerGraphics
,
void
sendCustomerMessage
(
String
appid
,
CustomerGraphics
customerGraphics
,
List
<
CrowdPackageUserVO
>
openidList
,
List
<
ReferralEntityVo
>
referralEntityVo
);
}
src/main/java/com/yaoyaozw/customer/service/wechat/service/WeChatServiceImpl.java
浏览文件 @
01d603b2
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论