Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
117ec7ed
提交
117ec7ed
authored
10月 13, 2022
作者:
gh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
人群包读取,客服推送
上级
aeca1804
显示空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
178 行增加
和
34 行删除
+178
-34
CustomerServiceApplication.java
...ava/com/yaoyaozw/customer/CustomerServiceApplication.java
+1
-1
CustomerServiceCommonAsyncComponent.java
...tomer/components/CustomerServiceCommonAsyncComponent.java
+1
-1
TestController.java
...java/com/yaoyaozw/customer/controller/TestController.java
+37
-0
CustomerGraphics.java
...n/java/com/yaoyaozw/customer/entity/CustomerGraphics.java
+4
-1
RegisterUserEntityMapper.java
...om/yaoyaozw/customer/mapper/RegisterUserEntityMapper.java
+8
-0
SchedulingTask.java
...java/com/yaoyaozw/customer/scheduling/SchedulingTask.java
+24
-3
CustomerGraphicsService.java
...om/yaoyaozw/customer/service/CustomerGraphicsService.java
+4
-0
ReferralEntityService.java
.../com/yaoyaozw/customer/service/ReferralEntityService.java
+5
-1
RegisterUserEntityService.java
.../yaoyaozw/customer/service/RegisterUserEntityService.java
+1
-1
CustomerGraphicsServiceImpl.java
...zw/customer/service/impl/CustomerGraphicsServiceImpl.java
+7
-12
RegisterUserEntityServiceImpl.java
.../customer/service/impl/RegisterUserEntityServiceImpl.java
+11
-1
WeChatService.java
...oyaozw/customer/service/wechat/service/WeChatService.java
+2
-1
WeChatServiceImpl.java
...zw/customer/service/wechat/service/WeChatServiceImpl.java
+51
-9
ReferralEntityVo.java
...a/com/yaoyaozw/customer/vo/referral/ReferralEntityVo.java
+5
-1
ReferralEntityMapper.xml
src/main/resources/mapper/ReferralEntityMapper.xml
+2
-2
RegisterUserEntityMapper.xml
src/main/resources/mapper/RegisterUserEntityMapper.xml
+15
-0
没有找到文件。
src/main/java/com/yaoyaozw/customer/CustomerServiceApplication.java
浏览文件 @
117ec7ed
...
@@ -12,7 +12,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
...
@@ -12,7 +12,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
* @date 2022/9/15 18:13
* @date 2022/9/15 18:13
*/
*/
@SpringBootApplication
@SpringBootApplication
@EnableScheduling
//
@EnableScheduling
@MapperScan
(
"com.yaoyaozw.customer.mapper"
)
@MapperScan
(
"com.yaoyaozw.customer.mapper"
)
@EnableFeignClients
@EnableFeignClients
@EnableAsync
@EnableAsync
...
...
src/main/java/com/yaoyaozw/customer/components/CustomerServiceCommonAsyncComponent.java
浏览文件 @
117ec7ed
...
@@ -83,7 +83,7 @@ public class CustomerServiceCommonAsyncComponent {
...
@@ -83,7 +83,7 @@ public class CustomerServiceCommonAsyncComponent {
LOCAL_LOG
.
info
(
"人群包ID: {} 新增用户 {}个"
,
packIdStr
,
userNotInPackageList
.
size
());
LOCAL_LOG
.
info
(
"人群包ID: {} 新增用户 {}个"
,
packIdStr
,
userNotInPackageList
.
size
());
if
(
needRemove
)
{
if
(
needRemove
)
{
// 当前在人群包内的用户
// 当前在人群包内的用户
List
<
CrowdPackageUserVO
>
packCurrentUserList
=
userEntityService
.
getCurrentInPackUserList
(
packageId
);
List
<
CrowdPackageUserVO
>
packCurrentUserList
=
userEntityService
.
getCurrentInPackUserList
(
packageId
,
true
);
if
(
CollectionUtil
.
isNotEmpty
(
packCurrentUserList
))
{
if
(
CollectionUtil
.
isNotEmpty
(
packCurrentUserList
))
{
List
<
String
>
userOpenIdList
=
userList
.
stream
().
map
(
CrowdPackageUserVO:
:
getOpenId
).
collect
(
Collectors
.
toList
());
List
<
String
>
userOpenIdList
=
userList
.
stream
().
map
(
CrowdPackageUserVO:
:
getOpenId
).
collect
(
Collectors
.
toList
());
// 筛选出之前在人群包内,现在不在地用户列表
// 筛选出之前在人群包内,现在不在地用户列表
...
...
src/main/java/com/yaoyaozw/customer/controller/TestController.java
0 → 100644
浏览文件 @
117ec7ed
package
com
.
yaoyaozw
.
customer
.
controller
;
import
com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO
;
import
com.yaoyaozw.customer.service.CustomerGraphicsService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Calendar
;
/**
* @author wgh
* @date 2022/10/10 20:04
*/
@RestController
@RequestMapping
(
"/customer-service/test"
)
public
class
TestController
{
@Autowired
private
CustomerGraphicsService
customerGraphicsService
;
@GetMapping
(
"/CustomerTest"
)
public
void
test
(){
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
Calendar
.
AM_PM
,
0
);
calendar
.
set
(
Calendar
.
HOUR
,
20
);
calendar
.
set
(
Calendar
.
MINUTE
,
0
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
IntegrationRequestDTO
integrationRequestDTO
=
new
IntegrationRequestDTO
();
integrationRequestDTO
.
setRequestDate
(
calendar
.
getTime
());
customerGraphicsService
.
sendCustomerMessage
(
integrationRequestDTO
);
}
}
src/main/java/com/yaoyaozw/customer/entity/CustomerGraphics.java
浏览文件 @
117ec7ed
...
@@ -8,7 +8,7 @@ import lombok.Data;
...
@@ -8,7 +8,7 @@ import lombok.Data;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.annotation.Id
;
/**
/**
* 客
户图片
* 客
服素材
*
*
* @author Admin
* @author Admin
* @date 2022/10/08
* @date 2022/10/08
...
@@ -86,6 +86,9 @@ public class CustomerGraphics implements Serializable {
...
@@ -86,6 +86,9 @@ public class CustomerGraphics implements Serializable {
@TableField
(
value
=
"gmt_modified"
)
@TableField
(
value
=
"gmt_modified"
)
private
Date
gmtModified
;
private
Date
gmtModified
;
@TableField
(
value
=
"referral_size"
)
private
Integer
referralSize
;
/**
/**
* 逻辑删除
* 逻辑删除
*/
*/
...
...
src/main/java/com/yaoyaozw/customer/mapper/RegisterUserEntityMapper.java
浏览文件 @
117ec7ed
...
@@ -44,4 +44,11 @@ public interface RegisterUserEntityMapper extends BaseMapper<RegisterUserEntity>
...
@@ -44,4 +44,11 @@ public interface RegisterUserEntityMapper extends BaseMapper<RegisterUserEntity>
*/
*/
List
<
CrowdPackageUserVO
>
getCurrentInPackUserList
(
@Param
(
"packageId"
)
Long
packageId
);
List
<
CrowdPackageUserVO
>
getCurrentInPackUserList
(
@Param
(
"packageId"
)
Long
packageId
);
/**
* 查询包中用户(不左连查询表)
* @param packageId
* @return
*/
List
<
CrowdPackageUserVO
>
getCurrentInPackUserListWithoutAccountId
(
@Param
(
"packageId"
)
Long
packageId
);
}
}
\ No newline at end of file
src/main/java/com/yaoyaozw/customer/scheduling/SchedulingTask.java
浏览文件 @
117ec7ed
package
com
.
yaoyaozw
.
customer
.
scheduling
;
package
com
.
yaoyaozw
.
customer
.
scheduling
;
import
com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO
;
import
com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO
;
import
com.yaoyaozw.customer.
service.AccountOrderService
;
import
com.yaoyaozw.customer.
entity.CustomerGraphics
;
import
com.yaoyaozw.customer.service.
RegisterUserEntityService
;
import
com.yaoyaozw.customer.service.
*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -16,7 +16,10 @@ public class SchedulingTask {
...
@@ -16,7 +16,10 @@ public class SchedulingTask {
private
AccountOrderService
accountOrderService
;
private
AccountOrderService
accountOrderService
;
@Autowired
@Autowired
private
RegisterUserEntityService
registerUserEntityService
;
private
CustomerGraphicsService
customerGraphicsService
;
@Autowired
private
CustomerDelayPublishService
customerDelayPublishService
;
/**
/**
...
@@ -58,6 +61,16 @@ public class SchedulingTask {
...
@@ -58,6 +61,16 @@ public class SchedulingTask {
*/
*/
public
void
publishCustomerMessage
(){
public
void
publishCustomerMessage
(){
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
IntegrationRequestDTO
integrationRequestDTO
=
new
IntegrationRequestDTO
();
customerGraphicsService
.
sendCustomerMessage
(
integrationRequestDTO
);
}
}
...
@@ -67,6 +80,14 @@ public class SchedulingTask {
...
@@ -67,6 +80,14 @@ public class SchedulingTask {
*/
*/
public
void
publishDelayCustomerMessage
(){
public
void
publishDelayCustomerMessage
(){
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
IntegrationRequestDTO
integrationRequestDTO
=
new
IntegrationRequestDTO
();
customerDelayPublishService
.
sendCustomerDelayMessage
(
integrationRequestDTO
);
}
}
}
}
src/main/java/com/yaoyaozw/customer/service/CustomerGraphicsService.java
浏览文件 @
117ec7ed
...
@@ -67,6 +67,10 @@ public interface CustomerGraphicsService extends IService<CustomerGraphics> {
...
@@ -67,6 +67,10 @@ public interface CustomerGraphicsService extends IService<CustomerGraphics> {
BaseResult
setPack
(
Long
id
,
Long
packId
);
BaseResult
setPack
(
Long
id
,
Long
packId
);
/**
* 客服发送
* @param integrationRequestDTO 请求DTO
*/
void
sendCustomerMessage
(
IntegrationRequestDTO
integrationRequestDTO
);
void
sendCustomerMessage
(
IntegrationRequestDTO
integrationRequestDTO
);
}
}
...
...
src/main/java/com/yaoyaozw/customer/service/ReferralEntityService.java
浏览文件 @
117ec7ed
...
@@ -20,6 +20,10 @@ public interface ReferralEntityService extends IService<ReferralEntity> {
...
@@ -20,6 +20,10 @@ public interface ReferralEntityService extends IService<ReferralEntity> {
*/
*/
void
ultimateDeleteReferrals
(
Long
sourceId
);
void
ultimateDeleteReferrals
(
Long
sourceId
);
/**
* 根据客服id找链接
* @param graphicsId 客服主体id
* @return
*/
List
<
ReferralEntityVo
>
findReferralByCustomerGraphicsId
(
Long
graphicsId
);
List
<
ReferralEntityVo
>
findReferralByCustomerGraphicsId
(
Long
graphicsId
);
}
}
src/main/java/com/yaoyaozw/customer/service/RegisterUserEntityService.java
浏览文件 @
117ec7ed
...
@@ -33,7 +33,7 @@ public interface RegisterUserEntityService extends IService<RegisterUserEntity>{
...
@@ -33,7 +33,7 @@ public interface RegisterUserEntityService extends IService<RegisterUserEntity>{
* @param packageId 包id
* @param packageId 包id
* @return {@link List}<{@link CrowdPackageUserVO}>
* @return {@link List}<{@link CrowdPackageUserVO}>
*/
*/
List
<
CrowdPackageUserVO
>
getCurrentInPackUserList
(
Long
packageId
);
List
<
CrowdPackageUserVO
>
getCurrentInPackUserList
(
Long
packageId
,
Boolean
isLeftJoin
);
...
...
src/main/java/com/yaoyaozw/customer/service/impl/CustomerGraphicsServiceImpl.java
浏览文件 @
117ec7ed
...
@@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil;
...
@@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.sun.xml.internal.bind.v2.TODO
;
import
com.yaoyaozw.customer.common.BaseResult
;
import
com.yaoyaozw.customer.common.BaseResult
;
import
com.yaoyaozw.customer.common.GenericsResult
;
import
com.yaoyaozw.customer.common.GenericsResult
;
import
com.yaoyaozw.customer.components.CustomerServiceCommonAsyncComponent
;
import
com.yaoyaozw.customer.components.CustomerServiceCommonAsyncComponent
;
...
@@ -193,23 +194,17 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
...
@@ -193,23 +194,17 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
public
void
sendCustomerMessage
(
IntegrationRequestDTO
integrationRequestDTO
)
{
public
void
sendCustomerMessage
(
IntegrationRequestDTO
integrationRequestDTO
)
{
Date
requestDate
=
integrationRequestDTO
.
getRequestDate
();
Date
requestDate
=
integrationRequestDTO
.
getRequestDate
();
//todo:当前时刻发送的客服(需要加启用禁用)
//当前时刻发送的客服(需要加启用禁用)
List
<
CustomerGraphics
>
customerGraphicsList
=
list
(
new
QueryWrapper
<
CustomerGraphics
>().
eq
(
CustomerGraphics
.
COL_POST_TIME
,
requestDate
));
List
<
CustomerGraphics
>
customerGraphicsList
=
list
(
new
QueryWrapper
<
CustomerGraphics
>().
eq
(
CustomerGraphics
.
COL_POST_TIME
,
requestDate
));
for
(
CustomerGraphics
customerGraphics
:
customerGraphicsList
)
{
for
(
CustomerGraphics
customerGraphics
:
customerGraphicsList
)
{
//人群包id
Long
packId
=
customerGraphics
.
getPackId
();
Long
packId
=
customerGraphics
.
getPackId
();
//根据人群包找人,并按appId分组
/*
List
<
CrowdPackageUserVO
>
userList
=
registerUserEntityService
.
getCurrentInPackUserList
(
packId
,
false
);
根据人群包找人
*/
List
<
CrowdPackageUserVO
>
userList
=
new
ArrayList
<>();
Map
<
String
,
List
<
CrowdPackageUserVO
>>
appidUserMap
=
userList
.
stream
().
collect
(
Collectors
.
groupingBy
(
CrowdPackageUserVO:
:
getAppId
));
Map
<
String
,
List
<
CrowdPackageUserVO
>>
appidUserMap
=
userList
.
stream
().
collect
(
Collectors
.
groupingBy
(
CrowdPackageUserVO:
:
getAppId
));
//根据客服id找不同公众号的链接,并按appId分组
//根据公众号找具体素材和链接
List
<
ReferralEntityVo
>
referralList
=
referralEntityService
.
findReferralByCustomerGraphicsId
(
customerGraphics
.
getId
());
List
<
ReferralEntityVo
>
referralList
=
referralEntityService
.
findReferralByCustomerGraphicsId
(
customerGraphics
.
getId
());
Map
<
String
,
List
<
ReferralEntityVo
>>
referralMap
=
referralList
.
stream
().
collect
(
Collectors
.
groupingBy
(
ReferralEntityVo:
:
getAppid
));
Map
<
String
,
List
<
ReferralEntityVo
>>
referralMap
=
referralList
.
stream
().
collect
(
Collectors
.
groupingBy
(
ReferralEntityVo:
:
getAppid
));
...
@@ -228,7 +223,7 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
...
@@ -228,7 +223,7 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
if
(
referralEntityVo
!=
null
&&!
referralEntityVo
.
isEmpty
()){
if
(
referralEntityVo
!=
null
&&!
referralEntityVo
.
isEmpty
()){
weChatService
.
sendCustomerMessage
(
appid
,
authorizerToken
.
getAuthorizerAccessToken
()
,
customerGraphics
,
packageUserVo
,
referralEntityVo
);
weChatService
.
sendCustomerMessage
(
appid
,
authorizerToken
,
customerGraphics
,
packageUserVo
,
referralEntityVo
);
}
}
}
}
}
}
...
...
src/main/java/com/yaoyaozw/customer/service/impl/RegisterUserEntityServiceImpl.java
浏览文件 @
117ec7ed
...
@@ -39,11 +39,21 @@ public class RegisterUserEntityServiceImpl extends ServiceImpl<RegisterUserEntit
...
@@ -39,11 +39,21 @@ public class RegisterUserEntityServiceImpl extends ServiceImpl<RegisterUserEntit
@Override
@Override
public
List
<
Long
>
getAccountIdListFromPackage
(
Long
packageId
)
{
public
List
<
Long
>
getAccountIdListFromPackage
(
Long
packageId
)
{
return
baseMapper
.
getAuthListFromPackage
(
packageId
);
return
baseMapper
.
getAuthListFromPackage
(
packageId
);
}
}
@Override
@Override
public
List
<
CrowdPackageUserVO
>
getCurrentInPackUserList
(
Long
packageId
)
{
public
List
<
CrowdPackageUserVO
>
getCurrentInPackUserList
(
Long
packageId
,
Boolean
isLeftJoin
)
{
if
(
isLeftJoin
!=
null
&&
isLeftJoin
){
return
baseMapper
.
getCurrentInPackUserList
(
packageId
);
return
baseMapper
.
getCurrentInPackUserList
(
packageId
);
}
else
{
return
baseMapper
.
getCurrentInPackUserListWithoutAccountId
(
packageId
);
}
}
}
}
}
src/main/java/com/yaoyaozw/customer/service/wechat/service/WeChatService.java
浏览文件 @
117ec7ed
package
com
.
yaoyaozw
.
customer
.
service
.
wechat
.
service
;
package
com
.
yaoyaozw
.
customer
.
service
.
wechat
.
service
;
import
com.yaoyaozw.customer.entity.AuthorizerToken
;
import
com.yaoyaozw.customer.entity.CustomerDelayPublish
;
import
com.yaoyaozw.customer.entity.CustomerDelayPublish
;
import
com.yaoyaozw.customer.entity.CustomerGraphics
;
import
com.yaoyaozw.customer.entity.CustomerGraphics
;
import
com.yaoyaozw.customer.entity.RegisterUserEntity
;
import
com.yaoyaozw.customer.entity.RegisterUserEntity
;
...
@@ -18,6 +19,6 @@ public interface WeChatService {
...
@@ -18,6 +19,6 @@ public interface WeChatService {
*/
*/
Future
<
CustomerDelayPublish
>
sendCustomerDelayMessage
(
String
token
,
CustomerDelayPublish
user
,
Map
<
Integer
,
CustomerDelayItemVO
>
delaySortMap
);
Future
<
CustomerDelayPublish
>
sendCustomerDelayMessage
(
String
token
,
CustomerDelayPublish
user
,
Map
<
Integer
,
CustomerDelayItemVO
>
delaySortMap
);
void
sendCustomerMessage
(
String
appid
,
String
token
,
CustomerGraphics
customerGraphics
,
List
<
CrowdPackageUserVO
>
openidList
,
List
<
ReferralEntityVo
>
referralEntityVo
);
void
sendCustomerMessage
(
String
appid
,
AuthorizerToken
authorizerToken
,
CustomerGraphics
customerGraphics
,
List
<
CrowdPackageUserVO
>
openidList
,
List
<
ReferralEntityVo
>
referralEntityVo
);
}
}
src/main/java/com/yaoyaozw/customer/service/wechat/service/WeChatServiceImpl.java
浏览文件 @
117ec7ed
package
com
.
yaoyaozw
.
customer
.
service
.
wechat
.
service
;
package
com
.
yaoyaozw
.
customer
.
service
.
wechat
.
service
;
import
com.yaoyaozw.customer.entity.AuthorizerToken
;
import
com.yaoyaozw.customer.entity.CustomerDelayPublish
;
import
com.yaoyaozw.customer.entity.CustomerDelayPublish
;
import
com.yaoyaozw.customer.entity.CustomerGraphics
;
import
com.yaoyaozw.customer.entity.CustomerGraphics
;
import
com.yaoyaozw.customer.service.ReferralEntityService
;
import
com.yaoyaozw.customer.service.ReferralEntityService
;
...
@@ -23,17 +24,24 @@ import java.util.Date;
...
@@ -23,17 +24,24 @@ import java.util.Date;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Service
@Service
public
class
WeChatServiceImpl
implements
WeChatService
{
public
class
WeChatServiceImpl
implements
WeChatService
{
private
String
customerPath
=
""
;
private
String
customerPath
=
"
https://api.weixin.qq.com/cgi-bin/message/custom/send
"
;
private
static
final
String
CUSTOMER_TEXT
=
"text"
;
private
static
final
String
CUSTOMER_TEXT
=
"text"
;
private
static
final
String
CUSTOMER_NEWS
=
"news"
;
private
static
final
String
CUSTOMER_NEWS
=
"news"
;
private
static
final
int
THREAD_NUM
=
1000
;
private
static
final
ThreadPoolExecutor
EXECUTOR
=
new
ThreadPoolExecutor
(
20
,
100
,
60L
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<>(
2
),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
@Autowired
@Autowired
private
WeChatRestService
weChatRestService
;
private
WeChatRestService
weChatRestService
;
...
@@ -58,38 +66,72 @@ public class WeChatServiceImpl implements WeChatService{
...
@@ -58,38 +66,72 @@ public class WeChatServiceImpl implements WeChatService{
@Override
@Override
public
void
sendCustomerMessage
(
String
appid
,
String
token
,
CustomerGraphics
customerGraphics
,
List
<
CrowdPackageUserVO
>
openidList
,
List
<
ReferralEntityVo
>
referralEntityVo
)
{
public
void
sendCustomerMessage
(
String
appid
,
AuthorizerToken
authorizerToken
,
CustomerGraphics
customerGraphics
,
List
<
CrowdPackageUserVO
>
openidList
,
List
<
ReferralEntityVo
>
referralEntityVo
)
{
//根据公众号发送客服
//根据公众号发送客服
String
fullPath
=
customerPath
+
"?
"
+
token
;
String
fullPath
=
customerPath
+
"?
access_token="
+
authorizerToken
.
getAuthorizerAccessToken
()
;
//构建请求参数(文本/图文)
//构建请求参数(文本/图文)
WeChatCustomerRequestEntity
customerRequest
=
buildCustomerRequest
(
customerGraphics
,
referralEntityVo
);
WeChatCustomerRequestEntity
customerRequest
=
buildCustomerRequest
(
customerGraphics
,
referralEntityVo
);
if
(
customerRequest
!=
null
){
for
(
int
i
=
0
;
i
<
openidList
.
size
();
i
+=
THREAD_NUM
)
{
List
<
CrowdPackageUserVO
>
subOpenidList
=
openidList
.
subList
(
i
,
Math
.
min
(
i
+
THREAD_NUM
,
openidList
.
size
()));
//TODO:配置多线程+测试
EXECUTOR
.
execute
(()->{
for
(
CrowdPackageUserVO
crowdPackageUserVO
:
subOpenidList
)
{
//遍历人群包,每个用户一发
customerRequest
.
setTouser
(
crowdPackageUserVO
.
getOpenId
());
try
{
try
{
System
.
err
.
println
(
customerRequest
.
getTouser
());
ResponseEntity
<
WeChatResponseEntity
>
response
=
weChatRestService
.
sendPostRequest
(
fullPath
,
WeChatResponseEntity
.
class
,
customerRequest
);
ResponseEntity
<
WeChatResponseEntity
>
response
=
weChatRestService
.
sendPostRequest
(
fullPath
,
WeChatResponseEntity
.
class
,
customerRequest
);
WeChatResponseEntity
body
=
response
.
getBody
();
WeChatResponseEntity
body
=
response
.
getBody
();
System
.
err
.
println
(
body
);
System
.
err
.
println
(
body
);
}
catch
(
URISyntaxException
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
});
}
}
}
}
private
WeChatCustomerRequestEntity
buildCustomerRequest
(
CustomerGraphics
customerGraphics
,
List
<
ReferralEntityVo
>
urlList
){
private
WeChatCustomerRequestEntity
buildCustomerRequest
(
CustomerGraphics
customerGraphics
,
List
<
ReferralEntityVo
>
urlList
){
//类型判断
//类型判断
if
(
CUSTOMER_TEXT
.
equals
(
customerGraphics
.
getType
())){
if
(
CUSTOMER_TEXT
.
equals
(
customerGraphics
.
getType
())){
//文本类客服,需要判断替换链接的个数
Map
<
Integer
,
String
>
sortReferral
=
urlList
.
stream
().
collect
(
Collectors
.
toMap
(
ReferralEntityVo:
:
getSort
,
ReferralEntityVo:
:
getReferral
,
(
v1
,
v2
)
->
v2
));
return
new
WeChatCustomerRequestEntity
(
CUSTOMER_TEXT
,
customerGraphics
.
getContent
());
if
(
customerGraphics
.
getReferralSize
()!=
null
&&
customerGraphics
.
getReferralSize
().
equals
(
sortReferral
.
size
())){
}
else
if
(
CUSTOMER_NEWS
.
equals
(
customerGraphics
.
getType
())){
String
content
=
customerGraphics
.
getContent
();
//TODO:配置文本,多条链接替换进content
for
(
Map
.
Entry
<
Integer
,
String
>
replaceReferral
:
sortReferral
.
entrySet
())
{
return
new
WeChatCustomerRequestEntity
(
CUSTOMER_NEWS
,
customerGraphics
.
getExtendTitle
(),
urlList
.
get
(
0
).
getReferral
(),
customerGraphics
.
getContent
(),
customerGraphics
.
getCoverUrl
()
);
Integer
sort
=
replaceReferral
.
getKey
(
);
String
url
=
replaceReferral
.
getValue
();
//替换占位符
content
=
content
.
replace
(
"占位符常量"
+
sort
,
url
);
}
return
new
WeChatCustomerRequestEntity
(
CUSTOMER_TEXT
,
content
);
}
else
{
return
null
;
}
}
}
else
if
(
CUSTOMER_NEWS
.
equals
(
customerGraphics
.
getType
())){
return
new
WeChatCustomerRequestEntity
(
CUSTOMER_NEWS
,
customerGraphics
.
getExtendTitle
(),
customerGraphics
.
getContent
(),
urlList
.
get
(
0
).
getReferral
(),
customerGraphics
.
getCoverUrl
());
}
return
null
;
return
null
;
}
}
}
}
src/main/java/com/yaoyaozw/customer/vo/referral/ReferralEntityVo.java
浏览文件 @
117ec7ed
...
@@ -13,9 +13,13 @@ public class ReferralEntityVo implements Serializable {
...
@@ -13,9 +13,13 @@ public class ReferralEntityVo implements Serializable {
private
Long
materialGraphicsId
;
private
Long
materialGraphicsId
;
private
Lo
ng
accountId
;
private
Stri
ng
accountId
;
private
String
appid
;
private
String
appid
;
private
String
referral
;
private
String
referral
;
private
Integer
sort
;
}
}
src/main/resources/mapper/ReferralEntityMapper.xml
浏览文件 @
117ec7ed
...
@@ -32,13 +32,13 @@
...
@@ -32,13 +32,13 @@
<select
id=
"findByMaterialGraphicsId"
resultType=
"com.yaoyaozw.customer.vo.referral.ReferralEntityVo"
>
<select
id=
"findByMaterialGraphicsId"
resultType=
"com.yaoyaozw.customer.vo.referral.ReferralEntityVo"
>
select material_graphics_id ,referral.account_id,authInfo.appid,referral.referral
select material_graphics_id ,referral.account_id,authInfo.appid,referral.referral
,referral.sort
from referral_entity referral left join authorizer_info authInfo
from referral_entity referral left join authorizer_info authInfo
on referral.account_id=authInfo.account_id
on referral.account_id=authInfo.account_id
where referral.material_graphics_id=#{graphicsId} and referral.is_deleted=0
where referral.material_graphics_id=#{graphicsId} and referral.is_deleted=0
and referral.account_id is not null
...
...
src/main/resources/mapper/RegisterUserEntityMapper.xml
浏览文件 @
117ec7ed
...
@@ -85,4 +85,18 @@
...
@@ -85,4 +85,18 @@
</select>
</select>
<select
id=
"getCurrentInPackUserListWithoutAccountId"
resultType=
"com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO"
>
select
id,
setup_id,
open_id,
in_Package,
app_id
from register_user_entity
where find_in_set(#{packageId}, in_package)
</select>
</mapper>
</mapper>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论