|
|
@@ -710,10 +710,13 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
private R handleRoom(FsUserCourseVideoAddKfUParam param,FsUser user) {
|
|
|
//查询客户列表
|
|
|
List<QwExternalContact> contacts = qwExternalContactMapper.selectQwExternalContactListVOByfsUserId(user.getUserId());
|
|
|
- log.info("查出来的企微客户数量:"+contacts.size());
|
|
|
- if (!contacts.isEmpty()){
|
|
|
+ List<QwExternalContact> nonNullContacts = contacts.stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ log.info("查出来的企微客户数量:"+nonNullContacts.size());
|
|
|
+ if (!nonNullContacts.isEmpty()){
|
|
|
//找出对应销售匹配的客户
|
|
|
- QwExternalContact matchedContact = contacts.stream()
|
|
|
+ QwExternalContact matchedContact = nonNullContacts.stream()
|
|
|
.filter(contact -> contact.getQwUserId().equals(Long.parseLong(param.getQwUserId())))
|
|
|
.findFirst()
|
|
|
.orElse(null);
|
|
|
@@ -729,6 +732,18 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
createWatchLog(param);
|
|
|
}
|
|
|
return R.error(567,"群聊通用链接").put("qwExternalId", matchedContact.getId());
|
|
|
+ }else {
|
|
|
+ QwExternalContact contact = nonNullContacts.get(0);
|
|
|
+ log.info("匹配到的第一个企微用户:"+contact.getUserId());
|
|
|
+ log.info("企微id:"+contact.getId());
|
|
|
+ log.info("用户:"+param.getVideoId());
|
|
|
+ log.info("企微用户:"+param.getQwUserId());
|
|
|
+ param.setQwExternalId(contact.getId());
|
|
|
+ FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideoByExt(contact.getId(), param.getVideoId(),param.getQwUserId());
|
|
|
+ if (log==null){
|
|
|
+ createWatchLog(param);
|
|
|
+ }
|
|
|
+ return R.error(567,"群聊通用链接").put("qwExternalId", contact.getId());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -737,77 +752,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
|
|
|
return addCustomerService(param.getQwUserId(),msg);
|
|
|
|
|
|
-// QwGroupChatDetailsResult result = qwApiService.groupChatDetails(courseLink.getChatId(), param.getCorpId());
|
|
|
-// if(result.getErrCode() != 0){
|
|
|
-// log.info("企微接口请求失败,请联系管理员:" +result.getErrMsg());
|
|
|
-// return R.error("不是此群成员");
|
|
|
-// }
|
|
|
-// List<QwGroupChatDetailsResult.Member> collect = result.getGroupChat().getMemberList().stream().filter(e -> e.getType() == 2).collect(Collectors.toList());
|
|
|
-// if(collect.isEmpty()){
|
|
|
-// logger.info("群聊里面为空弹二维码:"+param.getCorpId()+":"+param.getQwUserId()+":"+param.getChatId()+":"+param.getUserId());
|
|
|
-// return addCustomerService(param.getQwUserId(),msg);
|
|
|
-// }
|
|
|
-// Optional<QwGroupChatDetailsResult.Member> optional = collect.stream().filter(e -> e.getName().equals(user.getNickName()) || e.getName().equals(param.getNickName())).findFirst();
|
|
|
-// if(!optional.isPresent()){
|
|
|
-// logger.info("昵称未匹配上弹二维码:"+param.getCorpId()+":"+param.getQwUserId()+":"+param.getChatId()+":"+param.getUserId());
|
|
|
-//
|
|
|
-// return addCustomerService(param.getQwUserId(),msg);
|
|
|
-// }
|
|
|
-// QwGroupChatDetailsResult.Member member = optional.get();
|
|
|
-// QwExternalContact qwExternalContact = qwExternalContactMapper.selectOne(new QueryWrapper<QwExternalContact>().eq("user_id", result.getGroupChat().getOwner()).eq("external_user_id", member.getUserId()));
|
|
|
-// if(qwExternalContact==null){
|
|
|
-// logger.info("外部联系人为空弹二维码:"+param.getCorpId()+":"+param.getQwUserId()+":"+param.getChatId()+":"+param.getUserId()+":"+member.getUserId()+param.getNickName());
|
|
|
-// return addCustomerService(param.getQwUserId(),msg);
|
|
|
-// }
|
|
|
-// Long qwExternalId = qwExternalContact.getId();
|
|
|
-// log.info("外部联系人数据:{}", qwExternalContact);
|
|
|
-//// addCompanyCompanyFsUser(param);
|
|
|
-// FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideoByExt(qwExternalId, param.getVideoId(),param.getQwUserId());
|
|
|
-// if (log==null ){
|
|
|
-// logger.info("看课记录为空弹二维码:"+param.getCorpId()+":"+param.getQwUserId()+":"+param.getChatId()+":"+param.getUserId()+qwExternalId+":"+param.getVideoId()+":"+param.getQwUserId());
|
|
|
-// return addCustomerService(param.getQwUserId(),msg);
|
|
|
-// }
|
|
|
-// //判断外部联系人有没有绑定userId
|
|
|
-// if (qwExternalContact.getFsUserId()!=null){
|
|
|
-// //有客户有小程序id 但 登录的小程序id和根据外部联系人id查出来的小程序id不一致
|
|
|
-// if (!qwExternalContact.getFsUserId().equals(param.getUserId())) {
|
|
|
-// logger.info("小程序id不一致空弹二维码:"+param.getCorpId()+":"+param.getQwUserId()+":"+param.getChatId()+":"+param.getUserId());
|
|
|
-// return addCustomerService(param.getQwUserId(),msg);
|
|
|
-// }
|
|
|
-// List<QwExternalContact> qwExternalContacts = qwExternalContactMapper.selectQwExternalContactByMiniUserId(param.getUserId());
|
|
|
-// //匹配客户公司id
|
|
|
-// if (qwExternalContacts.stream().noneMatch(contact -> contact.getCorpId().equals(param.getCorpId()))){
|
|
|
-// logger.info("未匹配上公司空弹二维码:"+param.getCorpId()+":"+param.getQwUserId()+":"+param.getChatId()+":"+param.getUserId());
|
|
|
-// return addCustomerService(param.getQwUserId(),msg);
|
|
|
-// }
|
|
|
-//
|
|
|
-// //看课记录中userId为0绑定userId
|
|
|
-// if (log.getUserId()==null||log.getUserId().equals(0L) || !log.getUserId().equals(param.getUserId())){
|
|
|
-// log.setUserId(param.getUserId());
|
|
|
-// }
|
|
|
-//
|
|
|
-// log.setUpdateTime(new Date());
|
|
|
-// courseWatchLogMapper.updateFsCourseWatchLog(log);
|
|
|
-//
|
|
|
-// iSopUserLogsInfoService.updateSopUserInfoByExternalId(qwExternalId,param.getUserId());
|
|
|
-// }else {
|
|
|
-// //没绑定fsUser直接绑定fsUser
|
|
|
-// QwExternalContact contact = new QwExternalContact();
|
|
|
-// contact.setId(qwExternalId);
|
|
|
-// contact.setFsUserId(param.getUserId());
|
|
|
-// qwExternalContactMapper.updateQwExternalContact(contact);
|
|
|
-// FsUser fsUser = new FsUser();
|
|
|
-// fsUser.setUserId(user.getUserId());
|
|
|
-// fsUser.setIsAddQw(1);
|
|
|
-// fsUserMapper.updateFsUser(fsUser);
|
|
|
-// //绑定上之后 更新观看记录
|
|
|
-// //看课记录中userId为0绑定userId
|
|
|
-// log.setUserId(param.getUserId());
|
|
|
-// log.setUpdateTime(new Date());
|
|
|
-// courseWatchLogMapper.updateFsCourseWatchLog(log);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return R.error(567,"群聊通用链接").put("qwExternalId", qwExternalContact.getId());
|
|
|
}
|
|
|
|
|
|
private void createWatchLog(FsUserCourseVideoAddKfUParam param) {
|