|
|
@@ -1,5 +1,6 @@
|
|
|
package com.fs.course.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
@@ -9,6 +10,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fs.common.BeanCopyUtils;
|
|
|
import com.fs.common.constant.FsConstants;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
@@ -52,6 +56,7 @@ import com.fs.his.config.AppConfig;
|
|
|
import com.fs.his.domain.FsUser;
|
|
|
import com.fs.his.domain.FsUserIntegralLogs;
|
|
|
import com.fs.his.domain.FsUserWx;
|
|
|
+import com.fs.his.mapper.FsPackageMapper;
|
|
|
import com.fs.his.mapper.FsUserIntegralLogsMapper;
|
|
|
import com.fs.his.mapper.FsUserMapper;
|
|
|
import com.fs.his.param.WxSendRedPacketParam;
|
|
|
@@ -60,6 +65,7 @@ import com.fs.his.service.IFsUserIntegralLogsService;
|
|
|
import com.fs.his.service.IFsUserService;
|
|
|
import com.fs.his.service.IFsUserWxService;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
+import com.fs.his.vo.FsPackageListVO;
|
|
|
import com.fs.his.vo.OptionsVO;
|
|
|
import com.fs.im.service.OpenIMService;
|
|
|
import com.fs.qw.domain.*;
|
|
|
@@ -269,6 +275,12 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
|
|
|
@Autowired
|
|
|
private IFsCourseLinkService linkService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FsDepVideoShowMapper fsDepVideoShowMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsPackageMapper fsPackageMapper;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 查询课堂视频
|
|
|
@@ -2812,6 +2824,9 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
|
|
|
// 1、获取视频详情、问题详情
|
|
|
ResponseResult<FsUserCourseVideoDetailsVO> videoDetails = this.getVideoDetails(param.getVideoId());
|
|
|
FsUserCourseVideoDetailsVO courseVideoDetails = videoDetails.getData() != null ? videoDetails.getData() : null;
|
|
|
+ if(courseVideoDetails != null){
|
|
|
+ getGoodsAndShow(param.getVideoId(),courseVideoDetails);
|
|
|
+ }
|
|
|
|
|
|
//课程logo
|
|
|
if (param.getPeriodId() != null) {
|
|
|
@@ -2929,6 +2944,44 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
|
|
|
return ResponseResult.ok(vo);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 小黄车商品和展示
|
|
|
+ */
|
|
|
+ private void getGoodsAndShow(Long videoId, FsUserCourseVideoDetailsVO vo) {
|
|
|
+ String show = fsDepVideoShowMapper.selectFsDepVideoShowByVideoId(videoId, null);
|
|
|
+ vo.setShowTreatment(ObjectUtil.isEmpty(show) ? "1" : show);
|
|
|
+
|
|
|
+ FsUserCourseVideo courseVideo = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(videoId);
|
|
|
+ String packageJson = courseVideo.getPackageJson();
|
|
|
+ if (StringUtils.isNotEmpty(packageJson)) {
|
|
|
+ List<String> packageIds = new ArrayList<>();
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ JsonNode jsonNode = null;
|
|
|
+ try {
|
|
|
+ jsonNode = objectMapper.readTree(packageJson);
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ if (jsonNode.isArray()) {
|
|
|
+ for (JsonNode node : jsonNode) {
|
|
|
+ String packageId = node.path("packageId").asText();
|
|
|
+ if (StringUtils.isNotEmpty(packageId)) {
|
|
|
+ packageIds.add(packageId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<FsPackageListVO> fsPackageListVOS = new ArrayList<>();
|
|
|
+ if (!packageIds.isEmpty()) {
|
|
|
+ fsPackageListVOS = fsPackageMapper.selectFsPackagesByIds(packageIds);
|
|
|
+ }else {
|
|
|
+ fsPackageListVOS = new ArrayList<>();
|
|
|
+ }
|
|
|
+ vo.setTreatmentPackage(fsPackageListVOS);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ vo.setTreatmentPackage(new ArrayList<>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @Description: 是否看课中断
|
|
|
* @Param:
|
|
|
@@ -4533,6 +4586,146 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R registerQwFsUserFinish(FsUserCourseVideoAddKfUParam param) {// 查询用户
|
|
|
+ FsUser fsUser = fsUserMapper.selectFsUserByUserId(param.getUserId());
|
|
|
+
|
|
|
+ // 不能反401 前端会絮乱
|
|
|
+ // 用户不存在唤起重新授权
|
|
|
+ if (fsUser == null) {
|
|
|
+ return R.error("用户不存在");
|
|
|
+ }
|
|
|
+// if (StringUtils.isNotEmpty(fsUser.getNickName())
|
|
|
+// &&fsUser.getNickName().equals("微信用户")) {
|
|
|
+// return R.error(409, "请重新登录用户!");
|
|
|
+// }
|
|
|
+ if (fsUser.getStatus() != null && fsUser.getStatus() == 0) {
|
|
|
+ return R.error("会员被停用,无权限,请联系客服!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理群聊逻辑
|
|
|
+ if (param.getChatId() != null && StringUtils.isNotEmpty(param.getChatId())) {
|
|
|
+ QwGroupChat qwGroupChat = qwGroupChatMapper.selectQwGroupChatByChatId(param.getChatId());
|
|
|
+ if (qwGroupChat == null) {
|
|
|
+ logger.error("群聊不存在,chatId: {}", param.getChatId());
|
|
|
+ return R.error("群聊不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
+ SopUserLogsInfo sopUserLogsInfo = new SopUserLogsInfo();
|
|
|
+ sopUserLogsInfo.setChatId(param.getChatId());
|
|
|
+ List<QwGroupChatUser> qwGroupChatUsers = qwGroupChatUserMapper.selectByChatId(sopUserLogsInfo);
|
|
|
+
|
|
|
+ if (qwGroupChatUsers == null || qwGroupChatUsers.isEmpty()) {
|
|
|
+ logger.error("群聊用户为空,chatId: {}", param.getChatId());
|
|
|
+ return R.error("群聊用户为空!");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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", fsUser.getNickName())
|
|
|
+ .eq("corp_id", param.getCorpId())
|
|
|
+ .eq("status",0));
|
|
|
+ } catch(Exception e){
|
|
|
+ log.error("群聊用户昵称匹配异常,参数user_id:{},name:{},corp_id:{}",qwGroupChat.getOwner(),fsUser.getNickName(),param.getCorpId(),e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (qwExternalContact == null) {
|
|
|
+ return R.error("未查询到客户!");
|
|
|
+ }
|
|
|
+
|
|
|
+ QwExternalContact finalQwExternalContact = qwExternalContact;
|
|
|
+ if(qwGroupChatUsers.stream().noneMatch(e -> e.getUserId().equals(finalQwExternalContact.getExternalUserId()))){
|
|
|
+ log.error("客户不在群:{},里面:{}", qwGroupChat.getChatId(), qwExternalContact.getExternalUserId());
|
|
|
+ return R.error("客户不在群!");
|
|
|
+ }
|
|
|
+
|
|
|
+ logger.info("外部联系人数据:{}", qwExternalContact);
|
|
|
+
|
|
|
+ // 如果群在里面
|
|
|
+ if (qwExternalContact.getFsUserId() != null) {
|
|
|
+ // 有客户有小程序id,但登录的小程序id和根据外部联系人id查出来的小程序id不一致
|
|
|
+// if (!qwExternalContact.getFsUserId().equals(param.getUserId())) {
|
|
|
+// logger.error("已注册,但绑定的userId,不一致param.getUserId{},qwExternalContact.getFsUserId(){}",param.getUserId(),qwExternalContact.getFsUserId());
|
|
|
+// return R.error("已注册!");
|
|
|
+// }
|
|
|
+ }else {
|
|
|
+ // 未绑定
|
|
|
+ return R.error( "客户未绑定用户");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }else {
|
|
|
+ Long qwExternalId = param.getQwExternalId();
|
|
|
+
|
|
|
+ if (qwExternalId == null) {
|
|
|
+ return R.error("外部联系人ID不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询外部联系人
|
|
|
+ QwExternalContact externalContact = qwExternalContactMapper.selectQwExternalContactById(qwExternalId);
|
|
|
+
|
|
|
+ // 如果查不出来客户信息,加好友
|
|
|
+ if (externalContact == null) {
|
|
|
+ return R.error("未查询到企微客户信息!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (externalContact.getFsUserId() != null) {
|
|
|
+ // 有客户有小程序id,但登录的小程序id和根据外部联系人id查出来的小程序id不一致
|
|
|
+// if (!externalContact.getFsUserId().equals(param.getUserId())) {
|
|
|
+// logger.error("已注册,但绑定的userId,不一致param.getUserId{},qwExternalContact.getFsUserId(){}",param.getUserId(),externalContact.getFsUserId());
|
|
|
+// return R.error("已注册!");
|
|
|
+// }
|
|
|
+ }else {
|
|
|
+ // 未绑定
|
|
|
+ return R.error( "客户未绑定用户");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R registerQwFsUser(FsUserCourseVideoAddKfUParam param) {
|
|
|
+ logger.info("zyp \n【判断添加客服】:{}", param);
|
|
|
+
|
|
|
+ // 参数校验
|
|
|
+ if (param == null) {
|
|
|
+ return R.error("参数不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询用户
|
|
|
+ FsUser fsUser = fsUserMapper.selectFsUserByUserId(param.getUserId());
|
|
|
+
|
|
|
+ // 用户不存在唤起重新授权
|
|
|
+ if (fsUser == null) {
|
|
|
+ return R.error(401, "用户不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (fsUser.getStatus() != null && fsUser.getStatus() == 0) {
|
|
|
+ return R.error("会员被停用,无权限,请联系客服!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理群聊逻辑
|
|
|
+ if (param.getChatId() != null) {
|
|
|
+ return handleGroupChatLogic(param,fsUser);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理普通外部联系人逻辑
|
|
|
+ return handleExternalContactLogic(param, fsUser);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public void uploadSingleTaskWithRetry(FsVideoResource videoResource,Integer type) {
|
|
|
int maxRetry = 3;
|