|
|
@@ -11,6 +11,7 @@ import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.course.domain.FsCourseLink;
|
|
|
import com.fs.course.service.impl.FsUserCourseVideoServiceImpl;
|
|
|
import com.fs.his.domain.FsUser;
|
|
|
import com.fs.his.mapper.FsUserMapper;
|
|
|
@@ -562,7 +563,7 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
|
|
|
if (StringUtils.isNotBlank(param.getChatId())) {
|
|
|
return handleLiveChat(param,fsUser, noMemberMsg, noRegisterMsg);
|
|
|
} else if (null != param.getQwExternalId()) {
|
|
|
- return handleLivePerson(param, noMemberMsg, noRegisterMsg);
|
|
|
+ return handleLivePerson(param,fsUser, noMemberMsg, noRegisterMsg);
|
|
|
} else {
|
|
|
return R.error("直播参数错误");
|
|
|
}
|
|
|
@@ -678,7 +679,7 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
|
|
|
* @param noRegisterMsg
|
|
|
* @return
|
|
|
*/
|
|
|
- public R handleLivePerson(LiveIsAddKfParam param,String noMemberMsg,String noRegisterMsg){
|
|
|
+ public R handleLivePerson(LiveIsAddKfParam param,FsUser user,String noMemberMsg,String noRegisterMsg){
|
|
|
|
|
|
Long qwExternalId = param.getQwExternalId();
|
|
|
|
|
|
@@ -687,6 +688,51 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
|
|
|
if (liveWatchLog==null ){
|
|
|
return R.error(noMemberMsg);
|
|
|
}
|
|
|
+ //查询是否有添加客服
|
|
|
+ QwExternalContact externalContact = qwExternalContactMapper.selectQwExternalContactById(qwExternalId);
|
|
|
+
|
|
|
+ //用小程序id查询外部联系人
|
|
|
+ List<QwExternalContact> qwExternalContacts = qwExternalContactMapper.selectQwExternalContactByMiniUserId(param.getUserId());
|
|
|
+
|
|
|
+ //判断外部联系人有没有绑定userId
|
|
|
+ if (externalContact.getFsUserId() != null) {
|
|
|
+ //有客户有小程序id 但 登录的小程序id和根据外部联系人id查出来的小程序id不一致
|
|
|
+ if (!externalContact.getFsUserId().equals(param.getUserId())) {
|
|
|
+ return R.error(noMemberMsg);
|
|
|
+ }
|
|
|
+ //匹配客户公司id
|
|
|
+ if (qwExternalContacts.stream().noneMatch(contact -> contact.getCorpId().equals(param.getCorpId()))){
|
|
|
+ return R.error(noMemberMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ //看课记录中userId为0绑定userId
|
|
|
+ if (liveWatchLog.getUserId() == null || liveWatchLog.getUserId().equals(0L) || !liveWatchLog.getUserId().equals(param.getUserId())) {
|
|
|
+ liveWatchLog.setUserId(param.getUserId());
|
|
|
+ }
|
|
|
+
|
|
|
+ liveWatchLog.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ liveWatchLogMapper.updateLiveWatchLog(liveWatchLog);
|
|
|
+ iSopUserLogsInfoService.updateSopUserInfoByExternalId(qwExternalId, param.getUserId());
|
|
|
+
|
|
|
+ } else { //没绑定fsUser直接绑定fsUser
|
|
|
+ QwExternalContact contact = new QwExternalContact();
|
|
|
+ contact.setId(qwExternalId);
|
|
|
+ contact.setFsUserId(param.getUserId());
|
|
|
+ qwExternalContactMapper.updateQwExternalContact(contact);
|
|
|
+ iSopUserLogsInfoService.updateSopUserInfoByExternalId(qwExternalId, param.getUserId());
|
|
|
+
|
|
|
+ FsUser fsUser = new FsUser();
|
|
|
+ fsUser.setUserId(user.getUserId());
|
|
|
+ fsUser.setIsAddQw(1);
|
|
|
+ fsUserMapper.updateFsUser(fsUser);
|
|
|
+ //绑定上之后 更新观看记录
|
|
|
+ //看课记录中userId为0绑定userId
|
|
|
+ liveWatchLog.setUserId(param.getUserId());
|
|
|
+ liveWatchLog.setUpdateTime(new Date());
|
|
|
+ liveWatchLogMapper.updateLiveWatchLog(liveWatchLog);
|
|
|
+ }
|
|
|
+
|
|
|
return R.ok();
|
|
|
|
|
|
}
|