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 d61114e6
authored
Nov 14, 2021
by
danmo
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
重构活码并新增使用范围修改任务
1 parent
11e2a1b1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
173 additions
and
1 deletions
linkwe-quartz/src/main/java/com/linkwechat/quartz/task/WeQrCodeUpdateTask.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/client/WeExternalContactClient.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeContactWayDto.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeQrScopeMapper.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeQrScopeService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/IWeQrScopeServiceImpl.java
linkwe-wecom/src/main/resources/mapper/wecom/WeQrScopeMapper.xml
linkwe-quartz/src/main/java/com/linkwechat/quartz/task/WeQrCodeUpdateTask.java
0 → 100644
View file @
d61114e
package
com
.
linkwechat
.
quartz
.
task
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.Week
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.wecom.client.WeExternalContactClient
;
import
com.linkwechat.wecom.domain.WeQrCode
;
import
com.linkwechat.wecom.domain.dto.WeContactWayDto
;
import
com.linkwechat.wecom.domain.dto.WeExternalContactDto
;
import
com.linkwechat.wecom.domain.vo.qr.WeQrScopePartyVo
;
import
com.linkwechat.wecom.domain.vo.qr.WeQrScopeUserVo
;
import
com.linkwechat.wecom.domain.vo.qr.WeQrScopeVo
;
import
com.linkwechat.wecom.service.IWeQrCodeService
;
import
com.linkwechat.wecom.service.IWeQrScopeService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @author danmo
* @description 活码使用范围修改任务
* @date 2021/11/13 23:02
**/
@Slf4j
@Component
()
public
class
WeQrCodeUpdateTask
{
@Autowired
private
IWeQrScopeService
weQrScopeService
;
@Autowired
private
IWeQrCodeService
weQrCodeService
;
@Autowired
private
WeExternalContactClient
externalContactClient
;
private
void
qrCodeUpdateTask
()
{
Date
date
=
new
Date
();
Week
week
=
DateUtil
.
dayOfWeekEnum
(
date
);
String
formatTime
=
DateUtil
.
formatTime
(
date
);
List
<
WeQrScopeVo
>
weQrScopeList
=
weQrScopeService
.
getWeQrScopeByTime
(
week
.
getValue
(),
formatTime
);
if
(
CollectionUtil
.
isNotEmpty
(
weQrScopeList
))
{
for
(
WeQrScopeVo
weQrScope
:
weQrScopeList
)
{
WeQrCode
weQrCode
=
weQrCodeService
.
getById
(
weQrScope
.
getQrId
());
String
configId
=
weQrCode
.
getConfigId
();
WeContactWayDto
contactWay
=
externalContactClient
.
getContactWay
(
configId
);
if
(
contactWay
!=
null
&&
ObjectUtil
.
equal
(
0
,
contactWay
.
getErrcode
()))
{
String
userIds
=
""
;
String
partys
=
""
;
String
qrUserIds
=
""
;
String
qrPartys
=
""
;
if
(
CollectionUtil
.
isNotEmpty
(
contactWay
.
getContactWay
().
getUser
()))
{
userIds
=
String
.
join
(
","
,
contactWay
.
getContactWay
().
getUser
());
}
if
(
CollectionUtil
.
isNotEmpty
(
contactWay
.
getContactWay
().
getParty
()))
{
partys
=
contactWay
.
getContactWay
().
getParty
().
stream
().
map
(
String:
:
valueOf
).
collect
(
Collectors
.
joining
(
","
));
}
if
(
CollectionUtil
.
isNotEmpty
(
weQrScope
.
getWeQrUserList
()))
{
qrUserIds
=
weQrScope
.
getWeQrUserList
().
stream
().
map
(
WeQrScopeUserVo:
:
getUserId
).
collect
(
Collectors
.
joining
(
","
));
}
if
(
CollectionUtil
.
isNotEmpty
(
weQrScope
.
getWeQrPartyList
()))
{
qrPartys
=
weQrScope
.
getWeQrPartyList
().
stream
().
map
(
WeQrScopePartyVo:
:
getParty
).
collect
(
Collectors
.
joining
(
","
));
}
if
(!
ObjectUtil
.
equal
(
qrUserIds
,
userIds
)
||
!
ObjectUtil
.
equal
(
qrPartys
,
partys
))
{
WeExternalContactDto
.
WeContactWay
weContactWay
=
new
WeExternalContactDto
.
WeContactWay
();
weContactWay
.
setConfig_id
(
configId
);
if
(
StringUtils
.
isNotEmpty
(
qrUserIds
))
{
weContactWay
.
setUser
(
qrUserIds
.
split
(
","
));
}
if
(
StringUtils
.
isNotEmpty
(
qrPartys
))
{
Long
[]
qrPartyList
=
Arrays
.
stream
(
qrPartys
.
split
(
","
))
.
map
(
s
->
Long
.
parseLong
(
s
.
trim
())).
toArray
(
Long
[]::
new
);
weContactWay
.
setParty
(
qrPartyList
);
}
externalContactClient
.
updateContactWay
(
weContactWay
);
}
}
}
}
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/client/WeExternalContactClient.java
View file @
d61114e
package
com
.
linkwechat
.
wecom
.
client
;
package
com
.
linkwechat
.
wecom
.
client
;
import
com.dtflys.forest.annotation.*
;
import
com.dtflys.forest.annotation.*
;
import
com.linkwechat.wecom.domain.dto.WeContactWayDto
;
import
com.linkwechat.wecom.domain.dto.WeExternalContactDto
;
import
com.linkwechat.wecom.domain.dto.WeExternalContactDto
;
import
com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor
;
import
com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor
;
import
com.linkwechat.wecom.retry.WeCommonRetryWhen
;
import
com.linkwechat.wecom.retry.WeCommonRetryWhen
;
...
@@ -26,5 +27,5 @@ public interface WeExternalContactClient {
...
@@ -26,5 +27,5 @@ public interface WeExternalContactClient {
WeExternalContactDto
delContactWay
(
@Query
(
"configId"
)
String
configId
);
WeExternalContactDto
delContactWay
(
@Query
(
"configId"
)
String
configId
);
@Request
(
url
=
"/externalcontact/get_contact_way"
,
type
=
"POST"
)
@Request
(
url
=
"/externalcontact/get_contact_way"
,
type
=
"POST"
)
We
ExternalContact
Dto
getContactWay
(
@Query
(
"configId"
)
String
configId
);
We
ContactWay
Dto
getContactWay
(
@Query
(
"configId"
)
String
configId
);
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeContactWayDto.java
0 → 100644
View file @
d61114e
package
com
.
linkwechat
.
wecom
.
domain
.
dto
;
import
lombok.Data
;
import
java.util.List
;
/**
* @author danmo
* @description 联系我详情
* @date 2021/11/13 23:50
**/
@Data
public
class
WeContactWayDto
extends
WeResultDto
{
private
WeContactWay
contactWay
;
@Data
public
static
class
WeContactWay
{
//系我二维码链接,仅在scene为2时返回
private
String
configId
;
// 联系方式类型,1-单人, 2-多人
private
Integer
type
;
//场景,1-在小程序中联系,2-通过二维码联系
private
Integer
scene
;
//外部客户添加时是否无需验证,默认为true
private
Boolean
skipVerify
;
//使用该联系方式的用户userID列表,在type为1时为必填,且只能有一个
private
List
<
String
>
user
;
//使用该联系方式的部门id列表,只在type为2时有效
private
List
<
Long
>
party
;
//企业自定义的state参数,用于区分不同的添加渠道,在调用“获取外部联系人详情”时会返回该参数值,不超过30个字符
private
String
state
;
//样式
private
Integer
style
=
1
;
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeQrScopeMapper.java
View file @
d61114e
...
@@ -23,5 +23,7 @@ public interface WeQrScopeMapper extends BaseMapper<WeQrScope> {
...
@@ -23,5 +23,7 @@ public interface WeQrScopeMapper extends BaseMapper<WeQrScope> {
List
<
WeQrScopeVo
>
getWeQrScopeByQrIds
(
@Param
(
"qrIds"
)
List
<
Long
>
qrIds
);
List
<
WeQrScopeVo
>
getWeQrScopeByQrIds
(
@Param
(
"qrIds"
)
List
<
Long
>
qrIds
);
List
<
WeQrScopeVo
>
getWeQrScopeByTime
(
@Param
(
"value"
)
Integer
value
,
@Param
(
"formatTime"
)
String
formatTime
);
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeQrScopeService.java
View file @
d61114e
...
@@ -42,4 +42,12 @@ public interface IWeQrScopeService extends IService<WeQrScope> {
...
@@ -42,4 +42,12 @@ public interface IWeQrScopeService extends IService<WeQrScope> {
* @return
* @return
*/
*/
List
<
WeQrScopeVo
>
getWeQrScopeByQrIds
(
List
<
Long
>
qrIds
);
List
<
WeQrScopeVo
>
getWeQrScopeByQrIds
(
List
<
Long
>
qrIds
);
/**
* 查询当前时间使用范围活码数据
* @param value
* @param formatTime
* @return
*/
List
<
WeQrScopeVo
>
getWeQrScopeByTime
(
Integer
value
,
String
formatTime
);
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/IWeQrScopeServiceImpl.java
View file @
d61114e
...
@@ -91,4 +91,9 @@ public class IWeQrScopeServiceImpl extends ServiceImpl<WeQrScopeMapper, WeQrScop
...
@@ -91,4 +91,9 @@ public class IWeQrScopeServiceImpl extends ServiceImpl<WeQrScopeMapper, WeQrScop
public
List
<
WeQrScopeVo
>
getWeQrScopeByQrIds
(
List
<
Long
>
qrIds
)
{
public
List
<
WeQrScopeVo
>
getWeQrScopeByQrIds
(
List
<
Long
>
qrIds
)
{
return
this
.
baseMapper
.
getWeQrScopeByQrIds
(
qrIds
);
return
this
.
baseMapper
.
getWeQrScopeByQrIds
(
qrIds
);
}
}
@Override
public
List
<
WeQrScopeVo
>
getWeQrScopeByTime
(
Integer
value
,
String
formatTime
)
{
return
this
.
baseMapper
.
getWeQrScopeByTime
(
value
,
formatTime
);
}
}
}
linkwe-wecom/src/main/resources/mapper/wecom/WeQrScopeMapper.xml
View file @
d61114e
...
@@ -66,4 +66,23 @@
...
@@ -66,4 +66,23 @@
</where>
</where>
</select>
</select>
<select
id=
"getWeQrScopeByTime"
resultMap=
"QrScopeResult"
>
select
wqs.qr_id,
wqs.scope_id,
wqs.scope_type,
wqs.`type`,
wqs.begin_time,
wqs.end_time,
wqs.work_cycle,
wqs.user_id,
wqs.party
from we_qr_scope wqs
where find_in_set(#{value},wqs.work_cycle)
and str_to_date(wqs.begin_time,'%H:%i:%S')
<
= str_to_date(#{formatTime},'%H:%i:%S')
and str_to_date(wqs.end_time ,'%H:%i:%S')
>
= str_to_date(#{formatTime},'%H:%i:%S')
and wqs.`type` = 1
and wqs.del_flag = 0
</select>
</mapper>
</mapper>
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