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 fd9f06a8
authored
Sep 15, 2020
by
水库浪子
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
完成微信端企业服务人员,客户管理的对接
1 parent
ea175826
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
250 additions
and
14 deletions
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerController.java
linkwe-admin/src/main/resources/application.yml
linkwe-common/src/main/java/com/linkwechat/common/config/WeComeConfig.java
linkwe-common/src/main/java/com/linkwechat/common/constant/WeConstans.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/client/WeCustomerClient.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeCustomerDto.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeFollowUserDto.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeTagDto.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/interceptor/WeAccessTokenInterceptor.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeAccessTokenService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeAccessTokenServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
linkwe-wecom/src/main/resources/mapper/wecom/WeCorpAccountMapper.xml
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerController.java
View file @
fd9f06a
...
@@ -101,4 +101,20 @@ public class WeCustomerController extends BaseController
...
@@ -101,4 +101,20 @@ public class WeCustomerController extends BaseController
{
{
return
toAjax
(
weCustomerService
.
deleteWeCustomerByIds
(
ids
));
return
toAjax
(
weCustomerService
.
deleteWeCustomerByIds
(
ids
));
}
}
/**
* 客户同步接口
* @return
*/
@PreAuthorize
(
"@ss.hasPermi('wecom:customer:synchWeCustomer')"
)
@Log
(
title
=
"企业微信客户同步接口"
,
businessType
=
BusinessType
.
DELETE
)
@GetMapping
(
"/synchWeCustomer"
)
public
AjaxResult
synchWeCustomer
(){
weCustomerService
.
synchWeCustomer
();
return
null
;
}
}
}
linkwe-admin/src/main/resources/application.yml
View file @
fd9f06a
...
@@ -127,4 +127,5 @@ forest:
...
@@ -127,4 +127,5 @@ forest:
wecome
:
wecome
:
serverUrl
:
https://qyapi.weixin.qq.com/
serverUrl
:
https://qyapi.weixin.qq.com/
weComePrefix
:
cgi-bin
weComePrefix
:
cgi-bin
noAccessTokenUrl
:
/gettoken
\ No newline at end of file
\ No newline at end of file
noAccessTokenUrl
:
/gettoken
needContactTokenUrl
:
/externalcontact/get_follow_user_list
\ No newline at end of file
\ No newline at end of file
linkwe-common/src/main/java/com/linkwechat/common/config/WeComeConfig.java
View file @
fd9f06a
...
@@ -21,4 +21,7 @@ public class WeComeConfig {
...
@@ -21,4 +21,7 @@ public class WeComeConfig {
/** 企业微信端无需token的url */
/** 企业微信端无需token的url */
private
String
noAccessTokenUrl
;
private
String
noAccessTokenUrl
;
/** 需要使用外部联系人token的url*/
private
String
[]
needContactTokenUrl
;
}
}
linkwe-common/src/main/java/com/linkwechat/common/constant/WeConstans.java
View file @
fd9f06a
...
@@ -10,7 +10,13 @@ public class WeConstans {
...
@@ -10,7 +10,13 @@ public class WeConstans {
/**
/**
* 企业微信相关token
* 企业微信相关token
*/
*/
public
static
final
String
WE_ACCESS_TOKEN
=
"we_access_token"
;
public
static
final
String
WE_COMMON_ACCESS_TOKEN
=
"we_common_access_token"
;
/**
* 获取外部联系人相关 token
*/
public
static
final
String
WE_CONTACT_ACCESS_TOKEN
=
"we_contact_access_token"
;
/**
/**
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/client/WeCustomerClient.java
0 → 100644
View file @
fd9f06a
package
com
.
linkwechat
.
wecom
.
client
;
import
com.dtflys.forest.annotation.DataObject
;
import
com.dtflys.forest.annotation.Query
;
import
com.dtflys.forest.annotation.Request
;
import
com.linkwechat.wecom.domain.dto.WeCustomerDto
;
import
com.linkwechat.wecom.domain.dto.WeFollowUserDto
;
import
com.linkwechat.wecom.domain.dto.WeResultDto
;
/**
* @description: 获取配置客户联系人功能的成员
* @author: HaoN
* @create: 2020-09-15 14:15
**/
public
interface
WeCustomerClient
{
/**
* 获取配置了客户联系功能的成员列表
* @return
*/
@Request
(
url
=
"/externalcontact/get_follow_user_list"
)
WeFollowUserDto
getFollowUserList
();
/**
* 获取指定企业服务管理人员所有用的客户id
* @param userId 企业服务管理人员id(具有外部联系功能的员工)
* @return
*/
@Request
(
url
=
"/externalcontact/list"
)
WeCustomerDto
list
(
@Query
(
"userid"
)
String
userId
);
/**
* 根据客户id获取客户详情
* @param externalUserid
* @return
*/
@Request
(
url
=
"/externalcontact/get"
)
WeCustomerDto
get
(
@Query
(
"external_userid"
)
String
externalUserid
);
/**
* 修改客户备注信息
* @param weCustomerRemark
* @return
*/
@Request
(
url
=
"/externalcontact/remark"
,
type
=
"POST"
)
WeResultDto
remark
(
@DataObject
WeCustomerDto
.
WeCustomerRemark
weCustomerRemark
);
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeCustomerDto.java
0 → 100644
View file @
fd9f06a
package
com
.
linkwechat
.
wecom
.
domain
.
dto
;
import
lombok.Data
;
import
java.util.List
;
/**
* @description: 客户实体
* @author: HaoN
* @create: 2020-09-15 17:43
**/
@Data
public
class
WeCustomerDto
extends
WeResultDto
{
private
String
[]
external_userid
;
private
ExternalContact
external_contact
;
private
List
<
WeFollowUserDto
>
follow_user
;
@Data
class
ExternalContact
{
private
String
external_userid
;
private
String
name
;
private
String
position
;
private
String
avatar
;
private
String
corp_name
;
private
String
corp_full_name
;
private
Integer
type
;
private
Integer
gender
;
private
String
unionid
;
}
@Data
public
class
WeCustomerRemark
{
private
String
userid
;
private
String
external_userid
;
private
String
remark
;
private
String
description
;
private
String
remark_company
;
private
String
[]
remark_mobiles
;
private
String
remark_pic_mediaid
;
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeFollowUserDto.java
0 → 100644
View file @
fd9f06a
package
com
.
linkwechat
.
wecom
.
domain
.
dto
;
import
lombok.Data
;
import
java.util.List
;
/**
* @description: 企业服务人员数据传输实体(配置客户联系功能的成员)
* @author: HaoN
* @create: 2020-09-15 14:08
**/
@Data
public
class
WeFollowUserDto
extends
WeResultDto
{
private
String
[]
follow_user
;
private
String
userid
;
private
String
remark
;
private
String
description
;
private
Long
createtime
;
private
List
<
WeTagDto
>
tags
;
private
String
remark_corp_name
;
private
String
remark_mobiles
;
private
Integer
add_way
;
private
String
oper_userid
;
private
Integer
state
;
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeTagDto.java
0 → 100644
View file @
fd9f06a
package
com
.
linkwechat
.
wecom
.
domain
.
dto
;
import
lombok.Data
;
/**
* @description: 企业微信标签相关标签
* @author: HaoN
* @create: 2020-09-15 17:55
**/
@Data
public
class
WeTagDto
extends
WeResultDto
{
private
String
group_name
;
private
String
tag_name
;
private
Integer
type
;
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/interceptor/WeAccessTokenInterceptor.java
View file @
fd9f06a
...
@@ -12,6 +12,8 @@ import com.linkwechat.wecom.service.IWeAccessTokenService;
...
@@ -12,6 +12,8 @@ import com.linkwechat.wecom.service.IWeAccessTokenService;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.Arrays
;
/**
/**
* @description: 微信token拦截器
* @description: 微信token拦截器
* @author: HaoN
* @author: HaoN
...
@@ -40,13 +42,15 @@ public class WeAccessTokenInterceptor implements Interceptor{
...
@@ -40,13 +42,15 @@ public class WeAccessTokenInterceptor implements Interceptor{
String
uri
=
request
.
getUrl
().
replace
(
"http://"
,
""
);
String
uri
=
request
.
getUrl
().
replace
(
"http://"
,
""
);
// 添加请求参数access_token
// 添加请求参数access_token
if
(!
weComeConfig
.
getNoAccessTokenUrl
().
equals
(
uri
)){
if
(!
weComeConfig
.
getNoAccessTokenUrl
().
equals
(
uri
)){
request
.
addQuery
(
"access_token"
,
iWeAccessTokenService
.
findToken
());
request
.
addQuery
(
"access_token"
,
Arrays
.
asList
(
weComeConfig
.
getNeedContactTokenUrl
()).
contains
(
uri
)?
iWeAccessTokenService
.
findContactAccessToken
():
iWeAccessTokenService
.
findCommonAccessToken
());
}
}
//添加服务器统一请求地址
//添加服务器统一请求地址
request
.
setUrl
(
weComeConfig
.
getServerUrl
()+
weComeConfig
.
getWeComePrefix
()+
uri
);
request
.
setUrl
(
weComeConfig
.
getServerUrl
()+
weComeConfig
.
getWeComePrefix
()+
uri
);
return
true
;
return
true
;
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeAccessTokenService.java
View file @
fd9f06a
...
@@ -7,5 +7,8 @@ package com.linkwechat.wecom.service;
...
@@ -7,5 +7,8 @@ package com.linkwechat.wecom.service;
**/
**/
public
interface
IWeAccessTokenService
{
public
interface
IWeAccessTokenService
{
public
String
findToken
();
public
String
findCommonAccessToken
();
public
String
findContactAccessToken
();
}
}
\ No newline at end of file
\ No newline at end of file
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerService.java
View file @
fd9f06a
...
@@ -58,4 +58,11 @@ public interface IWeCustomerService
...
@@ -58,4 +58,11 @@ public interface IWeCustomerService
* @return 结果
* @return 结果
*/
*/
public
int
deleteWeCustomerById
(
Long
id
);
public
int
deleteWeCustomerById
(
Long
id
);
/**
* 同步客户接口
* @return
*/
public
int
synchWeCustomer
();
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeAccessTokenServiceImpl.java
View file @
fd9f06a
...
@@ -39,9 +39,28 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
...
@@ -39,9 +39,28 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
* 获取accessToken
* 获取accessToken
*/
*/
@Override
@Override
public
String
findToken
()
{
public
String
find
CommonAccess
Token
()
{
String
weAccessToken
=
redisCache
.
getCacheObject
(
WeConstans
.
WE_ACCESS_TOKEN
);
return
findAccessToken
(
WeConstans
.
WE_COMMON_ACCESS_TOKEN
);
}
/**
* 获取外部联系人相关accesstoken
* @return
*/
@Override
public
String
findContactAccessToken
()
{
return
findAccessToken
(
WeConstans
.
WE_CONTACT_ACCESS_TOKEN
);
}
private
String
findAccessToken
(
String
accessTokenKey
){
String
weAccessToken
=
redisCache
.
getCacheObject
(
accessTokenKey
);
//为空,请求微信服务器同时缓存到redis中
//为空,请求微信服务器同时缓存到redis中
if
(
StringUtils
.
isEmpty
(
weAccessToken
)){
if
(
StringUtils
.
isEmpty
(
weAccessToken
)){
...
@@ -53,18 +72,17 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
...
@@ -53,18 +72,17 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
}
}
WeAccessTokenDtoDto
accessToken
WeAccessTokenDtoDto
accessToken
=
accessTokenClient
.
getToken
(
wxCorpAccount
.
getCorpId
(),
wxCorpAccount
.
getCorpSecret
());
=
accessTokenClient
.
getToken
(
wxCorpAccount
.
getCorpId
(),
WeConstans
.
WE_COMMON_ACCESS_TOKEN
.
equals
(
accessTokenKey
)?
wxCorpAccount
.
getCorpSecret
():
wxCorpAccount
.
getContactSecret
());
if
(
accessToken
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
)){
if
(
accessToken
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
)){
redisCache
.
setCacheObject
(
WeConstans
.
WE_ACCESS_TOKEN
,
accessToken
.
getAccess_token
(),
accessToken
.
getExpires_in
().
intValue
(),
TimeUnit
.
SECONDS
);
redisCache
.
setCacheObject
(
accessTokenKey
,
accessToken
.
getAccess_token
(),
accessToken
.
getExpires_in
().
intValue
(),
TimeUnit
.
SECONDS
);
weAccessToken
=
accessToken
.
getAccess_token
();
weAccessToken
=
accessToken
.
getAccess_token
();
}
}
}
}
return
weAccessToken
;
return
weAccessToken
;
}
}
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
View file @
fd9f06a
...
@@ -3,6 +3,8 @@ package com.linkwechat.wecom.service.impl;
...
@@ -3,6 +3,8 @@ package com.linkwechat.wecom.service.impl;
import
java.util.List
;
import
java.util.List
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.wecom.client.WeCustomerClient
;
import
com.linkwechat.wecom.domain.dto.WeFollowUserDto
;
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
com.linkwechat.wecom.mapper.WeCustomerMapper
;
import
com.linkwechat.wecom.mapper.WeCustomerMapper
;
...
@@ -21,6 +23,10 @@ public class WeCustomerServiceImpl implements IWeCustomerService
...
@@ -21,6 +23,10 @@ public class WeCustomerServiceImpl implements IWeCustomerService
@Autowired
@Autowired
private
WeCustomerMapper
weCustomerMapper
;
private
WeCustomerMapper
weCustomerMapper
;
@Autowired
private
WeCustomerClient
weFollowUserClient
;
/**
/**
* 查询企业微信客户
* 查询企业微信客户
*
*
...
@@ -93,4 +99,17 @@ public class WeCustomerServiceImpl implements IWeCustomerService
...
@@ -93,4 +99,17 @@ public class WeCustomerServiceImpl implements IWeCustomerService
{
{
return
weCustomerMapper
.
deleteWeCustomerById
(
id
);
return
weCustomerMapper
.
deleteWeCustomerById
(
id
);
}
}
/**
* 客户同步接口
* @return
*/
@Override
public
int
synchWeCustomer
()
{
WeFollowUserDto
followUserList
=
weFollowUserClient
.
getFollowUserList
();
System
.
out
.
println
(
followUserList
.
getErrmsg
());
return
0
;
}
}
}
linkwe-wecom/src/main/resources/mapper/wecom/WeCorpAccountMapper.xml
View file @
fd9f06a
...
@@ -15,10 +15,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -15,10 +15,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"updateBy"
column=
"update_by"
/>
<result
property=
"updateBy"
column=
"update_by"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"contactSecret"
column=
"contact_secret"
/>
</resultMap>
</resultMap>
<sql
id=
"selectWeCorpAccountVo"
>
<sql
id=
"selectWeCorpAccountVo"
>
select id, company_name, corp_id, corp_secret, status, del_flag, create_by, create_time, update_by, update_time from we_corp_account
select id, company_name, corp_id, corp_secret, status, del_flag, create_by, create_time, update_by, update_time
,contact_secret
from we_corp_account
</sql>
</sql>
<select
id=
"selectWeCorpAccountList"
parameterType=
"WeCorpAccount"
resultMap=
"WeCorpAccountResult"
>
<select
id=
"selectWeCorpAccountList"
parameterType=
"WeCorpAccount"
resultMap=
"WeCorpAccountResult"
>
...
@@ -48,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -48,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateBy != null"
>
update_by,
</if>
<if
test=
"updateBy != null"
>
update_by,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"contact_secret != null "
>
contact_secret,
</if>
</trim>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"companyName != null"
>
#{companyName},
</if>
<if
test=
"companyName != null"
>
#{companyName},
</if>
...
@@ -59,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -59,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"createTime != null"
>
#{createTime},
</if>
<if
test=
"createTime != null"
>
#{createTime},
</if>
<if
test=
"updateBy != null"
>
#{updateBy},
</if>
<if
test=
"updateBy != null"
>
#{updateBy},
</if>
<if
test=
"updateTime != null"
>
#{updateTime},
</if>
<if
test=
"updateTime != null"
>
#{updateTime},
</if>
<if
test=
"contactSecret != null "
>
#{contactSecret},
</if>
</trim>
</trim>
</insert>
</insert>
...
@@ -74,6 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -74,6 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
<if
test=
"updateBy != null"
>
update_by = #{updateBy},
</if>
<if
test=
"updateBy != null"
>
update_by = #{updateBy},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"contactSecret != null "
>
contact_secret = #{contactSecret},
</if>
</trim>
</trim>
where id = #{id}
where id = #{id}
</update>
</update>
...
...
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