Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoban3.0
haoban-manage3.0
Commits
3e85a38e
Commit
3e85a38e
authored
Jul 18, 2022
by
墨竹
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fixbug_0719' into developer
parents
631045b4
67ea1063
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
3 deletions
+99
-3
StaffApiService.java
...va/com/gic/haoban/manage/api/service/StaffApiService.java
+12
-0
StaffMapper.java
...com/gic/haoban/manage/service/dao/mapper/StaffMapper.java
+15
-0
StaffApiServiceImpl.java
.../manage/service/service/out/impl/StaffApiServiceImpl.java
+27
-1
QywxStaffSyncOperation.java
...ic/haoban/manage/service/task/QywxStaffSyncOperation.java
+36
-2
StaffMapper.xml
...manage3-service/src/main/resources/mapper/StaffMapper.xml
+9
-0
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/StaffApiService.java
View file @
3e85a38e
...
@@ -308,4 +308,16 @@ public interface StaffApiService {
...
@@ -308,4 +308,16 @@ public interface StaffApiService {
*/
*/
List
<
String
>
getHaoBanStoreRolesByEnterpriseId
(
String
enterpriseId
,
String
wxEnterpriseId
);
List
<
String
>
getHaoBanStoreRolesByEnterpriseId
(
String
enterpriseId
,
String
wxEnterpriseId
);
/**
* 更新userid by open_userid
*
* @param wxEnterpriseId wx企业标识
* @param wxOpenUseId wx开放使用id
* @param wxUserId wx用户id
* @return int
* @author mozhu
* @date 2022-07-18 19:06:27
*/
int
updateWxUserIdsByWxOpenUserId
(
String
wxEnterpriseId
,
String
wxOpenUseId
,
String
wxUserId
);
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/StaffMapper.java
View file @
3e85a38e
...
@@ -172,4 +172,18 @@ public interface StaffMapper {
...
@@ -172,4 +172,18 @@ public interface StaffMapper {
int
updateUserIdByUserId
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
int
updateUserIdByUserId
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"newWxUserId"
)
String
newWxUserId
,
@Param
(
"newWxUserId"
)
String
newWxUserId
,
@Param
(
"oldWxUserId"
)
String
oldWxUserId
);
@Param
(
"oldWxUserId"
)
String
oldWxUserId
);
/**
* 更新userid by open_userid
*
* @param wxEnterpriseId wx企业标识
* @param wxOpenUseId wx开放使用id
* @param wxUserId wx用户id
* @return int
* @author mozhu
* @date 2022-07-18 19:09:16
*/
int
updateWxUserIdsByWxOpenUserId
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"wxOpenUseId"
)
String
wxOpenUseId
,
@Param
(
"wxUserId"
)
String
wxUserId
);
}
}
\ No newline at end of file
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/StaffApiServiceImpl.java
View file @
3e85a38e
...
@@ -362,6 +362,10 @@ public class StaffApiServiceImpl implements StaffApiService {
...
@@ -362,6 +362,10 @@ public class StaffApiServiceImpl implements StaffApiService {
String
openUserid
=
getOpenUserid
(
userId
,
corpid
);
String
openUserid
=
getOpenUserid
(
userId
,
corpid
);
if
(
StringUtils
.
isNotBlank
(
openUserid
))
{
if
(
StringUtils
.
isNotBlank
(
openUserid
))
{
staff
.
setWxOpenUseId
(
openUserid
);
staff
.
setWxOpenUseId
(
openUserid
);
String
userid
=
getUserid
(
openUserid
,
corpid
);
if
(
StringUtils
.
isNotBlank
(
userid
))
{
staff
.
setWxUserId
(
userid
);
}
}
}
//成员更改或更新
//成员更改或更新
if
(
StringUtils
.
isBlank
(
staff
.
getStaffId
()))
{
if
(
StringUtils
.
isBlank
(
staff
.
getStaffId
()))
{
...
@@ -380,7 +384,7 @@ public class StaffApiServiceImpl implements StaffApiService {
...
@@ -380,7 +384,7 @@ public class StaffApiServiceImpl implements StaffApiService {
}
}
/**
/**
* 获取wxopenid
* 获取wxopen
user
id
*
*
* @param userId
* @param userId
* @param corpid
* @param corpid
...
@@ -395,6 +399,23 @@ public class StaffApiServiceImpl implements StaffApiService {
...
@@ -395,6 +399,23 @@ public class StaffApiServiceImpl implements StaffApiService {
return
qywxNewUseridDTOS
.
get
(
0
).
getOpen_userid
();
return
qywxNewUseridDTOS
.
get
(
0
).
getOpen_userid
();
}
}
/**
* 获取wxuserid
* @param openUserId
* @param corpid
* @return
*/
private
String
getUserid
(
String
openUserId
,
String
corpid
)
{
TabHaobanWxApplication
tabHaobanWxApplication
=
wxApplicationService
.
selectByCorpIdAndApplicationType
(
corpid
,
3
);
SecretSettingDTO
secretSetting
=
secretSettingService
.
getSecretSetting
(
tabHaobanWxApplication
.
getWxEnterpriseId
(),
5
);
List
<
QywxNewUseridDTO
>
qywxNewUseridDTOS
=
qywxUserApiService
.
getSelfOpenuseridToUserid
(
tabHaobanWxApplication
.
getCorpid
(),
secretSetting
.
getSecretVal
(),
tabHaobanWxApplication
.
getAgentId
(),
Collections
.
singletonList
(
openUserId
));
if
(
CollectionUtils
.
isEmpty
(
qywxNewUseridDTOS
))
{
return
""
;
}
return
qywxNewUseridDTOS
.
get
(
0
).
getUserid
();
}
private
String
[]
getNationCodeAndPhoneNumber
(
String
phoneNumber
)
{
private
String
[]
getNationCodeAndPhoneNumber
(
String
phoneNumber
)
{
String
[]
arr
=
new
String
[
2
];
String
[]
arr
=
new
String
[
2
];
if
(
StringUtils
.
isBlank
(
phoneNumber
))
{
if
(
StringUtils
.
isBlank
(
phoneNumber
))
{
...
@@ -1380,6 +1401,11 @@ public class StaffApiServiceImpl implements StaffApiService {
...
@@ -1380,6 +1401,11 @@ public class StaffApiServiceImpl implements StaffApiService {
return
storeRangeService
.
listStoreIdByWxEnterpriseId
(
wxEnterpriseId
,
enterpriseId
);
return
storeRangeService
.
listStoreIdByWxEnterpriseId
(
wxEnterpriseId
,
enterpriseId
);
}
}
@Override
public
int
updateWxUserIdsByWxOpenUserId
(
String
wxEnterpriseId
,
String
wxOpenUseId
,
String
wxUserId
)
{
return
staffMapper
.
updateWxUserIdsByWxOpenUserId
(
wxEnterpriseId
,
wxOpenUseId
,
wxUserId
);
}
/**
/**
* 门店筛选器id企业端获取gic门店id列表
* 门店筛选器id企业端获取gic门店id列表
*
*
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/task/QywxStaffSyncOperation.java
View file @
3e85a38e
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.Page
;
import
com.gic.haoban.base.api.common.ServiceResponse
;
import
com.gic.haoban.base.api.common.ServiceResponse
;
import
com.gic.haoban.manage.api.dto.DealParamMqDTO
;
import
com.gic.haoban.manage.api.dto.DealParamMqDTO
;
import
com.gic.haoban.manage.api.dto.SecretSettingDTO
;
import
com.gic.haoban.manage.api.dto.StaffDTO
;
import
com.gic.haoban.manage.api.dto.StaffDTO
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseDTO
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseDTO
;
import
com.gic.haoban.manage.api.enums.PreDealStatusEnum
;
import
com.gic.haoban.manage.api.enums.PreDealStatusEnum
;
...
@@ -12,11 +13,13 @@ import com.gic.haoban.manage.api.enums.SyncTaskStatusEnum;
...
@@ -12,11 +13,13 @@ import com.gic.haoban.manage.api.enums.SyncTaskStatusEnum;
import
com.gic.haoban.manage.api.service.DealSyncOperationApiService
;
import
com.gic.haoban.manage.api.service.DealSyncOperationApiService
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseApiService
;
import
com.gic.haoban.manage.service.config.Config
;
import
com.gic.haoban.manage.service.dao.mapper.WxApplicationMapper
;
import
com.gic.haoban.manage.service.dao.mapper.WxApplicationMapper
;
import
com.gic.haoban.manage.service.entity.TabHaobanPreDealLog
;
import
com.gic.haoban.manage.service.entity.TabHaobanPreDealLog
;
import
com.gic.haoban.manage.service.entity.TabHaobanSyncTask
;
import
com.gic.haoban.manage.service.entity.TabHaobanSyncTask
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxApplication
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxApplication
;
import
com.gic.haoban.manage.service.service.PreDealService
;
import
com.gic.haoban.manage.service.service.PreDealService
;
import
com.gic.haoban.manage.service.service.SecretSettingService
;
import
com.gic.haoban.manage.service.service.SyncTaskService
;
import
com.gic.haoban.manage.service.service.SyncTaskService
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.dto.qywx.QywxNewUseridDTO
;
import
com.gic.wechat.api.dto.qywx.QywxNewUseridDTO
;
...
@@ -57,6 +60,10 @@ public class QywxStaffSyncOperation implements BaseSyncOperation {
...
@@ -57,6 +60,10 @@ public class QywxStaffSyncOperation implements BaseSyncOperation {
private
WxEnterpriseApiService
wxEnterpriseApiService
;
private
WxEnterpriseApiService
wxEnterpriseApiService
;
@Autowired
@Autowired
private
WxApplicationMapper
wxApplicationMapper
;
private
WxApplicationMapper
wxApplicationMapper
;
@Autowired
private
Config
config
;
@Autowired
private
SecretSettingService
secretSettingService
;
@Override
@Override
public
void
dealSingleByMq
(
DealParamMqDTO
dealParamMqDTO
,
TabHaobanPreDealLog
dataPre
)
{
public
void
dealSingleByMq
(
DealParamMqDTO
dealParamMqDTO
,
TabHaobanPreDealLog
dataPre
)
{
...
@@ -130,7 +137,6 @@ public class QywxStaffSyncOperation implements BaseSyncOperation {
...
@@ -130,7 +137,6 @@ public class QywxStaffSyncOperation implements BaseSyncOperation {
WxEnterpriseDTO
wxEnterpriseDTO
=
wxEnterpriseApiService
.
getOne
(
wxEnterpriseId
);
WxEnterpriseDTO
wxEnterpriseDTO
=
wxEnterpriseApiService
.
getOne
(
wxEnterpriseId
);
String
corpid
=
wxEnterpriseDTO
.
getCorpid
();
String
corpid
=
wxEnterpriseDTO
.
getCorpid
();
Integer
externalFlag
=
wxEnterpriseDTO
.
getExternalFlag
();
Integer
externalFlag
=
wxEnterpriseDTO
.
getExternalFlag
();
TabHaobanWxApplication
tabHaobanWxApplication
=
wxApplicationMapper
.
selectByCorpId
(
corpid
,
null
);
logger
.
info
(
"同步通讯录完成,批量处理wx_user_id,corpid:{}"
,
corpid
);
logger
.
info
(
"同步通讯录完成,批量处理wx_user_id,corpid:{}"
,
corpid
);
if
(
corpid
.
length
()
>
20
||
externalFlag
==
1
)
{
if
(
corpid
.
length
()
>
20
||
externalFlag
==
1
)
{
// 限流器
// 限流器
...
@@ -151,13 +157,41 @@ public class QywxStaffSyncOperation implements BaseSyncOperation {
...
@@ -151,13 +157,41 @@ public class QywxStaffSyncOperation implements BaseSyncOperation {
}
}
pageNum
++;
pageNum
++;
logger
.
info
(
"useridToOpenuserid请求:corpid:{}"
,
corpid
);
logger
.
info
(
"useridToOpenuserid请求:corpid:{}"
,
corpid
);
List
<
QywxNewUseridDTO
>
qywxNewUseridDTOS
=
qywxUserApiService
.
useridToOpenuserid
(
corpid
,
tabHaobanWxApplication
.
getSiteI
d
(),
staffDTOS
.
stream
().
map
(
StaffDTO:
:
getWxUserId
).
collect
(
Collectors
.
toList
()));
List
<
QywxNewUseridDTO
>
qywxNewUseridDTOS
=
qywxUserApiService
.
useridToOpenuserid
(
corpid
,
config
.
getWxSuitei
d
(),
staffDTOS
.
stream
().
map
(
StaffDTO:
:
getWxUserId
).
collect
(
Collectors
.
toList
()));
if
(
CollectionUtils
.
isNotEmpty
(
qywxNewUseridDTOS
))
{
if
(
CollectionUtils
.
isNotEmpty
(
qywxNewUseridDTOS
))
{
for
(
QywxNewUseridDTO
qywxNewUseridDTO
:
qywxNewUseridDTOS
)
{
for
(
QywxNewUseridDTO
qywxNewUseridDTO
:
qywxNewUseridDTOS
)
{
staffApiService
.
updateOpenUserIdsByUserId
(
wxEnterpriseId
,
qywxNewUseridDTO
.
getUserid
(),
qywxNewUseridDTO
.
getOpen_userid
());
staffApiService
.
updateOpenUserIdsByUserId
(
wxEnterpriseId
,
qywxNewUseridDTO
.
getUserid
(),
qywxNewUseridDTO
.
getOpen_userid
());
}
}
}
}
}
}
}
else
{
// 限流器
RRateLimiter
rateLimiter
=
RedisUtil
.
getRedisClient
().
getRateLimiter
(
"haoban:manage3:updateWxUserId:limit"
);
// 每1秒产生5个令牌
rateLimiter
.
trySetRate
(
RateType
.
OVERALL
,
5
,
1
,
RateIntervalUnit
.
SECONDS
);
TabHaobanWxApplication
tabHaobanWxApplication
=
wxApplicationMapper
.
selectByCorpId
(
corpid
,
3
);
SecretSettingDTO
secretSetting
=
secretSettingService
.
getSecretSetting
(
wxEnterpriseId
,
5
);
int
pageNum
=
1
;
while
(
true
)
{
// 获取令牌
rateLimiter
.
acquire
();
//企微转换最多支持1000个
//批量处理wx_user_id to wx_open_user_id
Page
<
StaffDTO
>
staffDTOPageInfo
=
staffApiService
.
listUserIdByWxEnterpriseId
(
wxEnterpriseId
,
pageNum
,
1000
);
List
<
StaffDTO
>
staffDTOS
=
staffDTOPageInfo
.
getResult
();
if
(
CollectionUtils
.
isEmpty
(
staffDTOS
))
{
logger
.
info
(
"转换完成,为最后一个"
);
break
;
}
pageNum
++;
logger
.
info
(
"useridToOpenuserid请求:corpid:{}"
,
corpid
);
List
<
QywxNewUseridDTO
>
qywxNewUseridDTOS
=
qywxUserApiService
.
getSelfOpenuseridToUserid
(
tabHaobanWxApplication
.
getCorpid
(),
secretSetting
.
getSecretVal
(),
tabHaobanWxApplication
.
getAgentId
(),
staffDTOS
.
stream
().
map
(
StaffDTO:
:
getWxUserId
).
collect
(
Collectors
.
toList
()));
if
(
CollectionUtils
.
isNotEmpty
(
qywxNewUseridDTOS
))
{
for
(
QywxNewUseridDTO
qywxNewUseridDTO
:
qywxNewUseridDTOS
)
{
staffApiService
.
updateWxUserIdsByWxOpenUserId
(
wxEnterpriseId
,
qywxNewUseridDTO
.
getOpen_userid
(),
qywxNewUseridDTO
.
getUserid
());
}
}
}
}
}
}
}
}
}
...
...
haoban-manage3-service/src/main/resources/mapper/StaffMapper.xml
View file @
3e85a38e
...
@@ -524,4 +524,12 @@
...
@@ -524,4 +524,12 @@
and wx_user_id = #{oldWxUserId}
and wx_user_id = #{oldWxUserId}
</update>
</update>
<update
id=
"updateWxUserIdsByWxOpenUserId"
parameterType=
"java.lang.String"
>
update tab_haoban_staff
set wx_user_id = #{wxUserId},
update_time = now()
where wx_enterprise_id = #{wxEnterpriseId}
and wx_open_user_id = #{wxOpenUseId}
</update>
</mapper>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment