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 ff8f84a3
authored
Feb 09, 2021
by
leejoker
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/back_end_dev' into back_end_dev
2 parents
bf6380fe
4d364d69
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
297 additions
and
25 deletions
linkwe-admin/src/main/resources/application.yml
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMessageOriginalService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMessageService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMessgaeResultService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessageOriginalServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessagePushServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessageServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessgaeResultServiceImpl.java
linkwe-admin/src/main/resources/application.yml
View file @
ff8f84a
...
@@ -160,6 +160,10 @@ elasticsearch:
...
@@ -160,6 +160,10 @@ elasticsearch:
forest
:
forest
:
interceptors
:
com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor
interceptors
:
com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor
backend
:
httpclient
backend
:
httpclient
retry-count
:
1
# 请求失败后重试次数,默认为0次不重试
max-retry-interval
:
1000
#重试间隔时间
connect-timeout
:
3000
#链接超时时间
timeout
:
3000
# 请求超时时间
wecome
:
wecome
:
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMessageOriginalService.java
View file @
ff8f84a
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.linkwechat.wecom.domain.WeCustomerMessageOriginal
;
import
com.linkwechat.wecom.domain.WeCustomerMessageOriginal
;
import
com.linkwechat.wecom.domain.dto.message.AsyncResultDto
;
import
com.linkwechat.wecom.domain.dto.message.AsyncResultDto
;
import
com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto
;
import
com.linkwechat.wecom.domain.vo.CustomerMessagePushVo
;
import
com.linkwechat.wecom.domain.vo.CustomerMessagePushVo
;
import
java.util.List
;
import
java.util.List
;
...
@@ -15,12 +16,7 @@ import java.util.List;
...
@@ -15,12 +16,7 @@ import java.util.List;
* @date 2020-12-12
* @date 2020-12-12
*/
*/
public
interface
IWeCustomerMessageOriginalService
extends
IService
<
WeCustomerMessageOriginal
>
{
public
interface
IWeCustomerMessageOriginalService
extends
IService
<
WeCustomerMessageOriginal
>
{
/**
* 保存原始数据信息
* @param weCustomerMessageOriginal 原始数据信息
* @return
*/
int
saveWeCustomerMessageOriginal
(
WeCustomerMessageOriginal
weCustomerMessageOriginal
);
/**
/**
* 群发消息列表
* 群发消息列表
...
@@ -49,4 +45,12 @@ public interface IWeCustomerMessageOriginalService extends IService<WeCustomerMe
...
@@ -49,4 +45,12 @@ public interface IWeCustomerMessageOriginalService extends IService<WeCustomerMe
*/
*/
void
asyncResult
(
AsyncResultDto
asyncResultDto
)
throws
JsonProcessingException
;
void
asyncResult
(
AsyncResultDto
asyncResultDto
)
throws
JsonProcessingException
;
/**
* 保存原始数据信息表 WeCustomerMessageOriginal 主键id
*
* @param customerMessagePushDto
* @return
*/
public
long
saveWeCustomerMessageOriginal
(
CustomerMessagePushDto
customerMessagePushDto
);
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMessageService.java
View file @
ff8f84a
package
com
.
linkwechat
.
wecom
.
service
;
package
com
.
linkwechat
.
wecom
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.linkwechat.wecom.domain.WeCustomer
;
import
com.linkwechat.wecom.domain.WeCustomerMessage
;
import
com.linkwechat.wecom.domain.WeCustomerMessage
;
import
com.linkwechat.wecom.domain.WeGroup
;
import
com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
/**
* 群发消息 微信消息表service接口
* 群发消息 微信消息表service接口
*
*
...
@@ -13,12 +19,6 @@ import org.apache.ibatis.annotations.Param;
...
@@ -13,12 +19,6 @@ import org.apache.ibatis.annotations.Param;
public
interface
IWeCustomerMessageService
extends
IService
<
WeCustomerMessage
>
{
public
interface
IWeCustomerMessageService
extends
IService
<
WeCustomerMessage
>
{
/**
/**
* @param customerMessage
* @return
*/
int
updateWeCustomerMessageMsgId
(
WeCustomerMessage
customerMessage
);
/**
*
*
* @param messageId 微信消息表主键id
* @param messageId 微信消息表主键id
* @param actualSend 实际发送消息数(客户对应多少人 客户群对应多个群)
* @param actualSend 实际发送消息数(客户对应多少人 客户群对应多个群)
...
@@ -26,5 +26,30 @@ public interface IWeCustomerMessageService extends IService<WeCustomerMessage> {
...
@@ -26,5 +26,30 @@ public interface IWeCustomerMessageService extends IService<WeCustomerMessage> {
*/
*/
int
updateWeCustomerMessageActualSend
(
Long
messageId
,
Integer
actualSend
);
int
updateWeCustomerMessageActualSend
(
Long
messageId
,
Integer
actualSend
);
/**
* 保存微信消息 WeCustomerMessage
* @param messageId
* @param messageOriginalId
* @param customerMessagePushDto
* @param size
*/
void
saveWeCustomerMessage
(
long
messageId
,
long
messageOriginalId
,
CustomerMessagePushDto
customerMessagePushDto
,
int
size
,
String
content
);
/**
*
* @param messageId
* @param msgIds
* @throws JsonProcessingException
*/
void
updateMsgId
(
long
messageId
,
List
<
String
>
msgIds
)
throws
JsonProcessingException
;
/**
* 发送消息
*
* @param customerMessagePushDto 消息信息
* @param messageId
* @throws JsonProcessingException
*/
public
void
sendMessgae
(
CustomerMessagePushDto
customerMessagePushDto
,
long
messageId
,
List
<
WeCustomer
>
customers
,
List
<
WeGroup
>
groups
)
throws
JsonProcessingException
;
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMessgaeResultService.java
View file @
ff8f84a
package
com
.
linkwechat
.
wecom
.
service
;
package
com
.
linkwechat
.
wecom
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.linkwechat.wecom.domain.WeCustomer
;
import
com.linkwechat.wecom.domain.WeCustomerMessgaeResult
;
import
com.linkwechat.wecom.domain.WeCustomerMessgaeResult
;
import
com.linkwechat.wecom.domain.WeGroup
;
import
com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto
;
import
com.linkwechat.wecom.domain.vo.WeCustomerMessageResultVo
;
import
com.linkwechat.wecom.domain.vo.WeCustomerMessageResultVo
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -24,4 +27,13 @@ public interface IWeCustomerMessgaeResultService extends IService<WeCustomerMess
...
@@ -24,4 +27,13 @@ public interface IWeCustomerMessgaeResultService extends IService<WeCustomerMess
*/
*/
List
<
WeCustomerMessageResultVo
>
customerMessagePushs
(
Long
messageId
,
String
status
);
List
<
WeCustomerMessageResultVo
>
customerMessagePushs
(
Long
messageId
,
String
status
);
/**
* 保存映射关系
*
* @param customerMessagePushDto
* @param messageId
* @return
*/
int
workerMappingCustomer
(
CustomerMessagePushDto
customerMessagePushDto
,
long
messageId
,
List
<
WeCustomer
>
customers
,
List
<
WeGroup
>
groups
);
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessageOriginalServiceImpl.java
View file @
ff8f84a
...
@@ -5,13 +5,11 @@ import com.fasterxml.jackson.core.JsonProcessingException;
...
@@ -5,13 +5,11 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.wecom.client.WeCustomerMessagePushClient
;
import
com.linkwechat.wecom.client.WeCustomerMessagePushClient
;
import
com.linkwechat.wecom.domain.WeCustomerMessageOriginal
;
import
com.linkwechat.wecom.domain.WeCustomerMessageOriginal
;
import
com.linkwechat.wecom.domain.dto.message.AsyncResultDto
;
import
com.linkwechat.wecom.domain.dto.message.*
;
import
com.linkwechat.wecom.domain.dto.message.DetailMessageStatusResultDto
;
import
com.linkwechat.wecom.domain.dto.message.QueryCustomerMessageStatusResultDataObjectDto
;
import
com.linkwechat.wecom.domain.dto.message.QueryCustomerMessageStatusResultDto
;
import
com.linkwechat.wecom.domain.vo.CustomerMessagePushVo
;
import
com.linkwechat.wecom.domain.vo.CustomerMessagePushVo
;
import
com.linkwechat.wecom.mapper.WeCustomerMessageOriginalMapper
;
import
com.linkwechat.wecom.mapper.WeCustomerMessageOriginalMapper
;
import
com.linkwechat.wecom.mapper.WeCustomerMessgaeResultMapper
;
import
com.linkwechat.wecom.mapper.WeCustomerMessgaeResultMapper
;
...
@@ -50,11 +48,6 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomer
...
@@ -50,11 +48,6 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomer
private
ObjectMapper
objectMapper
;
private
ObjectMapper
objectMapper
;
@Override
@Override
public
int
saveWeCustomerMessageOriginal
(
WeCustomerMessageOriginal
weCustomerMessageOriginal
)
{
return
weCustomerMessageOriginalMapper
.
insert
(
weCustomerMessageOriginal
);
}
@Override
public
List
<
CustomerMessagePushVo
>
customerMessagePushs
(
String
sender
,
String
content
,
String
pushType
,
String
beginTime
,
String
endTime
)
{
public
List
<
CustomerMessagePushVo
>
customerMessagePushs
(
String
sender
,
String
content
,
String
pushType
,
String
beginTime
,
String
endTime
)
{
return
weCustomerMessageOriginalMapper
.
selectCustomerMessagePushs
(
sender
,
content
,
pushType
,
beginTime
,
endTime
);
return
weCustomerMessageOriginalMapper
.
selectCustomerMessagePushs
(
sender
,
content
,
pushType
,
beginTime
,
endTime
);
}
}
...
@@ -80,6 +73,23 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomer
...
@@ -80,6 +73,23 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomer
syncSendResult
(
msgid
,
asyncResultDto
.
getMessageId
());
syncSendResult
(
msgid
,
asyncResultDto
.
getMessageId
());
}
}
@Override
public
long
saveWeCustomerMessageOriginal
(
CustomerMessagePushDto
customerMessagePushDto
)
{
//保存原始数据信息表 WeCustomerMessageOriginal 主键id
long
messageOriginalId
=
SnowFlakeUtil
.
nextId
();
WeCustomerMessageOriginal
original
=
new
WeCustomerMessageOriginal
();
original
.
setMessageOriginalId
(
messageOriginalId
);
original
.
setStaffId
(
customerMessagePushDto
.
getStaffId
());
original
.
setDepartment
(
customerMessagePushDto
.
getDepartment
());
original
.
setPushType
(
customerMessagePushDto
.
getPushType
());
original
.
setMessageType
(
customerMessagePushDto
.
getMessageType
());
original
.
setPushRange
(
customerMessagePushDto
.
getPushRange
());
original
.
setTag
(
customerMessagePushDto
.
getTag
());
original
.
setDelFlag
(
0
);
this
.
save
(
original
);
return
messageOriginalId
;
}
public
void
syncSendResult
(
String
msgid
,
Long
messageId
)
{
public
void
syncSendResult
(
String
msgid
,
Long
messageId
)
{
AtomicInteger
atomicInteger
=
new
AtomicInteger
();
AtomicInteger
atomicInteger
=
new
AtomicInteger
();
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessagePushServiceImpl.java
View file @
ff8f84a
This diff is collapsed.
Click to expand it.
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessageServiceImpl.java
View file @
ff8f84a
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.enums.ChatType
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.wecom.client.WeCustomerMessagePushClient
;
import
com.linkwechat.wecom.domain.WeCustomer
;
import
com.linkwechat.wecom.domain.WeCustomerMessage
;
import
com.linkwechat.wecom.domain.WeCustomerMessage
;
import
com.linkwechat.wecom.domain.WeGroup
;
import
com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto
;
import
com.linkwechat.wecom.domain.dto.message.SendMessageResultDto
;
import
com.linkwechat.wecom.domain.dto.message.WeCustomerMessagePushDto
;
import
com.linkwechat.wecom.mapper.WeCustomerMessageMapper
;
import
com.linkwechat.wecom.mapper.WeCustomerMessageMapper
;
import
com.linkwechat.wecom.service.IWeCustomerMessageService
;
import
com.linkwechat.wecom.service.IWeCustomerMessageService
;
import
org.apache.commons.collections4.CollectionUtils
;
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.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
/**
* 群发消息 微信消息表service接口
* 群发消息 微信消息表service接口
*
*
...
@@ -18,14 +36,148 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
...
@@ -18,14 +36,148 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
@Autowired
@Autowired
private
WeCustomerMessageMapper
weCustomerMessageMapper
;
private
WeCustomerMessageMapper
weCustomerMessageMapper
;
@Override
public
int
updateWeCustomerMessageMsgId
(
WeCustomerMessage
customerMessage
)
{
@Autowired
return
weCustomerMessageMapper
.
updateWeCustomerMessageMsgIdById
(
customerMessage
);
private
ObjectMapper
objectMapper
;
}
@Autowired
private
WeCustomerMessagePushClient
weCustomerMessagePushClient
;
@Override
@Override
public
int
updateWeCustomerMessageActualSend
(
Long
messageId
,
Integer
actualSend
)
{
public
int
updateWeCustomerMessageActualSend
(
Long
messageId
,
Integer
actualSend
)
{
return
weCustomerMessageMapper
.
updateWeCustomerMessageActualSend
(
messageId
,
actualSend
);
return
weCustomerMessageMapper
.
updateWeCustomerMessageActualSend
(
messageId
,
actualSend
);
}
}
@Override
public
void
saveWeCustomerMessage
(
long
messageId
,
long
messageOriginalId
,
CustomerMessagePushDto
customerMessagePushDto
,
int
size
,
String
content
)
{
//保存微信消息
//微信群发消息表 WeCustomerMessage
WeCustomerMessage
customerMessage
=
new
WeCustomerMessage
();
customerMessage
.
setOriginalId
(
messageOriginalId
);
customerMessage
.
setMessageId
(
messageId
);
customerMessage
.
setChatType
(
customerMessagePushDto
.
getPushType
());
// customerMessage.setExternalUserid(objectMapper.writeValueAsString(customers));
// customerMessage.setSender(objectMapper.writeValueAsString(senders));
customerMessage
.
setCheckStatus
(
"0"
);
customerMessage
.
setDelFlag
(
0
);
customerMessage
.
setContent
(
content
);
customerMessage
.
setCreateBy
(
SecurityUtils
.
getUsername
());
customerMessage
.
setMsgid
(
""
);
if
(
StringUtils
.
isNotEmpty
(
customerMessagePushDto
.
getSettingTime
())){
customerMessage
.
setSettingTime
(
customerMessagePushDto
.
getSettingTime
());
customerMessage
.
setTimedTask
(
1
);
}
else
{
customerMessage
.
setTimedTask
(
0
);
}
customerMessage
.
setExpectSend
(
size
);
customerMessage
.
setActualSend
(
0
);
this
.
save
(
customerMessage
);
}
@Override
public
void
updateMsgId
(
long
messageId
,
List
<
String
>
msgIds
)
throws
JsonProcessingException
{
//通过messageId更新msgIds
WeCustomerMessage
weCustomerMessage
=
new
WeCustomerMessage
();
weCustomerMessage
.
setMessageId
(
messageId
);
weCustomerMessage
.
setMsgid
(
objectMapper
.
writeValueAsString
(
msgIds
));
weCustomerMessageMapper
.
updateWeCustomerMessageMsgIdById
(
weCustomerMessage
);
}
@Override
public
void
sendMessgae
(
CustomerMessagePushDto
customerMessagePushDto
,
long
messageId
,
List
<
WeCustomer
>
customers
,
List
<
WeGroup
>
groups
)
throws
JsonProcessingException
{
List
<
String
>
msgid
=
new
ArrayList
<>();
//发送群发消息
//发送类类型: 给单个客户发,群发
//发给客户
if
(
customerMessagePushDto
.
getPushType
().
equals
(
"0"
))
{
WeCustomerMessagePushDto
messagePushDto
=
new
WeCustomerMessagePushDto
();
messagePushDto
.
setChat_type
(
ChatType
.
of
(
customerMessagePushDto
.
getPushType
()).
getName
());
List
<
String
>
externalUserIds
=
customers
.
stream
().
map
(
WeCustomer:
:
getExternalUserid
).
collect
(
Collectors
.
toList
());
messagePushDto
.
setExternal_userid
(
externalUserIds
);
childMessage
(
messagePushDto
,
customerMessagePushDto
);
SendMessageResultDto
sendMessageResultDto
=
weCustomerMessagePushClient
.
sendCustomerMessageToUser
(
messagePushDto
);
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
sendMessageResultDto
.
getErrcode
()))
{
msgid
.
add
(
sendMessageResultDto
.
getMsgid
());
}
}
//发给客户群
if
(
customerMessagePushDto
.
getPushType
().
equals
(
"1"
))
{
if
(
CollectionUtils
.
isNotEmpty
(
groups
))
{
List
<
String
>
owners
=
groups
.
stream
().
map
(
WeGroup:
:
getOwner
).
collect
(
Collectors
.
toList
());
for
(
String
owner
:
owners
)
{
WeCustomerMessagePushDto
messagePushDto
=
new
WeCustomerMessagePushDto
();
messagePushDto
.
setChat_type
(
ChatType
.
of
(
customerMessagePushDto
.
getPushType
()).
getName
());
//客户群的员工id
messagePushDto
.
setSender
(
owner
);
childMessage
(
messagePushDto
,
customerMessagePushDto
);
SendMessageResultDto
sendMessageResultDto
=
weCustomerMessagePushClient
.
sendCustomerMessageToUser
(
messagePushDto
);
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
sendMessageResultDto
.
getErrcode
()))
{
//发送的msgId
msgid
.
add
(
sendMessageResultDto
.
getMsgid
());
}
}
}
}
this
.
updateMsgId
(
messageId
,
msgid
);
}
/**
* 子消息体
*
* @param weCustomerMessagePushDto 群发消息体
* @param customerMessagePushDto 群发消息
*/
public
void
childMessage
(
WeCustomerMessagePushDto
weCustomerMessagePushDto
,
CustomerMessagePushDto
customerMessagePushDto
)
{
// 消息类型 0 文本消息 1 图片消息 2 链接消息 3 小程序消息
if
(
customerMessagePushDto
.
getMessageType
().
equals
(
"0"
))
{
weCustomerMessagePushDto
.
setImage
(
null
);
weCustomerMessagePushDto
.
setLink
(
null
);
weCustomerMessagePushDto
.
setMiniprogram
(
null
);
weCustomerMessagePushDto
.
setText
(
customerMessagePushDto
.
getTextMessage
());
}
if
(
customerMessagePushDto
.
getMessageType
().
equals
(
"1"
))
{
weCustomerMessagePushDto
.
setImage
(
customerMessagePushDto
.
getImageMessage
());
weCustomerMessagePushDto
.
setLink
(
null
);
weCustomerMessagePushDto
.
setMiniprogram
(
null
);
weCustomerMessagePushDto
.
setText
(
null
);
}
if
(
customerMessagePushDto
.
getMessageType
().
equals
(
"2"
))
{
weCustomerMessagePushDto
.
setImage
(
null
);
weCustomerMessagePushDto
.
setLink
(
customerMessagePushDto
.
getLinkMessage
());
weCustomerMessagePushDto
.
setMiniprogram
(
null
);
weCustomerMessagePushDto
.
setText
(
null
);
}
if
(
customerMessagePushDto
.
getMessageType
().
equals
(
"3"
))
{
weCustomerMessagePushDto
.
setImage
(
null
);
weCustomerMessagePushDto
.
setLink
(
null
);
weCustomerMessagePushDto
.
setMiniprogram
(
customerMessagePushDto
.
getMiniprogramMessage
());
weCustomerMessagePushDto
.
setText
(
null
);
}
if
(
customerMessagePushDto
.
getMessageType
().
equals
(
"4"
)){
weCustomerMessagePushDto
.
setImage
(
customerMessagePushDto
.
getImageMessage
());
weCustomerMessagePushDto
.
setLink
(
null
);
weCustomerMessagePushDto
.
setMiniprogram
(
null
);
weCustomerMessagePushDto
.
setText
(
customerMessagePushDto
.
getTextMessage
());
}
}
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessgaeResultServiceImpl.java
View file @
ff8f84a
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.google.common.collect.Lists
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.wecom.domain.WeCustomer
;
import
com.linkwechat.wecom.domain.WeCustomerMessgaeResult
;
import
com.linkwechat.wecom.domain.WeCustomerMessgaeResult
;
import
com.linkwechat.wecom.domain.WeGroup
;
import
com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto
;
import
com.linkwechat.wecom.domain.vo.WeCustomerMessageResultVo
;
import
com.linkwechat.wecom.domain.vo.WeCustomerMessageResultVo
;
import
com.linkwechat.wecom.mapper.WeCustomerMessgaeResultMapper
;
import
com.linkwechat.wecom.mapper.WeCustomerMessgaeResultMapper
;
import
com.linkwechat.wecom.service.IWeCustomerMessgaeResultService
;
import
com.linkwechat.wecom.service.IWeCustomerMessgaeResultService
;
import
org.apache.commons.collections4.CollectionUtils
;
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.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -27,4 +34,62 @@ public class WeCustomerMessgaeResultServiceImpl extends ServiceImpl<WeCustomerMe
...
@@ -27,4 +34,62 @@ public class WeCustomerMessgaeResultServiceImpl extends ServiceImpl<WeCustomerMe
return
customerMessgaeResultMapper
.
customerMessagePushs
(
messageId
,
status
);
return
customerMessgaeResultMapper
.
customerMessagePushs
(
messageId
,
status
);
}
}
@Override
public
int
workerMappingCustomer
(
CustomerMessagePushDto
customerMessagePushDto
,
long
messageId
,
List
<
WeCustomer
>
customers
,
List
<
WeGroup
>
groups
)
{
int
size
=
0
;
// 0 发给客户
if
(
customerMessagePushDto
.
getPushType
().
equals
(
"0"
))
{
if
(
CollectionUtils
.
isNotEmpty
(
customers
))
{
size
=
customers
.
size
();
customers
.
forEach
(
customer
->
{
//微信消息发送结果、保存员工客户关系映射关系数据
WeCustomerMessgaeResult
customerMessgaeResult
=
new
WeCustomerMessgaeResult
();
customerMessgaeResult
.
setMessgaeResultId
(
SnowFlakeUtil
.
nextId
());
customerMessgaeResult
.
setMessageId
(
messageId
);
//这个是实际发送时间
customerMessgaeResult
.
setSendTime
(
null
);
customerMessgaeResult
.
setSendType
(
customerMessgaeResult
.
getSettingTime
()
==
null
?
customerMessagePushDto
.
getPushType
()
:
"2"
);
customerMessgaeResult
.
setExternalUserid
(
customer
.
getExternalUserid
());
customerMessgaeResult
.
setExternalName
(
customer
.
getName
());
customerMessgaeResult
.
setUserid
(
customer
.
getUserId
());
customerMessgaeResult
.
setUserName
(
customer
.
getUserName
());
customerMessgaeResult
.
setStatus
(
"0"
);
customerMessgaeResult
.
setSettingTime
(
customerMessagePushDto
.
getSettingTime
());
customerMessgaeResult
.
setDelFlag
(
0
);
this
.
save
(
customerMessgaeResult
);
});
}
}
// 1 发给客户群
if
(
customerMessagePushDto
.
getPushType
().
equals
(
"1"
))
{
if
(
CollectionUtils
.
isNotEmpty
(
groups
))
{
size
=
groups
.
size
();
groups
.
forEach
(
group
->
{
//微信消息发送结果、保存员工客户关系映射关系数据
WeCustomerMessgaeResult
customerMessgaeResult
=
new
WeCustomerMessgaeResult
();
customerMessgaeResult
.
setMessgaeResultId
(
SnowFlakeUtil
.
nextId
());
customerMessgaeResult
.
setMessageId
(
messageId
);
customerMessgaeResult
.
setSendTime
(
customerMessagePushDto
.
getSettingTime
());
customerMessgaeResult
.
setSendType
(
customerMessgaeResult
.
getSettingTime
()
==
null
?
customerMessagePushDto
.
getPushType
()
:
"2"
);
customerMessgaeResult
.
setSettingTime
(
customerMessagePushDto
.
getSettingTime
());
customerMessgaeResult
.
setChatId
(
group
.
getChatId
());
customerMessgaeResult
.
setChatName
(
group
.
getGroupName
());
customerMessgaeResult
.
setStatus
(
"0"
);
//群管理员id
customerMessgaeResult
.
setUserid
(
group
.
getGroupLeader
());
//群管理员名称
customerMessgaeResult
.
setUserName
(
group
.
getGroupLeaderName
());
customerMessgaeResult
.
setDelFlag
(
0
);
this
.
save
(
customerMessgaeResult
);
});
}
}
return
size
;
}
}
}
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