Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 57986c2c
authored
Dec 02, 2021
by
linkwechat8856@163.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
重构H5消息相关接口;修复朋友圈不能创建任务BUG
1 parent
adbcb5ab
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
232 additions
and
99 deletions
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerSeasController.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeMomentsController.java
linkwe-common/src/main/java/com/linkwechat/common/config/WeComeConfig.java
linkwe-common/src/main/java/com/linkwechat/common/core/domain/entity/WeCorpAccount.java
linkwe-common/src/main/java/com/linkwechat/common/enums/CommunityTaskType.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeAppDto.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeAuthorizeUrlService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeMessagePushService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeAuthorizeUrlServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeGroupSopServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeMessagePushServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeMomentsServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WePresTagGroupTaskServiceImpl.java
pom.xml
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerSeasController.java
View file @
57986c2
...
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
com.linkwechat.common.core.controller.BaseController
;
import
com.linkwechat.common.core.controller.BaseController
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.enums.CommunityTaskType
;
import
com.linkwechat.common.exception.CustomException
;
import
com.linkwechat.common.exception.CustomException
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
...
@@ -15,6 +16,7 @@ import com.linkwechat.wecom.domain.WeCustomerSeas;
...
@@ -15,6 +16,7 @@ import com.linkwechat.wecom.domain.WeCustomerSeas;
import
com.linkwechat.wecom.domain.vo.CustomerSeasRecordVo
;
import
com.linkwechat.wecom.domain.vo.CustomerSeasRecordVo
;
import
com.linkwechat.wecom.service.IWeCustomerMessagePushService
;
import
com.linkwechat.wecom.service.IWeCustomerMessagePushService
;
import
com.linkwechat.wecom.service.IWeCustomerSeasService
;
import
com.linkwechat.wecom.service.IWeCustomerSeasService
;
import
com.linkwechat.wecom.service.IWeMessagePushService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -33,8 +35,10 @@ public class WeCustomerSeasController extends BaseController {
...
@@ -33,8 +35,10 @@ public class WeCustomerSeasController extends BaseController {
private
IWeCustomerSeasService
iWeCustomerSeasService
;
private
IWeCustomerSeasService
iWeCustomerSeasService
;
@Autowired
@Autowired
private
IWe
CustomerMessagePushService
iWeCustomer
MessagePushService
;
private
IWe
MessagePushService
iWe
MessagePushService
;
/**
/**
* 客户公海模版下载
* 客户公海模版下载
...
@@ -140,7 +144,7 @@ public class WeCustomerSeasController extends BaseController {
...
@@ -140,7 +144,7 @@ public class WeCustomerSeasController extends BaseController {
* @param ids
* @param ids
* @return
* @return
*/
*/
@
Pos
tMapping
(
"/remidUser/{ids}"
)
@
Ge
tMapping
(
"/remidUser/{ids}"
)
public
AjaxResult
remidUser
(
@PathVariable
Long
[]
ids
){
public
AjaxResult
remidUser
(
@PathVariable
Long
[]
ids
){
List
<
WeCustomerSeas
>
weCustomerSeas
List
<
WeCustomerSeas
>
weCustomerSeas
...
@@ -149,8 +153,9 @@ public class WeCustomerSeasController extends BaseController {
...
@@ -149,8 +153,9 @@ public class WeCustomerSeasController extends BaseController {
if
(
CollectionUtil
.
isNotEmpty
(
weCustomerSeas
)){
if
(
CollectionUtil
.
isNotEmpty
(
weCustomerSeas
)){
weCustomerSeas
.
stream
().
collect
(
Collectors
.
groupingBy
(
WeCustomerSeas:
:
getAddUserId
)).
forEach
((
k
,
v
)->{
weCustomerSeas
.
stream
().
collect
(
Collectors
.
groupingBy
(
WeCustomerSeas:
:
getAddUserId
)).
forEach
((
k
,
v
)->{
String
messageRemindContent
=
"管理员给你分配了"
+
v
.
size
()+
"个客户还未添加,快去复制电话号码添加客户吧,<a href='%s?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect'>点击查看详情</a>"
;
iWeMessagePushService
.
pushMessageSelfH5
(
ListUtil
.
toList
(
k
),
iWeCustomerMessagePushService
.
messagePushRemind
(
messageRemindContent
,
k
);
"管理员给你分配了"
+
v
.
size
()+
"个客户还未添加,快去复制电话号码添加客户吧,"
,
CommunityTaskType
.
SEAS
.
getType
());
});
});
...
...
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeMomentsController.java
View file @
57986c2
...
@@ -4,8 +4,10 @@ import com.linkwechat.common.constant.WeConstans;
...
@@ -4,8 +4,10 @@ import com.linkwechat.common.constant.WeConstans;
import
com.linkwechat.common.core.controller.BaseController
;
import
com.linkwechat.common.core.controller.BaseController
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.wecom.client.WeMomentsClient
;
import
com.linkwechat.wecom.constants.SynchRecordConstants
;
import
com.linkwechat.wecom.constants.SynchRecordConstants
;
import
com.linkwechat.wecom.domain.WeMoments
;
import
com.linkwechat.wecom.domain.WeMoments
;
import
com.linkwechat.wecom.domain.dto.moments.MomentsCreateResultDto
;
import
com.linkwechat.wecom.service.IWeMomentsService
;
import
com.linkwechat.wecom.service.IWeMomentsService
;
import
com.linkwechat.wecom.service.IWeSynchRecordService
;
import
com.linkwechat.wecom.service.IWeSynchRecordService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -28,6 +30,11 @@ public class WeMomentsController extends BaseController {
...
@@ -28,6 +30,11 @@ public class WeMomentsController extends BaseController {
IWeSynchRecordService
iWeSynchRecordService
;
IWeSynchRecordService
iWeSynchRecordService
;
@Autowired
WeMomentsClient
weMomentsClient
;
/**
/**
* 获取朋友圈列表
* 获取朋友圈列表
* @param weMoments
* @param weMoments
...
...
linkwe-common/src/main/java/com/linkwechat/common/config/WeComeConfig.java
View file @
57986c2
...
@@ -46,4 +46,6 @@ public class WeComeConfig {
...
@@ -46,4 +46,6 @@ public class WeComeConfig {
* 需要进行重试的企业微信请求错误码
* 需要进行重试的企业微信请求错误码
*/
*/
private
List
<
Integer
>
weNeedRetryErrorCodes
;
private
List
<
Integer
>
weNeedRetryErrorCodes
;
}
}
linkwe-common/src/main/java/com/linkwechat/common/core/domain/entity/WeCorpAccount.java
View file @
57986c2
...
@@ -124,6 +124,28 @@ public class WeCorpAccount extends BaseEntity
...
@@ -124,6 +124,28 @@ public class WeCorpAccount extends BaseEntity
**********************************************/
**********************************************/
/***********************************************
*******************H5跳转start******************
**********************************************/
/**JS SDK 身份校验url*/
private
String
authorizeUrl
;
/**群sop和老客标签建群,跳转链接*/
private
String
sopTagRedirectUrl
;
/**客户公海,跳转链接*/
private
String
seasRedirectUrl
;
/***********************************************
*******************H5跳转end*******************
**********************************************/
/**客服密钥*/
/**客服密钥*/
private
String
kfSecret
;
private
String
kfSecret
;
...
@@ -136,4 +158,8 @@ public class WeCorpAccount extends BaseEntity
...
@@ -136,4 +158,8 @@ public class WeCorpAccount extends BaseEntity
private
String
customerChurnNoticeSwitch
=
Constants
.
NORMAL_CODE
;
private
String
customerChurnNoticeSwitch
=
Constants
.
NORMAL_CODE
;
}
}
linkwe-common/src/main/java/com/linkwechat/common/enums/CommunityTaskType.java
View file @
57986c2
...
@@ -3,7 +3,7 @@ package com.linkwechat.common.enums;
...
@@ -3,7 +3,7 @@ package com.linkwechat.common.enums;
import
lombok.Getter
;
import
lombok.Getter
;
/**
/**
*
社群运营
H5列表页数据类型
* H5列表页数据类型
* @Author Hang
* @Author Hang
* @Date 2021/3/24 11:02
* @Date 2021/3/24 11:02
*/
*/
...
@@ -12,6 +12,8 @@ public enum CommunityTaskType {
...
@@ -12,6 +12,8 @@ public enum CommunityTaskType {
TAG
(
1
,
"老客标签建群"
),
TAG
(
1
,
"老客标签建群"
),
SEAS
(
3
,
"客户公海"
),
SOP
(
2
,
"群sop"
);
SOP
(
2
,
"群sop"
);
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeAppDto.java
View file @
57986c2
...
@@ -20,11 +20,6 @@ public class WeAppDto extends WeResultDto{
...
@@ -20,11 +20,6 @@ public class WeAppDto extends WeResultDto{
private
String
name
;
private
String
name
;
//企业应用方形头像url
//企业应用方形头像url
private
String
square_logo_url
;
private
String
square_logo_url
;
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeAuthorizeUrlService.java
0 → 100644
View file @
57986c2
package
com
.
linkwechat
.
wecom
.
service
;
public
interface
IWeAuthorizeUrlService
{
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeMessagePushService.java
View file @
57986c2
...
@@ -50,4 +50,10 @@ public interface IWeMessagePushService {
...
@@ -50,4 +50,10 @@ public interface IWeMessagePushService {
* @return 结果
* @return 结果
*/
*/
public
int
deleteWeMessagePushById
(
Long
messagePushId
);
public
int
deleteWeMessagePushById
(
Long
messagePushId
);
/**
* 推送信息给员工附带自己的url链接,跳转H5
*/
public
void
pushMessageSelfH5
(
List
<
String
>
toUser
,
String
textContent
,
Integer
taskType
);
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeAuthorizeUrlServiceImpl.java
0 → 100644
View file @
57986c2
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.linkwechat.wecom.service.IWeAuthorizeUrlService
;
import
org.springframework.stereotype.Service
;
/**
* 认证链接生成接口
*/
@Service
public
class
WeAuthorizeUrlServiceImpl
implements
IWeAuthorizeUrlService
{
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeGroupSopServiceImpl.java
View file @
57986c2
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.common.core.domain.entity.WeCorpAccount
;
import
com.linkwechat.common.core.domain.entity.WeCorpAccount
;
...
@@ -17,6 +18,7 @@ import com.linkwechat.wecom.domain.vo.WeMaterialVo;
...
@@ -17,6 +18,7 @@ import com.linkwechat.wecom.domain.vo.WeMaterialVo;
import
com.linkwechat.wecom.mapper.*
;
import
com.linkwechat.wecom.mapper.*
;
import
com.linkwechat.wecom.service.IWeCorpAccountService
;
import
com.linkwechat.wecom.service.IWeCorpAccountService
;
import
com.linkwechat.wecom.service.IWeGroupSopService
;
import
com.linkwechat.wecom.service.IWeGroupSopService
;
import
com.linkwechat.wecom.service.IWeMessagePushService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -54,17 +56,11 @@ public class WeGroupSopServiceImpl extends ServiceImpl<WeGroupSopMapper, WeGroup
...
@@ -54,17 +56,11 @@ public class WeGroupSopServiceImpl extends ServiceImpl<WeGroupSopMapper, WeGroup
@Autowired
@Autowired
private
WeGroupSopPicMapper
sopPicMapper
;
private
WeGroupSopPicMapper
sopPicMapper
;
@Autowired
private
IWeCorpAccountService
corpAccountService
;
@Autowired
@Autowired
private
WeMessagePushClient
messagePushClient
;
private
IWeMessagePushService
weMessagePushService
;
@Value
(
"${wecome.authorizeUrl}"
)
private
String
authorizeUrl
;
@Value
(
"${wecome.authorizeRedirectUrl}"
)
private
String
authorizeRedirectUrl
;
/**
/**
* 通过规则id获取sop规则
* 通过规则id获取sop规则
...
@@ -332,41 +328,57 @@ public class WeGroupSopServiceImpl extends ServiceImpl<WeGroupSopMapper, WeGroup
...
@@ -332,41 +328,57 @@ public class WeGroupSopServiceImpl extends ServiceImpl<WeGroupSopMapper, WeGroup
@Override
@Override
// @Async
// @Async
public
void
sendMessage
(
List
<
String
>
groupIdList
)
{
public
void
sendMessage
(
List
<
String
>
groupIdList
)
{
// 构造请求参数
WeMessagePushDto
pushDto
=
new
WeMessagePushDto
();
// 查询群聊列表,获取群主列表
// 查询群聊列表,获取群主列表
LambdaQueryWrapper
<
WeGroup
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
WeGroup
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
in
(
WeGroup:
:
getChatId
,
groupIdList
);
queryWrapper
.
in
(
WeGroup:
:
getChatId
,
groupIdList
);
List
<
WeGroup
>
groupList
=
groupMapper
.
selectList
(
queryWrapper
);
List
<
WeGroup
>
groupList
=
groupMapper
.
selectList
(
queryWrapper
);
String
toUser
=
groupList
if
(
CollectionUtil
.
isNotEmpty
(
groupList
)){
.
stream
()
.
map
(
WeGroup:
:
getOwner
)
weMessagePushService
.
pushMessageSelfH5
(
.
collect
(
Collectors
.
joining
(
"|"
));
groupList
.
stream
().
map
(
WeGroup:
:
getOwner
).
collect
(
Collectors
.
toList
()),
pushDto
.
setTouser
(
toUser
);
"你有新的SOP待发送,"
,
CommunityTaskType
.
SOP
.
getType
()
// 获取agentId
);
WeCorpAccount
validWeCorpAccount
=
corpAccountService
.
findValidWeCorpAccount
();
String
agentId
=
validWeCorpAccount
.
getAgentId
();
String
corpId
=
validWeCorpAccount
.
getCorpId
();
if
(
StringUtils
.
isEmpty
(
agentId
))
{
throw
new
WeComException
(
"当前agentId不可用或不存在"
);
}
}
pushDto
.
setAgentid
(
Integer
.
valueOf
(
agentId
));
// 设置消息内容
pushDto
.
setMsgtype
(
"text"
);
TextMessageDto
text
=
new
TextMessageDto
();
String
REDIRECT_URI
=
URLEncoder
.
encode
(
String
.
format
(
"%s?corpId=%s&agentId=%s&type=%s"
,
authorizeRedirectUrl
,
corpId
,
agentId
,
CommunityTaskType
.
SOP
.
getType
()));
String
context
=
String
.
format
(
"你有新的SOP待发送,<a href='%s?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect'>请点击此链接查看</a>"
,
authorizeUrl
,
corpId
,
REDIRECT_URI
);
text
.
setContent
(
context
);
pushDto
.
setText
(
text
);
// 请求消息推送接口,获取结果 [消息推送 - 发送应用消息]
messagePushClient
.
sendMessageToUser
(
pushDto
,
agentId
);
// // 构造请求参数
// WeMessagePushDto pushDto = new WeMessagePushDto();
// // 查询群聊列表,获取群主列表
// LambdaQueryWrapper<WeGroup> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.in(WeGroup::getChatId, groupIdList);
// List<WeGroup> groupList = groupMapper.selectList(queryWrapper);
// String toUser = groupList
// .stream()
// .map(WeGroup::getOwner)
// .collect(Collectors.joining("|"));
// pushDto.setTouser(toUser);
//
// // 获取agentId
// WeCorpAccount validWeCorpAccount = corpAccountService.findValidWeCorpAccount();
// String agentId = validWeCorpAccount.getAgentId();
// String corpId = validWeCorpAccount.getCorpId();
// if (StringUtils.isEmpty(agentId)) {
// throw new WeComException("当前agentId不可用或不存在");
// }
// pushDto.setAgentid(Integer.valueOf(agentId));
//
// // 设置消息内容
// pushDto.setMsgtype("text");
//
// TextMessageDto text = new TextMessageDto();
// String REDIRECT_URI = URLEncoder.encode(String.format("%s?corpId=%s&agentId=%s&type=%s", authorizeRedirectUrl, corpId, agentId, CommunityTaskType.SOP.getType()));
// String context = String.format(
// "你有新的SOP待发送,<a href='%s?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect'>请点击此链接查看</a>",
// authorizeUrl, corpId, REDIRECT_URI);
// text.setContent(context);
// pushDto.setText(text);
//
// // 请求消息推送接口,获取结果 [消息推送 - 发送应用消息]
// messagePushClient.sendMessageToUser(pushDto, agentId);
}
}
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeMessagePushServiceImpl.java
View file @
57986c2
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.google.common.base.Joiner
;
import
com.linkwechat.common.core.domain.entity.WeCorpAccount
;
import
com.linkwechat.common.enums.CommunityTaskType
;
import
com.linkwechat.common.enums.PushType
;
import
com.linkwechat.common.enums.PushType
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.wecom.client.WeMessagePushClient
;
import
com.linkwechat.wecom.domain.WeMessagePush
;
import
com.linkwechat.wecom.domain.WeMessagePush
;
import
com.linkwechat.wecom.domain.dto.WeMessagePushDto
;
import
com.linkwechat.wecom.domain.dto.message.TextMessageDto
;
import
com.linkwechat.wecom.mapper.WeMessagePushMapper
;
import
com.linkwechat.wecom.mapper.WeMessagePushMapper
;
import
com.linkwechat.wecom.service.IWeCorpAccountService
;
import
com.linkwechat.wecom.service.IWeMessagePushService
;
import
com.linkwechat.wecom.service.IWeMessagePushService
;
import
com.linkwechat.wecom.strategy.MessageContext
;
import
com.linkwechat.wecom.strategy.MessageContext
;
import
com.linkwechat.wecom.strategy.SendMessageToUserGroupStrategy
;
import
com.linkwechat.wecom.strategy.SendMessageToUserGroupStrategy
;
...
@@ -14,6 +23,7 @@ import com.linkwechat.wecom.strategy.SendMessageToUserStrategy;
...
@@ -14,6 +23,7 @@ import com.linkwechat.wecom.strategy.SendMessageToUserStrategy;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.net.URLEncoder
;
import
java.util.*
;
import
java.util.*
;
/**
/**
...
@@ -34,6 +44,12 @@ public class WeMessagePushServiceImpl implements IWeMessagePushService {
...
@@ -34,6 +44,12 @@ public class WeMessagePushServiceImpl implements IWeMessagePushService {
@Autowired
@Autowired
private
SendMessageToUserStrategy
sendMessageToUserStrategy
;
private
SendMessageToUserStrategy
sendMessageToUserStrategy
;
@Autowired
private
IWeCorpAccountService
corpAccountService
;
@Autowired
private
WeMessagePushClient
messagePushClient
;
@Override
@Override
public
WeMessagePush
selectWeMessagePushById
(
Long
messagePushId
)
{
public
WeMessagePush
selectWeMessagePushById
(
Long
messagePushId
)
{
return
weMessagePushMapper
.
selectById
(
messagePushId
);
return
weMessagePushMapper
.
selectById
(
messagePushId
);
...
@@ -76,4 +92,62 @@ public class WeMessagePushServiceImpl implements IWeMessagePushService {
...
@@ -76,4 +92,62 @@ public class WeMessagePushServiceImpl implements IWeMessagePushService {
return
weMessagePushMapper
.
deleteById
(
messagePushId
);
return
weMessagePushMapper
.
deleteById
(
messagePushId
);
}
}
@Override
public
void
pushMessageSelfH5
(
List
<
String
>
toUser
,
String
textContent
,
Integer
taskType
)
{
if
(
CollectionUtil
.
isEmpty
(
toUser
)){
throw
new
WeComException
(
"接受人不可为空"
);
}
WeMessagePushDto
pushDto
=
new
WeMessagePushDto
();
// 获取agentId
WeCorpAccount
validWeCorpAccount
=
corpAccountService
.
findValidWeCorpAccount
();
String
agentId
=
validWeCorpAccount
.
getAgentId
();
String
corpId
=
validWeCorpAccount
.
getCorpId
();
if
(
StringUtils
.
isEmpty
(
agentId
))
{
throw
new
WeComException
(
"当前agentId不可用或不存在"
);
}
if
(
StringUtils
.
isEmpty
(
validWeCorpAccount
.
getAuthorizeUrl
())){
throw
new
WeComException
(
"JS SDK 身份校验url不可为空"
);
}
pushDto
.
setAgentid
(
Integer
.
valueOf
(
agentId
));
//推送给指定员工
pushDto
.
setTouser
(
Joiner
.
on
(
"|"
).
join
(
toUser
));
// 设置消息内容
pushDto
.
setMsgtype
(
"text"
);
TextMessageDto
text
=
new
TextMessageDto
();
String
REDIRECT_URI
=
null
;
if
(
taskType
.
equals
(
CommunityTaskType
.
SEAS
.
getType
())){
//客户公海链接
if
(
StringUtils
.
isEmpty
(
validWeCorpAccount
.
getSeasRedirectUrl
())){
throw
new
WeComException
(
"客户公海H5跳转链接不可为空"
);
}
URLEncoder
.
encode
(
String
.
format
(
"%s?corpId=%s&agentId=%s"
,
validWeCorpAccount
.
getSeasRedirectUrl
()
,
corpId
,
agentId
));
}
else
{
//群sop与老客标签建群
if
(
StringUtils
.
isEmpty
(
validWeCorpAccount
.
getSopTagRedirectUrl
())){
throw
new
WeComException
(
"群SOP与老客标签建群H5跳转链接不可为空"
);
}
REDIRECT_URI
=
URLEncoder
.
encode
(
String
.
format
(
"%s?corpId=%s&agentId=%s&type=%s"
,
validWeCorpAccount
.
getSopTagRedirectUrl
(),
corpId
,
agentId
,
taskType
));
}
if
(
StringUtils
.
isNotEmpty
(
REDIRECT_URI
)){
String
context
=
String
.
format
(
textContent
+
"<a href='%s?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect'>请点击此链接查看</a>"
,
validWeCorpAccount
.
getAuthorizeUrl
(),
corpId
,
REDIRECT_URI
);
text
.
setContent
(
context
);
pushDto
.
setText
(
text
);
// 请求消息推送接口,获取结果 [消息推送 - 发送应用消息]
messagePushClient
.
sendMessageToUser
(
pushDto
,
agentId
);
}
}
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeMomentsServiceImpl.java
View file @
57986c2
...
@@ -36,6 +36,7 @@ import java.text.ParseException;
...
@@ -36,6 +36,7 @@ import java.text.ParseException;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
@Service
@Service
public
class
WeMomentsServiceImpl
extends
ServiceImpl
<
WeMomentsMapper
,
WeMoments
>
implements
IWeMomentsService
{
public
class
WeMomentsServiceImpl
extends
ServiceImpl
<
WeMomentsMapper
,
WeMoments
>
implements
IWeMomentsService
{
...
@@ -92,11 +93,17 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
...
@@ -92,11 +93,17 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
List
<
WeMoments
.
OtherContent
>
otherContent
=
weMoments
.
getOtherContent
();
List
<
WeMoments
.
OtherContent
>
otherContent
=
weMoments
.
getOtherContent
();
if
(
CollectionUtil
.
isNotEmpty
(
otherContent
)){
if
(
CollectionUtil
.
isNotEmpty
(
otherContent
)){
List
<
WeMoments
.
OtherContent
>
otherContents
=
otherContent
.
stream
().
filter
(
s
->
StringUtils
.
isNotEmpty
(
s
.
getAnnexType
())
&&
StringUtils
.
isNotEmpty
(
s
.
getAnnexUrl
()))
.
collect
(
Collectors
.
toList
());
if
(
CollectionUtil
.
isNotEmpty
(
otherContents
)){
List
<
MomentsParamDto
.
BaseAttachments
>
attachments
=
new
ArrayList
<>();
List
<
MomentsParamDto
.
BaseAttachments
>
attachments
=
new
ArrayList
<>();
//图片
//图片
if
(
weMoments
.
getContentType
().
equals
(
MediaType
.
IMAGE
.
getMediaType
())){
if
(
weMoments
.
getContentType
().
equals
(
MediaType
.
IMAGE
.
getMediaType
())){
otherContent
.
stream
().
forEach
(
image
->{
otherContents
.
stream
().
forEach
(
image
->{
String
media_id
=
iWeMaterialService
.
uploadAttachmentMaterial
(
image
.
getAnnexUrl
(),
String
media_id
=
iWeMaterialService
.
uploadAttachmentMaterial
(
image
.
getAnnexUrl
(),
MediaType
.
IMAGE
.
getMediaType
(),
MediaType
.
IMAGE
.
getMediaType
(),
1
1
...
@@ -124,7 +131,7 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
...
@@ -124,7 +131,7 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
//视频
//视频
if
(
weMoments
.
getContentType
().
equals
(
MediaType
.
VIDEO
.
getMediaType
())){
if
(
weMoments
.
getContentType
().
equals
(
MediaType
.
VIDEO
.
getMediaType
())){
otherContent
.
stream
().
forEach
(
video
->{
otherContents
.
stream
().
forEach
(
video
->{
String
media_id
=
iWeMaterialService
.
uploadAttachmentMaterial
(
video
.
getAnnexUrl
(),
String
media_id
=
iWeMaterialService
.
uploadAttachmentMaterial
(
video
.
getAnnexUrl
(),
MediaType
.
VIDEO
.
getMediaType
(),
MediaType
.
VIDEO
.
getMediaType
(),
...
@@ -152,7 +159,7 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
...
@@ -152,7 +159,7 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
//图文
//图文
if
(
weMoments
.
getContentType
().
equals
(
MediaType
.
LINK
.
getMediaType
())){
if
(
weMoments
.
getContentType
().
equals
(
MediaType
.
LINK
.
getMediaType
())){
otherContent
.
stream
().
forEach
(
link
->{
otherContents
.
stream
().
forEach
(
link
->{
attachments
.
add
(
attachments
.
add
(
MomentsParamDto
.
LinkAttachments
.
builder
()
MomentsParamDto
.
LinkAttachments
.
builder
()
.
msgtype
(
MediaType
.
LINK
.
getMediaType
())
.
msgtype
(
MediaType
.
LINK
.
getMediaType
())
...
@@ -177,6 +184,9 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
...
@@ -177,6 +184,9 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
attachments
attachments
);
);
}
}
}
...
@@ -217,18 +227,21 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
...
@@ -217,18 +227,21 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
//入库
//入库
if
(
weResultDto
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
)){
if
(
weResultDto
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
)){
weMoments
.
setJobId
(
weResultDto
.
getJobid
());
weMoments
.
setJobId
(
weResultDto
.
getJobid
());
//根据任务id,获取朋友圈主键
weMoments
.
setMomentId
(
weResultDto
.
getJobid
());
MomentsCreateResultDto
momentTaskResult
=
weMomentsClient
.
getMomentTaskResult
(
weResultDto
.
getJobid
());
if
(
momentTaskResult
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
)){
if
(
StringUtils
.
isNotEmpty
(
momentTaskResult
.
getResult
().
getMoment_id
())){
weMoments
.
setMomentId
(
momentTaskResult
.
getResult
().
getMoment_id
()
);
this
.
saveOrUpdate
(
weMoments
);
this
.
saveOrUpdate
(
weMoments
);
}
// //根据任务id,获取朋友圈主键
// MomentsCreateResultDto momentTaskResult
}
// = weMomentsClient.getMomentTaskResult(weResultDto.getJobid());
// if(momentTaskResult.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)){
//
// if(StringUtils.isNotEmpty(momentTaskResult.getResult().getMoment_id())){
// weMoments.setMomentId(
// momentTaskResult.getResult().getMoment_id()
// );
// this.saveOrUpdate(weMoments);
// }
//
// }
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WePresTagGroupTaskServiceImpl.java
View file @
57986c2
...
@@ -63,8 +63,6 @@ public class WePresTagGroupTaskServiceImpl extends ServiceImpl<WePresTagGroupTas
...
@@ -63,8 +63,6 @@ public class WePresTagGroupTaskServiceImpl extends ServiceImpl<WePresTagGroupTas
@Autowired
@Autowired
private
WeCustomerMessagePushClient
customerMessagePushClient
;
private
WeCustomerMessagePushClient
customerMessagePushClient
;
@Autowired
private
WeMessagePushClient
messagePushClient
;
@Autowired
@Autowired
private
IWeMaterialService
materialService
;
private
IWeMaterialService
materialService
;
...
@@ -72,20 +70,14 @@ public class WePresTagGroupTaskServiceImpl extends ServiceImpl<WePresTagGroupTas
...
@@ -72,20 +70,14 @@ public class WePresTagGroupTaskServiceImpl extends ServiceImpl<WePresTagGroupTas
@Autowired
@Autowired
private
WeGroupCodeMapper
groupCodeMapper
;
private
WeGroupCodeMapper
groupCodeMapper
;
@Autowired
private
IWeCorpAccountService
corpAccountService
;
@Autowired
@Autowired
private
WeCustomerMapper
customerMapper
;
private
WeCustomerMapper
customerMapper
;
@
Value
(
"${wecome.authorizeUrl}"
)
@
Autowired
private
String
authorizeUrl
;
private
IWeMessagePushService
weMessagePushService
;
@Value
(
"${wecome.authorizeRedirectUrl}"
)
private
String
authorizeRedirectUrl
;
@Autowired
private
IWeCustomerMessagePushService
weCustomerMessagePushService
;
/**
/**
* 添加新标签建群任务
* 添加新标签建群任务
...
@@ -440,34 +432,19 @@ public class WePresTagGroupTaskServiceImpl extends ServiceImpl<WePresTagGroupTas
...
@@ -440,34 +432,19 @@ public class WePresTagGroupTaskServiceImpl extends ServiceImpl<WePresTagGroupTas
* @param task 建群任务信息
* @param task 建群任务信息
*/
*/
private
void
sendEmployeeMessage
(
WePresTagGroupTask
task
)
{
private
void
sendEmployeeMessage
(
WePresTagGroupTask
task
)
{
WeMessagePushDto
pushDto
=
new
WeMessagePushDto
();
// 设置toUser参数
// 设置toUser参数
List
<
WeCommunityTaskEmplVo
>
employeeList
=
taskScopeMapper
.
getScopeListByTaskId
(
task
.
getTaskId
());
List
<
WeCommunityTaskEmplVo
>
employeeList
=
taskScopeMapper
.
getScopeListByTaskId
(
task
.
getTaskId
());
String
toUser
=
employeeList
.
stream
().
map
(
WeCommunityTaskEmplVo:
:
getUserId
).
collect
(
Collectors
.
joining
(
"|"
));
pushDto
.
setTouser
(
toUser
);
// 获取agentId
if
(
CollectionUtil
.
isNotEmpty
(
employeeList
)){
WeCorpAccount
validWeCorpAccount
=
corpAccountService
.
findValidWeCorpAccount
();
String
agentId
=
validWeCorpAccount
.
getAgentId
();
weMessagePushService
.
pushMessageSelfH5
(
String
corpId
=
validWeCorpAccount
.
getCorpId
();
employeeList
.
stream
().
map
(
WeCommunityTaskEmplVo:
:
getUserId
).
collect
(
Collectors
.
toList
()),
if
(
StringUtils
.
isEmpty
(
agentId
))
{
"你有一个新任务,"
,
throw
new
WeComException
(
"当前agentId不可用或不存在"
);
CommunityTaskType
.
TAG
.
getType
()
);
}
}
pushDto
.
setAgentid
(
Integer
.
valueOf
(
agentId
));
// 设置文本消息
TextMessageDto
text
=
new
TextMessageDto
();
String
REDIRECT_URI
=
URLEncoder
.
encode
(
String
.
format
(
"%s?corpId=%s&agentId=%s&type=%s"
,
authorizeRedirectUrl
,
corpId
,
agentId
,
CommunityTaskType
.
TAG
.
getType
()));
String
context
=
String
.
format
(
"你有一个新任务,<a href='%s?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect'>请点击此链接查看</a>"
,
authorizeUrl
,
corpId
,
REDIRECT_URI
);
text
.
setContent
(
context
);
pushDto
.
setText
(
text
);
pushDto
.
setMsgtype
(
"text"
);
// 请求消息推送接口,获取结果 [消息推送 - 发送应用消息]
log
.
debug
(
"发送个人群发信息 ============> "
);
messagePushClient
.
sendMessageToUser
(
pushDto
,
agentId
);
}
}
}
}
pom.xml
View file @
57986c2
...
@@ -308,13 +308,6 @@
...
@@ -308,13 +308,6 @@
</dependency>
</dependency>
<dependency>
<groupId>
com.github.jeffreyning
</groupId>
<artifactId>
mybatisplus-plus
</artifactId>
<version>
1.5.1-RELEASE
</version>
</dependency>
</dependencies>
</dependencies>
</dependencyManagement>
</dependencyManagement>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment