| 
					
				 | 
			
			
				@@ -439,99 +439,105 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private R handleRoom(FsUserCourseVideoAddKfUParam param,FsUser user) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //查询客户列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        List<QwExternalContact> contacts = qwExternalContactMapper.selectQwExternalContactListVOByfsUserId(user.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        if (!contacts.isEmpty()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            //找出对应销售匹配的客户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            QwExternalContact matchedContact = contacts.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                    .filter(contact -> contact.getQwUserId().equals(Long.parseLong(param.getQwUserId()))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                    .findFirst() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                    .orElse(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            if (matchedContact!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                param.setQwExternalId(matchedContact.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideoByExt(param.getQwExternalId(), param.getVideoId(),param.getQwUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                if (log==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                    createWatchLog(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                return R.ok().put("qwExternalId",matchedContact.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<QwExternalContact> contacts = qwExternalContactMapper.selectQwExternalContactListVOByfsUserId(user.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        log.info("查出来的企微客户数量:"+contacts.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!contacts.isEmpty()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //找出对应销售匹配的客户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            QwExternalContact matchedContact = contacts.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .filter(contact -> contact.getQwUserId().equals(Long.parseLong(param.getQwUserId()))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .findFirst() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .orElse(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (matchedContact!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info("匹配到的第一个企微用户:"+matchedContact.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info("企微id:"+matchedContact.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info("用户:"+param.getVideoId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info("企微用户:"+param.getQwUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                param.setQwExternalId(matchedContact.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideoByExt(matchedContact.getId(), param.getVideoId(),param.getQwUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (log==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    createWatchLog(param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return R.error(567,"群聊通用链接").put("qwExternalId", matchedContact.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        FsCourseLink courseLink = courseLinkMapper.selectFsCourseLinkByLink(param.getLink()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        System.out.println("查询的链接参数"+courseLink); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         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>"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        System.out.println("企微传参:"+courseLink.getChatId()+"corpId:"+param.getCorpId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        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.ok().put("qwExternalId", qwExternalContact.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        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) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -539,7 +545,10 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         BeanUtils.copyProperties(param,log); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.setQwExternalContactId(param.getQwExternalId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.setSendType(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        log.setUserId(param.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        log.setVideoId(param.getVideoId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.setDuration(0L); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        log.setQwUserId(Long.parseLong(param.getQwUserId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.setLogType(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         logger.info("zyp \n【群聊生成看课记录】:{}",param); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -967,7 +976,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         packetParam.setRedPacketMode(config.getRedPacketMode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         packetParam.setCompanyId(param.getCompanyId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        System.out.println("红包商户号"+amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        System.out.println("红包金额"+amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         System.out.println("红包商户号"+packetParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //2025.6.19 红包金额为0的时候 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (amount.compareTo(BigDecimal.ZERO)>0){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1569,7 +1578,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         addWatchLogIfNeeded(param.getVideoId(), param.getCourseId(),param.getFsUserId(),qwUser , param.getExternalUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //生成小程序链接 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String linkByMiniApp = createLinkByMiniApp(new Date(), param.getCourseId(), param.getVideoId(), qwUser, param.getExternalUserId(),2,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String linkByMiniApp = createLinkByMiniApp(new Date(), param.getCourseId(), param.getVideoId(), qwUser, param.getExternalUserId(),2,null,0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         JSONObject news = new JSONObject(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         news.put("miniprogramAppid", qwCompany.getMiniAppId()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1611,7 +1620,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         addWatchLogIfNeeded(param.getVideoId(), param.getCourseId(),param.getFsUserId(),qwUser , param.getExternalUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String linkByCartLink = createLinkByMiniApp(new Date(), param.getCourseId(), param.getVideoId(), qwUser, param.getExternalUserId(),1,domainName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String linkByCartLink = createLinkByMiniApp(new Date(), param.getCourseId(), param.getVideoId(), qwUser, param.getExternalUserId(),1,domainName,0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //生成卡片链接 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1661,7 +1670,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private String createLinkByMiniApp(Date sendTime, Long courseId, Long videoId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                       QwUser qwUser, Long externalId,int type,String domainName) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                       QwUser qwUser, Long externalId,int type,String domainName,Integer isRoom) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         FsCourseLink link = new FsCourseLink(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         link.setCompanyId(qwUser.getCompanyId()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1671,7 +1680,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         link.setCorpId(qwUser.getCorpId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         link.setCourseId(courseId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         link.setQwExternalId(externalId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        link.setIsRoom(isRoom); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (type == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             link.setLinkType(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1826,6 +1835,32 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return ResponseResult.ok(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public R createRoomMiniLink(FsCourseLinkMiniParam param) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        QwUser qwUser = qwExternalContactService.getQwUserByRedis(param.getCorpId().trim(), param.getQwUserId().trim()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (qwUser==null||qwUser.getCompanyId()==null||qwUser.getCompanyUserId()==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return R.error("员工未绑定 销售公司 或 销售 请先绑定"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        QwCompany qwCompany = iQwCompanyService.getQwCompanyByRedis(param.getCorpId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (qwCompany == null ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return  R.error().put("msg","企业不存在,请联系管理员"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //生成小程序链接 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String linkByMiniApp = createLinkByMiniApp(new Date(), param.getCourseId(), param.getVideoId(), qwUser, param.getExternalUserId(),2,null,1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        JSONObject news = new JSONObject(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        news.put("miniprogramAppid", qwCompany.getMiniAppId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        news.put("miniprogramTitle", param.getTitle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        news.put("miniprogramPicUrl", "https://cos.his.cdwjyyh.com/fs/20250523/9c8af5735d784847818cada7fa776a7b.jpg"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        news.put("miniprogramPage", linkByMiniApp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return R.ok().put("data",news); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 获取视频时长(优先从Redis获取,不存在则查数据库) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 |