|
@@ -484,6 +484,74 @@ public class WeiXinCorpController {
|
|
ReportServiceImpl.corpwxJobCenter.put(jobId, result);
|
|
ReportServiceImpl.corpwxJobCenter.put(jobId, result);
|
|
UserServiceImpl.corpwxJobCenter.put(jobId, result);
|
|
UserServiceImpl.corpwxJobCenter.put(jobId, result);
|
|
TaskServiceImpl.corpwxJobCenter.put(jobId, result);
|
|
TaskServiceImpl.corpwxJobCenter.put(jobId, result);
|
|
|
|
+ } else if ("auto_activate".equals(infoType)) {
|
|
|
|
+ //被邀请的同事自动激活使用
|
|
|
|
+ //{"xml":{"Scene":1,"InfoType":"auto_activate",
|
|
|
|
+ // "AccountList":{"Type":1,"PreviousStatus":1,"UserId":"woy9TkCAAACuqbgmQBZxra6gy6Bv7mMg",
|
|
|
|
+ // "ExpireTime":1671465600,"ActiveCode":"LA10000001400000163774145"},
|
|
|
|
+ // "ServiceCorpId":"wwf11426cf618e1703",
|
|
|
|
+ // "AuthCorpId":"wpy9TkCAAA6ii2OYKAEj5rCEqjwEQSuA","TimeStamp":1668761791}}
|
|
|
|
+ org.json.JSONObject authUserJson = jsonObject.getJSONObject("AccountList");
|
|
|
|
+ String authUserId = authUserJson.getString("UserId");
|
|
|
|
+ User oneUser = userMapper.selectOne(new QueryWrapper<User>().eq("corpwx_userid", authUserId));
|
|
|
|
+ if (oneUser == null) {
|
|
|
|
+ //生成该用户
|
|
|
|
+ String corpId = authUserJson.getString("AuthCorpId");
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectById(corpId);
|
|
|
|
+ if (wxCorpInfo != null) {
|
|
|
|
+ Integer companyId = wxCorpInfo.getCompanyId();
|
|
|
|
+ SysRole defaultRole = sysRoleMapper.selectOne(new QueryWrapper<SysRole>().eq("company_id", companyId).eq("is_default", 1));
|
|
|
|
+ String corpWxUserId = jsonObject.getString("UserID");
|
|
|
|
+ String openUserId = jsonObject.getString("OpenUserID");
|
|
|
|
+ if (wxCorpInfo.getSaasSyncContact() == 1) {
|
|
|
|
+ //直接通过企业微信通讯录同步
|
|
|
|
+ JSONObject userObj = getUserInfo(getCorpAccessToken(wxCorpInfo), corpWxUserId);
|
|
|
|
+ //成功获取到通讯录的个人详情
|
|
|
|
+ Long id = SnowFlake.nextId();
|
|
|
|
+ //通过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));
|
|
|
|
+ String userId = userObj.getString("userid");
|
|
|
|
+ User user = new User()
|
|
|
|
+ .setId(id.toString())
|
|
|
|
+ .setRoleId(defaultRole.getId())
|
|
|
|
+ .setRoleName(defaultRole.getRolename())
|
|
|
|
+ .setName(userObj.getString("name"))
|
|
|
|
+ .setPhone(userObj.getString("mobile"))
|
|
|
|
+ .setPassword(MD5Util.getPassword("000000"))
|
|
|
|
+ .setCorpwxUserid(openUserId)
|
|
|
|
+ .setCorpwxRealUserid(corpWxUserId)
|
|
|
|
+ .setJobNumber(openUserId.equals(userId)?null:userId)
|
|
|
|
+ .setColor(ColorUtil.randomColor())
|
|
|
|
+ .setCompanyId(companyId);
|
|
|
|
+ if (sysDept != null) {
|
|
|
|
+ user.setDepartmentId(sysDept.getDepartmentId());
|
|
|
|
+ List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
|
|
+ user.setDepartmentCascade(convertDepartmentIdToCascade(user.getDepartmentId(), allDeptList));
|
|
|
|
+ }
|
|
|
|
+ Integer employeeCnt = userMapper.selectCount(new QueryWrapper<User>().eq("company_id", companyId).eq("is_active",1));
|
|
|
|
+ Company company = companyMapper.selectOne(new QueryWrapper<Company>().eq("id", companyId));
|
|
|
|
+ ContactSyncLog contactSyncLog = new ContactSyncLog();
|
|
|
|
+ contactSyncLog.setCompanyId(companyId);
|
|
|
|
+ System.err.println("企业微信自动同步新增人员日志记录===============================");
|
|
|
|
+ if (employeeCnt + 1 > company.getStaffCountMax()){
|
|
|
|
+ contactSyncLog.setResult(0);
|
|
|
|
+ //contactSyncLog.setMsg("公司人员已达上限,请联系客服提高人数上限。");
|
|
|
|
+ contactSyncLog.setMsg(MessageUtils.message("wx.employeeFull"));
|
|
|
|
+ System.err.println("日志信息:"+ contactSyncLog.toString());
|
|
|
|
+ contactSyncLogMapper.insert(contactSyncLog);
|
|
|
|
+ }else {
|
|
|
|
+ userMapper.insert(user);
|
|
|
|
+ contactSyncLog.setResult(1);
|
|
|
|
+ //contactSyncLog.setMsg("同步成功");
|
|
|
|
+ contactSyncLog.setMsg(MessageUtils.message("wx.synSuccess"));
|
|
|
|
+ System.err.println("日志信息:"+ contactSyncLog.toString());
|
|
|
|
+ contactSyncLogMapper.insert(contactSyncLog);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|