|
@@ -393,7 +393,7 @@ public class WeiXinCorpController {
|
|
|
getTicketUrl = getTicketUrl.replace("ACCESS_TOKEN", corpToken);
|
|
|
String forObject = this.restTemplate.getForObject(getTicketUrl, String.class);
|
|
|
JSONObject json = JSONObject.parseObject(forObject);
|
|
|
- System.out.println("返回:"+json.toJSONString());
|
|
|
+ System.out.println("getCorpWXAgentConfig返回:"+json.toJSONString());
|
|
|
if (json.getIntValue("errcode") == 0) {
|
|
|
String ticket = json.getString("ticket");
|
|
|
AgentItem it = new AgentItem();
|
|
@@ -408,7 +408,7 @@ public class WeiXinCorpController {
|
|
|
msg.setError(MessageUtils.message("wx.TicketError"));
|
|
|
return msg;
|
|
|
}
|
|
|
- System.out.println("jsTicket = " + agentItem.jsTicket);
|
|
|
+ System.out.println("getCorpWXAgentConfig jsTicket = " + agentItem.jsTicket);
|
|
|
// 对以下字段进行签名
|
|
|
SortedMap<String, String> packageParams = new TreeMap<String, String>();
|
|
|
SortedMap<String, String> packageParam = new TreeMap<String, String>();
|
|
@@ -517,42 +517,47 @@ public class WeiXinCorpController {
|
|
|
if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1) {
|
|
|
//企业存在,生成对应的用户
|
|
|
Integer companyId = wxCorpInfo.getCompanyId();
|
|
|
- User user = wxCorpInfoService.generateUserInfo(companyId, corpWxUserId);
|
|
|
-
|
|
|
- new Thread(() -> {
|
|
|
- //查询详情进行更新
|
|
|
- JSONObject userObj = null;
|
|
|
- try {
|
|
|
- userObj = getUserInfo(getCorpAccessToken(wxCorpInfo), corpWxUserId);
|
|
|
- } catch (Exception exception) {
|
|
|
- exception.printStackTrace();
|
|
|
- }
|
|
|
- System.out.println("关注时获取详情userObj=="+userObj);
|
|
|
- //成功获取到通讯录的个人详情
|
|
|
- String userId = userObj.getString("userid");
|
|
|
- String openUserId = userObj.getString("open_userid");
|
|
|
- User userUpdate = new User();
|
|
|
- userUpdate.setId(user.getId());
|
|
|
- userUpdate.setName(userObj.getString("name"))
|
|
|
- .setPhone(userObj.getString("mobile"))
|
|
|
- .setCorpwxUserid(openUserId)
|
|
|
- .setCorpwxRealUserid(userId)
|
|
|
- .setJobNumber(openUserId.equals(userId)?null:userId);
|
|
|
+ User find = userMapper.selectOne(new QueryWrapper<User>().eq("company_id", companyId).eq("corpwx_userid", corpWxUserId));
|
|
|
+ if (find == null) {
|
|
|
+ User user = wxCorpInfoService.generateUserInfo(companyId, corpWxUserId);
|
|
|
|
|
|
- //通过getUserInfo接口获取到的json key是小写的
|
|
|
- JSONArray department = userObj.getJSONArray("department");
|
|
|
- Integer curUserWXDeptid = getMaxDeptIdFromArray(department);
|
|
|
- Department sysDept = departmentMapper.selectOne(new QueryWrapper<Department>().eq("company_id", companyId).eq("corpwx_deptid", curUserWXDeptid));
|
|
|
+ new Thread(() -> {
|
|
|
+ //查询详情进行更新
|
|
|
+ JSONObject userObj = null;
|
|
|
+ try {
|
|
|
+ userObj = getUserInfo(getCorpAccessToken(wxCorpInfo), corpWxUserId);
|
|
|
+ } catch (Exception exception) {
|
|
|
+ exception.printStackTrace();
|
|
|
+ }
|
|
|
+ System.out.println("关注时获取详情userObj=="+userObj);
|
|
|
+ //成功获取到通讯录的个人详情
|
|
|
+ String userId = userObj.getString("userid");
|
|
|
+ String openUserId = userObj.getString("open_userid");
|
|
|
+ User userUpdate = new User();
|
|
|
+ userUpdate.setId(user.getId());
|
|
|
+ userUpdate.setName(userObj.getString("name"))
|
|
|
+ .setPhone(userObj.getString("mobile"))
|
|
|
+ .setCorpwxUserid(openUserId)
|
|
|
+ .setCorpwxRealUserid(userId)
|
|
|
+ .setJobNumber(openUserId.equals(userId)?null:userId);
|
|
|
|
|
|
- if (sysDept != null) {
|
|
|
- userUpdate.setDepartmentId(sysDept.getDepartmentId());
|
|
|
- List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
|
- userUpdate.setDepartmentCascade(convertDepartmentIdToCascade(user.getDepartmentId(), allDeptList));
|
|
|
- }
|
|
|
- userMapper.updateById(userUpdate);
|
|
|
- System.out.println("======关注时更新人员======");
|
|
|
- sendCardMsg(corpWxUserId);
|
|
|
- }).start();
|
|
|
+ //通过getUserInfo接口获取到的json key是小写的
|
|
|
+ JSONArray department = userObj.getJSONArray("department");
|
|
|
+ Integer curUserWXDeptid = getMaxDeptIdFromArray(department);
|
|
|
+ Department sysDept = departmentMapper.selectOne(new QueryWrapper<Department>().eq("company_id", companyId).eq("corpwx_deptid", curUserWXDeptid));
|
|
|
+
|
|
|
+ if (sysDept != null) {
|
|
|
+ userUpdate.setDepartmentId(sysDept.getDepartmentId());
|
|
|
+ List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
|
+ userUpdate.setDepartmentCascade(convertDepartmentIdToCascade(user.getDepartmentId(), allDeptList));
|
|
|
+ }
|
|
|
+ userMapper.updateById(userUpdate);
|
|
|
+ System.out.println("======关注时更新人员======");
|
|
|
+ sendCardMsg(corpWxUserId);
|
|
|
+ }).start();
|
|
|
+ } else {
|
|
|
+ log.info("当前用户已存在");
|
|
|
+ }
|
|
|
}
|
|
|
} else if ("enter_agent".equals(event)) {
|
|
|
|
|
@@ -738,12 +743,12 @@ public class WeiXinCorpController {
|
|
|
jsonObject = jsonObject.getJSONObject("xml");
|
|
|
//订单回调。存储更新订单、更新公司续费情况
|
|
|
if (jsonObject.has("InfoType")){
|
|
|
- System.err.println("+++++++++++++++++++订单回调开始++++++++++++++++++++++");
|
|
|
- System.err.println(jsonObject);
|
|
|
String infoType = jsonObject.getString("InfoType");
|
|
|
String orderId = "";
|
|
|
if (jsonObject.has("OrderId")){
|
|
|
orderId = jsonObject.getString("OrderId");
|
|
|
+ System.err.println("+++++++++++++++++++订单回调开始++++++++++++++++++++++");
|
|
|
+ System.err.println(jsonObject);
|
|
|
}
|
|
|
WxOrder wxOrder = null;
|
|
|
switch (infoType){
|
|
@@ -810,8 +815,16 @@ public class WeiXinCorpController {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (jsonObject.has("AuthCode")) {
|
|
|
+ if ("cancel_auth".equals(jsonObject.get("InfoType"))) {
|
|
|
+ //企业取消授权通知,更新ticket缓存
|
|
|
+ String corpId = jsonObject.getString("AuthCorpId");
|
|
|
+ if (corpTicketMap.containsKey(corpId)) {
|
|
|
+ System.out.println("企业取消授权,清除缓存ticket=="+corpId);
|
|
|
+ agentCorpTicketMap.remove(corpId);
|
|
|
+ corpTicketMap.remove(corpId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (jsonObject.has("AuthCode")) {
|
|
|
//企业授权通知
|
|
|
String authCode = jsonObject.getString("AuthCode");
|
|
|
new Thread(){
|
|
@@ -1231,7 +1244,7 @@ public class WeiXinCorpController {
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
JSONObject reqParam = new JSONObject();
|
|
|
reqParam.put("auth_code", authCode);
|
|
|
-
|
|
|
+ log.info("处理企业授权开通==========");
|
|
|
HttpEntity<String> requestEntity = new HttpEntity<String>(reqParam.toJSONString(), headers);
|
|
|
ResponseEntity<String> responseEntity = this.restTemplate.exchange(url,
|
|
|
HttpMethod.POST, requestEntity, String.class);
|
|
@@ -1395,6 +1408,7 @@ public class WeiXinCorpController {
|
|
|
.setJobNumber(openUserId.equals(userId)?null:userId)
|
|
|
.setCorpwxRealUserid(userId);
|
|
|
userMapper.insert(user);
|
|
|
+ System.out.println("生成超级管理员:"+userId);
|
|
|
//todo: 生成初始测试项目及任务
|
|
|
Project project=new Project();
|
|
|
project.setCompanyId(company.getId());
|
|
@@ -1548,7 +1562,7 @@ public class WeiXinCorpController {
|
|
|
String userId = authUserInfo.getString("userid");//授权人的userid
|
|
|
String openUserId = authUserInfo.getString("open_userid");
|
|
|
//检查该授权人是否已经存在
|
|
|
- if (userMapper.selectCount(new QueryWrapper<User>().eq("corpwx_userid", userId)) == 0) {
|
|
|
+ if (userMapper.selectCount(new QueryWrapper<User>().eq("corpwx_userid", openUserId)) == 0) {
|
|
|
JSONObject userDetail = getUserInfo(curCorpAccessToken, userId);
|
|
|
//检查是否有超级管理员
|
|
|
SysRole smanager = sysRoleMapper.selectOne(
|
|
@@ -2263,6 +2277,7 @@ public class WeiXinCorpController {
|
|
|
changeUser.setDepartmentId(0);
|
|
|
changeUser.setDepartmentCascade("0");
|
|
|
}
|
|
|
+ changeUser.setCorpwxDeptid(userItem.getCorpwxDeptid());
|
|
|
}
|
|
|
if (oldUser.getCorpwxRealUserid() == null || !userItem.getCorpwxRealUserid().equals(oldUser.getCorpwxRealUserid())) {
|
|
|
changeUser.setId(oldUser.getId());
|