三七 4 روز پیش
والد
کامیت
2f1e318d5d

+ 23 - 22
fs-qw-api-msg/src/main/java/com/fs/app/controller/QwMsgController.java

@@ -401,29 +401,30 @@ public class QwMsgController {
                         }
                         try {
                             QwUser user = qwUserMapper.selectQwUserById(id);
-                            //获取当前用户的external_user_id
-                            String extId1 = getExtId(wxWorkMessageDTO.getReceiver(), user.getUid(), user.getServerId());
-                            QwExternalContact qwExternalContact = qwExternalContactMapper.selectQwExternalContactByExternalUserIdAndQwUserId(extId1, user.getCorpId(),user.getQwUserId());
-                            Long id1 = qwExternalContact.getId();
-                            QwExternalContactInfo info = qwExternalContactInfoMapper.selectQwExternalContactInfoByExternalContactId(id1);
-                            if(info == null){
-                                info = new QwExternalContactInfo();
-                                info.setTalk("非首次交流");
-                                info.setExternalContactId(id1);
-                                info.setCreateTime(new Date());
-                                qwExternalContactInfoMapper.insertQwExternalContactInfo(info);
-                                //去除新客对话
-                                aiHookService.cleanNewUserDialogue(user, qwExternalContact);
-
-                                //发送宣导语音和视频
-                                aiHookService.sendVideoAndVoice(wxWorkMessageDTO.getSender(), wxWorkMsgResp.getUuid(), user);
-                            }else{
-                                //将交流状态改为非首次交流
-                                qwExternalContactInfoMapper.updateQwExternalContactInfoByExtId(id1);
-                                //去除新客对话
-                                aiHookService.cleanNewUserDialogue(user, qwExternalContact);
+                            if (user.getFastGptRoleId()!=null&&user.getFastGptRoleId()!=0){
+                                //获取当前用户的external_user_id
+                                String extId1 = getExtId(wxWorkMessageDTO.getReceiver(), user.getUid(), user.getServerId());
+                                QwExternalContact qwExternalContact = qwExternalContactMapper.selectQwExternalContactByExternalUserIdAndQwUserId(extId1, user.getCorpId(),user.getQwUserId());
+                                Long id1 = qwExternalContact.getId();
+                                QwExternalContactInfo info = qwExternalContactInfoMapper.selectQwExternalContactInfoByExternalContactId(id1);
+                                if(info == null){
+                                    info = new QwExternalContactInfo();
+                                    info.setTalk("非首次交流");
+                                    info.setExternalContactId(id1);
+                                    info.setCreateTime(new Date());
+                                    qwExternalContactInfoMapper.insertQwExternalContactInfo(info);
+                                    //去除新客对话
+                                    aiHookService.cleanNewUserDialogue(user, qwExternalContact);
+
+                                    //发送宣导语音和视频
+                                    aiHookService.sendVideoAndVoice(wxWorkMessageDTO.getSender(), wxWorkMsgResp.getUuid(), user);
+                                }else{
+                                    //将交流状态改为非首次交流
+                                    qwExternalContactInfoMapper.updateQwExternalContactInfoByExtId(id1);
+                                    //去除新客对话
+                                    aiHookService.cleanNewUserDialogue(user, qwExternalContact);
+                                }
                             }
-
                         } catch (Exception e) {
                             log.error("id:{}, 处理通话后的视频语音", id, e);
                         }

+ 2 - 2
fs-service/src/main/java/com/fs/course/mapper/FsCourseWatchLogMapper.java

@@ -118,8 +118,8 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
     FsCourseWatchLog getWatchCourseVideo(@Param("userId") Long userId, @Param("videoId") Long videoId,@Param("qwUserId") String qwUserId,@Param("externalId") Long externalId);
 
     @Select("select * from fs_course_watch_log " +
-            "where qw_external_contact_id = #{externalId} " +
-            "and video_id = #{videoId} " +
+            "where video_id = #{videoId} " +
+            "and  qw_external_contact_id = #{externalId} " +
             "and qw_user_id = #{qwUserId} ")
     FsCourseWatchLog getWatchCourseVideoByExt( @Param("externalId") Long externalId, @Param("videoId") Long videoId,@Param("qwUserId") String qwUserId);
 

+ 48 - 118
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -474,21 +474,21 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 //            logger.error("看课重粉提交mq失败", e);
 //        }
 
-        String json = configService.selectConfigByKey("course.config");
-        CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
-        boolean oneCompanyCourse = config.isOneCompanyCourse();
-        if(oneCompanyCourse && fsUser.getQwExtId() != null){
-            QwExternalContact qwExternalContact = qwExternalContactMapper.selectById(fsUser.getQwExtId());
-            if(qwExternalContact.getCompanyUserId() != null && !qwExternalContact.getCompanyUserId().equals(param.getCompanyUserId())){
-                return R.error(500, "该用户("+fsUser.getUserId() + ")已成为其他客服会员");
-            }
-        }
+//        String json = configService.selectConfigByKey("course.config");
+//        CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
+//        boolean oneCompanyCourse = config.isOneCompanyCourse();
+//        if(oneCompanyCourse && fsUser.getQwExtId() != null){
+//            QwExternalContact qwExternalContact = qwExternalContactMapper.selectById(fsUser.getQwExtId());
+//            if(qwExternalContact.getCompanyUserId() != null && !qwExternalContact.getCompanyUserId().equals(param.getCompanyUserId())){
+//                return R.error(500, "该用户("+fsUser.getUserId() + ")已成为其他客服会员");
+//            }
+//        }
         Integer isRoom = param.getIsRoom();
 
         // 处理逻辑
         if (isRoom == null || isRoom == 0) {
             // 当 isRoom 为 null 或 0 时走 handleExt
-            return handleExt(param,msg, oneCompanyCourse,fsUser);
+            return handleExt(param,msg, false,fsUser);
         } else if (isRoom == 1) {
             // 当 isRoom 为 1 时走 handleRoom
             return handleRoom(param,fsUser);
@@ -502,43 +502,43 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 
     private R handleRoom(FsUserCourseVideoAddKfUParam param,FsUser user) {
         //查询客户列表
-        List<QwExternalContact> contacts = qwExternalContactMapper.selectQwExternalContactListVOByfsUserId(user.getUserId());
-        List<QwExternalContact> nonNullContacts = contacts.stream()
-                .filter(Objects::nonNull)
-                .collect(Collectors.toList());
-        log.info("查出来的企微客户数量:"+nonNullContacts.size());
-        if (!nonNullContacts.isEmpty()){
-            //找出对应销售匹配的客户
-            QwExternalContact matchedContact = nonNullContacts.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());
-            }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());
-            }
-        }
+//        List<QwExternalContact> contacts = qwExternalContactMapper.selectQwExternalContactListVOByfsUserId(user.getUserId());
+//        List<QwExternalContact> nonNullContacts = contacts.stream()
+//                .filter(Objects::nonNull)
+//                .collect(Collectors.toList());
+//        log.info("查出来的企微客户数量:"+nonNullContacts.size());
+//        if (!nonNullContacts.isEmpty()){
+//            //找出对应销售匹配的客户
+//            QwExternalContact matchedContact = nonNullContacts.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());
+//            }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());
+//            }
+//        }
         //一个都找不到
         QwExternalContact UnionEXt = qwExternalContactMapper.selectQwExternalByUnionID(user.getUnionId());
         if (UnionEXt!=null){
@@ -558,77 +558,7 @@ 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) {