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 c6d64a95
authored
Jan 07, 2021
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
297ec1f6
cae67579
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
43 deletions
README.md
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeGroupController.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeMaterialController.java
linkwe-admin/src/main/resources/application.yml
linkwe-ui/README.md
linkwe-ui/src/views/customerManage/customer.vue
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeGroupServiceImpl.java
README.md
View file @
c6d64a9
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<div
align=
"center"
>
<div
align=
"center"
>






...
...
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeGroupController.java
View file @
c6d64a9
...
@@ -11,6 +11,8 @@ import com.linkwechat.wecom.service.IWeGroupMemberService;
...
@@ -11,6 +11,8 @@ import com.linkwechat.wecom.service.IWeGroupMemberService;
import
com.linkwechat.wecom.service.IWeGroupService
;
import
com.linkwechat.wecom.service.IWeGroupService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.core.context.SecurityContext
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
@@ -59,10 +61,14 @@ public class WeGroupController extends BaseController {
...
@@ -59,10 +61,14 @@ public class WeGroupController extends BaseController {
@PreAuthorize
(
"@ss.hasPermi('customerManage:group:sync')"
)
@PreAuthorize
(
"@ss.hasPermi('customerManage:group:sync')"
)
@GetMapping
({
"/synchWeGroup"
})
@GetMapping
({
"/synchWeGroup"
})
public
AjaxResult
synchWeGroup
(){
public
AjaxResult
synchWeGroup
(){
try
{
SecurityContext
context
=
SecurityContextHolder
.
getContext
();
weGroupService
.
synchWeGroup
();
SecurityContextHolder
.
setStrategyName
(
SecurityContextHolder
.
MODE_INHERITABLETHREADLOCAL
);
SecurityContextHolder
.
setContext
(
context
);
weGroupService
.
synchWeGroup
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
AjaxResult
.
success
(
WeConstans
.
SYNCH_TIP
);
return
AjaxResult
.
success
(
WeConstans
.
SYNCH_TIP
);
}
}
...
...
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeMaterialController.java
View file @
c6d64a9
...
@@ -51,7 +51,7 @@ public class WeMaterialController extends BaseController {
...
@@ -51,7 +51,7 @@ public class WeMaterialController extends BaseController {
startPage
();
startPage
();
List
<
WeMaterial
>
list
;
List
<
WeMaterial
>
list
;
if
(
StringUtils
.
isNotBlank
(
mediaType
)
&&
mediaType
.
equals
(
MediaType
.
POSTER
.
getType
())){
if
(
StringUtils
.
isNotBlank
(
mediaType
)
&&
mediaType
.
equals
(
MediaType
.
POSTER
.
getType
())){
list
=
wePosterService
.
list
(
Long
.
valueOf
(
categoryId
),
search
).
stream
().
map
(
wePoster
->
{
list
=
wePosterService
.
list
(
StringUtils
.
isBlank
(
categoryId
)?
null
:
Long
.
valueOf
(
categoryId
),
search
).
stream
().
map
(
wePoster
->
{
WeMaterial
weMaterial
=
new
WeMaterial
();
WeMaterial
weMaterial
=
new
WeMaterial
();
weMaterial
.
setMaterialName
(
wePoster
.
getTitle
());
weMaterial
.
setMaterialName
(
wePoster
.
getTitle
());
weMaterial
.
setMaterialUrl
(
wePoster
.
getSampleImgPath
());
weMaterial
.
setMaterialUrl
(
wePoster
.
getSampleImgPath
());
...
...
linkwe-admin/src/main/resources/application.yml
View file @
c6d64a9
...
@@ -178,6 +178,8 @@ wecome:
...
@@ -178,6 +178,8 @@ wecome:
-
/externalcontact/get_unassigned_list
-
/externalcontact/get_unassigned_list
-
/externalcontact/send_welcome_msg
-
/externalcontact/send_welcome_msg
-
/externalcontact/unionid_to_external_userid
-
/externalcontact/unionid_to_external_userid
-
/get_jsapi_ticket
-
/ticket/get
fileUplodUrl
:
/media/upload,/media/uploadimg
fileUplodUrl
:
/media/upload,/media/uploadimg
needProviderTokenUrl
:
needProviderTokenUrl
:
-
/service/get_login_info
-
/service/get_login_info
...
...
linkwe-ui/README.md
View file @
c6d64a9
...
@@ -2,10 +2,10 @@
...
@@ -2,10 +2,10 @@
```
bash
```
bash
# 克隆项目
# 克隆项目
git clone https://gitee.com/
y_project/RuoYi-Vue
git clone https://gitee.com/
LinkWeChat/link-wechat.git
# 进入项目目录
# 进入项目目录
cd
ruoyi
-ui
cd
linkwe
-ui
# 安装依赖
# 安装依赖
npm install
npm install
...
@@ -14,7 +14,7 @@ npm install
...
@@ -14,7 +14,7 @@ npm install
npm install --registry
=
https://registry.npm.taobao.org
npm install --registry
=
https://registry.npm.taobao.org
# 启动服务
# 启动服务
npm run
dev
npm run
serve
```
```
浏览器访问 http://localhost:80
浏览器访问 http://localhost:80
...
...
linkwe-ui/src/views/customerManage/customer.vue
View file @
c6d64a9
...
@@ -398,12 +398,13 @@ export default {
...
@@ -398,12 +398,13 @@ export default {
></el-table-column>
></el-table-column>
<el-table-column prop="
userName
" label="
添加人(首位)
" align="
center
">
<el-table-column prop="
userName
" label="
添加人(首位)
" align="
center
">
<template slot-scope="
scope
"
>
{{
<template slot-scope="
scope
"
>
{{
scope
.
row
.
weFlowerCustomerRels
[
0
].
userName
scope
.
row
.
weFlowerCustomerRels
[
0
]?
scope
.
row
.
weFlowerCustomerRels
[
0
].
userName
:
""
}}
<
/template
>
}}
<
/template
>
<
/el-table-column
>
<
/el-table-column
>
<
el
-
table
-
column
prop
=
"createTime"
label
=
"添加时间"
align
=
"center"
>
<
el
-
table
-
column
prop
=
"createTime"
label
=
"添加时间"
align
=
"center"
>
<
template
slot
-
scope
=
"scope"
>
{{
<
template
slot
-
scope
=
"scope"
>
{{
scope
.
row
.
weFlowerCustomerRels
[
0
]
.
createTime
scope
.
row
.
weFlowerCustomerRels
[
0
]
?
scope
.
row
.
weFlowerCustomerRels
[
0
].
createTime
:
""
}}
<
/template
>
}}
<
/template
>
<
/el-table-column
>
<
/el-table-column
>
<
el
-
table
-
column
prop
=
"address"
label
=
"标签"
align
=
"center"
>
<
el
-
table
-
column
prop
=
"address"
label
=
"标签"
align
=
"center"
>
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeGroupServiceImpl.java
View file @
c6d64a9
...
@@ -2,8 +2,6 @@ package com.linkwechat.wecom.service.impl;
...
@@ -2,8 +2,6 @@ package com.linkwechat.wecom.service.impl;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONUtil
;
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.constant.WeConstans
;
import
com.linkwechat.common.constant.WeConstans
;
...
@@ -14,11 +12,16 @@ import com.linkwechat.wecom.domain.WeAllocateGroup;
...
@@ -14,11 +12,16 @@ import com.linkwechat.wecom.domain.WeAllocateGroup;
import
com.linkwechat.wecom.domain.WeGroup
;
import
com.linkwechat.wecom.domain.WeGroup
;
import
com.linkwechat.wecom.domain.WeGroupMember
;
import
com.linkwechat.wecom.domain.WeGroupMember
;
import
com.linkwechat.wecom.domain.dto.AllocateWeGroupDto
;
import
com.linkwechat.wecom.domain.dto.AllocateWeGroupDto
;
import
com.linkwechat.wecom.domain.dto.customer.*
;
import
com.linkwechat.wecom.domain.dto.customer.CustomerGroupDetail
;
import
com.linkwechat.wecom.domain.dto.customer.CustomerGroupList
;
import
com.linkwechat.wecom.domain.dto.customer.CustomerGroupMember
;
import
com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo
;
import
com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo
;
import
com.linkwechat.wecom.mapper.WeGroupMapper
;
import
com.linkwechat.wecom.mapper.WeGroupMapper
;
import
com.linkwechat.wecom.service.*
;
import
com.linkwechat.wecom.service.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.security.core.context.SecurityContext
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -33,8 +36,7 @@ import java.util.stream.Collectors;
...
@@ -33,8 +36,7 @@ import java.util.stream.Collectors;
* @Date: create in 2020/9/22 0022 0:03
* @Date: create in 2020/9/22 0022 0:03
*/
*/
@Service
@Service
public
class
WeGroupServiceImpl
extends
ServiceImpl
<
WeGroupMapper
,
WeGroup
>
implements
IWeGroupService
{
public
class
WeGroupServiceImpl
extends
ServiceImpl
<
WeGroupMapper
,
WeGroup
>
implements
IWeGroupService
{
@Autowired
@Autowired
...
@@ -69,6 +71,7 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
...
@@ -69,6 +71,7 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
/**
/**
* 离职员工群分配
* 离职员工群分配
*
* @param weLeaveUserInfoAllocateVo
* @param weLeaveUserInfoAllocateVo
* @return
* @return
*/
*/
...
@@ -78,10 +81,10 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
...
@@ -78,10 +81,10 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
List
<
WeGroup
>
weGroups
List
<
WeGroup
>
weGroups
=
this
.
list
(
new
LambdaQueryWrapper
<
WeGroup
>().
eq
(
WeGroup:
:
getOwner
,
weLeaveUserInfoAllocateVo
.
getHandoverUserid
()));
=
this
.
list
(
new
LambdaQueryWrapper
<
WeGroup
>().
eq
(
WeGroup:
:
getOwner
,
weLeaveUserInfoAllocateVo
.
getHandoverUserid
()));
if
(
CollectionUtil
.
isNotEmpty
(
weGroups
))
{
if
(
CollectionUtil
.
isNotEmpty
(
weGroups
))
{
List
<
WeAllocateGroup
>
weAllocateGroups
=
new
ArrayList
<>();
List
<
WeAllocateGroup
>
weAllocateGroups
=
new
ArrayList
<>();
//更改本地群主
//更改本地群主
weGroups
.
stream
().
forEach
(
k
->
{
weGroups
.
stream
().
forEach
(
k
->
{
k
.
setOwner
(
weLeaveUserInfoAllocateVo
.
getTakeoverUserid
());
k
.
setOwner
(
weLeaveUserInfoAllocateVo
.
getTakeoverUserid
());
weAllocateGroups
.
add
(
WeAllocateGroup
.
builder
()
weAllocateGroups
.
add
(
WeAllocateGroup
.
builder
()
.
allocateTime
(
new
Date
())
.
allocateTime
(
new
Date
())
...
@@ -92,13 +95,13 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
...
@@ -92,13 +95,13 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
});
});
this
.
saveOrUpdateBatch
(
weGroups
);
this
.
saveOrUpdateBatch
(
weGroups
);
//分配记录保存
//分配记录保存
if
(
CollectionUtil
.
isNotEmpty
(
weAllocateGroups
))
{
if
(
CollectionUtil
.
isNotEmpty
(
weAllocateGroups
))
{
if
(
iWeAllocateGroupService
.
saveOrUpdateBatch
(
weAllocateGroups
))
{
if
(
iWeAllocateGroupService
.
saveOrUpdateBatch
(
weAllocateGroups
))
{
//同步企业微信端
//同步企业微信端
weUserClient
.
allocateGroup
(
weUserClient
.
allocateGroup
(
AllocateWeGroupDto
.
builder
()
AllocateWeGroupDto
.
builder
()
.
chat_id_list
(
ArrayUtil
.
toArray
(
weAllocateGroups
.
stream
().
map
(
WeAllocateGroup:
:
getChatId
).
collect
(
Collectors
.
toList
()),
String
.
class
))
.
chat_id_list
(
ArrayUtil
.
toArray
(
weAllocateGroups
.
stream
().
map
(
WeAllocateGroup:
:
getChatId
).
collect
(
Collectors
.
toList
()),
String
.
class
))
.
new_owner
(
weLeaveUserInfoAllocateVo
.
getTakeoverUserid
())
.
new_owner
(
weLeaveUserInfoAllocateVo
.
getTakeoverUserid
())
.
build
()
.
build
()
);
);
...
@@ -114,27 +117,28 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
...
@@ -114,27 +117,28 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
* 客户群同步
* 客户群同步
*/
*/
@Override
@Override
@Async
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
synchWeGroup
()
{
public
void
synchWeGroup
()
{
CustomerGroupList
customerGroupList
=
CustomerGroupList
customerGroupList
=
weCustomerGroupClient
.
groupChatLists
(
new
CustomerGroupList
().
new
Params
());
weCustomerGroupClient
.
groupChatLists
(
new
CustomerGroupList
().
new
Params
());
if
(
customerGroupList
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
)
if
(
customerGroupList
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
)
&&
CollectionUtil
.
isNotEmpty
(
customerGroupList
.
getGroup_chat_list
()))
{
&&
CollectionUtil
.
isNotEmpty
(
customerGroupList
.
getGroup_chat_list
()))
{
List
<
WeGroup
>
weGroups
=
new
ArrayList
<>();
List
<
WeGroup
>
weGroups
=
new
ArrayList
<>();
List
<
WeGroupMember
>
weGroupMembers
=
new
ArrayList
<>();
List
<
WeGroupMember
>
weGroupMembers
=
new
ArrayList
<>();
customerGroupList
.
getGroup_chat_list
().
stream
().
forEach
(
k
->
{
customerGroupList
.
getGroup_chat_list
().
stream
().
forEach
(
k
->
{
CustomerGroupDetail
customerGroupDetail
=
weCustomerGroupClient
.
groupChatDetail
(
CustomerGroupDetail
customerGroupDetail
=
weCustomerGroupClient
.
groupChatDetail
(
new
CustomerGroupDetail
().
new
Params
(
k
.
getChat_id
())
new
CustomerGroupDetail
().
new
Params
(
k
.
getChat_id
())
);
);
if
(
customerGroupDetail
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
)
if
(
customerGroupDetail
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
)
&&
CollectionUtil
.
isNotEmpty
(
customerGroupDetail
.
getGroup_chat
()))
{
&&
CollectionUtil
.
isNotEmpty
(
customerGroupDetail
.
getGroup_chat
()))
{
customerGroupDetail
.
getGroup_chat
().
stream
().
forEach
(
kk
->
{
customerGroupDetail
.
getGroup_chat
().
stream
().
forEach
(
kk
->
{
weGroups
.
add
(
weGroups
.
add
(
WeGroup
.
builder
()
WeGroup
.
builder
()
.
chatId
(
kk
.
getChat_id
())
.
chatId
(
kk
.
getChat_id
())
...
@@ -146,8 +150,8 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
...
@@ -146,8 +150,8 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
.
build
()
.
build
()
);
);
List
<
CustomerGroupMember
>
memberLists
=
kk
.
getMember_list
();
List
<
CustomerGroupMember
>
memberLists
=
kk
.
getMember_list
();
if
(
CollectionUtil
.
isNotEmpty
(
memberLists
))
{
if
(
CollectionUtil
.
isNotEmpty
(
memberLists
))
{
memberLists
.
stream
().
forEach
(
member
->
{
memberLists
.
stream
().
forEach
(
member
->
{
//unionid不为空,获取非好友客户相关消息
//unionid不为空,获取非好友客户相关消息
...
@@ -171,8 +175,6 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
...
@@ -171,8 +175,6 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
// }
// }
//
//
// }
// }
weGroupMembers
.
add
(
weGroupMembers
.
add
(
WeGroupMember
.
builder
()
WeGroupMember
.
builder
()
.
chatId
(
kk
.
getChat_id
())
.
chatId
(
kk
.
getChat_id
())
...
@@ -192,17 +194,33 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
...
@@ -192,17 +194,33 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
}
}
});
});
//同步组织架构成员
/**
weUserService
.
synchWeUser
();
* 此处不同步成员和客户理由
//同步客户
* 1、如果是存量同步,不存在新客户新成员问题
weCustomerService
.
synchWeCustomer
();
* 2、增量同步的,成员和客户增删改群变更都会走回调通知,不用考虑新增成员和客户回调通知没有处理问题
*/
//同步组织架构成员
//weUserService.synchWeUser();
//同步客户
//weCustomerService.synchWeCustomer();
this
.
saveOrUpdateBatch
(
weGroups
);
this
.
saveOrUpdateBatch
(
weGroups
);
iWeGroupMemberService
.
remove
(
new
LambdaQueryWrapper
<
WeGroupMember
>().
in
(
WeGroupMember:
:
getChatId
,
List
<
WeGroupMember
>
weGroupMemberList
=
iWeGroupMemberService
.
list
(
new
LambdaQueryWrapper
<
WeGroupMember
>().
in
(
WeGroupMember:
:
getChatId
,
weGroups
.
stream
().
map
(
WeGroup:
:
getChatId
).
collect
(
Collectors
.
toList
())));
weGroups
.
stream
().
map
(
WeGroup:
:
getChatId
).
collect
(
Collectors
.
toList
())));
iWeGroupMemberService
.
saveOrUpdateBatch
(
weGroupMembers
);
//存量去重
if
(
CollectionUtil
.
isNotEmpty
(
weGroupMemberList
)){
List
<
WeGroupMember
>
groupMemberList
=
weGroupMembers
.
stream
().
filter
(
e
->
{
for
(
WeGroupMember
weGroupMember
:
weGroupMemberList
)
{
if
(
e
.
getUserId
().
equals
(
weGroupMember
.
getUserId
()))
{
return
false
;
}
}
return
true
;
}).
collect
(
Collectors
.
toList
());
iWeGroupMemberService
.
saveBatch
(
groupMemberList
);
}
else
{
iWeGroupMemberService
.
saveBatch
(
weGroupMembers
);
}
}
}
...
...
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