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 adde9ccc
authored
Dec 16, 2020
by
xinlaa
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' of
https://gitee.com/LinkWeChat/link-wechat
into master
2 parents
70e7fc4d
29de1cae
Show whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
801 additions
and
32 deletions
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerMessagePushController.java
linkwe-admin/src/main/resources/application.yml
linkwe-common/src/main/java/com/linkwechat/common/config/RuoYiConfig.java
linkwe-common/src/main/java/com/linkwechat/common/enums/ChatType.java
linkwe-common/src/main/java/com/tencent/wework/FinanceUtils.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeCustomer.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeCustomerMessageOriginal.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeGroup.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/message/CustomerMessagePushDto.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerImageMessageService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerLinkMessageService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMessageOriginalService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMessagePushService.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/IWeCustomerMiniprogramMessageService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerTextMessagService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerImageMessageServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerLinkMessageServiceImpl.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-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMiniprogramMessageServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerTextMessagServiceImpl.java
linkwe-wecom/src/main/resources/mapper/wecom/WeCorpAccountMapper.xml
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerImageMessageMapper.xml
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerLinkMessageMapper.xml
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerMapper.xml
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerMessageMapper.xml
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerMessageOriginalMapper.xml
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerMiniprogramMessageMapper.xml
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerTextMessagMapper.xml
linkwe-wecom/src/main/resources/mapper/wecom/WeGroupMapper.xml
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerMessagePushController.java
View file @
adde9cc
package
com
.
linkwechat
.
web
.
controller
.
wecom
;
package
com
.
linkwechat
.
web
.
controller
.
wecom
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.linkwechat.common.annotation.Log
;
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.enums.BusinessType
;
import
com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto
;
import
com.linkwechat.wecom.service.IWeCustomerMessagePushService
;
import
com.linkwechat.wecom.service.IWeCustomerMessagePushService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -11,12 +19,29 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -11,12 +19,29 @@ import org.springframework.web.bind.annotation.RestController;
* @author: KeWen
* @author: KeWen
* @create: 2020-12-01 20:23
* @create: 2020-12-01 20:23
**/
**/
@Slf4j
@RestController
@RestController
@RequestMapping
(
"/wecom/customerMessagePush"
)
@RequestMapping
(
"/wecom/customerMessagePush"
)
public
class
WeCustomerMessagePushController
extends
BaseController
{
public
class
WeCustomerMessagePushController
extends
BaseController
{
@Autowired
@Autowired
private
IWeCustomerMessagePushService
weCustomerMessagePushService
;
private
IWeCustomerMessagePushService
weCustomerMessagePushService
;
/**
* 新增群发消息发送
*/
@PreAuthorize
(
"@ss.hasPermi('system:push:add')"
)
@Log
(
title
=
"新增群发消息发送"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
(
value
=
"add"
)
public
AjaxResult
add
(
CustomerMessagePushDto
customerMessagePushDto
)
{
try
{
weCustomerMessagePushService
.
addWeCustomerMessagePush
(
customerMessagePushDto
);
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
return
AjaxResult
.
error
(
"群发失败"
);
}
return
AjaxResult
.
success
();
}
}
}
linkwe-admin/src/main/resources/application.yml
View file @
adde9cc
...
@@ -170,6 +170,7 @@ wecome:
...
@@ -170,6 +170,7 @@ wecome:
-
/externalcontact/get_unassigned_list
-
/externalcontact/get_unassigned_list
-
/externalcontact/send_welcome_msg
-
/externalcontact/send_welcome_msg
-
/msgaudit/get_permit_user_list
-
/msgaudit/get_permit_user_list
-
/externalcontact/unionid_to_external_userid
fileUplodUrl
:
/media/upload,/media/uploadimg
fileUplodUrl
:
/media/upload,/media/uploadimg
needProviderTokenUrl
:
needProviderTokenUrl
:
-
/service/get_login_info
-
/service/get_login_info
...
...
linkwe-common/src/main/java/com/linkwechat/common/config/RuoYiConfig.java
View file @
adde9cc
...
@@ -110,6 +110,14 @@ public class RuoYiConfig
...
@@ -110,6 +110,14 @@ public class RuoYiConfig
}
}
/**
/**
* 获取会话存档素材下载路径
*/
public
static
String
getDownloadWeWorkPath
()
{
return
getProfile
()
+
"/download/media_data/{type}/{date}/{fileName}"
;
}
/**
* 获取上传路径
* 获取上传路径
*/
*/
public
static
String
getUploadPath
()
public
static
String
getUploadPath
()
...
...
linkwe-common/src/main/java/com/linkwechat/common/enums/ChatType.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
common
.
enums
;
import
lombok.Getter
;
import
java.util.stream.Stream
;
/**
* 群发任务的类型,默认为single,表示发送给客户,group表示发送给客户群
*/
@Getter
public
enum
ChatType
{
/**
* 发给客户
*/
SINGLE
(
"single"
,
"0"
),
/**
* 发给客户群
*/
GROUP
(
"group"
,
"1"
)
;
private
String
name
;
private
String
type
;
ChatType
(
String
name
,
String
type
)
{
this
.
name
=
name
;
this
.
type
=
type
;
}
public
static
ChatType
of
(
String
type
){
return
Stream
.
of
(
values
()).
filter
(
s
->
s
.
getType
().
equals
(
type
)).
findFirst
().
orElseGet
(
null
);
}
}
linkwe-common/src/main/java/com/tencent/wework/FinanceUtils.java
View file @
adde9cc
...
@@ -3,13 +3,22 @@ package com.tencent.wework;
...
@@ -3,13 +3,22 @@ package com.tencent.wework;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.linkwechat.common.config.RuoYiConfig
;
import
com.linkwechat.common.core.domain.elastic.ElasticSearchEntity
;
import
com.linkwechat.common.core.domain.elastic.ElasticSearchEntity
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.common.utils.uuid.IdUtils
;
import
com.linkwechat.common.utils.wecom.RSAUtil
;
import
com.linkwechat.common.utils.wecom.RSAUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.security.PrivateKey
;
import
java.security.PrivateKey
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
/**
* @author sxw
* @author sxw
...
@@ -27,19 +36,22 @@ public class FinanceUtils {
...
@@ -27,19 +36,22 @@ public class FinanceUtils {
*/
*/
private
final
static
long
timeout
=
5
*
60
;
private
final
static
long
timeout
=
5
*
60
;
/**
/**
*一次拉取的消息条数,最大值1000条,超过1000条会返回错误
*
一次拉取的消息条数,最大值1000条,超过1000条会返回错误
*/
*/
private
final
static
long
LIMIT
=
1000
;
private
final
static
long
LIMIT
=
1000
;
private
static
String
downloadWeWorkPath
=
RuoYiConfig
.
getDownloadWeWorkPath
();
/**
/**
* 初始化
* 初始化
*
* @param corpId 企业id
* @param corpId 企业id
* @param secret 会话存档密钥
* @param secret 会话存档密钥
*/
*/
public
static
void
initSDK
(
String
corpId
,
String
secret
)
{
public
static
void
initSDK
(
String
corpId
,
String
secret
)
{
if
(
sdk
==
0
)
{
if
(
sdk
==
0
)
{
sdk
=
Finance
.
NewSdk
();
sdk
=
Finance
.
NewSdk
();
Finance
.
Init
(
sdk
,
corpId
,
secret
);
Finance
.
Init
(
sdk
,
corpId
,
secret
);
}
}
}
}
...
@@ -73,11 +85,12 @@ public class FinanceUtils {
...
@@ -73,11 +85,12 @@ public class FinanceUtils {
/**
/**
* 拉取聊天记录
* 拉取聊天记录
*
* @param seq 消息的seq值,标识消息的序号
* @param seq 消息的seq值,标识消息的序号
* @param proxy 代理
* @param proxy 代理
* @param passwd 密码
* @param passwd 密码
*/
*/
public
static
List
<
ElasticSearchEntity
>
getChatData
(
long
seq
,
String
proxy
,
String
passwd
){
public
static
List
<
ElasticSearchEntity
>
getChatData
(
long
seq
,
String
proxy
,
String
passwd
)
{
List
<
ElasticSearchEntity
>
resList
=
new
ArrayList
<>();
List
<
ElasticSearchEntity
>
resList
=
new
ArrayList
<>();
long
slice
=
Finance
.
NewSlice
();
long
slice
=
Finance
.
NewSlice
();
int
ret
=
Finance
.
GetChatData
(
sdk
,
seq
,
LIMIT
,
proxy
,
passwd
,
timeout
,
slice
);
int
ret
=
Finance
.
GetChatData
(
sdk
,
seq
,
LIMIT
,
proxy
,
passwd
,
timeout
,
slice
);
...
@@ -87,14 +100,14 @@ public class FinanceUtils {
...
@@ -87,14 +100,14 @@ public class FinanceUtils {
}
}
String
content
=
Finance
.
GetContentFromSlice
(
slice
);
String
content
=
Finance
.
GetContentFromSlice
(
slice
);
JSONArray
chatdataArr
=
JSONObject
.
parseObject
(
content
).
getJSONArray
(
"chatdata"
);
JSONArray
chatdataArr
=
JSONObject
.
parseObject
(
content
).
getJSONArray
(
"chatdata"
);
if
(
CollectionUtil
.
isNotEmpty
(
chatdataArr
)){
if
(
CollectionUtil
.
isNotEmpty
(
chatdataArr
))
{
chatdataArr
.
stream
().
map
(
data
->
(
JSONObject
)
data
).
forEach
(
data
->{
chatdataArr
.
stream
().
map
(
data
->
(
JSONObject
)
data
).
forEach
(
data
->
{
try
{
try
{
ElasticSearchEntity
elasticSearchEntity
=
new
ElasticSearchEntity
();
ElasticSearchEntity
elasticSearchEntity
=
new
ElasticSearchEntity
();
long
LocalSEQ
=
data
.
getLong
(
"seq"
);
long
LocalSEQ
=
data
.
getLong
(
"seq"
);
JSONObject
jsonObject
=
decryptChatRecord
(
sdk
,
data
.
getString
(
"encrypt_random_key"
),
JSONObject
jsonObject
=
decryptChatRecord
(
sdk
,
data
.
getString
(
"encrypt_random_key"
),
data
.
getString
(
"encrypt_chat_msg"
),
privateKey
);
data
.
getString
(
"encrypt_chat_msg"
),
privateKey
);
jsonObject
.
put
(
"seq"
,
LocalSEQ
);
jsonObject
.
put
(
"seq"
,
LocalSEQ
);
elasticSearchEntity
.
setData
(
jsonObject
);
elasticSearchEntity
.
setData
(
jsonObject
);
elasticSearchEntity
.
setId
(
jsonObject
.
getString
(
"msgid"
));
elasticSearchEntity
.
setId
(
jsonObject
.
getString
(
"msgid"
));
resList
.
add
(
elasticSearchEntity
);
resList
.
add
(
elasticSearchEntity
);
...
@@ -110,8 +123,10 @@ public class FinanceUtils {
...
@@ -110,8 +123,10 @@ public class FinanceUtils {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
String
secret
=
"_Ruv_TD_GzE4wJLvhMv4MeYkjM81_IJFDPcsUiss9fw"
;
String
secret
=
"_Ruv_TD_GzE4wJLvhMv4MeYkjM81_IJFDPcsUiss9fw"
;
initSDK
(
"ww24262ce93851488f"
,
secret
);
initSDK
(
"ww24262ce93851488f"
,
secret
);
getChatData
(
0
,
""
,
""
);
//getChatData(0,"","");
getMediaData
(
"CiBkZDk3ZmJjMTlhYjU1YWJiNDQ4MjI3NWRlMzk1NmMzYxI4TkRkZk56ZzRNVE13TURVNU5Ua3lOVFEyTlY4NU5ERTBOekUwTWpaZk1UWXdOemt4TkRrMU1BPT0aIDBiMzY3YjkyNzE5ZDE3ZWU4NjkyNTVlYzJkNTlmNjI3"
,
""
,
""
,
""
);
}
}
...
@@ -123,7 +138,7 @@ public class FinanceUtils {
...
@@ -123,7 +138,7 @@ public class FinanceUtils {
* @return JSONObject 返回不同格式的聊天数据,格式有二十来种
* @return JSONObject 返回不同格式的聊天数据,格式有二十来种
* 详情请看官网 https://open.work.weixin.qq.com/api/doc/90000/90135/91774#%E6%B6%88%E6%81%AF%E6%A0%BC%E5%BC%8F
* 详情请看官网 https://open.work.weixin.qq.com/api/doc/90000/90135/91774#%E6%B6%88%E6%81%AF%E6%A0%BC%E5%BC%8F
*/
*/
private
static
JSONObject
decryptChatRecord
(
Long
sdk
,
String
ncrypt_random_key
,
String
encrypt_chat_msg
,
String
privateKey
){
private
static
JSONObject
decryptChatRecord
(
Long
sdk
,
String
ncrypt_random_key
,
String
encrypt_chat_msg
,
String
privateKey
)
{
Long
msg
=
null
;
Long
msg
=
null
;
try
{
try
{
//获取私钥
//获取私钥
...
@@ -137,17 +152,151 @@ public class FinanceUtils {
...
@@ -137,17 +152,151 @@ public class FinanceUtils {
String
jsonDataStr
=
Finance
.
GetContentFromSlice
(
msg
);
String
jsonDataStr
=
Finance
.
GetContentFromSlice
(
msg
);
log
.
info
(
"解析数据:------------"
+
jsonDataStr
);
log
.
info
(
"解析数据:------------"
+
jsonDataStr
);
JSONObject
realJsonData
=
(
JSONObject
)
JSONObject
.
parseObject
(
jsonDataStr
);
JSONObject
realJsonData
=
JSONObject
.
parseObject
(
jsonDataStr
);
String
msgType
=
realJsonData
.
getString
(
"msgtype"
);
getSwitchType
(
realJsonData
,
msgType
);
return
realJsonData
;
return
realJsonData
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"解析密文失败"
);
log
.
error
(
"解析密文失败"
);
return
null
;
return
null
;
}
finally
{
}
finally
{
if
(
msg
!=
null
)
{
if
(
msg
!=
null
)
{
//释放参数slice
//释放参数slice
Finance
.
FreeSlice
(
msg
);
Finance
.
FreeSlice
(
msg
);
}
}
}
}
}
}
private
static
void
getSwitchType
(
JSONObject
realJsonData
,
String
msgType
)
{
switch
(
msgType
)
{
case
"image"
:
setMediaImageData
(
realJsonData
,
msgType
);
break
;
case
"voice"
:
setMediaVoiceData
(
realJsonData
,
msgType
);
break
;
case
"video"
:
setMediaVideoData
(
realJsonData
,
msgType
);
break
;
case
"emotion"
:
setMediaEmotionData
(
realJsonData
,
msgType
);
break
;
case
"file"
:
setMediaFileData
(
realJsonData
,
msgType
);
break
;
case
"mixed"
:
setMediaMixedData
(
realJsonData
,
msgType
);
break
;
case
"meeting_voice_call"
:
case
"voip_doc_share"
:
setMediaMeetingVoiceCallData
(
realJsonData
,
msgType
);
break
;
default
:
break
;
}
}
private
static
void
setMediaMeetingVoiceCallData
(
JSONObject
realJsonData
,
String
msgType
)
{
JSONObject
meetingVoiceCall
=
Optional
.
ofNullable
(
realJsonData
.
getJSONObject
(
msgType
))
.
orElse
(
realJsonData
.
getJSONObject
(
"content"
));
String
fileName
=
meetingVoiceCall
.
getString
(
"filename"
);
getPath
(
realJsonData
,
msgType
,
fileName
);
}
private
static
void
setMediaMixedData
(
JSONObject
realJsonData
,
String
msgType
)
{
JSONObject
mixedData
=
realJsonData
.
getJSONObject
(
msgType
);
JSONArray
items
=
mixedData
.
getJSONArray
(
"item"
);
items
.
stream
().
map
(
item
->(
JSONObject
)
item
).
forEach
(
item
->{
getSwitchType
(
item
,
item
.
getString
(
"type"
));
});
}
private
static
void
setMediaFileData
(
JSONObject
realJsonData
,
String
msgType
)
{
JSONObject
emotionData
=
Optional
.
ofNullable
(
realJsonData
.
getJSONObject
(
msgType
))
.
orElse
(
realJsonData
.
getJSONObject
(
"content"
));
String
filename
=
emotionData
.
getString
(
"filename"
);
String
fileext
=
emotionData
.
getString
(
"fileext"
);
String
fileName
=
filename
+
"."
+
fileext
;
getPath
(
realJsonData
,
msgType
,
fileName
);
}
private
static
void
setMediaImageData
(
JSONObject
realJsonData
,
String
msgType
)
{
String
fileName
=
IdUtils
.
simpleUUID
()+
".jpg"
;
getPath
(
realJsonData
,
msgType
,
fileName
);
}
private
static
void
setMediaVoiceData
(
JSONObject
realJsonData
,
String
msgType
)
{
String
fileName
=
IdUtils
.
simpleUUID
()+
".mp3"
;
getPath
(
realJsonData
,
msgType
,
fileName
);
}
private
static
void
setMediaVideoData
(
JSONObject
realJsonData
,
String
msgType
)
{
String
fileName
=
IdUtils
.
simpleUUID
()+
".mp4"
;
getPath
(
realJsonData
,
msgType
,
fileName
);
}
private
static
void
setMediaEmotionData
(
JSONObject
realJsonData
,
String
msgType
)
{
String
fileName
=
""
;
JSONObject
emotionData
=
realJsonData
.
getJSONObject
(
msgType
);
Integer
type
=
emotionData
.
getInteger
(
"type"
);
switch
(
type
){
case
1
:
fileName
=
IdUtils
.
simpleUUID
()
+
".gif"
;
break
;
case
2
:
fileName
=
IdUtils
.
simpleUUID
()
+
".png"
;
break
;
default
:
break
;
}
getPath
(
realJsonData
,
msgType
,
fileName
);
}
private
static
void
getPath
(
JSONObject
realJsonData
,
String
msgType
,
String
fileName
)
{
String
filePath
=
getFilePath
(
msgType
,
fileName
);
JSONObject
data
=
Optional
.
ofNullable
(
realJsonData
.
getJSONObject
(
msgType
))
.
orElse
(
realJsonData
.
getJSONObject
(
"content"
));
String
sdkfileid
=
data
.
getString
(
"sdkfileid"
);
try
{
getMediaData
(
sdkfileid
,
""
,
""
,
filePath
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
realJsonData
.
put
(
"attachment"
,
filePath
);
}
private
static
String
getFilePath
(
String
msgType
,
String
fileName
)
{
return
StringUtils
.
format
(
downloadWeWorkPath
,
msgType
,
DateUtils
.
getDate
(),
fileName
);
}
private
static
void
getMediaData
(
String
sdkFileid
,
String
proxy
,
String
passwd
,
String
filePath
)
{
String
indexbuf
=
""
;
while
(
true
)
{
long
media_data
=
Finance
.
NewMediaData
();
int
ret
=
Finance
.
GetMediaData
(
sdk
,
indexbuf
,
sdkFileid
,
proxy
,
passwd
,
timeout
,
media_data
);
log
.
info
(
"getMediaData ret:"
+
ret
);
if
(
ret
!=
0
)
{
return
;
}
/* int indexLen = Finance.GetIndexLen(media_data);
int dataLen = Finance.GetDataLen(media_data);
int isMediaDataFinish = Finance.IsMediaDataFinish(media_data);*/
try
{
FileOutputStream
outputStream
=
new
FileOutputStream
(
new
File
(
filePath
),
true
);
//File file = new File("D:\\浏览器下载\\media_data\\"+ IdUtils.simpleUUID()+".jpg");
//FileOutputStream outputStream = new FileOutputStream(file, true);
outputStream
.
write
(
Finance
.
GetData
(
media_data
));
outputStream
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
Finance
.
IsMediaDataFinish
(
media_data
)
==
1
)
{
Finance
.
FreeMediaData
(
media_data
);
break
;
}
else
{
indexbuf
=
Finance
.
GetOutIndexBuf
(
media_data
);
Finance
.
FreeMediaData
(
media_data
);
}
}
}
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeCustomer.java
View file @
adde9cc
...
@@ -91,4 +91,7 @@ public class WeCustomer extends BaseEntity
...
@@ -91,4 +91,7 @@ public class WeCustomer extends BaseEntity
@JSONField
(
defaultValue
=
"0"
)
@JSONField
(
defaultValue
=
"0"
)
private
Integer
status
;
private
Integer
status
;
/** 部门 */
private
String
departmentIds
;
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeCustomerMessageOriginal.java
View file @
adde9cc
...
@@ -47,11 +47,6 @@ public class WeCustomerMessageOriginal extends BaseEntity {
...
@@ -47,11 +47,6 @@ public class WeCustomerMessageOriginal extends BaseEntity {
private
String
tag
;
private
String
tag
;
/**
/**
* 群组名称id
*/
private
String
group
;
/**
* 部门id
* 部门id
*/
*/
private
String
department
;
private
String
department
;
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeGroup.java
View file @
adde9cc
...
@@ -62,5 +62,8 @@ public class WeGroup {
...
@@ -62,5 +62,8 @@ public class WeGroup {
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
private
String
endTime
;
private
String
endTime
;
/**员工id*/
private
String
userIds
;
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/message/CustomerMessagePushDto.java
View file @
adde9cc
...
@@ -39,10 +39,10 @@ public class CustomerMessagePushDto {
...
@@ -39,10 +39,10 @@ public class CustomerMessagePushDto {
/**
/**
* 发送时间 为空表示立即发送 ,不为空为指定时间发送
* 发送时间 为空表示立即发送 ,不为空为指定时间发送
*/
*/
private
String
se
nd
Time
;
private
String
se
tting
Time
;
/**
/**
* 消息类型 0 文本消息 1 图片消息 2
语音消息 3 视频消息 4 文件消息 5 文本卡片消息 6 图文消息\r\n7 图文消息(mpnews) 8 markdown消息 9 小程序通知消息 10 任务卡片
消息
* 消息类型 0 文本消息 1 图片消息 2
链接消息 3 小程序
消息
*/
*/
private
String
messageType
;
private
String
messageType
;
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerImageMessageService.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.linkwechat.wecom.domain.WeCustomerImageMessage
;
public
interface
IWeCustomerImageMessageService
extends
IService
<
WeCustomerImageMessage
>
{
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerLinkMessageService.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.linkwechat.wecom.domain.WeCustomerLinkMessage
;
public
interface
IWeCustomerLinkMessageService
extends
IService
<
WeCustomerLinkMessage
>
{
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMessageOriginalService.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.linkwechat.wecom.domain.WeCustomerMessageOriginal
;
/**
* 群发消息 原始数据信息表 we_customer_messageOriginal
*
* @author kewen
* @date 2020-12-12
*/
public
interface
IWeCustomerMessageOriginalService
extends
IService
<
WeCustomerMessageOriginal
>
{
/**
* 保存原始数据信息
* @param weCustomerMessageOriginal 原始数据信息
* @return
*/
int
saveWeCustomerMessageOriginal
(
WeCustomerMessageOriginal
weCustomerMessageOriginal
);
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMessagePushService.java
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
;
package
com
.
linkwechat
.
wecom
.
service
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto
;
/**
/**
* @description: 群发消息服务类
* @description: 群发消息服务类
* @author: KeWen
* @author: KeWen
* @create: 2020-12-01 20:23
* @create: 2020-12-01 20:23
**/
**/
public
interface
IWeCustomerMessagePushService
{
public
interface
IWeCustomerMessagePushService
{
/**
* 新增群发消息发送
*
*@param customerMessagePushDto 原始数据信息
*/
public
void
addWeCustomerMessagePush
(
CustomerMessagePushDto
customerMessagePushDto
)
throws
JsonProcessingException
;
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMessageService.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.linkwechat.wecom.domain.WeCustomerMessage
;
/**
* 群发消息 微信消息表service接口
*
* @author kewen
* @date 2020-12-12
*/
public
interface
IWeCustomerMessageService
extends
IService
<
WeCustomerMessage
>
{
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMessgaeResultService.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.linkwechat.wecom.domain.WeCustomerMessgaeResult
;
/**
* 群发消息 微信消息发送结果表 we_customer_messgaeResult
*
* @author kewen
* @date 2020-12-12
*/
public
interface
IWeCustomerMessgaeResultService
extends
IService
<
WeCustomerMessgaeResult
>
{
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMiniprogramMessageService.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.linkwechat.wecom.domain.WeCustomerMiniprogramMessage
;
public
interface
IWeCustomerMiniprogramMessageService
extends
IService
<
WeCustomerMiniprogramMessage
>
{
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerTextMessagService.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.linkwechat.wecom.domain.WeCustomerTextMessag
;
public
interface
IWeCustomerTextMessagService
extends
IService
<
WeCustomerTextMessag
>
{
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerImageMessageServiceImpl.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.wecom.domain.WeCustomerImageMessage
;
import
com.linkwechat.wecom.mapper.WeCustomerImageMessageMapper
;
import
com.linkwechat.wecom.service.IWeCustomerImageMessageService
;
import
org.springframework.stereotype.Service
;
/**
* 群发消息 图片消息表 we_customer_imageMessage
*
* @author kewen
* @date 2020-12-12
*/
@Service
public
class
WeCustomerImageMessageServiceImpl
extends
ServiceImpl
<
WeCustomerImageMessageMapper
,
WeCustomerImageMessage
>
implements
IWeCustomerImageMessageService
{
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerLinkMessageServiceImpl.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.wecom.domain.WeCustomerLinkMessage
;
import
com.linkwechat.wecom.mapper.WeCustomerLinkMessageMapper
;
import
com.linkwechat.wecom.service.IWeCustomerLinkMessageService
;
import
org.springframework.stereotype.Service
;
/**
* 群发消息 链接消息表 we_customer_linkMessage
*
* @author kewen
* @date 2020-12-13
*/
@Service
public
class
WeCustomerLinkMessageServiceImpl
extends
ServiceImpl
<
WeCustomerLinkMessageMapper
,
WeCustomerLinkMessage
>
implements
IWeCustomerLinkMessageService
{
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessageOriginalServiceImpl.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.wecom.domain.WeCustomerMessageOriginal
;
import
com.linkwechat.wecom.mapper.WeCustomerMessageOriginalMapper
;
import
com.linkwechat.wecom.service.IWeCustomerMessageOriginalService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* 群发消息 原始数据信息表 we_customer_messageOriginal
*
* @author kewen
* @date 2020-12-12
*/
@Service
public
class
WeCustomerMessageOriginalServiceImpl
extends
ServiceImpl
<
WeCustomerMessageOriginalMapper
,
WeCustomerMessageOriginal
>
implements
IWeCustomerMessageOriginalService
{
@Autowired
private
WeCustomerMessageOriginalMapper
weCustomerMessageOriginalMapper
;
@Override
public
int
saveWeCustomerMessageOriginal
(
WeCustomerMessageOriginal
weCustomerMessageOriginal
)
{
return
weCustomerMessageOriginalMapper
.
insert
(
weCustomerMessageOriginal
);
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessagePushServiceImpl.java
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.linkwechat.wecom.service.IWeCustomerMessagePushService
;
import
cn.hutool.core.date.DateUtil
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.google.common.collect.Lists
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.enums.ChatType
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.wecom.client.WeCustomerMessagePushClient
;
import
com.linkwechat.wecom.domain.*
;
import
com.linkwechat.wecom.domain.dto.message.*
;
import
com.linkwechat.wecom.service.*
;
import
lombok.SneakyThrows
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
java.util.stream.Collectors
;
/**
/**
* @description: 群发消息服务类
* @description: 群发消息服务类
...
@@ -11,17 +33,258 @@ import org.springframework.stereotype.Service;
...
@@ -11,17 +33,258 @@ import org.springframework.stereotype.Service;
**/
**/
@Slf4j
@Slf4j
@Service
@Service
@SuppressWarnings
(
"all"
)
public
class
WeCustomerMessagePushServiceImpl
implements
IWeCustomerMessagePushService
{
public
class
WeCustomerMessagePushServiceImpl
implements
IWeCustomerMessagePushService
{
@Autowired
private
IWeCustomerMessageOriginalService
weCustomerMessageOriginalService
;
@Autowired
private
WeCustomerMessagePushClient
weCustomerMessagePushClient
;
@Autowired
private
IWeCustomerImageMessageService
weCustomerImageMessageService
;
@Autowired
private
IWeCustomerLinkMessageService
weCustomerLinkMessageService
;
@Autowired
private
IWeCustomerMessageService
weCustomerMessageService
;
@Autowired
private
IWeCustomerMiniprogramMessageService
weCustomerMiniprogramMessageService
;
@Autowired
private
IWeCustomerTextMessagService
weCustomerTextMessagService
;
@Autowired
private
IWeCustomerService
weCustomerService
;
@Autowired
private
IWeGroupService
weGroupService
;
@Autowired
private
ObjectMapper
objectMapper
;
@Override
@Transactional
public
void
addWeCustomerMessagePush
(
CustomerMessagePushDto
customerMessagePushDto
)
throws
JsonProcessingException
{
//立即发送
if
(
null
==
customerMessagePushDto
.
getSettingTime
())
{
sendMessgae
(
customerMessagePushDto
);
}
else
{
//发送时间不能小于当前时间
//定时发送消息(异步执行)
//保存消息体到数据库,增加一个发送状态(0 已发送 1 未发送)
//定义一个任务执行队列
//把任务放入执行队列
//任务执行 sendMessgae(WeMessagePush weMessagePush) 方法
if
(
DateUtils
.
diffTime
(
new
Date
(),
DateUtil
.
parse
(
customerMessagePushDto
.
getSettingTime
(),
"yyyy-MM-dd HH:mm:ss"
))
<
0
)
{
throw
new
WeComException
(
"发送时间不能小于当前时间"
);
}
Timer
timer
=
new
Timer
();
timer
.
schedule
(
new
TimerTask
()
{
@SneakyThrows
@Override
public
void
run
()
{
sendMessgae
(
customerMessagePushDto
);
}
},
DateUtil
.
parse
(
customerMessagePushDto
.
getSettingTime
(),
"yyyy-MM-dd HH:mm:ss"
));
}
}
/**
* 发送消息
* @param customerMessagePushDto 消息信息
* @throws JsonProcessingException
*/
public
void
sendMessgae
(
CustomerMessagePushDto
customerMessagePushDto
)
throws
JsonProcessingException
{
//原始数据信息表 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
);
weCustomerMessageOriginalService
.
save
(
original
);
List
<
String
>
msgIds
=
Lists
.
newArrayList
();
List
<
String
>
senders
=
Lists
.
newArrayList
();
List
<
String
>
externalUserIds
=
Lists
.
newArrayList
();
//发送群发消息
//发送群发消息
//发送类类型: 给单个客户发,群发
//发送类类型: 给单个客户发,群发
//发给客户
if
(
customerMessagePushDto
.
getPushType
().
equals
(
"0"
)){
WeCustomerMessagePushDto
messagePushDto
=
new
WeCustomerMessagePushDto
();
messagePushDto
.
setChat_type
(
ChatType
.
of
(
customerMessagePushDto
.
getPushType
()).
getType
());
externalUserIds
=
externalUserIds
(
customerMessagePushDto
.
getPushRange
(),
customerMessagePushDto
.
getStaffId
()
,
customerMessagePushDto
.
getDepartment
(),
customerMessagePushDto
.
getTag
());
messagePushDto
.
setExternal_userid
(
externalUserIds
);
messagePushDto
.
setImage
(
customerMessagePushDto
.
getImageMessage
());
messagePushDto
.
setLink
(
customerMessagePushDto
.
getLinkMessage
());
messagePushDto
.
setMiniprogram
(
customerMessagePushDto
.
getMiniprogramMessage
());
messagePushDto
.
setText
(
customerMessagePushDto
.
getTextMessage
());
SendMessageResultDto
sendMessageResultDto
=
weCustomerMessagePushClient
.
sendCustomerMessageToUser
(
messagePushDto
);
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
sendMessageResultDto
.
getErrcode
())){
msgIds
.
add
(
sendMessageResultDto
.
getMsgid
());
}
}
//发给客户群
if
(
customerMessagePushDto
.
getPushType
().
equals
(
"1"
)){
//通过员工id查询群列表
WeGroup
weGroup
=
new
WeGroup
();
weGroup
.
setUserIds
(
customerMessagePushDto
.
getStaffId
());
List
<
WeGroup
>
groups
=
weGroupService
.
selectWeGroupList
(
weGroup
);
if
(
CollectionUtils
.
isNotEmpty
(
groups
)){
List
<
String
>
owners
=
groups
.
stream
().
map
(
WeGroup:
:
getOwner
).
collect
(
Collectors
.
toList
());
owners
.
forEach
(
s
->{
WeCustomerMessagePushDto
messagePushDto
=
new
WeCustomerMessagePushDto
();
messagePushDto
.
setChat_type
(
ChatType
.
of
(
customerMessagePushDto
.
getPushType
()).
getType
());
//客户群的员工id
messagePushDto
.
setSender
(
s
);
messagePushDto
.
setImage
(
customerMessagePushDto
.
getImageMessage
());
messagePushDto
.
setLink
(
customerMessagePushDto
.
getLinkMessage
());
messagePushDto
.
setMiniprogram
(
customerMessagePushDto
.
getMiniprogramMessage
());
messagePushDto
.
setText
(
customerMessagePushDto
.
getTextMessage
());
SendMessageResultDto
sendMessageResultDto
=
weCustomerMessagePushClient
.
sendCustomerMessageToUser
(
messagePushDto
);
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
sendMessageResultDto
.
getErrcode
())){
//发送的msgId
msgIds
.
add
(
sendMessageResultDto
.
getMsgid
());
senders
.
add
(
s
);
}
});
}
}
//微信群发消息表 WeCustomerMessage
long
messageId
=
SnowFlakeUtil
.
nextId
();
WeCustomerMessage
customerMessage
=
new
WeCustomerMessage
();
customerMessage
.
setOriginalId
(
messageOriginalId
);
customerMessage
.
setMessageId
(
messageId
);
customerMessage
.
setChatType
(
customerMessagePushDto
.
getPushType
());
customerMessage
.
setExternalUserid
(
objectMapper
.
writeValueAsString
(
externalUserIds
));
customerMessage
.
setSender
(
objectMapper
.
writeValueAsString
(
senders
));
customerMessage
.
setCheckStatus
(
"0"
);
customerMessage
.
setMsgid
(
objectMapper
.
writeValueAsString
(
msgIds
));
customerMessage
.
setDelFlag
(
0
);
weCustomerMessageService
.
save
(
customerMessage
);
//TODO 消息发送结果保存逻辑待定 到底是怎么保存
WeCustomerMessgaeResult
weCustomerMessgaeResult
=
new
WeCustomerMessgaeResult
();
//保存分类消息信息
saveSeedMessage
(
customerMessagePushDto
,
messageId
);
//原始数据信息表 主键id
}
/**
* 各分类消息表
* @param customerMessagePushDto 群发消息
* @param messageId 消息id
*/
public
void
saveSeedMessage
(
CustomerMessagePushDto
customerMessagePushDto
,
long
messageId
){
String
messageType
=
customerMessagePushDto
.
getMessageType
();
switch
(
messageType
){
case
"0"
:
//文本消息
WeCustomerTextMessag
textMessage
=
new
WeCustomerTextMessag
();
textMessage
.
setTextMessageId
(
SnowFlakeUtil
.
nextId
());
textMessage
.
setMessageId
(
messageId
);
TextMessageDto
textMessageDto
=
customerMessagePushDto
.
getTextMessage
();
textMessage
.
setContent
(
textMessageDto
.
getContent
());
textMessage
.
setDelFlag
(
0
);
weCustomerTextMessagService
.
save
(
textMessage
);
break
;
case
"1"
:
//图片消息
WeCustomerImageMessage
imageMessage
=
new
WeCustomerImageMessage
();
imageMessage
.
setImageMessageId
(
SnowFlakeUtil
.
nextId
());
imageMessage
.
setMessageId
(
messageId
);
ImageMessageDto
imageMessageDto
=
customerMessagePushDto
.
getImageMessage
();
imageMessage
.
setMediaId
(
imageMessageDto
.
getMedia_id
());
imageMessage
.
setPicUrl
(
imageMessageDto
.
getPic_url
());
imageMessage
.
setDelFlag
(
0
);
weCustomerImageMessageService
.
save
(
imageMessage
);
break
;
case
"2"
:
//链接消息
WeCustomerLinkMessage
linkMessage
=
new
WeCustomerLinkMessage
();
linkMessage
.
setLinkMessageId
(
SnowFlakeUtil
.
nextId
());
linkMessage
.
setMessageId
(
messageId
);
LinkMessageDto
linkMessageDto
=
customerMessagePushDto
.
getLinkMessage
();
linkMessage
.
setUrl
(
linkMessageDto
.
getUrl
());
linkMessage
.
setPicurl
(
linkMessageDto
.
getPicurl
());
linkMessage
.
setTitle
(
linkMessageDto
.
getTitle
());
linkMessage
.
setDesc
(
linkMessageDto
.
getDesc
());
linkMessage
.
setDelFlag
(
0
);
weCustomerLinkMessageService
.
save
(
linkMessage
);
break
;
case
"3"
:
//小程序消息
WeCustomerMiniprogramMessage
miniprogramMessage
=
new
WeCustomerMiniprogramMessage
();
miniprogramMessage
.
setMiniprogramMessageId
(
SnowFlakeUtil
.
nextId
());
miniprogramMessage
.
setMessageId
(
messageId
);
MiniprogramMessageDto
miniprogramMessageDto
=
customerMessagePushDto
.
getMiniprogramMessage
();
miniprogramMessage
.
setAppid
(
miniprogramMessageDto
.
getAppid
());
miniprogramMessage
.
setPage
(
miniprogramMessageDto
.
getPage
());
miniprogramMessage
.
setPicMediaId
(
miniprogramMessageDto
.
getPic_media_id
());
miniprogramMessage
.
setTitle
(
miniprogramMessageDto
.
getTitle
());
miniprogramMessage
.
setDelFlag
(
0
);
weCustomerMiniprogramMessageService
.
save
(
miniprogramMessage
);
break
;
}
}
//微信群发消息表
/**
* 客户的外部联系人id列表,仅在chat_type为single时有效,不可与sender同时为空,最多可传入1万个客户
*
* @param pushRange 消息范围 0 全部客户 1 指定客户
* @param staffId 员工id
* @param department 部门id
* @param tag 客户标签id列表
* @return {@link List}s 客户的外部联系人id列表
*/
public
List
<
String
>
externalUserIds
(
String
pushRange
,
String
staffId
,
String
department
,
String
tag
){
List
<
String
>
customers
=
Lists
.
newArrayList
();
if
(
pushRange
.
equals
(
"0"
)){
//查询系统所有客户
List
<
WeCustomer
>
weCustomers
=
weCustomerService
.
list
();
if
(
CollectionUtils
.
isNotEmpty
(
weCustomers
)){
customers
=
weCustomers
.
stream
().
map
(
WeCustomer:
:
getExternalUserid
).
distinct
().
collect
(
Collectors
.
toList
());
}
}
else
{
//按条件查询客户
//通过部门id查询所有的员工
//通过员工列表查询该员工的外部联系人列表
WeCustomer
weCustomer
=
new
WeCustomer
();
weCustomer
.
setUserIds
(
staffId
);
weCustomer
.
setTagIds
(
tag
);
weCustomer
.
setDepartmentIds
(
department
);
List
<
WeCustomer
>
weCustomers
=
weCustomerService
.
selectWeCustomerList
(
weCustomer
);
if
(
CollectionUtils
.
isNotEmpty
(
weCustomers
)){
customers
=
weCustomers
.
stream
().
map
(
WeCustomer:
:
getExternalUserid
).
distinct
().
collect
(
Collectors
.
toList
());
}
//各分类消息表
}
return
customers
;
}
//查询发送结果表
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessageServiceImpl.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.wecom.domain.WeCustomerMessage
;
import
com.linkwechat.wecom.mapper.WeCustomerMessageMapper
;
import
com.linkwechat.wecom.service.IWeCustomerMessageService
;
import
org.springframework.stereotype.Service
;
/**
* 群发消息 微信消息表service接口
*
* @author kewen
* @date 2020-12-12
*/
@Service
public
class
WeCustomerMessageServiceImpl
extends
ServiceImpl
<
WeCustomerMessageMapper
,
WeCustomerMessage
>
implements
IWeCustomerMessageService
{
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessgaeResultServiceImpl.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.wecom.domain.WeCustomerMessgaeResult
;
import
com.linkwechat.wecom.mapper.WeCustomerMessgaeResultMapper
;
import
com.linkwechat.wecom.service.IWeCustomerMessgaeResultService
;
import
org.springframework.stereotype.Service
;
/**
* 群发消息 微信消息发送结果表 we_customer_messgaeResult
*
* @author kewen
* @date 2020-12-12
*/
@Service
public
class
WeCustomerMessgaeResultServiceImpl
extends
ServiceImpl
<
WeCustomerMessgaeResultMapper
,
WeCustomerMessgaeResult
>
implements
IWeCustomerMessgaeResultService
{
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMiniprogramMessageServiceImpl.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.wecom.domain.WeCustomerMiniprogramMessage
;
import
com.linkwechat.wecom.mapper.WeCustomerMiniprogramMessageMapper
;
import
com.linkwechat.wecom.service.IWeCustomerMiniprogramMessageService
;
import
org.springframework.stereotype.Service
;
/**
* 群发消息 小程序消息表 we_customer_miniprogramMessage
*
* @author kewen
* @date 2020-12-12
*/
@Service
public
class
WeCustomerMiniprogramMessageServiceImpl
extends
ServiceImpl
<
WeCustomerMiniprogramMessageMapper
,
WeCustomerMiniprogramMessage
>
implements
IWeCustomerMiniprogramMessageService
{
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
View file @
adde9cc
...
@@ -409,20 +409,21 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -409,20 +409,21 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
if
(
CollectionUtil
.
isNotEmpty
(
addTags
))
{
if
(
CollectionUtil
.
isNotEmpty
(
addTags
))
{
//获取当前客户需要移除的标签
List
<
WeFlowerCustomerTagRel
>
removeTag
=
iWeFlowerCustomerTagRelService
.
list
(
new
LambdaQueryWrapper
<
WeFlowerCustomerTagRel
>()
.
in
(
WeFlowerCustomerTagRel:
:
getFlowerCustomerRelId
,
iWeFlowerCustomerRelService
.
list
(
new
LambdaQueryWrapper
<
WeFlowerCustomerRel
>().
eq
(
WeFlowerCustomerRel:
:
getExternalUserid
,
weMakeCustomerTag
.
getExternalUserid
())).
stream
().
map
(
WeFlowerCustomerRel:
:
getId
).
collect
(
Collectors
.
toList
()))
.
notIn
(
WeFlowerCustomerTagRel:
:
getTagId
,
addTags
.
stream
().
map
(
WeTag:
:
getTagId
).
collect
(
Collectors
.
toList
()))
);
//查询出当前用户对应的
//查询出当前用户对应的
List
<
WeFlowerCustomerRel
>
flowerCustomerRels
=
iWeFlowerCustomerRelService
.
list
(
new
LambdaQueryWrapper
<
WeFlowerCustomerRel
>()
List
<
WeFlowerCustomerRel
>
flowerCustomerRels
=
iWeFlowerCustomerRelService
.
list
(
new
LambdaQueryWrapper
<
WeFlowerCustomerRel
>()
.
eq
(
WeFlowerCustomerRel:
:
getExternalUserid
,
weMakeCustomerTag
.
getExternalUserid
()));
.
eq
(
WeFlowerCustomerRel:
:
getExternalUserid
,
weMakeCustomerTag
.
getExternalUserid
()));
if
(
CollectionUtil
.
isNotEmpty
(
flowerCustomerRels
))
{
if
(
CollectionUtil
.
isNotEmpty
(
flowerCustomerRels
))
{
List
<
WeFlowerCustomerTagRel
>
removeTag
=
iWeFlowerCustomerTagRelService
.
list
(
new
LambdaQueryWrapper
<
WeFlowerCustomerTagRel
>()
.
in
(
WeFlowerCustomerTagRel:
:
getFlowerCustomerRelId
,
flowerCustomerRels
.
stream
().
map
(
WeFlowerCustomerRel:
:
getId
).
collect
(
Collectors
.
toList
()))
.
in
(
WeFlowerCustomerTagRel:
:
getTagId
,
addTags
.
stream
().
map
(
WeTag:
:
getTagId
).
collect
(
Collectors
.
toList
())));
if
(
CollectionUtil
.
isNotEmpty
(
removeTag
)){
if
(
iWeFlowerCustomerTagRelService
.
remove
(
if
(
iWeFlowerCustomerTagRelService
.
remove
(
new
LambdaQueryWrapper
<
WeFlowerCustomerTagRel
>()
new
LambdaQueryWrapper
<
WeFlowerCustomerTagRel
>()
.
in
(
WeFlowerCustomerTagRel:
:
getFlowerCustomerRelId
,
flowerCustomerRels
.
stream
().
map
(
WeFlowerCustomerRel:
:
getId
).
collect
(
Collectors
.
toList
()))
.
in
(
WeFlowerCustomerTagRel:
:
getFlowerCustomerRelId
,
flowerCustomerRels
.
stream
().
map
(
WeFlowerCustomerRel:
:
getId
).
collect
(
Collectors
.
toList
()))
...
@@ -441,6 +442,13 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -441,6 +442,13 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
});
});
}
}
}
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerTextMessagServiceImpl.java
0 → 100644
View file @
adde9cc
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.wecom.domain.WeCustomerTextMessag
;
import
com.linkwechat.wecom.mapper.WeCustomerTextMessagMapper
;
import
com.linkwechat.wecom.service.IWeCustomerTextMessagService
;
import
org.springframework.stereotype.Service
;
/**
* 群发消息 文本消息表 we_customer_textMessage
*
* @author kewen
* @date 2020-12-12
*/
@Service
public
class
WeCustomerTextMessagServiceImpl
extends
ServiceImpl
<
WeCustomerTextMessagMapper
,
WeCustomerTextMessag
>
implements
IWeCustomerTextMessagService
{
}
linkwe-wecom/src/main/resources/mapper/wecom/WeCorpAccountMapper.xml
View file @
adde9cc
...
@@ -19,10 +19,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -19,10 +19,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"agentId"
column=
"agent_id"
/>
<result
property=
"agentId"
column=
"agent_id"
/>
<result
property=
"providerSecret"
column=
"provider_secret"
/>
<result
property=
"providerSecret"
column=
"provider_secret"
/>
<result
property=
"customerChurnNoticeSwitch"
column=
"customer_churn_notice_switch"
/>
<result
property=
"customerChurnNoticeSwitch"
column=
"customer_churn_notice_switch"
/>
<result
property=
"wxQrLoginRedirectUri"
column=
"wx_qr_login_redirect_uri"
/>
</resultMap>
</resultMap>
<sql
id=
"selectWeCorpAccountVo"
>
<sql
id=
"selectWeCorpAccountVo"
>
select id,provider_secret,company_name, corp_id, corp_secret,agent_id ,status, del_flag, create_by, create_time, update_by, update_time,contact_secret, customer_churn_notice_switch from we_corp_account
select id,provider_secret,company_name, corp_id, corp_secret,agent_id ,status, del_flag, create_by, create_time, update_by, update_time,contact_secret, customer_churn_notice_switch
,wx_qr_login_redirect_uri
from we_corp_account
</sql>
</sql>
<select
id=
"selectWeCorpAccountList"
parameterType=
"WeCorpAccount"
resultMap=
"WeCorpAccountResult"
>
<select
id=
"selectWeCorpAccountList"
parameterType=
"WeCorpAccount"
resultMap=
"WeCorpAccountResult"
>
...
...
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerImageMessageMapper.xml
0 → 100644
View file @
adde9cc
<?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.linkwechat.wecom.mapper.WeCustomerImageMessageMapper"
>
</mapper>
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerLinkMessageMapper.xml
0 → 100644
View file @
adde9cc
<?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.linkwechat.wecom.mapper.WeCustomerLinkMessageMapper"
>
</mapper>
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerMapper.xml
View file @
adde9cc
...
@@ -114,6 +114,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -114,6 +114,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND wt.tag_id=#{tagIds}
AND wt.tag_id=#{tagIds}
</if>
</if>
</if>
</if>
<if
test=
"departmentIds != null and departmentIds !=''"
>
<if
test=
"departmentIds.indexOf(',') != -1"
>
AND wu.department in
<foreach
item=
"item"
index=
"index"
collection=
"departmentIds.split(',')"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</if>
<if
test=
"departmentIds.indexOf(',') == -1"
>
AND wu.department=#{departmentIds}
</if>
</if>
<if
test=
"status !=null and status !=''"
>
AND wfcr.status=#{status}
</if>
</where>
</where>
ORDER BY wfcr.create_time DESC
ORDER BY wfcr.create_time DESC
</select>
</select>
...
...
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerMessageMapper.xml
0 → 100644
View file @
adde9cc
<?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.linkwechat.wecom.mapper.WeCustomerMessageMapper"
>
</mapper>
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerMessageOriginalMapper.xml
0 → 100644
View file @
adde9cc
<?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.linkwechat.wecom.mapper.WeCustomerMessageOriginalMapper"
>
</mapper>
\ No newline at end of file
\ No newline at end of file
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerMiniprogramMessageMapper.xml
0 → 100644
View file @
adde9cc
<?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.linkwechat.wecom.mapper.WeCustomerMiniprogramMessageMapper"
>
</mapper>
\ No newline at end of file
\ No newline at end of file
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerTextMessagMapper.xml
0 → 100644
View file @
adde9cc
<?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.linkwechat.wecom.mapper.WeCustomerTextMessagMapper"
>
</mapper>
\ No newline at end of file
\ No newline at end of file
linkwe-wecom/src/main/resources/mapper/wecom/WeGroupMapper.xml
View file @
adde9cc
...
@@ -27,6 +27,17 @@
...
@@ -27,6 +27,17 @@
<if
test=
"endTime != null and endTime != ''"
>
<!-- 结束时间检索 -->
<if
test=
"endTime != null and endTime != ''"
>
<!-- 结束时间检索 -->
AND date_format(wg.create_time,'%y%m%d')
<
= date_format(#{endTime},'%y%m%d')
AND date_format(wg.create_time,'%y%m%d')
<
= date_format(#{endTime},'%y%m%d')
</if>
</if>
<if
test=
"userIds != null and userIds !=''"
>
<if
test=
"userIds.indexOf(',') != -1"
>
AND wg.`owner` in
<foreach
item=
"item"
index=
"index"
collection=
"userIds.split(',')"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</if>
<if
test=
"userIds.indexOf(',') == -1"
>
AND wg.`owner`=#{userIds}
</if>
</if>
</where>
</where>
</select>
</select>
...
...
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