|
|
@@ -604,26 +604,69 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
if(qwGroupChatUsers == null || qwGroupChatUsers.isEmpty()){
|
|
|
return R.error("群参数异常");
|
|
|
}
|
|
|
- QwExternalContact qwExternalContact =
|
|
|
- qwExternalContactMapper.selectOne(new QueryWrapper<QwExternalContact>()
|
|
|
+ //群聊寻找用户新逻辑
|
|
|
+ QwExternalContact qwExternalContact = null;
|
|
|
+ if( null != param.getUserId() && null == qwExternalContact){
|
|
|
+ try {
|
|
|
+ qwExternalContact = qwExternalContactMapper.selectOne(new QueryWrapper<QwExternalContact>()
|
|
|
.eq("user_id", qwGroupChat.getOwner())
|
|
|
.eq("fs_user_id", param.getUserId())
|
|
|
.eq("corp_id", param.getCorpId())
|
|
|
.eq("status",0));
|
|
|
- if(null == qwExternalContact){
|
|
|
- try{
|
|
|
- //修改成通过昵称匹配
|
|
|
- qwExternalContact =
|
|
|
- qwExternalContactMapper.selectOne(new QueryWrapper<QwExternalContact>()
|
|
|
- .eq("user_id", qwGroupChat.getOwner())
|
|
|
- .eq("name", user.getNickName())
|
|
|
- .eq("corp_id", param.getCorpId())
|
|
|
- .eq("status",0));
|
|
|
- } catch(Exception e){
|
|
|
- log.error("群聊用户昵称匹配异常,参数user_id:{},name:{},corp_id:{}",qwGroupChat.getOwner(),user.getNickName(),param.getCorpId(),e);
|
|
|
+ } catch (Exception e){
|
|
|
+ log.error("群聊用户id匹配异常,参数user_id:{},fs_user_id:{},corp_id:{}",qwGroupChat.getOwner(),param.getUserId(),param.getCorpId(),e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //找当前群中的用户匹配
|
|
|
+ if(StringUtils.isNotBlank(param.getChatId()) && null == qwExternalContact){
|
|
|
+ List<QwExternalContact> groupChatUserByChatIdAndUserName = qwExternalContactMapper.getGroupChatUserByChatIdAndUserName(qwGroupChat.getOwner(), user.getNickName(), param.getCorpId(), param.getChatId());
|
|
|
+ //没找到用户 || 找到的用户数量大于1 使用userid查询匹配
|
|
|
+ if(null == groupChatUserByChatIdAndUserName || groupChatUserByChatIdAndUserName.isEmpty() || groupChatUserByChatIdAndUserName.size() > 1){
|
|
|
+ log.error("群聊用户昵称匹配异常,参数user_id:{},name:{},corp_id:{},chatId:{}",qwGroupChat.getOwner(),user.getNickName(),param.getCorpId(),param.getChatId());
|
|
|
+ } else {
|
|
|
+ qwExternalContact = groupChatUserByChatIdAndUserName.get(0);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+// QwExternalContact qwExternalContact = qwExternalContactMapper.selectOne(new QueryWrapper<QwExternalContact>()
|
|
|
+// .eq("user_id", qwGroupChat.getOwner())
|
|
|
+// .eq("fs_user_id", param.getUserId())
|
|
|
+// .eq("corp_id", param.getCorpId())
|
|
|
+// .eq("status",0));
|
|
|
+//
|
|
|
+// if(null == qwExternalContact){
|
|
|
+// try{
|
|
|
+// //修改成通过昵称匹配
|
|
|
+// qwExternalContact =
|
|
|
+// qwExternalContactMapper.selectOne(new QueryWrapper<QwExternalContact>()
|
|
|
+// .eq("user_id", qwGroupChat.getOwner())
|
|
|
+// .eq("name", user.getNickName())
|
|
|
+// .eq("corp_id", param.getCorpId())
|
|
|
+// .eq("status",0));
|
|
|
+// } catch(Exception e){
|
|
|
+// log.error("群聊用户昵称匹配异常,参数user_id:{},name:{},corp_id:{}",qwGroupChat.getOwner(),user.getNickName(),param.getCorpId(),e);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+// QwExternalContact qwExternalContact =
|
|
|
+// qwExternalContactMapper.selectOne(new QueryWrapper<QwExternalContact>()
|
|
|
+// .eq("user_id", qwGroupChat.getOwner())
|
|
|
+// .eq("fs_user_id", param.getUserId())
|
|
|
+// .eq("corp_id", param.getCorpId())
|
|
|
+// .eq("status",0));
|
|
|
+// if(null == qwExternalContact){
|
|
|
+// try{
|
|
|
+// //修改成通过昵称匹配
|
|
|
+// qwExternalContact =
|
|
|
+// qwExternalContactMapper.selectOne(new QueryWrapper<QwExternalContact>()
|
|
|
+// .eq("user_id", qwGroupChat.getOwner())
|
|
|
+// .eq("name", user.getNickName())
|
|
|
+// .eq("corp_id", param.getCorpId())
|
|
|
+// .eq("status",0));
|
|
|
+// } catch(Exception e){
|
|
|
+// log.error("群聊用户昵称匹配异常,参数user_id:{},name:{},corp_id:{}",qwGroupChat.getOwner(),user.getNickName(),param.getCorpId(),e);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
if(qwExternalContact==null){
|
|
|
return addCustomerService(param.getQwUserId(),msg);
|
|
|
}
|
|
|
@@ -723,82 +766,36 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
return R.error(567,"群聊通用链接").put("qwExternalId", contact.getId());
|
|
|
}
|
|
|
}
|
|
|
+ if ("今正科技".equals(cloudHostProper.getCompanyName())) {
|
|
|
+ QwExternalContact UnionEXt = qwExternalContactMapper.selectQwExternalByUnionID(user.getUnionId());
|
|
|
+ if (UnionEXt!=null){
|
|
|
+ log.info("匹配到的第一个企微用户:"+UnionEXt.getUserId());
|
|
|
+ log.info("企微id:"+UnionEXt.getId());
|
|
|
+ log.info("用户:"+param.getVideoId());
|
|
|
+ log.info("企微用户:"+param.getQwUserId());
|
|
|
+ param.setQwExternalId(UnionEXt.getId());
|
|
|
+ FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideoByExt(UnionEXt.getId(), param.getVideoId(),param.getQwUserId());
|
|
|
+ if (log==null){
|
|
|
+ param.setUserId(user.getUserId());
|
|
|
+ createWatchLog(param);
|
|
|
+ }else {
|
|
|
+ if (log.getUserId()==null||log.getUserId().equals(0L) || !log.getUserId().equals(param.getUserId())){
|
|
|
+ log.setUserId(param.getUserId());
|
|
|
+ }
|
|
|
+ log.setUpdateTime(new Date());
|
|
|
+ courseWatchLogMapper.updateFsCourseWatchLog(log);
|
|
|
+ }
|
|
|
+ return R.error(567,"群聊通用链接").put("qwExternalId", UnionEXt.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
String msg = "<div style=\"color: red;margin-bottom: 15px;font-weight: bold;\">本课程为群会员独享<br>请长按二维码</div>\n" +
|
|
|
"\t\t\t\t\t<div style=\"color: #999;font-size: 14px;font-weight: bold;\">添加伴学助手免费领取会员权限</div>";
|
|
|
|
|
|
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) {
|
|
|
@@ -2184,11 +2181,15 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
if((companyUser.getIsAllowedAllRegister() !=null && companyUser.getIsAllowedAllRegister() != 1)){
|
|
|
return ResponseResult.fail(504,"当前销售禁止绑定会员,请联系销售!");
|
|
|
}
|
|
|
+ // 使用 Stream API 检查是否包含 companyId
|
|
|
+ // 修正类型转换问题
|
|
|
if (companyUser.getIsNeedRegisterMember() == null || companyUser.getIsNeedRegisterMember() == 1
|
|
|
- ||(ObjectUtils.isNotEmpty(fsUserCoursePeriod)
|
|
|
- &&ObjectUtils.isNotEmpty(fsUserCoursePeriod.getIsNeedRegisterMember())
|
|
|
- &&fsUserCoursePeriod.getIsNeedRegisterMember().equals(1))){
|
|
|
- return ResponseResult.fail(504,"请联系销售发送邀请链接成为会员!");
|
|
|
+ || (ObjectUtils.isNotEmpty(fsUserCoursePeriod)
|
|
|
+ && ObjectUtils.isNotEmpty(fsUserCoursePeriod.getIsNeedRegisterMember())
|
|
|
+ && Arrays.stream(fsUserCoursePeriod.getIsNeedRegisterMember().split(","))
|
|
|
+ .map(String::trim)
|
|
|
+ .anyMatch(id -> id.equals(String.valueOf(company.getCompanyId()))))) {
|
|
|
+ return ResponseResult.fail(504, "请联系销售发送邀请链接成为会员!");
|
|
|
}
|
|
|
int defaultStatus = (company != null ? company.getFsUserIsDefaultBlack() : 0) == 1 ? 0 : 1;
|
|
|
userCompanyUser = userCompanyUserService.bindRelationship(param.getUserId(), courseProject, companyUser.getCompanyId(), companyUser.getUserId(), defaultStatus);
|