|
@@ -51,6 +51,7 @@ import com.fs.qw.mapper.QwUserMapper;
|
|
import com.fs.qw.service.IQwCompanyService;
|
|
import com.fs.qw.service.IQwCompanyService;
|
|
import com.fs.qw.service.IQwExternalContactService;
|
|
import com.fs.qw.service.IQwExternalContactService;
|
|
import com.fs.qwApi.Result.QwAddContactWayResult;
|
|
import com.fs.qwApi.Result.QwAddContactWayResult;
|
|
|
|
+import com.fs.qwApi.Result.QwGroupChatDetailsResult;
|
|
import com.fs.qwApi.param.QwAddContactWayParam;
|
|
import com.fs.qwApi.param.QwAddContactWayParam;
|
|
import com.fs.qwApi.service.QwApiService;
|
|
import com.fs.qwApi.service.QwApiService;
|
|
import com.fs.repeat.vo.RepeatUploadVo;
|
|
import com.fs.repeat.vo.RepeatUploadVo;
|
|
@@ -59,6 +60,7 @@ import com.fs.sop.mapper.SopUserLogsInfoMapper;
|
|
import com.fs.sop.service.ISopUserLogsInfoService;
|
|
import com.fs.sop.service.ISopUserLogsInfoService;
|
|
import com.fs.system.service.ISysConfigService;
|
|
import com.fs.system.service.ISysConfigService;
|
|
import com.fs.voice.utils.StringUtil;
|
|
import com.fs.voice.utils.StringUtil;
|
|
|
|
+import com.fs.wx.cp.config.WxCpProperties;
|
|
import com.github.binarywang.wxpay.bean.transfer.TransferBillsResult;
|
|
import com.github.binarywang.wxpay.bean.transfer.TransferBillsResult;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -433,35 +435,101 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
}
|
|
}
|
|
|
|
|
|
private R handleRoom(FsUserCourseVideoAddKfUParam param,FsUser user) {
|
|
private R handleRoom(FsUserCourseVideoAddKfUParam param,FsUser user) {
|
|
- //查询客户列表
|
|
|
|
- List<QwExternalContact> contacts = qwExternalContactMapper.selectQwExternalContactListVOByfsUserId(user.getUserId());
|
|
|
|
- if (contacts.isEmpty()){
|
|
|
|
- return R.error("未注册");
|
|
|
|
- }
|
|
|
|
- //找出对应销售匹配的客户
|
|
|
|
- QwExternalContact matchedContact = contacts.stream()
|
|
|
|
- .filter(contact -> contact.getQwUserId().equals(Long.parseLong(param.getQwUserId())))
|
|
|
|
- .findFirst()
|
|
|
|
- .orElse(null);
|
|
|
|
-
|
|
|
|
- if (matchedContact==null){
|
|
|
|
- return R.error("无权限观看,未添加本群主");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- param.setQwExternalId(matchedContact.getId());
|
|
|
|
-// //查询是否有添加客服
|
|
|
|
-// QwExternalContact externalContact = qwExternalContactMapper.selectQwExternalContactById(param.getQwExternalId());
|
|
|
|
-// if (externalContact==null){
|
|
|
|
-// return R.error("客户不存在!");
|
|
|
|
|
|
+// //查询客户列表
|
|
|
|
+// List<QwExternalContact> contacts = qwExternalContactMapper.selectQwExternalContactListVOByfsUserId(user.getUserId());
|
|
|
|
+// if (contacts.isEmpty()){
|
|
|
|
+// return R.error("未注册");
|
|
// }
|
|
// }
|
|
-// if (!externalContact.getQwUserId().equals(param.getUserId())){
|
|
|
|
-// return R.error("无权限观看,添加群主非本群主");
|
|
|
|
|
|
+// //找出对应销售匹配的客户
|
|
|
|
+// QwExternalContact matchedContact = contacts.stream()
|
|
|
|
+// .filter(contact -> contact.getQwUserId().equals(Long.parseLong(param.getQwUserId())))
|
|
|
|
+// .findFirst()
|
|
|
|
+// .orElse(null);
|
|
|
|
+//
|
|
|
|
+// if (matchedContact==null){
|
|
|
|
+// return R.error("无权限观看,未添加本群主");
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// param.setQwExternalId(matchedContact.getId());
|
|
|
|
+//// //查询是否有添加客服
|
|
|
|
+//// QwExternalContact externalContact = qwExternalContactMapper.selectQwExternalContactById(param.getQwExternalId());
|
|
|
|
+//// if (externalContact==null){
|
|
|
|
+//// return R.error("客户不存在!");
|
|
|
|
+//// }
|
|
|
|
+//// if (!externalContact.getQwUserId().equals(param.getUserId())){
|
|
|
|
+//// return R.error("无权限观看,添加群主非本群主");
|
|
|
|
+//// }
|
|
|
|
+// FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideoByExt(param.getQwExternalId(), param.getVideoId(),param.getQwUserId());
|
|
|
|
+// if (log==null){
|
|
|
|
+// createWatchLog(param);
|
|
// }
|
|
// }
|
|
- FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideoByExt(param.getQwExternalId(), param.getVideoId(),param.getQwUserId());
|
|
|
|
- if (log==null){
|
|
|
|
- createWatchLog(param);
|
|
|
|
|
|
+// return R.ok().put("qwExternalId",matchedContact.getId());
|
|
|
|
+ FsCourseLink courseLink = courseLinkMapper.selectFsCourseLinkByLink(param.getLink());
|
|
|
|
+ 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>";
|
|
|
|
+ QwGroupChatDetailsResult result = qwApiService.groupChatDetails(courseLink.getChatId(), param.getCorpId());
|
|
|
|
+ if(result.getErrCode() != 0){
|
|
|
|
+ return R.error("企微接口请求失败,请联系管理员:" +result.getErrMsg());
|
|
|
|
+ }
|
|
|
|
+ List<QwGroupChatDetailsResult.Member> collect = result.getGroupChat().getMemberList().stream().filter(e -> e.getType() == 2).collect(Collectors.toList());
|
|
|
|
+ if(collect.isEmpty()){
|
|
|
|
+ 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()){
|
|
|
|
+ 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){
|
|
|
|
+ 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 ){
|
|
|
|
+ return addCustomerService(param.getQwUserId(),msg);
|
|
}
|
|
}
|
|
- return R.ok().put("qwExternalId",matchedContact.getId());
|
|
|
|
|
|
+ //判断外部联系人有没有绑定userId
|
|
|
|
+ if (qwExternalContact.getFsUserId()!=null){
|
|
|
|
+ //有客户有小程序id 但 登录的小程序id和根据外部联系人id查出来的小程序id不一致
|
|
|
|
+ if (!qwExternalContact.getFsUserId().equals(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()))){
|
|
|
|
+ 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());
|
|
}
|
|
}
|
|
|
|
|
|
private void createWatchLog(FsUserCourseVideoAddKfUParam param) {
|
|
private void createWatchLog(FsUserCourseVideoAddKfUParam param) {
|