|
@@ -4,8 +4,6 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.google.gson.JsonArray;
|
|
|
-import com.google.gson.JsonObject;
|
|
|
import com.management.platform.controller.WeiXinCorpController;
|
|
|
import com.management.platform.entity.*;
|
|
|
import com.management.platform.mapper.*;
|
|
@@ -13,9 +11,6 @@ import com.management.platform.service.WxCorpInfoService;
|
|
|
import com.management.platform.util.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.http.client.utils.HttpClientUtils;
|
|
|
-import org.apache.tomcat.jni.Local;
|
|
|
-import org.json.HTTP;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.core.io.FileSystemResource;
|
|
@@ -31,6 +26,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
|
|
import sun.net.www.http.HttpClient;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.*;
|
|
|
import java.lang.reflect.Array;
|
|
|
import java.math.BigDecimal;
|
|
@@ -2052,4 +2048,93 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询成员的激活状态
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<Map<String, String>> getActiveInfoByUser(HttpServletRequest request) throws Exception {
|
|
|
+ List<Map<String, String>> resultList = new ArrayList<>();
|
|
|
+ String providerAccessToken = getProviderAccessToken();
|
|
|
+ String url ="https://qyapi.weixin.qq.com/cgi-bin/license/get_active_info_by_user?provider_access_token=" + providerAccessToken;
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
+ List<User> users = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).eq("is_active", 0));
|
|
|
+ if (users.size() != 0 && wxCorpInfo != null && wxCorpInfo.getSaasSyncContact().equals(1)){
|
|
|
+ //发送请求
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
|
|
|
+ headers.setContentType(type);
|
|
|
+ headers.add("Accept", MediaType.APPLICATION_JSON.toString());
|
|
|
+ for (User item : users) {
|
|
|
+ JSONObject requestMap = new JSONObject();
|
|
|
+ requestMap.put("corpid", wxCorpInfo.getCorpid());
|
|
|
+ requestMap.put("userid", item.getCorpwxUserid());
|
|
|
+ HttpEntity<JSONObject> entity = new HttpEntity<>(requestMap, headers);
|
|
|
+ ResponseEntity<String> ResponseEntity = restTemplate.postForEntity(url, entity, String.class);
|
|
|
+ if (ResponseEntity.getStatusCode() == HttpStatus.OK) {
|
|
|
+ String resp = ResponseEntity.getBody();
|
|
|
+ JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
+ if (respJson.getInteger("errcode")==0){
|
|
|
+ Integer status = respJson.getInteger("active_status");
|
|
|
+ if (status.equals(1)){
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ map.put("id",item.getId());
|
|
|
+ map.put("corpid",item.getCorpwxUserid());
|
|
|
+ resultList.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 企业微信账号继承
|
|
|
+ * @param handoverId
|
|
|
+ * @param takeoverId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg batchTransferLicense(HttpServletRequest request,String handoverId, String takeoverId) throws Exception {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ handoverId = userMapper.selectById(handoverId).getCorpwxUserid();
|
|
|
+ takeoverId = userMapper.selectById(takeoverId).getCorpwxUserid();
|
|
|
+ msg.setError("转移失败!");
|
|
|
+ String providerAccessToken = getProviderAccessToken();
|
|
|
+ String url =" https://qyapi.weixin.qq.com/cgi-bin/license/batch_transfer_license?provider_access_token=" + providerAccessToken;
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
|
|
|
+ headers.setContentType(type);
|
|
|
+ headers.add("Accept", MediaType.APPLICATION_JSON.toString());
|
|
|
+ JSONObject requestMap = new JSONObject();
|
|
|
+ requestMap.put("corpid", wxCorpInfo.getCorpid());
|
|
|
+ ArrayList<HashMap<String, String>> list = new ArrayList<>();
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ map.put("handover_userid",handoverId);
|
|
|
+ map.put("takeover_userid",takeoverId);
|
|
|
+ list.add(map);
|
|
|
+ requestMap.put("transfer_list", map);
|
|
|
+
|
|
|
+ HttpEntity<JSONObject> entity = new HttpEntity<>(requestMap, headers);
|
|
|
+ ResponseEntity<String> ResponseEntity = restTemplate.postForEntity(url, entity, String.class);
|
|
|
+ if (ResponseEntity.getStatusCode() == HttpStatus.OK) {
|
|
|
+ String resp = ResponseEntity.getBody();
|
|
|
+ JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
+ System.err.println(resp);
|
|
|
+ if (respJson.getInteger("errcode")==0){
|
|
|
+ msg.msg = "转移成功";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
}
|