|
|
@@ -36,6 +36,10 @@ import com.linkwechat.framework.service.TokenService;
|
|
|
import com.linkwechat.mapper.WeGroupFissionMapper;
|
|
|
import com.linkwechat.service.*;
|
|
|
import me.chanjar.weixin.cp.api.WxCpExternalContactService;
|
|
|
+import me.chanjar.weixin.cp.api.WxCpService;
|
|
|
+import me.chanjar.weixin.cp.api.WxCpUserService;
|
|
|
+import me.chanjar.weixin.cp.bean.WxCpUser;
|
|
|
+import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatInfo;
|
|
|
import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatList;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
@@ -78,10 +82,7 @@ public class WeGroupFissionServiceImpl extends ServiceImpl<WeGroupFissionMapper,
|
|
|
private LocalRightsInfoService localRightsInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
- private IWeGroupService weGroupService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private QwCustomerClient qwCustomerClient;
|
|
|
+ private WxCpService wxCpService;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -430,23 +431,27 @@ public class WeGroupFissionServiceImpl extends ServiceImpl<WeGroupFissionMapper,
|
|
|
@Override
|
|
|
public List<DistDto> getWecomGroupList() {
|
|
|
List<DistDto> list = new ArrayList<>();
|
|
|
- List<WeGroupChatListVo.GroupChat> groupChatList=new ArrayList<>();
|
|
|
- WeGroupChatListQuery chatListQuery =new WeGroupChatListQuery(0, null, null, 1000) ;
|
|
|
- WeGroupChatListVo groupChatListVo = qwCustomerClient.getGroupChatList(chatListQuery).getData();
|
|
|
- if (groupChatListVo.getErrCode().equals(WeErrorCodeEnum.ERROR_CODE_0.getErrorCode())
|
|
|
- && CollectionUtil.isNotEmpty(groupChatListVo.getGroupChatList())) {
|
|
|
- groupChatList.addAll(groupChatListVo.getGroupChatList());
|
|
|
- }
|
|
|
- if(groupChatList!=null && !groupChatList.isEmpty()){
|
|
|
- for (WeGroupChatListVo.GroupChat groupChat : groupChatList) {
|
|
|
- WeGroupChatDetailQuery weGroupChatDetailQuery =new WeGroupChatDetailQuery();
|
|
|
- weGroupChatDetailQuery.setChat_id("wwfe67d19509d43ec5");
|
|
|
- AjaxResult<WeGroupChatDetailVo> groupChatDetail = qwCustomerClient.getGroupChatDetail(weGroupChatDetailQuery);
|
|
|
- DistDto dto = new DistDto();
|
|
|
- dto.setVal(groupChat.getChatId());
|
|
|
- dto.setName(groupChatDetail.getData().getGroupChat().getName());
|
|
|
- list.add(dto);
|
|
|
- }
|
|
|
+ //获取企业微信群列表
|
|
|
+ WxCpExternalContactService externalContactService = wxCpService.getExternalContactService();
|
|
|
+ try{
|
|
|
+ // 调用获取客户群列表接口
|
|
|
+ WxCpUserExternalGroupChatList wxCpUserExternalGroupChatList = externalContactService.listGroupChat(0, 100, 0, null, null);
|
|
|
+ if(wxCpUserExternalGroupChatList!=null && wxCpUserExternalGroupChatList.getGroupChatList()!=null && !wxCpUserExternalGroupChatList.getGroupChatList().isEmpty()){
|
|
|
+ List<WxCpUserExternalGroupChatList.ChatStatus> groupChatList = wxCpUserExternalGroupChatList.getGroupChatList();
|
|
|
+ for (WxCpUserExternalGroupChatList.ChatStatus chat : groupChatList) {
|
|
|
+ WxCpUserExternalGroupChatInfo groupChat = externalContactService.getGroupChat(chat.getChatId());
|
|
|
+ if (groupChat == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ DistDto dto = new DistDto();
|
|
|
+ dto.setVal(chat.getChatId());
|
|
|
+ dto.setName(groupChat.getGroupChat().getName());
|
|
|
+ list.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage());
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
@@ -459,20 +464,25 @@ public class WeGroupFissionServiceImpl extends ServiceImpl<WeGroupFissionMapper,
|
|
|
@Override
|
|
|
public List<DistDto> getWecomEmployeeList() {
|
|
|
List<DistDto> list = new ArrayList<>();
|
|
|
- WeBaseQuery query = new WeBaseQuery();
|
|
|
- query.setCorpid("wwfe67d19509d43ec5");
|
|
|
- AjaxResult<WeFollowUserListVo> result = qwCustomerClient.getFollowUserList(query);
|
|
|
- if(result!=null ){
|
|
|
- for (String followUserId : result.getData().getFollowUser()) {
|
|
|
- WeCustomerQuery weCustomerQuery = new WeCustomerQuery();
|
|
|
- weCustomerQuery.setExternal_userid(followUserId);
|
|
|
- weCustomerQuery.setCorpid("wwfe67d19509d43ec5");
|
|
|
- WeCustomerDetailVo customerDetail = qwCustomerClient.getCustomerDetail(weCustomerQuery).getData();
|
|
|
+ //获取外部联系人列表
|
|
|
+ WxCpExternalContactService externalContactService = wxCpService.getExternalContactService();
|
|
|
+ try{
|
|
|
+ List<String> followerUserIdList = externalContactService.listFollowers();
|
|
|
+ // 4. 补充成员详情(沿用 4.1.0 版本支持的 getUserService())
|
|
|
+ WxCpUserService userService = wxCpService.getUserService();
|
|
|
+ for (String userId : followerUserIdList) {
|
|
|
+ WxCpUser userDetail = userService.getById(userId);
|
|
|
+ if (userDetail == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
DistDto dto = new DistDto();
|
|
|
- dto.setVal(customerDetail.getExternalContact().getExternalUserId());
|
|
|
- dto.setName(customerDetail.getExternalContact().getName());
|
|
|
+ dto.setVal(userId);
|
|
|
+ dto.setName(userDetail.getName());
|
|
|
list.add(dto);
|
|
|
}
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage());
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
return list;
|
|
|
}
|