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 dee159df
authored
Dec 09, 2020
by
sunxiwang
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
2 parents
8d7ab65d
cc4f54bb
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
170 additions
and
23 deletions
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerController.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTagGroupController.java
linkwe-common/src/main/java/com/linkwechat/common/constant/Constants.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeTagGroupServiceImpl.java
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerMapper.xml
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerController.java
View file @
dee159d
...
...
@@ -33,6 +33,8 @@ public class WeCustomerController extends BaseController
@Autowired
private
IWeCustomerService
weCustomerService
;
/**
* 查询企业微信客户列表
*/
...
...
@@ -41,6 +43,7 @@ public class WeCustomerController extends BaseController
public
TableDataInfo
list
(
WeCustomer
weCustomer
)
{
startPage
();
List
<
WeCustomer
>
list
=
weCustomerService
.
selectWeCustomerList
(
weCustomer
);
return
getDataTable
(
list
);
}
...
...
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTagGroupController.java
View file @
dee159d
...
...
@@ -7,8 +7,11 @@ import com.linkwechat.common.core.controller.BaseController;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.enums.BusinessType
;
import
com.linkwechat.common.utils.Threads
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.beans.factory.annotation.Autowired
;
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.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
...
...
@@ -41,6 +44,19 @@ public class WeTagGroupController extends BaseController
public
TableDataInfo
list
(
WeTagGroup
weTagGroup
)
{
startPage
();
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
//异步同步一下标签库,解决标签不同步问题
Threads
.
SINGLE_THREAD_POOL
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
SecurityContextHolder
.
setContext
(
securityContext
);
weTagGroupService
.
synchWeTags
();
}
});
return
getDataTable
(
weTagGroupService
.
selectWeTagGroupList
(
weTagGroup
)
);
...
...
linkwe-common/src/main/java/com/linkwechat/common/constant/Constants.java
View file @
dee159d
...
...
@@ -156,4 +156,8 @@ public class Constants
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeTagGroupServiceImpl.java
View file @
dee159d
...
...
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.api.R;
import
com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.common.constant.Constants
;
import
com.linkwechat.common.constant.UserConstants
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
com.linkwechat.common.utils.StringUtils
;
...
...
@@ -203,7 +204,6 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper,WeTagGr
@Transactional
public
void
synchWeTags
()
{
WeCropGroupTagListDto
weCropGroupTagListDto
=
weCropTagClient
.
getAllCorpTagList
();
if
(
weCropGroupTagListDto
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
)){
...
...
@@ -248,12 +248,32 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper,WeTagGr
}
//先逻辑删除不存在得组
if
(
CollectionUtil
.
isNotEmpty
(
weTagGroups
)){
List
<
WeTagGroup
>
noExist
=
this
.
list
(
new
LambdaQueryWrapper
<
WeTagGroup
>().
notIn
(
WeTagGroup:
:
getGroupId
,
weTagGroups
.
stream
().
map
(
WeTagGroup:
:
getGroupId
).
collect
(
Collectors
.
toList
())));
//企业微信端删除得标签
if
(
CollectionUtil
.
isNotEmpty
(
noExist
)){
noExist
.
stream
().
forEach
(
k
->
k
.
setStatus
(
Constants
.
DELETE_CODE
));
this
.
updateBatchById
(
noExist
);
}
this
.
saveOrUpdateBatch
(
weTagGroups
);
List
<
WeTag
>
weTags
=
weTagGroups
.
stream
().
map
(
WeTagGroup:
:
getWeTags
).
collect
(
ArrayList:
:
new
,
ArrayList:
:
addAll
,
ArrayList:
:
addAll
);
if
(
CollectionUtil
.
isNotEmpty
(
weTags
)){
List
<
WeTag
>
noExistWeTags
=
iWeTagService
.
list
(
new
LambdaQueryWrapper
<
WeTag
>().
notIn
(
WeTag:
:
getTagId
,
weTags
.
stream
().
map
(
WeTag:
:
getTagId
).
collect
(
Collectors
.
toList
())));
if
(
CollectionUtil
.
isNotEmpty
(
noExistWeTags
)){
noExistWeTags
.
stream
().
forEach
(
k
->
k
.
setStatus
(
Constants
.
DELETE_CODE
));
iWeTagService
.
updateBatchById
(
noExistWeTags
);
}
iWeTagService
.
saveOrUpdateBatch
(
weTags
);
}
...
...
@@ -264,4 +284,10 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper,WeTagGr
}
}
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerMapper.xml
View file @
dee159d
...
...
@@ -28,22 +28,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"status"
column=
"status"
/>
<result
property=
"userName"
column=
"user_name"
/>
<result
property=
"department"
column=
"department"
/>
<collection
property=
"weFlowerCustomerTagRels"
ofType=
"com.linkwechat.wecom.domain.WeFlowerCustomerTagRel"
>
<collection
property=
"weFlowerCustomerTagRels"
javaType=
"ArrayList"
column=
"{id = wfcrId}"
select=
"selectWeCustomerTags"
>
</collection>
</collection>
</resultMap>
<resultMap
id=
"weFlowerCustomerRelsMapper"
type=
"com.linkwechat.wecom.domain.WeFlowerCustomerTagRel"
>
<result
property=
"flowerCustomerRelId"
column=
"flower_customer_rel_id"
/>
<result
property=
"tagId"
column=
"tag_id"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"tagName"
column=
"tagName"
/>
</collection>
</collection>
</resultMap>
<sql
id=
"selectWeCustomerVo"
>
select external_userid, name, avatar, type, gender, unionid, birthday, corp_name, corp_full_name, position from we_customer
</sql>
<select
id=
"selectWeCustomerList"
parameterType=
"WeCustomer"
resultMap=
"WeCustomerResult"
>
SELECT
wc.external_userid,
DISTINCT
wc.external_userid,
wc.`name`,
wc.avatar,
wc.type,
...
...
@@ -64,57 +70,149 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wfcr.state,
wfcr.status,
wu.user_name,
wfcrf.flower_customer_rel_id,
wt.tag_id,
wt.`name` as tagName,
(SELECT GROUP_CONCAT(wd.`name`) FROM we_department wd WHERE wd.id=wu.department) as department
FROM
we_customer wc
LEFT JOIN we_flower_customer_rel wfcr ON wc.external_userid=wfcr.external_userid
LEFT JOIN we_user wu ON wu.user_id=wfcr.user_id
LEFT JOIN we_flower_customer_tag_rel wfcrf ON wfcrf.flower_customer_rel_id = wfcr.id
INNER
JOIN we_tag wt ON wt.tag_id = wfcrf.tag_id
LEFT
JOIN we_tag wt ON wt.tag_id = wfcrf.tag_id
<where>
<if
test=
"name != null and name !=''"
>
AND wc.name like concat('%', #{name}, '%')
</if>
<if
test=
"userIds != null and userIds !=''"
>
<if
test=
"userIds.indexOf(',') != -1"
>
and
wfcr.user_id in
AND
wfcr.user_id in
<foreach
item=
"item"
index=
"index"
collection=
"userIds.split(',')"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</if>
<if
test=
"userIds.indexOf(',') == -1"
>
and
wfcr.user_id=#{userIds}
AND
wfcr.user_id=#{userIds}
</if>
</if>
<if
test=
"beginTime != null and beginTime != ''"
>
<!-- 开始时间检索 -->
AND date_format(wfcr.create_time,'%y%m%d')
>
= date_format(#{beginTime},'%y%m%d')
</if>
<if
test=
"endTime != null and endTime != ''"
>
<!-- 结束时间检索 -->
AND date_format(wfcr.create_time,'%y%m%d')
<
= date_format(#{endTime},'%y%m%d')
</if>
<if
test=
"tagIds != null and tagIds !=''"
>
<if
test=
"tagIds.indexOf(',') != -1"
>
and
wt.tag_id in
AND
wt.tag_id in
<foreach
item=
"item"
index=
"index"
collection=
"tagIds.split(',')"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</if>
<if
test=
"tagIds.indexOf(',') == -1"
>
and
wt.tag_id=#{tagIds}
AND
wt.tag_id=#{tagIds}
</if>
</if>
<if
test=
"beginTime != null and beginTime != ''"
>
<!-- 开始时间检索 -->
AND date_format(wfcr.create_time,'%y%m%d')
>
= date_format(#{beginTime},'%y%m%d')
</if>
<if
test=
"endTime != null and endTime != ''"
>
<!-- 结束时间检索 -->
AND date_format(wfcr.create_time,'%y%m%d')
<
= date_format(#{endTime},'%y%m%d')
</if>
<if
test=
"status != null and status !=''"
>
AND wfcr.status = #{status}
</if>
</where>
ORDER BY wfcr.create_time DESC
<!-- SELECT-->
<!-- wc.external_userid,-->
<!-- wc.`name`,-->
<!-- wc.avatar,-->
<!-- wc.type,-->
<!-- wc.gender,-->
<!-- wc.unionid,-->
<!-- wc.birthday,-->
<!-- wc.corp_name,-->
<!-- wc.corp_full_name,-->
<!-- wc.position,-->
<!-- wfcr.id as wfcrId,-->
<!-- wfcr.user_id,-->
<!-- wfcr.remark,-->
<!-- wfcr.description,-->
<!-- wfcr.create_time,-->
<!-- wfcr.remark_corp_name,-->
<!-- wfcr.oper_userid,-->
<!-- wfcr.add_way,-->
<!-- wfcr.state,-->
<!-- wfcr.status,-->
<!-- wu.user_name,-->
<!-- wfcrf.flower_customer_rel_id,-->
<!-- wt.tag_id,-->
<!-- wt.`name` as tagName,-->
<!-- (SELECT GROUP_CONCAT(wd.`name`) FROM we_department wd WHERE wd.id=wu.department) as department-->
<!-- FROM-->
<!-- we_customer wc-->
<!-- LEFT JOIN we_flower_customer_rel wfcr ON wc.external_userid=wfcr.external_userid-->
<!-- LEFT JOIN we_user wu ON wu.user_id=wfcr.user_id-->
<!-- LEFT JOIN we_flower_customer_tag_rel wfcrf ON wfcrf.flower_customer_rel_id = wfcr.id-->
<!-- INNER JOIN we_tag wt ON wt.tag_id = wfcrf.tag_id-->
<!-- <where>-->
<!-- <if test="name != null and name !=''">-->
<!-- AND wc.name like concat('%', #{name}, '%')-->
<!-- </if>-->
<!-- <if test="userIds != null and userIds !=''">-->
<!-- <if test="userIds.indexOf(',') != -1">-->
<!-- and wfcr.user_id in-->
<!-- <foreach item="item" index="index" collection="userIds.split(',')" open="(" separator="," close=")">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="userIds.indexOf(',') == -1">-->
<!-- and wfcr.user_id=#{userIds}-->
<!-- </if>-->
<!-- </if>-->
<!-- <if test="tagIds != null and tagIds !=''">-->
<!-- <if test="tagIds.indexOf(',') != -1">-->
<!-- and wt.tag_id in-->
<!-- <foreach item="item" index="index" collection="tagIds.split(',')" open="(" separator="," close=")">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="tagIds.indexOf(',') == -1">-->
<!-- and wt.tag_id=#{tagIds}-->
<!-- </if>-->
<!-- </if>-->
<!-- <if test="beginTime != null and beginTime != ''"><!– 开始时间检索 –>-->
<!-- AND date_format(wfcr.create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')-->
<!-- </if>-->
<!-- <if test="endTime != null and endTime != ''"><!– 结束时间检索 –>-->
<!-- AND date_format(wfcr.create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')-->
<!-- </if>-->
<!-- <if test="status != null and status !=''">-->
<!-- AND wfcr.status = #{status}-->
<!-- </if>-->
<!-- </where>-->
</select>
<select
id=
"selectWeCustomerTags"
resultMap=
"weFlowerCustomerRelsMapper"
>
SELECT
wfcrf.flower_customer_rel_id,
wt.tag_id,
wt.`name` as tagName
FROM
we_flower_customer_tag_rel wfcrf
LEFT JOIN we_tag wt ON wt.tag_id = wfcrf.tag_id
where wfcrf.flower_customer_rel_id=#{id}
</select>
<select
id=
"selectWeCustomerById"
parameterType=
"String"
resultMap=
"WeCustomerResult"
>
<include
refid=
"selectWeCustomerVo"
/>
where external_userid = #{externalUserId}
...
...
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