|
@@ -2,9 +2,12 @@ package com.linkwechat.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.google.gson.JsonObject;
|
|
|
|
|
+import com.google.gson.JsonParser;
|
|
|
import com.linkwechat.common.core.domain.AjaxResult;
|
|
import com.linkwechat.common.core.domain.AjaxResult;
|
|
|
import com.linkwechat.common.core.domain.entity.SysUser;
|
|
import com.linkwechat.common.core.domain.entity.SysUser;
|
|
|
import com.linkwechat.common.core.domain.model.LoginUser;
|
|
import com.linkwechat.common.core.domain.model.LoginUser;
|
|
@@ -19,6 +22,7 @@ import com.linkwechat.domain.weGroupFission.bdsh.LotteryActivity;
|
|
|
import com.linkwechat.domain.weGroupFission.dto.DistDto;
|
|
import com.linkwechat.domain.weGroupFission.dto.DistDto;
|
|
|
import com.linkwechat.domain.weGroupFission.dto.WeGroupFissionDetailDto;
|
|
import com.linkwechat.domain.weGroupFission.dto.WeGroupFissionDetailDto;
|
|
|
import com.linkwechat.domain.weGroupFission.dto.WeGroupFissionDto;
|
|
import com.linkwechat.domain.weGroupFission.dto.WeGroupFissionDto;
|
|
|
|
|
+import com.linkwechat.domain.weGroupFission.entity.WeExternalChat;
|
|
|
import com.linkwechat.domain.weGroupFission.entity.WeGroupFission;
|
|
import com.linkwechat.domain.weGroupFission.entity.WeGroupFission;
|
|
|
import com.linkwechat.domain.weGroupFission.entity.WeGroupFissionExtraRecord;
|
|
import com.linkwechat.domain.weGroupFission.entity.WeGroupFissionExtraRecord;
|
|
|
import com.linkwechat.domain.weGroupFission.entity.WeGroupFissionStepRecord;
|
|
import com.linkwechat.domain.weGroupFission.entity.WeGroupFissionStepRecord;
|
|
@@ -41,6 +45,7 @@ import me.chanjar.weixin.cp.api.WxCpUserService;
|
|
|
import me.chanjar.weixin.cp.bean.WxCpUser;
|
|
import me.chanjar.weixin.cp.bean.WxCpUser;
|
|
|
import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatInfo;
|
|
import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatInfo;
|
|
|
import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatList;
|
|
import me.chanjar.weixin.cp.bean.external.WxCpUserExternalGroupChatList;
|
|
|
|
|
+import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -84,6 +89,9 @@ public class WeGroupFissionServiceImpl extends ServiceImpl<WeGroupFissionMapper,
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private WxCpService wxCpService;
|
|
private WxCpService wxCpService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IWeExternalChatService weExternalChatService;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @version
|
|
* @version
|
|
@@ -426,12 +434,23 @@ public class WeGroupFissionServiceImpl extends ServiceImpl<WeGroupFissionMapper,
|
|
|
* @version
|
|
* @version
|
|
|
* @author: hxl
|
|
* @author: hxl
|
|
|
* @Date: 2026/1/28 16:42
|
|
* @Date: 2026/1/28 16:42
|
|
|
- * @Description: 获取企业微信群列表
|
|
|
|
|
|
|
+ * @Description: 获取企业微信群列表 优化
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public List<DistDto> getWecomGroupList() {
|
|
public List<DistDto> getWecomGroupList() {
|
|
|
List<DistDto> list = new ArrayList<>();
|
|
List<DistDto> list = new ArrayList<>();
|
|
|
- //获取企业微信群列表
|
|
|
|
|
|
|
+
|
|
|
|
|
+ List<WeExternalChat> chatList = weExternalChatService.list(new QueryWrapper<WeExternalChat>().eq("dismiss_flag", "0").orderByDesc("create_time"));
|
|
|
|
|
+
|
|
|
|
|
+ if(chatList!=null && !chatList.isEmpty()){
|
|
|
|
|
+ for (WeExternalChat weExternalChat : chatList) {
|
|
|
|
|
+ DistDto dto = new DistDto();
|
|
|
|
|
+ dto.setVal(weExternalChat.getChatId());
|
|
|
|
|
+ dto.setName(weExternalChat.getChatName());
|
|
|
|
|
+ list.add(dto);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ /* //获取企业微信群列表
|
|
|
WxCpExternalContactService externalContactService = wxCpService.getExternalContactService();
|
|
WxCpExternalContactService externalContactService = wxCpService.getExternalContactService();
|
|
|
try{
|
|
try{
|
|
|
// 调用获取客户群列表接口
|
|
// 调用获取客户群列表接口
|
|
@@ -452,9 +471,11 @@ public class WeGroupFissionServiceImpl extends ServiceImpl<WeGroupFissionMapper,
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
log.error(e.getMessage());
|
|
log.error(e.getMessage());
|
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
|
- }
|
|
|
|
|
|
|
+ }*/
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|
|
|
|
|
+ // 企微原生API - 用户详情
|
|
|
|
|
+ private static final String API_USER_DETAIL_GET = "https://qyapi.weixin.qq.com/cgi-bin/user/get?userid=%s";
|
|
|
/**
|
|
/**
|
|
|
* @version
|
|
* @version
|
|
|
* @author: hxl
|
|
* @author: hxl
|
|
@@ -463,28 +484,34 @@ public class WeGroupFissionServiceImpl extends ServiceImpl<WeGroupFissionMapper,
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public List<DistDto> getWecomEmployeeList() {
|
|
public List<DistDto> getWecomEmployeeList() {
|
|
|
- List<DistDto> list = new ArrayList<>();
|
|
|
|
|
|
|
+ /* List<DistDto> list = new ArrayList<>();
|
|
|
//获取外部联系人列表
|
|
//获取外部联系人列表
|
|
|
WxCpExternalContactService externalContactService = wxCpService.getExternalContactService();
|
|
WxCpExternalContactService externalContactService = wxCpService.getExternalContactService();
|
|
|
try{
|
|
try{
|
|
|
List<String> followerUserIdList = externalContactService.listFollowers();
|
|
List<String> followerUserIdList = externalContactService.listFollowers();
|
|
|
// 4. 补充成员详情(沿用 4.1.0 版本支持的 getUserService())
|
|
// 4. 补充成员详情(沿用 4.1.0 版本支持的 getUserService())
|
|
|
WxCpUserService userService = wxCpService.getUserService();
|
|
WxCpUserService userService = wxCpService.getUserService();
|
|
|
|
|
+ String accessToken = wxCpService.getAccessToken();
|
|
|
for (String userId : followerUserIdList) {
|
|
for (String userId : followerUserIdList) {
|
|
|
- WxCpUser userDetail = userService.getById(userId);
|
|
|
|
|
|
|
+ // WxCpUser userDetail = userService.getById(userId);
|
|
|
|
|
+ String requestUrl = String.format(API_USER_DETAIL_GET, userId);
|
|
|
|
|
+ String response = wxCpService.get(requestUrl,null);
|
|
|
|
|
+ JsonObject userDetail = JsonParser.parseString(response).getAsJsonObject();
|
|
|
|
|
+
|
|
|
if (userDetail == null) {
|
|
if (userDetail == null) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
DistDto dto = new DistDto();
|
|
DistDto dto = new DistDto();
|
|
|
dto.setVal(userId);
|
|
dto.setVal(userId);
|
|
|
- dto.setName(userDetail.getName());
|
|
|
|
|
|
|
+ dto.setName(userDetail.get("name").getAsString());
|
|
|
|
|
+ dto.setUnionid(userDetail.get("unionid")!=null ?userDetail.get("unionid").getAsString():null);
|
|
|
list.add(dto);
|
|
list.add(dto);
|
|
|
}
|
|
}
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
log.error(e.getMessage());
|
|
log.error(e.getMessage());
|
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
|
- }
|
|
|
|
|
- return list;
|
|
|
|
|
|
|
+ }*/
|
|
|
|
|
+ return getUserDictDtos();
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
|
* @version
|
|
* @version
|