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
31a6a76c
Commit
31a6a76c
authored
Apr 16, 2020
by
qwmqiuwenmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
0ccc09d8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
130 deletions
+131
-130
StaffApiServiceImpl.java
.../manage/service/service/out/impl/StaffApiServiceImpl.java
+3
-0
ServiceTest.java
haoban-manage3-service/src/test/java/ServiceTest.java
+92
-91
ClerkController.java
...com/gic/haoban/manage/web/controller/ClerkController.java
+36
-39
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/StaffApiServiceImpl.java
View file @
31a6a76c
...
...
@@ -309,6 +309,9 @@ public class StaffApiServiceImpl implements StaffApiService {
if
(
enterpriseDTO
!=
null
)
{
Date
now
=
new
Date
();
UserDTO
user
=
qywxUserApiService
.
getSelfWorkWxUser
(
enterpriseDTO
.
getCorpid
(),
enterpriseDTO
.
getContactSecret
(),
userId
);
if
(
user
==
null
){
return
;
}
logger
.
info
(
"【新增用户】user={}"
,
JSON
.
toJSONString
(
user
));
TabHaobanStaff
tab
=
new
TabHaobanStaff
();
tab
.
setWxUserId
(
userId
);
...
...
haoban-manage3-service/src/test/java/ServiceTest.java
View file @
31a6a76c
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.JSONResponse
;
import
com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.dto.qywx.DepartmentDTO
;
import
com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO
;
import
com.gic.wechat.api.dto.qywx.UserDTO
;
import
com.gic.wechat.api.service.qywx.QywxDepartmentApiService
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
...
...
@@ -35,98 +36,98 @@ public class ServiceTest {
@Test
public
void
test
()
{
//wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId("073e89a37eb14acabf258e59a57359b6"
);
System
.
err
.
println
(
RedisUtil
.
getCache
(
"init-enterprise-ca66a01b79474c40b3e7c7f93daf1a3b"
)
);
}
@Test
public
void
test1
()
{
String
res
=
qywxUserApiService
.
leaveClerkExternal
(
"ww9ede832a84b7ae5f"
,
"01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk"
,
0
,
1000
);
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
res
);
jsonArray
.
forEach
(
o
->
{
JSONObject
mid
=
(
JSONObject
)
o
;
qywxUserApiService
.
leaveClerkReTransfer
(
"ww9ede832a84b7ae5f"
,
"01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk"
,
mid
.
getString
(
"handover_userid"
)
,
mid
.
getString
(
"handover_userid"
),
mid
.
getString
(
"external_userid"
));
});
System
.
out
.
println
(
res
);
}
@Test
public
void
test2
()
{
UserDTO
userDTO
=
new
UserDTO
();
userDTO
.
setUserid
(
"niweizhong"
);
userDTO
.
setName
(
"空闻大师"
);
userDTO
.
setDepartment
(
new
Integer
[]{
4
});
userDTO
.
setMobile
(
"17605628855"
);
userDTO
.
setCorpid
(
"ww9ede832a84b7ae5f"
);
JSONResponse
workWxUser
=
qywxUserApiService
.
createWorkWxUser
(
userDTO
,
"ww9ede832a84b7ae5f"
,
"ww7d6566614055cf27"
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
workWxUser
));
}
@Test
public
void
list
()
{
List
<
DepartmentDTO
>
list
=
qywxDepartmentApiService
.
listSelfDepartment
(
"ww9ede832a84b7ae5f"
,
"3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8"
,
1
);
Iterator
<
DepartmentDTO
>
iterator
=
list
.
iterator
();
// while (iterator.hasNext()) {
// DepartmentDTO next = iterator.next();
// if(!next.getParentid().equals("1")) {
// iterator.remove();
// }
// }
System
.
out
.
println
(
JSONObject
.
toJSONString
(
list
));
}
@Test
public
void
addDepart
()
{
DepartmentDTO
dto
=
new
DepartmentDTO
();
// dto.set
// JSONResponse department = qywxDepartmentApiService.createDepartment("ww9ede832a84b7ae5f"
// , "ww7d6566614055cf27", null);
// List<DepartmentDTO> list = (List<DepartmentDTO>) department;
// System.out.println(JSONObject.toJSONString(list));
}
@Test
public
void
getUser
()
{
DepartmentDTO
dto
=
new
DepartmentDTO
();
// dto.set
UserDTO
phonenumber
=
qywxUserApiService
.
getWxUserByPhonenumber
(
"ww9ede832a84b7ae5f"
,
"ww7d6566614055cf27"
,
"13735457631"
);
// String phonenumber = phonenumber;
// UserDTO phonenumber = (UserDTO) useridBymobile;
System
.
out
.
println
(
JSONObject
.
toJSONString
(
phonenumber
));
}
@Test
public
void
createSelfUser
()
{
UserDTO
userDTO
=
new
UserDTO
();
userDTO
.
setUserid
(
"niweizhong2"
);
userDTO
.
setName
(
"空闻大师2"
);
userDTO
.
setDepartment
(
new
Integer
[]{
5072
});
userDTO
.
setMobile
(
"17605628851"
);
userDTO
.
setCorpid
(
"ww9ede832a84b7ae5f"
);
JSONResponse
workWxUser
=
qywxUserApiService
.
createSelfWorkWxUser
(
userDTO
,
"ww9ede832a84b7ae5f"
,
"3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8"
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
workWxUser
));
}
@Test
public
void
sendMessage
()
{
QywxXcxSendMessageDTO
messageDTO
=
new
QywxXcxSendMessageDTO
();
messageDTO
.
setAppid
(
"wx6054e7be35015afc"
);
ArrayList
<
String
>
userIDs
=
new
ArrayList
<>();
userIDs
.
add
(
"9ae4c4f1277340a186b16a17d937c72c"
);
messageDTO
.
setUserIds
(
userIDs
);
messageDTO
.
setTitle
(
"我的测试test"
);
messageDTO
.
setDescription
(
"我的测试test11111"
);
boolean
ret
=
qywxSuiteApiService
.
sendMessage
(
"ww9ede832a84b7ae5f"
,
"ww2c34dc56739bb105"
,
messageDTO
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
ret
));
}
//
@Test
//
public void test1() {
//
String res = qywxUserApiService.leaveClerkExternal("ww9ede832a84b7ae5f"
//
, "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", 0, 1000);
//
JSONArray jsonArray = JSONArray.parseArray(res);
//
jsonArray.forEach(o -> {
//
JSONObject mid = (JSONObject) o;
//
qywxUserApiService.leaveClerkReTransfer("ww9ede832a84b7ae5f"
//
, "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", mid.getString("handover_userid")
//
, mid.getString("handover_userid"), mid.getString("external_userid"));
//
});
//
System.out.println(res);
//
}
//
//
@Test
//
public void test2() {
//
UserDTO userDTO = new UserDTO();
//
userDTO.setUserid("niweizhong");
//
userDTO.setName("空闻大师");
//
userDTO.setDepartment(new Integer[]{4});
//
userDTO.setMobile("17605628855");
//
userDTO.setCorpid("ww9ede832a84b7ae5f");
//
JSONResponse workWxUser = qywxUserApiService.createWorkWxUser(userDTO, "ww9ede832a84b7ae5f", "ww7d6566614055cf27");
//
System.out.println(JSONObject.toJSONString(workWxUser));
//
}
//
//
@Test
//
public void list() {
//
//
List<DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment("ww9ede832a84b7ae5f"
//
, "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8", 1);
//
Iterator<DepartmentDTO> iterator = list.iterator();
//
//
while (iterator.hasNext()) {
//
//
DepartmentDTO next = iterator.next();
//
//
if(!next.getParentid().equals("1")) {
//
//
iterator.remove();
//
//
}
//
//
}
//
System.out.println(JSONObject.toJSONString(list));
//
}
//
//
@Test
//
public void addDepart() {
//
DepartmentDTO dto = new DepartmentDTO();
//
//
dto.set
//
//
JSONResponse department = qywxDepartmentApiService.createDepartment("ww9ede832a84b7ae5f"
//
//
, "ww7d6566614055cf27", null);
//
//
List<DepartmentDTO> list = (List<DepartmentDTO>) department;
//
//
System.out.println(JSONObject.toJSONString(list));
//
}
//
//
@Test
//
public void getUser() {
//
DepartmentDTO dto = new DepartmentDTO();
//
//
dto.set
//
UserDTO phonenumber = qywxUserApiService.getWxUserByPhonenumber("ww9ede832a84b7ae5f"
//
, "ww7d6566614055cf27", "13735457631");
//
//
String phonenumber = phonenumber;
//
//
UserDTO phonenumber = (UserDTO) useridBymobile;
//
System.out.println(JSONObject.toJSONString(phonenumber));
//
}
//
//
@Test
//
public void createSelfUser() {
//
UserDTO userDTO = new UserDTO();
//
userDTO.setUserid("niweizhong2");
//
userDTO.setName("空闻大师2");
//
userDTO.setDepartment(new Integer[]{5072});
//
userDTO.setMobile("17605628851");
//
userDTO.setCorpid("ww9ede832a84b7ae5f");
//
JSONResponse workWxUser = qywxUserApiService.createSelfWorkWxUser(userDTO, "ww9ede832a84b7ae5f",
//
"3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8");
//
System.out.println(JSONObject.toJSONString(workWxUser));
//
}
//
//
//
@Test
//
public void sendMessage() {
//
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
//
messageDTO.setAppid("wx6054e7be35015afc");
//
ArrayList<String> userIDs = new ArrayList<>();
//
userIDs.add("9ae4c4f1277340a186b16a17d937c72c");
//
messageDTO.setUserIds(userIDs);
//
messageDTO.setTitle("我的测试test");
//
messageDTO.setDescription("我的测试test11111");
//
boolean ret = qywxSuiteApiService.sendMessage("ww9ede832a84b7ae5f",
//
"ww2c34dc56739bb105", messageDTO);
//
System.out.println(JSONObject.toJSONString(ret));
//
}
}
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/controller/ClerkController.java
View file @
31a6a76c
...
...
@@ -23,12 +23,9 @@ import com.gic.clerk.api.dto.ClerkDTO;
import
com.gic.clerk.api.service.ClerkService
;
import
com.gic.commons.util.DateUtil
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.enterprise.api.dto.EnterpriseDTO
;
import
com.gic.enterprise.api.dto.StoreDTO
;
import
com.gic.enterprise.api.service.EnterpriseService
;
import
com.gic.enterprise.api.service.StoreService
;
import
com.gic.haoban.app.customer.service.api.service.DistributeApiService
;
import
com.gic.haoban.base.api.common.ServiceResponse
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.communicate.api.service.SyncHaobanToGicServiceApi
;
import
com.gic.haoban.manage.api.dto.DepartmentDTO
;
...
...
@@ -47,7 +44,6 @@ import com.gic.haoban.manage.web.anno.HttpLimit;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.interceptor.WebInterceptor
;
import
com.gic.haoban.manage.web.vo.ClerkVo
;
import
com.gic.haoban.manage.web.vo.StoreVO
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
...
...
@@ -169,7 +165,8 @@ public class ClerkController extends WebBaseController{
if
(
size
>
20
){
ClerkDTO
clerk
=
clerkService
.
getClerkByClerkCode
(
departmentDTO
.
getEnterpriseId
(),
related
.
getClerkCode
());
if
(
clerk
!=
null
){
dto
.
setMemberCount
(
distributeApiService
.
getClerkMemberCount
(
departmentDTO
.
getEnterpriseId
(),
clerk
.
getClerkId
(),
storeId
));
dto
.
setMemberCount
(
0
);
// dto.setMemberCount(distributeApiService.getClerkMemberCount(departmentDTO.getEnterpriseId(), clerk.getClerkId(), storeId));
}
}
else
{
dto
.
setMemberCount
(
0
);
...
...
@@ -305,10 +302,10 @@ public class ClerkController extends WebBaseController{
staffApiService
.
del
(
staffDepartmentRelatedId
);
}
else
{
ClerkDTO
clerk
=
clerkService
.
getClerkByClerkCode
(
departmentDTO
.
getEnterpriseId
(),
related
.
getClerkCode
());
if
(
clerk
!=
null
&&
distributeApiService
.
getClerkMemberCount
(
departmentDTO
.
getEnterpriseId
(),
clerk
.
getClerkId
(),
storeId
)
==
0
){
syncHaobanToGicServiceApi
.
delGicClerk
(
clerk
.
getClerkId
());
staffApiService
.
del
(
staffDepartmentRelatedId
);
}
//
if(clerk != null && distributeApiService.getClerkMemberCount(departmentDTO.getEnterpriseId(), clerk.getClerkId(), storeId) == 0){
//
syncHaobanToGicServiceApi.delGicClerk(clerk.getClerkId());
//
staffApiService.del(staffDepartmentRelatedId);
//
}
}
}
if
(
flag
){
...
...
@@ -341,36 +338,36 @@ public class ClerkController extends WebBaseController{
//刷新微信好友
@RequestMapping
(
"/fresh-wx-friend"
)
public
HaobanResponse
freshWxFrend
(
String
staffId
,
String
storeId
,
String
wxEnterpriseId
,
String
staffDepartmentRelatedId
,
String
wxUserId
)
{
StaffDTO
staff
=
staffApiService
.
selectById
(
staffId
);
String
yyyyMM
=
DateUtil
.
dateToStr
(
new
Date
(),
"yyyyMM"
);
if
(
staff
==
null
){
return
resultResponse
(
HaoBanErrCode
.
ERR_10006
);
}
String
key
=
"haoban_fresh_wx_friend"
+
yyyyMM
+
staffId
;
Integer
count
=
RedisUtil
.
getCache
(
key
)
==
null
?
0
:
(
Integer
)
RedisUtil
.
getCache
(
key
);
if
(
count
==
null
||
count
<
4
){
WxEnterpriseDTO
enterprise
=
wxEnterpriseApiService
.
getOne
(
wxEnterpriseId
);
RedisUtil
.
setCache
(
key
,
count
+
1
,
31
*
24
*
60
*
60
l
);
String
res
=
qywxUserApiService
.
listSelfExternalUserid
(
enterprise
.
getCorpid
(),
enterprise
.
getWxSecretKey
(),
staff
.
getWxUserId
());
JSONObject
json
=
JSON
.
parseObject
(
res
);
if
(
"0"
.
equals
(
json
.
getString
(
"errcode"
))){
String
external_userid
=
json
.
getString
(
"external_userid"
);
JSONArray
jsonArr
=
json
.
getJSONArray
(
external_userid
);
List
<
MemberUnionidRelatedDTO
>
list
=
memberUnionidRelatedApiService
.
getByWxUserIdAndWxEnterpriseId
(
wxUserId
,
wxEnterpriseId
);
List
<
String
>
externalUserIdList
=
list
.
stream
().
map
(
student
->
student
.
getExternalUserid
())
.
collect
(
Collectors
.
toList
());
for
(
Object
object
:
jsonArr
)
{
if
(
externalUserIdList
.
contains
(
object
.
toString
())){
continue
;
}
else
{
//String string = qywxUserApiService.getCorpSelfExternalUseridInfo(enterprise.getCorpid(), enterprise.getWxSecretKey(), object.toString());
memberUnionidRelatedApiService
.
add
(
wxEnterpriseId
,
object
.
toString
(),
wxUserId
);
}
}
}
}
else
{
return
resultResponse
(
HaoBanErrCode
.
ERR_10011
);
}
//
StaffDTO staff = staffApiService.selectById(staffId);
//
String yyyyMM = DateUtil.dateToStr(new Date(), "yyyyMM");
//
if(staff == null){
//
return resultResponse(HaoBanErrCode.ERR_10006);
//
}
//
String key = "haoban_fresh_wx_friend" + yyyyMM + staffId;
//
Integer count = RedisUtil.getCache(key) == null ? 0 : (Integer)RedisUtil.getCache(key);
//
if(count == null || count < 4){
//
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
//
RedisUtil.setCache(key,count + 1,31 * 24 * 60 * 60l);
//
String res = qywxUserApiService.listSelfExternalUserid(enterprise.getCorpid(), enterprise.getWxSecretKey(), staff.getWxUserId());
//
JSONObject json = JSON.parseObject(res);
//
if("0".equals(json.getString("errcode"))){
//
String external_userid = json.getString("external_userid");
//
JSONArray jsonArr = json.getJSONArray(external_userid);
//
List<MemberUnionidRelatedDTO> list = memberUnionidRelatedApiService.getByWxUserIdAndWxEnterpriseId(wxUserId, wxEnterpriseId);
//
List<String> externalUserIdList = list.stream().map(student->student.getExternalUserid())
//
.collect(Collectors.toList());
//
for (Object object : jsonArr) {
//
if(externalUserIdList.contains(object.toString())){
//
continue;
//
}else{
//
//String string = qywxUserApiService.getCorpSelfExternalUseridInfo(enterprise.getCorpid(), enterprise.getWxSecretKey(), object.toString());
//
memberUnionidRelatedApiService.add(wxEnterpriseId, object.toString(), wxUserId);
//
}
//
}
//
}
//
}else{
//
return resultResponse(HaoBanErrCode.ERR_10011);
//
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
...
...
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