zx 2 dní pred
rodič
commit
d4a4c76193

+ 55 - 20
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -439,22 +439,28 @@ 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.ok().put("qwExternalId",matchedContact.getId());
+            }
+        }
 
         FsCourseLink courseLink = courseLinkMapper.selectFsCourseLinkByLink(param.getLink());
         System.out.println("查询的链接参数"+courseLink);
@@ -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);
@@ -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获取,不存在则查数据库)
      */