WeComUserDataJob.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. package com.tzld.piaoquan.offline.job;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
  5. import com.tzld.piaoquan.growth.common.dao.mapper.*;
  6. import com.tzld.piaoquan.growth.common.model.bo.XxlJobParam;
  7. import com.tzld.piaoquan.growth.common.model.po.*;
  8. import com.tzld.piaoquan.growth.common.service.WeComAccessTokenService;
  9. import com.tzld.piaoquan.growth.common.service.WeComStaffService;
  10. import com.tzld.piaoquan.growth.common.service.WeComUserService;
  11. import com.tzld.piaoquan.growth.common.utils.DateUtil;
  12. import com.tzld.piaoquan.growth.common.utils.LarkRobotUtil;
  13. import com.xxl.job.core.biz.model.ReturnT;
  14. import com.xxl.job.core.handler.annotation.XxlJob;
  15. import lombok.extern.slf4j.Slf4j;
  16. import org.apache.commons.lang3.StringUtils;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.stereotype.Component;
  19. import org.springframework.util.CollectionUtils;
  20. import java.io.IOException;
  21. import java.util.ArrayList;
  22. import java.util.HashMap;
  23. import java.util.List;
  24. import java.util.Map;
  25. import java.util.stream.Collectors;
  26. import static com.tzld.piaoquan.growth.common.common.constant.WeComConstant.*;
  27. @Slf4j
  28. @Component
  29. public class WeComUserDataJob {
  30. @Autowired
  31. private HttpPoolClient httpPoolClient;
  32. @Autowired
  33. private StaffMapper staffMapper;
  34. @Autowired
  35. private WeComUserMapper weComUserMapper;
  36. @Autowired
  37. private WeComAccessTokenService weComAccessTokenService;
  38. @Autowired
  39. private StaffWithUserMapper staffWithUserMapper;
  40. @Autowired
  41. private WeComUserService weComUserService;
  42. @Autowired
  43. private CorpMapper corpMapper;
  44. @Autowired
  45. private UserCountMapper userCountMapper;
  46. @Autowired
  47. private TagMapper tagMapper;
  48. @Autowired
  49. private UserWithTagMapper userWithTagMapper;
  50. @Autowired
  51. private WeComStaffService weComStaffService;
  52. @XxlJob("updateStaffWithUserJob")
  53. public ReturnT<String> updateStaffWithUser(String param) {
  54. XxlJobParam xxlJobParam = new XxlJobParam();
  55. if (StringUtils.isNotEmpty(param)) {
  56. xxlJobParam = JSONObject.parseObject(param, XxlJobParam.class);
  57. }
  58. CorpExample corpExample = new CorpExample();
  59. CorpExample.Criteria corpCriteria = corpExample.createCriteria();
  60. if (xxlJobParam.getCorpId() != null) {
  61. corpCriteria.andIdEqualTo(xxlJobParam.getCorpId());
  62. }
  63. List<Corp> corps = corpMapper.selectByExample(corpExample);
  64. if (CollectionUtils.isEmpty(corps)) {
  65. return ReturnT.SUCCESS;
  66. }
  67. for (Corp corp : corps) {
  68. StaffExample staffExample = new StaffExample();
  69. StaffExample.Criteria staffCriteria = staffExample.createCriteria();
  70. staffCriteria.andCorpIdEqualTo(corp.getId());
  71. if (xxlJobParam.getStaffId() != null) {
  72. staffCriteria.andIdEqualTo(xxlJobParam.getStaffId());
  73. }
  74. List<Staff> staffList = staffMapper.selectByExample(staffExample);
  75. if (CollectionUtils.isEmpty(staffList)) {
  76. continue;
  77. }
  78. for (Staff staff : staffList) {
  79. updateUserList(staff, corp.getId());
  80. }
  81. }
  82. return ReturnT.SUCCESS;
  83. }
  84. private void updateUserList(Staff staff, Long corpId) {
  85. try {
  86. String cursor = "";
  87. do {
  88. String res = getUserDetailList(staff.getCarrierId(), cursor, corpId);
  89. log.info("updateUserList res={} cursor={}", res, cursor);
  90. JSONObject jsonObject = JSONObject.parseObject(res);
  91. Integer errCode = jsonObject.getInteger("errcode");
  92. if (errCode != 0) {
  93. log.error("updateUserList error carrierId={} cursor={}", staff.getCarrierId(), cursor);
  94. return;
  95. }
  96. JSONArray externalContactList = jsonObject.getJSONArray("external_contact_list");
  97. for (int i = 0; i < externalContactList.size(); i++) {
  98. JSONObject externalContact = externalContactList.getJSONObject(i).getJSONObject("external_contact");
  99. JSONObject followInfo = externalContactList.getJSONObject(i).getJSONObject("follow_info");
  100. Long createAt = followInfo.getLong("createtime");
  101. String externalUserId = externalContact.getString("external_userid");
  102. String name = externalContact.getString("name");
  103. String unionId = externalContact.getString("unionid");
  104. String avatar = externalContact.getString("avatar");
  105. Integer type = externalContact.getInteger("type");
  106. Integer gender = externalContact.getInteger("gender");
  107. WeComUserExample example = new WeComUserExample();
  108. example.createCriteria().andExternalUserIdEqualTo(externalUserId);
  109. List<WeComUser> weComUserList = weComUserMapper.selectByExample(example);
  110. WeComUser weComUser = new WeComUser();
  111. weComUser.setExternalUserId(externalUserId);
  112. weComUser.setName(name);
  113. weComUser.setType(type);
  114. weComUser.setUnionId(unionId);
  115. weComUser.setGender(gender);
  116. weComUser.setAvatar(avatar);
  117. weComUser.setCreatedAt(createAt);
  118. Long userId;
  119. if (CollectionUtils.isEmpty(weComUserList)) {
  120. weComUserMapper.insertSelective(weComUser);
  121. userId = weComUser.getId();
  122. } else {
  123. WeComUser oldWeComUser = weComUserList.get(0);
  124. weComUser.setId(oldWeComUser.getId());
  125. weComUserMapper.updateByPrimaryKeySelective(weComUser);
  126. userId = oldWeComUser.getId();
  127. }
  128. if (userId == null) {
  129. continue;
  130. }
  131. StaffWithUserExample staffWithUserExample = new StaffWithUserExample();
  132. staffWithUserExample.createCriteria().andStaffIdEqualTo(staff.getId()).andUserIdEqualTo(userId);
  133. List<StaffWithUser> staffWithUserList = staffWithUserMapper.selectByExample(staffWithUserExample);
  134. if (CollectionUtils.isEmpty(staffWithUserList)) {
  135. StaffWithUser staffWithUser = new StaffWithUser();
  136. staffWithUser.setStaffId(staff.getId());
  137. staffWithUser.setUserId(userId);
  138. staffWithUserMapper.insertSelective(staffWithUser);
  139. }
  140. }
  141. String nextCursor = jsonObject.getString("next_cursor");
  142. if (cursor.equals(nextCursor)) {
  143. break;
  144. }
  145. cursor = nextCursor;
  146. } while (StringUtils.isNotEmpty(cursor));
  147. } catch (IOException e) {
  148. LarkRobotUtil.sendMessage("updateUser error" + e);
  149. log.error("updateUser error", e);
  150. }
  151. }
  152. private String getUserDetailList(String userId, String cursor, Long corpId) throws IOException {
  153. String accessToken = weComAccessTokenService.getWeComAccessToken(corpId);
  154. String url = POST_WE_COM_GET_BY_USER
  155. + "?access_token=" + accessToken;
  156. JSONObject param = new JSONObject();
  157. JSONArray userIdList = new JSONArray();
  158. userIdList.add(userId);
  159. param.put("userid_list", userIdList);
  160. param.put("limit", 100);
  161. if (StringUtils.isNotEmpty(cursor)) {
  162. param.put("cursor", cursor);
  163. }
  164. return httpPoolClient.post(url, param.toJSONString());
  165. }
  166. @XxlJob("insertStaffWithUserJob")
  167. public ReturnT<String> insertStaffWithUserJob(String param) {
  168. try {
  169. XxlJobParam xxlJobParam = new XxlJobParam();
  170. if (StringUtils.isNotEmpty(param)) {
  171. xxlJobParam = JSONObject.parseObject(param, XxlJobParam.class);
  172. }
  173. CorpExample corpExample = new CorpExample();
  174. CorpExample.Criteria corpCriteria = corpExample.createCriteria();
  175. if (xxlJobParam.getCorpId() != null) {
  176. corpCriteria.andIdEqualTo(xxlJobParam.getCorpId());
  177. }
  178. List<Corp> corps = corpMapper.selectByExample(corpExample);
  179. for (Corp corp : corps) {
  180. StaffExample staffExample = new StaffExample();
  181. StaffExample.Criteria staffCriteria = staffExample.createCriteria();
  182. staffCriteria.andCorpIdEqualTo(corp.getId());
  183. if (xxlJobParam.getStaffId() != null) {
  184. staffCriteria.andIdEqualTo(xxlJobParam.getStaffId());
  185. }
  186. List<Staff> staffList = staffMapper.selectByExample(staffExample);
  187. for (Staff staff : staffList) {
  188. List<String> existExternalUserIds = getUserList(staff.getCarrierId(), corp.getId());
  189. List<String> allExternalUserIds = staffWithUserMapper.selectExternalUserIdByStaffId(staff.getId());
  190. if (!CollectionUtils.isEmpty(existExternalUserIds)) {
  191. allExternalUserIds.removeAll(existExternalUserIds);
  192. }
  193. if (!CollectionUtils.isEmpty(allExternalUserIds)) {
  194. for (String delExternalUserId : allExternalUserIds) {
  195. weComUserService.delStaffWithUser(delExternalUserId, staff.getCarrierId(), corp.getId(),
  196. System.currentTimeMillis());
  197. }
  198. }
  199. if (CollectionUtils.isEmpty(existExternalUserIds)) {
  200. continue;
  201. }
  202. for (String externalUserId : existExternalUserIds) {
  203. weComUserService.insertStaffWithUser(externalUserId, staff, corp.getId());
  204. }
  205. }
  206. }
  207. } catch (Exception e) {
  208. LarkRobotUtil.sendMessage("insertStaffWithUserJob error" + e);
  209. log.error("insertStaffWithUserJob error", e);
  210. }
  211. return ReturnT.SUCCESS;
  212. }
  213. public List<String> getUserList(String userId, Long corpId) throws IOException {
  214. String weComAccessToken = weComAccessTokenService.getWeComAccessToken(corpId);
  215. String url = String.format(GET_WE_COM_EXTERNAL_CONTACT_LIST + "?access_token=%s&userid=%s", weComAccessToken, userId);
  216. String res = httpPoolClient.get(url);
  217. JSONObject jsonObject = JSONObject.parseObject(res);
  218. Integer errcode = jsonObject.getInteger("errcode");
  219. if (errcode == 0) {
  220. return jsonObject.getJSONArray("external_userid").stream().map(String::valueOf).collect(Collectors.toList());
  221. }
  222. return null;
  223. }
  224. @XxlJob("statisticsUserCountJob")
  225. public ReturnT<String> statisticsUserCount(String param) {
  226. StaffExample staffExample = new StaffExample();
  227. List<Staff> staffList = staffMapper.selectByExample(staffExample);
  228. String date;
  229. if (StringUtils.isEmpty(param)) {
  230. date = DateUtil.getBeforeDayDateString1();
  231. } else {
  232. date = param;
  233. }
  234. for (Staff staff : staffList) {
  235. Map<String, Integer> userCountRes = getUserList(staff, 1L, date);
  236. if (userCountRes == null || userCountRes.get("count") == 0) {
  237. continue;
  238. }
  239. UserCountExample userCountExample = new UserCountExample();
  240. userCountExample.createCriteria().andStaffIdEqualTo(staff.getId()).andDateEqualTo(date);
  241. List<UserCount> userCounts = userCountMapper.selectByExample(userCountExample);
  242. if (CollectionUtils.isEmpty(userCounts)) {
  243. UserCount userCount = new UserCount();
  244. userCount.setStaffId(staff.getId());
  245. userCount.setStaffName(staff.getRemark());
  246. userCount.setAllCount(userCountRes.get("count"));
  247. userCount.setNewCount(userCountRes.get("newCount"));
  248. userCount.setDate(date);
  249. userCountMapper.insertSelective(userCount);
  250. } else {
  251. UserCount userCount = userCounts.get(0);
  252. userCount.setAllCount(userCountRes.get("count"));
  253. userCount.setNewCount(userCountRes.get("newCount"));
  254. userCountMapper.updateByPrimaryKeySelective(userCount);
  255. }
  256. }
  257. return ReturnT.SUCCESS;
  258. }
  259. private Map<String, Integer> getUserList(Staff staff, Long corpId, String date) {
  260. Map<String, Integer> result = new HashMap<>();
  261. int count = 0;
  262. int newCount = 0;
  263. try {
  264. String cursor = "";
  265. do {
  266. String res = getUserDetailList(staff.getCarrierId(), cursor, corpId);
  267. log.info("getUserList res={} cursor={}", res, cursor);
  268. JSONObject jsonObject = JSONObject.parseObject(res);
  269. Integer errCode = jsonObject.getInteger("errcode");
  270. if (errCode != 0) {
  271. log.error("getUserList error carrierId={} cursor={}", staff.getCarrierId(), cursor);
  272. return null;
  273. }
  274. JSONArray externalContactList = jsonObject.getJSONArray("external_contact_list");
  275. for (int i = 0; i < externalContactList.size(); i++) {
  276. JSONObject externalContact = externalContactList.getJSONObject(i).getJSONObject("external_contact");
  277. String externalUserId = externalContact.getString("external_userid");
  278. JSONObject followInfo = externalContactList.getJSONObject(i).getJSONObject("follow_info");
  279. Long createAt = followInfo.getLong("createtime");
  280. String dateString = DateUtil.getDateString(createAt * 1000, "yyyy-MM-dd");
  281. if (dateString.equals(date)) {
  282. newCount++;
  283. }
  284. count++;
  285. Long userId = weComUserMapper.selectIdByExternalUserId(externalUserId);
  286. userId = addAndUpdateUser(externalContact, corpId, externalUserId, createAt, staff.getId(), userId);
  287. JSONArray tagIds = followInfo.getJSONArray("tag_id");
  288. if (!CollectionUtils.isEmpty(tagIds)) {
  289. List<String> tagIdList = tagIds.toJavaList(String.class);
  290. for (String tagId : tagIdList) {
  291. TagExample example = new TagExample();
  292. example.createCriteria().andTagIdEqualTo(tagId);
  293. List<Tag> tags = tagMapper.selectByExample(example);
  294. if (!CollectionUtils.isEmpty(tags)) {
  295. Tag tag = tags.get(0);
  296. UserWithTag userWithTag = new UserWithTag();
  297. userWithTag.setUserId(userId);
  298. userWithTag.setTagId(tag.getId());
  299. addUserWithTag(userWithTag);
  300. }
  301. }
  302. }
  303. }
  304. String nextCursor = jsonObject.getString("next_cursor");
  305. if (cursor.equals(nextCursor)) {
  306. break;
  307. }
  308. cursor = nextCursor;
  309. } while (StringUtils.isNotEmpty(cursor));
  310. } catch (IOException e) {
  311. log.error("getUserList error", e);
  312. }
  313. result.put("count", count);
  314. result.put("newCount", newCount);
  315. return result;
  316. }
  317. @XxlJob("getUserTagJob")
  318. public ReturnT<String> getUserTag(String param) {
  319. try {
  320. refreshTag();
  321. XxlJobParam xxlJobParam = new XxlJobParam();
  322. if (StringUtils.isNotEmpty(param)) {
  323. xxlJobParam = JSONObject.parseObject(param, XxlJobParam.class);
  324. }
  325. CorpExample corpExample = new CorpExample();
  326. CorpExample.Criteria corpCriteria = corpExample.createCriteria();
  327. if (xxlJobParam.getCorpId() != null) {
  328. corpCriteria.andIdEqualTo(xxlJobParam.getCorpId());
  329. }
  330. List<Corp> corps = corpMapper.selectByExample(corpExample);
  331. for (Corp corp : corps) {
  332. StaffExample staffExample = new StaffExample();
  333. StaffExample.Criteria staffCriteria = staffExample.createCriteria();
  334. staffCriteria.andCorpIdEqualTo(corp.getId());
  335. List<Long> staffIds = new ArrayList<>();
  336. if (xxlJobParam.getStaffId() != null) {
  337. staffIds.add(xxlJobParam.getStaffId());
  338. }
  339. if (!CollectionUtils.isEmpty(xxlJobParam.getStaffIds())) {
  340. staffIds.addAll(xxlJobParam.getStaffIds());
  341. }
  342. if (!CollectionUtils.isEmpty(staffIds)) {
  343. staffCriteria.andIdIn(staffIds);
  344. }
  345. List<Staff> staffList = staffMapper.selectByExample(staffExample);
  346. for (Staff staff : staffList) {
  347. List<String> existExternalUserIds = getUserList(staff.getCarrierId(), corp.getId());
  348. for (String externalUserId : existExternalUserIds) {
  349. JSONObject userDetail = weComUserService.getUserDetail(externalUserId, corp.getId());
  350. JSONObject externalContact = userDetail.getJSONObject("external_contact");
  351. JSONArray followUserList = userDetail.getJSONArray("follow_user");
  352. Long createAt = null;
  353. for (int i = 0; i < followUserList.size(); i++) {
  354. JSONObject followUser = followUserList.getJSONObject(i);
  355. if (createAt == null) {
  356. createAt = followUser.getLong("createtime");
  357. } else {
  358. createAt = Math.min(createAt, followUser.getLong("createtime"));
  359. }
  360. JSONArray tagIds = followUser.getJSONArray("tags");
  361. if (!CollectionUtils.isEmpty(tagIds)) {
  362. List<String> tagIdList = new ArrayList<>();
  363. for (int j = 0; j < tagIds.size(); j++) {
  364. JSONObject jsonObject = tagIds.getJSONObject(j);
  365. tagIdList.add(jsonObject.getString("tag_id"));
  366. }
  367. for (String tagId : tagIdList) {
  368. TagExample example = new TagExample();
  369. example.createCriteria().andTagIdEqualTo(tagId);
  370. List<Tag> tags = tagMapper.selectByExample(example);
  371. if (!CollectionUtils.isEmpty(tags)) {
  372. Long userId = weComUserMapper.selectIdByExternalUserId(externalUserId);
  373. userId = addAndUpdateUser(externalContact, corp.getId(), externalUserId,
  374. createAt, staff.getId(), userId);
  375. Tag tag = tags.get(0);
  376. UserWithTag userWithTag = new UserWithTag();
  377. userWithTag.setUserId(userId);
  378. userWithTag.setTagId(tag.getId());
  379. addUserWithTag(userWithTag);
  380. }
  381. }
  382. }
  383. }
  384. }
  385. }
  386. }
  387. } catch (Exception e) {
  388. log.error("getUserTag error", e);
  389. }
  390. return ReturnT.SUCCESS;
  391. }
  392. public void refreshTag() throws IOException {
  393. String weComAccessToken = weComAccessTokenService.getWeComAccessToken(1L);
  394. String url = String.format(POST_CORP_TAG_LIST + "?access_token=%s", weComAccessToken);
  395. String res = httpPoolClient.post(url);
  396. JSONObject jsonObject = JSONObject.parseObject(res);
  397. Integer errcode = jsonObject.getInteger("errcode");
  398. if (errcode == 0) {
  399. JSONArray tagGroup = jsonObject.getJSONArray("tag_group");
  400. if (!tagGroup.isEmpty()) {
  401. for (int i = 0; i < tagGroup.size(); i++) {
  402. JSONObject tagGroupJSONObject = tagGroup.getJSONObject(i);
  403. String groupId = tagGroupJSONObject.getString("group_id");
  404. String groupName = tagGroupJSONObject.getString("group_name");
  405. JSONArray tags = tagGroupJSONObject.getJSONArray("tag");
  406. if (tags.isEmpty()) {
  407. continue;
  408. }
  409. for (int j = 0; j < tags.size(); j++) {
  410. JSONObject tagsJSONObject = tags.getJSONObject(j);
  411. String tagId = tagsJSONObject.getString("id");
  412. String tagName = tagsJSONObject.getString("name");
  413. Tag tag = new Tag();
  414. tag.setTagGroupId(groupId);
  415. tag.setTagGroupName(groupName);
  416. tag.setTagId(tagId);
  417. tag.setTagName(tagName);
  418. addAndUpdateTag(tag);
  419. }
  420. }
  421. }
  422. }
  423. }
  424. private void addAndUpdateTag(Tag tag) {
  425. TagExample example = new TagExample();
  426. example.createCriteria().andTagGroupIdEqualTo(tag.getTagGroupId()).andTagIdEqualTo(tag.getTagId());
  427. List<Tag> tags = tagMapper.selectByExample(example);
  428. if (CollectionUtils.isEmpty(tags)) {
  429. tagMapper.insertSelective(tag);
  430. } else {
  431. tag.setId(tags.get(0).getId());
  432. tagMapper.updateByPrimaryKeySelective(tag);
  433. }
  434. }
  435. private void addUserWithTag(UserWithTag userWithTag) {
  436. UserWithTagExample userWithTagExample = new UserWithTagExample();
  437. userWithTagExample.createCriteria().andUserIdEqualTo(userWithTag.getUserId()).andTagIdEqualTo(userWithTag.getTagId());
  438. long l = userWithTagMapper.countByExample(userWithTagExample);
  439. if (l == 0) {
  440. userWithTagMapper.insertSelective(userWithTag);
  441. }
  442. }
  443. private Long addAndUpdateUser(JSONObject externalContact, Long corpId, String externalUserId, Long createAt, Long staffId, Long userId) {
  444. String name = externalContact.getString("name");
  445. String unionId = externalContact.getString("unionid");
  446. String avatar = externalContact.getString("avatar");
  447. Integer type = externalContact.getInteger("type");
  448. Integer gender = externalContact.getInteger("gender");
  449. if (userId == null) {
  450. WeComUser weComUser = new WeComUser();
  451. weComUser.setCorpId(corpId);
  452. weComUser.setExternalUserId(externalUserId);
  453. weComUser.setName(name);
  454. weComUser.setType(type);
  455. weComUser.setUnionId(unionId);
  456. weComUser.setGender(gender);
  457. weComUser.setAvatar(avatar);
  458. weComUser.setCreatedAt(createAt);
  459. weComUserMapper.insertSelective(weComUser);
  460. userId = weComUser.getId();
  461. StaffWithUser staffWithUser = new StaffWithUser();
  462. staffWithUser.setStaffId(staffId);
  463. staffWithUser.setUserId(userId);
  464. staffWithUserMapper.insertSelective(staffWithUser);
  465. } else {
  466. WeComUser weComUser = new WeComUser();
  467. weComUser.setId(userId);
  468. weComUser.setName(name);
  469. weComUser.setType(type);
  470. weComUser.setUnionId(unionId);
  471. weComUser.setGender(gender);
  472. weComUser.setAvatar(avatar);
  473. weComUserMapper.updateByPrimaryKeySelective(weComUser);
  474. StaffWithUserExample example = new StaffWithUserExample();
  475. example.createCriteria().andStaffIdEqualTo(staffId).andUserIdEqualTo(userId);
  476. List<StaffWithUser> staffWithUsers = staffWithUserMapper.selectByExample(example);
  477. if (CollectionUtils.isEmpty(staffWithUsers)) {
  478. StaffWithUser staffWithUser = new StaffWithUser();
  479. staffWithUser.setStaffId(staffId);
  480. staffWithUser.setUserId(userId);
  481. staffWithUserMapper.insertSelective(staffWithUser);
  482. }
  483. }
  484. return userId;
  485. }
  486. }