Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
8e5478b2
提交
8e5478b2
authored
9月 28, 2022
作者:
gh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
延时客服排期提出实体类
上级
a5f9d5e1
隐藏空白字符变更
内嵌
并排
正在显示
22 个修改的文件
包含
355 行增加
和
87 行删除
+355
-87
ThreadConfig.java
src/main/java/com/yaoyaozw/customer/ThreadConfig.java
+45
-0
CustomerDelayController.java
...yaoyaozw/customer/controller/CustomerDelayController.java
+2
-2
CustomerDelayPublish.java
...va/com/yaoyaozw/customer/entity/CustomerDelayPublish.java
+78
-0
RegisterUserEntity.java
...java/com/yaoyaozw/customer/entity/RegisterUserEntity.java
+0
-14
AuthorizerTokenMapper.java
...a/com/yaoyaozw/customer/mapper/AuthorizerTokenMapper.java
+4
-0
CustomerDelayPublishMapper.java
.../yaoyaozw/customer/mapper/CustomerDelayPublishMapper.java
+14
-0
CustomerGraphicsDelayMapper.java
...yaoyaozw/customer/mapper/CustomerGraphicsDelayMapper.java
+3
-2
AuthorizerTokenService.java
...com/yaoyaozw/customer/service/AuthorizerTokenService.java
+1
-0
CustomerDelayPublishService.java
...aoyaozw/customer/service/CustomerDelayPublishService.java
+14
-0
CustomerGraphicsDelayService.java
...oyaozw/customer/service/CustomerGraphicsDelayService.java
+2
-2
RegisterUserEntityService.java
.../yaoyaozw/customer/service/RegisterUserEntityService.java
+0
-3
AuthorizerTokenServiceImpl.java
...ozw/customer/service/impl/AuthorizerTokenServiceImpl.java
+6
-0
CustomerDelayPublishServiceImpl.java
...ustomer/service/impl/CustomerDelayPublishServiceImpl.java
+107
-0
CustomerGraphicsDelayServiceImpl.java
...stomer/service/impl/CustomerGraphicsDelayServiceImpl.java
+2
-2
RegisterUserEntityServiceImpl.java
.../customer/service/impl/RegisterUserEntityServiceImpl.java
+9
-54
WeChatService.java
...oyaozw/customer/service/wechat/service/WeChatService.java
+12
-2
WeChatServiceImpl.java
...zw/customer/service/wechat/service/WeChatServiceImpl.java
+27
-2
CustomerDelayItemVO.java
...om/yaoyaozw/customer/vo/customer/CustomerDelayItemVO.java
+2
-1
AuthorizerTokenMapper.xml
src/main/resources/mapper/AuthorizerTokenMapper.xml
+7
-0
CustomerDelayPublishMapper.xml
src/main/resources/mapper/CustomerDelayPublishMapper.xml
+19
-0
CustomerGraphicsDelayMapper.xml
src/main/resources/mapper/CustomerGraphicsDelayMapper.xml
+1
-1
RegisterUserEntityMapper.xml
src/main/resources/mapper/RegisterUserEntityMapper.xml
+0
-2
没有找到文件。
src/main/java/com/yaoyaozw/customer/ThreadConfig.java
0 → 100644
浏览文件 @
8e5478b2
package
com
.
yaoyaozw
.
customer
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
java.util.concurrent.ThreadPoolExecutor
;
/**
* @author darker
* @date 2022/8/2 15:01
*/
@Configuration
@EnableAsync
public
class
ThreadConfig
{
/** 核心线程数(默认线程数) */
private
static
final
int
CORE_POOL_SIZE
=
15
;
/** 最大线程数 */
private
static
final
int
MAX_POOL_SIZE
=
50
;
/** 允许线程空闲时间(单位:默认为秒) */
private
static
final
int
KEEP_ALIVE_TIME
=
60
;
/** 缓冲队列大小 */
private
static
final
int
QUEUE_CAPACITY
=
100
;
/** 线程池名前缀 */
private
static
final
String
THREAD_NAME_PREFIX
=
"Async-Service-"
;
@Bean
(
"myExecutor"
)
public
ThreadPoolTaskExecutor
myExecutor
()
{
ThreadPoolTaskExecutor
executor
=
new
ThreadPoolTaskExecutor
();
executor
.
setCorePoolSize
(
CORE_POOL_SIZE
);
executor
.
setMaxPoolSize
(
MAX_POOL_SIZE
);
executor
.
setQueueCapacity
(
QUEUE_CAPACITY
);
executor
.
setKeepAliveSeconds
(
KEEP_ALIVE_TIME
);
executor
.
setThreadNamePrefix
(
THREAD_NAME_PREFIX
);
// 线程池对拒绝任务的处理策略
// CallerRunsPolicy:由调用线程(提交任务的线程)处理该任务
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
// 初始化
executor
.
initialize
();
return
executor
;
}
}
src/main/java/com/yaoyaozw/customer/controller/CustomerDelayController.java
浏览文件 @
8e5478b2
...
...
@@ -4,7 +4,7 @@ import com.yaoyaozw.customer.common.BaseResult;
import
com.yaoyaozw.customer.common.GenericsResult
;
import
com.yaoyaozw.customer.dto.customer.CustomerDelayQueryDTO
;
import
com.yaoyaozw.customer.dto.customer.CustomerDelaySaveDTO
;
import
com.yaoyaozw.customer.vo.customer.
DelayCustomer
ItemVO
;
import
com.yaoyaozw.customer.vo.customer.
CustomerDelay
ItemVO
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -37,7 +37,7 @@ public class CustomerDelayController {
@ApiOperation
(
"查询"
)
@PostMapping
(
"/pageList"
)
public
GenericsResult
<
List
<
DelayCustomer
ItemVO
>>
pageList
(
@RequestBody
CustomerDelayQueryDTO
queryDto
)
{
public
GenericsResult
<
List
<
CustomerDelay
ItemVO
>>
pageList
(
@RequestBody
CustomerDelayQueryDTO
queryDto
)
{
return
new
GenericsResult
<>(
new
ArrayList
<>());
}
...
...
src/main/java/com/yaoyaozw/customer/entity/CustomerDelayPublish.java
0 → 100644
浏览文件 @
8e5478b2
package
com
.
yaoyaozw
.
customer
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
java.io.Serializable
;
import
java.util.Date
;
import
lombok.Data
;
/**
* @author wgh
* @date 2022/9/28 18:51
*/
@Data
@TableName
(
value
=
"register_user_entity"
)
public
class
CustomerDelayPublish
implements
Serializable
{
/**
* 主键
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Long
id
;
/**
* app_id
*/
@TableField
(
exist
=
false
,
value
=
"app_id"
)
private
String
appId
;
/**
* openid
*/
@TableField
(
exist
=
false
,
value
=
"open_id"
)
private
String
openId
;
/**
* 未付费0/付费1/VIP 2
*/
@TableField
(
exist
=
false
,
value
=
"pay_type"
)
private
Byte
payType
;
/**
* 延时客服序列
*/
@TableField
(
value
=
"customer_sort"
)
private
Integer
customerSort
;
/**
* 延时客服发送时间
*/
@TableField
(
value
=
"customer_publish"
)
private
Date
customerPublish
;
/**
* 创建时间
*/
@TableField
(
exist
=
false
,
value
=
"gmt_create"
)
private
Date
gmtCreate
;
private
static
final
long
serialVersionUID
=
1L
;
public
static
final
String
COL_ID
=
"id"
;
public
static
final
String
COL_APP_ID
=
"app_id"
;
public
static
final
String
COL_OPEN_ID
=
"open_id"
;
public
static
final
String
COL_PAY_TYPE
=
"pay_type"
;
public
static
final
String
COL_CUSTOMER_SORT
=
"customer_sort"
;
public
static
final
String
COL_CUSTOMER_PUBLISH
=
"customer_publish"
;
public
static
final
String
COL_GMT_CREATE
=
"gmt_create"
;
}
\ No newline at end of file
src/main/java/com/yaoyaozw/customer/entity/RegisterUserEntity.java
浏览文件 @
8e5478b2
...
...
@@ -75,17 +75,6 @@ public class RegisterUserEntity implements Serializable {
@TableField
(
value
=
"gmt_create"
)
private
Date
gmtCreate
;
/**
* 延时客服序列
*/
@TableField
(
value
=
"customer_sort"
)
private
Integer
customerSort
;
/**
* 延时客服发送时间
*/
@TableField
(
value
=
"customer_publish"
)
private
Date
customerPublish
;
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -109,7 +98,5 @@ public class RegisterUserEntity implements Serializable {
public
static
final
String
COL_GMT_CREATE
=
"gmt_create"
;
public
static
final
String
COL_CUSTOMER_SORT
=
"customer_sort"
;
public
static
final
String
COL_CUSTOMER_PUBLISH
=
"customer_publish"
;
}
\ No newline at end of file
src/main/java/com/yaoyaozw/customer/mapper/AuthorizerTokenMapper.java
浏览文件 @
8e5478b2
...
...
@@ -3,7 +3,10 @@ package com.yaoyaozw.customer.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yaoyaozw.customer.entity.AuthorizerToken
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
@Mapper
public
interface
AuthorizerTokenMapper
extends
BaseMapper
<
AuthorizerToken
>
{
AuthorizerToken
findByAppid
(
@Param
(
"appid"
)
String
appid
);
}
\ No newline at end of file
src/main/java/com/yaoyaozw/customer/mapper/CustomerDelayPublishMapper.java
0 → 100644
浏览文件 @
8e5478b2
package
com
.
yaoyaozw
.
customer
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yaoyaozw.customer.entity.CustomerDelayPublish
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* @author wgh
* @date 2022/9/28 18:51
*/
@Mapper
public
interface
CustomerDelayPublishMapper
extends
BaseMapper
<
CustomerDelayPublish
>
{
}
\ No newline at end of file
src/main/java/com/yaoyaozw/customer/mapper/CustomerGraphicsDelayMapper.java
浏览文件 @
8e5478b2
...
...
@@ -3,7 +3,7 @@ package com.yaoyaozw.customer.mapper;
import
com.baomidou.dynamic.datasource.annotation.DS
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yaoyaozw.customer.entity.CustomerGraphicsDelay
;
import
com.yaoyaozw.customer.vo.customer.
DelayCustomer
ItemVO
;
import
com.yaoyaozw.customer.vo.customer.
CustomerDelay
ItemVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
...
...
@@ -20,5 +20,5 @@ public interface CustomerGraphicsDelayMapper extends BaseMapper<CustomerGraphics
* @param appidList
* @return
*/
List
<
DelayCustomer
ItemVO
>
findAllDelayCustomerMessage
(
@Param
(
"appidList"
)
Set
<
String
>
appidList
);
List
<
CustomerDelay
ItemVO
>
findAllDelayCustomerMessage
(
@Param
(
"appidList"
)
Set
<
String
>
appidList
);
}
\ No newline at end of file
src/main/java/com/yaoyaozw/customer/service/AuthorizerTokenService.java
浏览文件 @
8e5478b2
...
...
@@ -4,5 +4,6 @@ import com.yaoyaozw.customer.entity.AuthorizerToken;
import
com.baomidou.mybatisplus.extension.service.IService
;
public
interface
AuthorizerTokenService
extends
IService
<
AuthorizerToken
>{
AuthorizerToken
findTokenByAppid
(
String
appid
);
}
src/main/java/com/yaoyaozw/customer/service/CustomerDelayPublishService.java
0 → 100644
浏览文件 @
8e5478b2
package
com
.
yaoyaozw
.
customer
.
service
;
import
com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO
;
import
com.yaoyaozw.customer.entity.CustomerDelayPublish
;
import
com.baomidou.mybatisplus.extension.service.IService
;
/**
* @author wgh
* @date 2022/9/28 18:51
*/
public
interface
CustomerDelayPublishService
extends
IService
<
CustomerDelayPublish
>{
public
void
sendCustomerDelayMessage
(
IntegrationRequestDTO
integrationRequestDTO
);
}
src/main/java/com/yaoyaozw/customer/service/CustomerGraphicsDelayService.java
浏览文件 @
8e5478b2
...
...
@@ -2,7 +2,7 @@ package com.yaoyaozw.customer.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.yaoyaozw.customer.entity.CustomerGraphicsDelay
;
import
com.yaoyaozw.customer.vo.customer.
DelayCustomer
ItemVO
;
import
com.yaoyaozw.customer.vo.customer.
CustomerDelay
ItemVO
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -13,6 +13,6 @@ import java.util.Set;
*/
public
interface
CustomerGraphicsDelayService
extends
IService
<
CustomerGraphicsDelay
>
{
List
<
DelayCustomer
ItemVO
>
findAllDelayCustomerMessage
(
Set
<
String
>
appidList
);
List
<
CustomerDelay
ItemVO
>
findAllDelayCustomerMessage
(
Set
<
String
>
appidList
);
}
src/main/java/com/yaoyaozw/customer/service/RegisterUserEntityService.java
浏览文件 @
8e5478b2
...
...
@@ -11,7 +11,4 @@ public interface RegisterUserEntityService extends IService<RegisterUserEntity>{
void
sendCustomerMessage
(
IntegrationRequestDTO
integrationRequestDTO
);
void
sendCustomerDelayMessage
(
IntegrationRequestDTO
integrationRequestDTO
);
}
src/main/java/com/yaoyaozw/customer/service/impl/AuthorizerTokenServiceImpl.java
浏览文件 @
8e5478b2
...
...
@@ -10,4 +10,10 @@ import com.yaoyaozw.customer.service.AuthorizerTokenService;
@Service
public
class
AuthorizerTokenServiceImpl
extends
ServiceImpl
<
AuthorizerTokenMapper
,
AuthorizerToken
>
implements
AuthorizerTokenService
{
@Override
public
AuthorizerToken
findTokenByAppid
(
String
appid
)
{
return
baseMapper
.
findByAppid
(
appid
);
}
}
src/main/java/com/yaoyaozw/customer/service/impl/CustomerDelayPublishServiceImpl.java
0 → 100644
浏览文件 @
8e5478b2
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.vo.customer.CustomerDelayItemVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.Future
;
import
java.util.stream.Collectors
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.yaoyaozw.customer.entity.CustomerDelayPublish
;
import
com.yaoyaozw.customer.mapper.CustomerDelayPublishMapper
;
import
com.yaoyaozw.customer.service.CustomerDelayPublishService
;
/**
* @author wgh
* @date 2022/9/28 18:51
*/
@Service
public
class
CustomerDelayPublishServiceImpl
extends
ServiceImpl
<
CustomerDelayPublishMapper
,
CustomerDelayPublish
>
implements
CustomerDelayPublishService
{
@Autowired
private
CustomerGraphicsDelayService
customerGraphicsDelayService
;
@Autowired
private
AuthorizerTokenService
authorizerTokenService
;
@Autowired
private
WeChatService
weChatService
;
@Override
public
void
sendCustomerDelayMessage
(
IntegrationRequestDTO
integrationRequestDTO
)
{
//读取延时客服排期人
List
<
CustomerDelayPublish
>
allPostUser
=
list
(
new
QueryWrapper
<
CustomerDelayPublish
>().
eq
(
CustomerDelayPublish
.
COL_CUSTOMER_PUBLISH
,
integrationRequestDTO
.
getRequestDate
()));
//涉及的appid
Set
<
String
>
appidSet
=
allPostUser
.
stream
().
map
(
CustomerDelayPublish:
:
getAppId
).
collect
(
Collectors
.
toSet
());
if
(!
allPostUser
.
isEmpty
()){
//号-用户
Map
<
String
,
List
<
CustomerDelayPublish
>>
userMap
=
allPostUser
.
stream
().
collect
(
Collectors
.
groupingBy
(
CustomerDelayPublish:
:
getAppId
));
List
<
CustomerDelayItemVO
>
allDelayCustomerMessage
=
customerGraphicsDelayService
.
findAllDelayCustomerMessage
(
appidSet
);
/*
List<AuthorizerToken> tokenList = authorizerTokenService.list();
Map<String, String> tokenMap = tokenList.stream().collect(Collectors.toMap(AuthorizerToken::getAuthorizerAppid, AuthorizerToken::getAuthorizerAccessToken));
*/
if
(
allDelayCustomerMessage
!=
null
&&!
allDelayCustomerMessage
.
isEmpty
()){
List
<
Future
<
CustomerDelayPublish
>>
futureList
=
new
ArrayList
<>();
//号-发送序列-客服id
Map
<
String
,
Map
<
Integer
,
CustomerDelayItemVO
>>
customerMap
=
allDelayCustomerMessage
.
stream
().
collect
(
Collectors
.
groupingBy
(
CustomerDelayItemVO:
:
getAppId
,
Collectors
.
toMap
(
CustomerDelayItemVO:
:
getPostSort
,
a
->
a
,
(
v1
,
v2
)
->
v2
)));
for
(
Map
.
Entry
<
String
,
List
<
CustomerDelayPublish
>>
userEntry
:
userMap
.
entrySet
())
{
String
appid
=
userEntry
.
getKey
();
AuthorizerToken
authorizerToken
=
authorizerTokenService
.
findTokenByAppid
(
appid
);
String
token
=
authorizerToken
.
getAuthorizerAppid
();
//没token过滤
if
(
token
==
null
||
""
.
equals
(
token
)){
continue
;
}
//该号下延时客服
Map
<
Integer
,
CustomerDelayItemVO
>
delaySortMap
=
customerMap
.
get
(
appid
);
//所有的用户
List
<
CustomerDelayPublish
>
userList
=
userEntry
.
getValue
();
if
(
delaySortMap
!=
null
&&!
delaySortMap
.
isEmpty
()){
for
(
CustomerDelayPublish
userPublish
:
userList
)
{
//发送客服
futureList
.
add
(
weChatService
.
sendCustomerDelayMessage
(
token
,
userPublish
,
delaySortMap
))
;
}
}
}
List
<
CustomerDelayPublish
>
registerUserEntities
=
new
ArrayList
<>();
for
(
Future
<
CustomerDelayPublish
>
delayPublishFuture
:
futureList
)
{
try
{
registerUserEntities
.
add
(
delayPublishFuture
.
get
())
;
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
e
.
printStackTrace
();
}
}
updateBatchById
(
registerUserEntities
);
}
}
}
}
src/main/java/com/yaoyaozw/customer/service/impl/CustomerGraphicsDelayServiceImpl.java
浏览文件 @
8e5478b2
...
...
@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
com.yaoyaozw.customer.entity.CustomerGraphicsDelay
;
import
com.yaoyaozw.customer.mapper.CustomerGraphicsDelayMapper
;
import
com.yaoyaozw.customer.service.CustomerGraphicsDelayService
;
import
com.yaoyaozw.customer.vo.customer.
DelayCustomer
ItemVO
;
import
com.yaoyaozw.customer.vo.customer.
CustomerDelay
ItemVO
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
...
...
@@ -20,7 +20,7 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
@Override
public
List
<
DelayCustomer
ItemVO
>
findAllDelayCustomerMessage
(
Set
<
String
>
appidList
)
{
public
List
<
CustomerDelay
ItemVO
>
findAllDelayCustomerMessage
(
Set
<
String
>
appidList
)
{
return
baseMapper
.
findAllDelayCustomerMessage
(
appidList
);
...
...
src/main/java/com/yaoyaozw/customer/service/impl/RegisterUserEntityServiceImpl.java
浏览文件 @
8e5478b2
...
...
@@ -3,10 +3,12 @@ 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.entity.CustomerDelayPublish
;
import
com.yaoyaozw.customer.service.AuthorizerTokenService
;
import
com.yaoyaozw.customer.service.CustomerGraphicsDelayService
;
import
com.yaoyaozw.customer.service.CustomerGraphicsService
;
import
com.yaoyaozw.customer.vo.customer.DelayCustomerItemVO
;
import
com.yaoyaozw.customer.service.wechat.service.WeChatService
;
import
com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
...
...
@@ -14,9 +16,12 @@ import com.yaoyaozw.customer.mapper.RegisterUserEntityMapper;
import
com.yaoyaozw.customer.entity.RegisterUserEntity
;
import
com.yaoyaozw.customer.service.RegisterUserEntityService
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.Future
;
import
java.util.stream.Collectors
;
...
...
@@ -27,72 +32,22 @@ public class RegisterUserEntityServiceImpl extends ServiceImpl<RegisterUserEntit
private
CustomerGraphicsService
customerGraphicsService
;
@Autowired
private
CustomerGraphicsDelayService
customerGraphicsDelay
Service
;
private
AuthorizerTokenService
authorizerToken
Service
;
@Autowired
private
AuthorizerTokenService
authorizerToken
Service
;
private
WeChatService
weChat
Service
;
@Override
public
void
sendCustomerMessage
(
IntegrationRequestDTO
integrationRequestDTO
)
{
//1.读取人群包
List
<
RegisterUserEntity
>
list
=
list
();
//2.发送客服消息
}
@Override
public
void
sendCustomerDelayMessage
(
IntegrationRequestDTO
integrationRequestDTO
)
{
//1.读取延时客服排期人
List
<
RegisterUserEntity
>
allPostUser
=
list
(
new
QueryWrapper
<
RegisterUserEntity
>().
eq
(
RegisterUserEntity
.
COL_CUSTOMER_PUBLISH
,
integrationRequestDTO
.
getRequestDate
()));
//涉及的appid
Set
<
String
>
appidSet
=
allPostUser
.
stream
().
map
(
RegisterUserEntity:
:
getAppId
).
collect
(
Collectors
.
toSet
());
if
(!
allPostUser
.
isEmpty
()){
//号-用户
Map
<
String
,
List
<
RegisterUserEntity
>>
userMap
=
allPostUser
.
stream
().
collect
(
Collectors
.
groupingBy
(
RegisterUserEntity:
:
getAppId
));
List
<
DelayCustomerItemVO
>
allDelayCustomerMessage
=
customerGraphicsDelayService
.
findAllDelayCustomerMessage
(
appidSet
);
if
(
allDelayCustomerMessage
!=
null
&&!
allDelayCustomerMessage
.
isEmpty
()){
//号-发送序列-客服id
Map
<
String
,
Map
<
Integer
,
List
<
DelayCustomerItemVO
>>>
customerMap
=
allDelayCustomerMessage
.
stream
().
collect
(
Collectors
.
groupingBy
(
DelayCustomerItemVO:
:
getAppId
,
Collectors
.
groupingBy
(
DelayCustomerItemVO:
:
getPostSort
)));
List
<
AuthorizerToken
>
tokenList
=
authorizerTokenService
.
list
();
//找token
Map
<
String
,
String
>
tokenMap
=
tokenList
.
stream
().
collect
(
Collectors
.
toMap
(
AuthorizerToken:
:
getAuthorizerAppid
,
AuthorizerToken:
:
getAuthorizerAccessToken
));
for
(
Map
.
Entry
<
String
,
List
<
RegisterUserEntity
>>
userEntry
:
userMap
.
entrySet
())
{
String
appid
=
userEntry
.
getKey
();
//该号下延时客服
Map
<
Integer
,
List
<
DelayCustomerItemVO
>>
delaySortMap
=
customerMap
.
get
(
appid
);
//所有的用户
List
<
RegisterUserEntity
>
userList
=
userEntry
.
getValue
();
if
(
delaySortMap
!=
null
&&!
delaySortMap
.
isEmpty
()){
for
(
RegisterUserEntity
user
:
userList
)
{
Integer
customerSort
=
user
.
getCustomerSort
();
}
}
}
}
}
}
//2.发送延时客服
}
}
src/main/java/com/yaoyaozw/customer/service/wechat/service/WeChatService.java
浏览文件 @
8e5478b2
package
com
.
yaoyaozw
.
customer
.
service
.
wechat
.
service
;
import
com.yaoyaozw.customer.entity.CustomerDelayPublish
;
import
com.yaoyaozw.customer.entity.RegisterUserEntity
;
import
com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO
;
import
java.util.Map
;
import
java.util.concurrent.Future
;
public
interface
WeChatService
{
/**
* 发送客服消息
* 发送
延时
客服消息
*/
void
sendCustomerServiceMessage
();
Future
<
CustomerDelayPublish
>
sendCustomerDelayMessage
(
String
token
,
CustomerDelayPublish
user
,
Map
<
Integer
,
CustomerDelayItemVO
>
delaySortMap
);
}
src/main/java/com/yaoyaozw/customer/service/wechat/service/WeChatServiceImpl.java
浏览文件 @
8e5478b2
package
com
.
yaoyaozw
.
customer
.
service
.
wechat
.
service
;
import
com.yaoyaozw.customer.entity.CustomerDelayPublish
;
import
com.yaoyaozw.customer.entity.RegisterUserEntity
;
import
com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.AsyncResult
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.concurrent.Future
;
@Service
public
class
WeChatServiceImpl
implements
WeChatService
{
@Autowired
private
WeChatRestService
weChatRestService
;
@Async
(
"myExecutor"
)
@Override
public
void
sendCustomerServiceMessage
()
{
public
Future
<
CustomerDelayPublish
>
sendCustomerDelayMessage
(
String
token
,
CustomerDelayPublish
user
,
Map
<
Integer
,
CustomerDelayItemVO
>
delaySortMap
)
{
//根据公众号发送客服
//当前时间批次发文素材的用户关注时间一致
Long
subscribeTimestamp
=
user
.
getGmtCreate
().
getTime
();
Integer
newSort
=
user
.
getCustomerSort
()+
1
;
CustomerDelayItemVO
customerDelayItemVO
=
delaySortMap
.
get
(
newSort
);
if
(
customerDelayItemVO
!=
null
&&
customerDelayItemVO
.
getTimeInterval
()!=
null
){
//根据人群包发送客服
user
.
setCustomerSort
(
newSort
);
user
.
setCustomerPublish
(
new
Date
(
subscribeTimestamp
+
customerDelayItemVO
.
getTimeInterval
()));
}
return
new
AsyncResult
<>(
user
);
}
}
src/main/java/com/yaoyaozw/customer/vo/customer/
DelayCustomer
ItemVO.java
→
src/main/java/com/yaoyaozw/customer/vo/customer/
CustomerDelay
ItemVO.java
浏览文件 @
8e5478b2
...
...
@@ -10,8 +10,9 @@ import java.io.Serializable;
* @date 2022/9/16 10:45
*/
@Data
public
class
DelayCustomer
ItemVO
implements
Serializable
{
public
class
CustomerDelay
ItemVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
4630777409975737444L
;
/**
* appid
*/
...
...
src/main/resources/mapper/AuthorizerTokenMapper.xml
浏览文件 @
8e5478b2
...
...
@@ -12,4 +12,10 @@
<!--@mbg.generated-->
id, authorizer_access_token, authorizer_appid
</sql>
<select
id=
"findByAppid"
resultMap=
"BaseResultMap"
>
select id,authorizer_access_token,authorizer_appid from authorizer_token where authorizer_appid=#{appid}
</select>
</mapper>
\ No newline at end of file
src/main/resources/mapper/CustomerDelayPublishMapper.xml
0 → 100644
浏览文件 @
8e5478b2
<?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.CustomerDelayPublishMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.yaoyaozw.customer.entity.CustomerDelayPublish"
>
<!--@mbg.generated-->
<!--@Table register_user_entity-->
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"app_id"
jdbcType=
"VARCHAR"
property=
"appId"
/>
<result
column=
"open_id"
jdbcType=
"VARCHAR"
property=
"openId"
/>
<result
column=
"pay_type"
jdbcType=
"TINYINT"
property=
"payType"
/>
<result
column=
"customer_sort"
jdbcType=
"INTEGER"
property=
"customerSort"
/>
<result
column=
"customer_publish"
jdbcType=
"TIMESTAMP"
property=
"customerPublish"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--@mbg.generated-->
id, app_id, open_id, pay_type, customer_sort, customer_publish
</sql>
</mapper>
\ No newline at end of file
src/main/resources/mapper/CustomerGraphicsDelayMapper.xml
浏览文件 @
8e5478b2
...
...
@@ -21,7 +21,7 @@
</sql>
<select
id=
"findAllDelayCustomerMessage"
resultType=
"com.yaoyaozw.customer.vo.customer.
DelayCustomer
ItemVO"
>
<select
id=
"findAllDelayCustomerMessage"
resultType=
"com.yaoyaozw.customer.vo.customer.
CustomerDelay
ItemVO"
>
select * from customer_graphics_delay
...
...
src/main/resources/mapper/RegisterUserEntityMapper.xml
浏览文件 @
8e5478b2
...
...
@@ -14,8 +14,6 @@
<result
column=
"avg_month"
jdbcType=
"DOUBLE"
property=
"avgMonth"
/>
<result
column=
"last_active"
jdbcType=
"TIMESTAMP"
property=
"lastActive"
/>
<result
column=
"gmt_create"
jdbcType=
"TIMESTAMP"
property=
"gmtCreate"
/>
<result
column=
"customer_sort"
jdbcType=
"INTEGER"
property=
"customerSort"
/>
<result
column=
"customer_publish"
jdbcType=
"TIMESTAMP"
property=
"customerPublish"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--@mbg.generated-->
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论