|
|
@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.utils.uuid.IdUtils;
|
|
|
+import com.fs.company.domain.CompanyUser;
|
|
|
+import com.fs.company.mapper.CompanyUserMapper;
|
|
|
import com.fs.fastGpt.domain.FastGptRole;
|
|
|
import com.fs.fastGpt.service.AiHookService;
|
|
|
import com.fs.fastGpt.service.IFastGptRoleService;
|
|
|
@@ -79,6 +81,9 @@ public class QwMsgController {
|
|
|
@Autowired
|
|
|
private QwExternalContactInfoMapper qwExternalContactInfoMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CompanyUserMapper companyUserMapper;
|
|
|
+
|
|
|
@GetMapping("/sendExpressInfo/{orderId}")
|
|
|
public R sendExpressInfo(@PathVariable Long orderId){
|
|
|
String isSend = redisCache.getCacheObject("fs:express:info:send:" +orderId);
|
|
|
@@ -350,6 +355,20 @@ public class QwMsgController {
|
|
|
|
|
|
if (2000000000000000L-receiver>0){
|
|
|
log.info("id:{}, 客户发送", id);
|
|
|
+ QwUser user = qwUserMapper.selectQwUserById(id);
|
|
|
+ if(user != null){
|
|
|
+ Long userId = user.getId();
|
|
|
+ CompanyUser companyUser = companyUserMapper.selectCompanyUserByQwUserId(userId);
|
|
|
+ if(companyUser != null && companyUser.getReplyText() != null){
|
|
|
+ String extId1 = getExtId(wxWorkMessageDTO.getSender(), user.getUid(), user.getServerId());
|
|
|
+ QwExternalContact qwExternalContact = qwExternalContactMapper.selectQwExternalContactByExternalUserIdAndQwUserId(extId1, user.getCorpId(),user.getQwUserId());
|
|
|
+ //用户是未回复状态
|
|
|
+ if(qwExternalContact != null && qwExternalContact.getIsReply() == 0){
|
|
|
+ qwExternalContactMapper.updateQwExternalContactIsRePlyById(qwExternalContact.getId());
|
|
|
+ sendAiTxtMsg(companyUser.getReplyText(),sender,user.getUid(),serverId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
aiHookService.qwHookNotifyAiReply(id,sender,content,wxWorkMsgResp.getUuid(),wxWorkMessageDTO.getMsgtype());
|
|
|
}else {
|
|
|
log.info("销售发送");
|
|
|
@@ -398,37 +417,36 @@ public class QwMsgController {
|
|
|
totalSeconds = hours * 3600L + minutes * 60L + seconds;
|
|
|
log.info("id:{}, 总通话秒数: " + totalSeconds, id);
|
|
|
}
|
|
|
- }
|
|
|
- try {
|
|
|
- QwUser user = qwUserMapper.selectQwUserById(id);
|
|
|
- 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);
|
|
|
+ try {
|
|
|
+ QwUser user = qwUserMapper.selectQwUserById(id);
|
|
|
+ if (user.getFastGptRoleId()!=null&&user.getFastGptRoleId()!=0){
|
|
|
+ //获取当前用户的external_user_id
|
|
|
+ String extId1 = getExtId(extId, 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(extId, wxWorkMsgResp.getUuid(), user);
|
|
|
+ }else{
|
|
|
+ //将交流状态改为非首次交流
|
|
|
+ qwExternalContactInfoMapper.updateQwExternalContactInfoByExtId(id1);
|
|
|
+ //去除新客对话
|
|
|
+ aiHookService.cleanNewUserDialogue(user, qwExternalContact);
|
|
|
+ }
|
|
|
}
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("id:{}, 处理通话后的视频语音", id, e);
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("id:{}, 处理通话后的视频语音", id, e);
|
|
|
}
|
|
|
-
|
|
|
} else if (recordType==2){
|
|
|
log.info("id:{}, 通话挂断", id);
|
|
|
}else if (recordType==3){
|
|
|
@@ -450,6 +468,30 @@ public class QwMsgController {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送固定的文字
|
|
|
+ * @param content
|
|
|
+ * @param sendId
|
|
|
+ * @param uuid
|
|
|
+ * @param serverId
|
|
|
+ */
|
|
|
+ private void sendAiTxtMsg(String content, Long sendId , String uuid,Long serverId) {
|
|
|
+ if (content == null || content.trim().isEmpty()){
|
|
|
+ System.out.println("输出为空格");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ WxWorkSendTextMsgDTO wxWorkSendTextMsgDTO = new WxWorkSendTextMsgDTO();
|
|
|
+ wxWorkSendTextMsgDTO.setSend_userid(sendId);
|
|
|
+ wxWorkSendTextMsgDTO.setUuid(uuid);
|
|
|
+ wxWorkSendTextMsgDTO.setContent(content);
|
|
|
+ wxWorkSendTextMsgDTO.setIsRoom(false);
|
|
|
+ WxWorkResponseDTO<WxWorkSendTextMsgRespDTO> wxWorkSendTextMsgRespDTOWxWorkResponseDTO = wxWorkService.SendTextMsg(wxWorkSendTextMsgDTO,serverId);
|
|
|
+ WxWorkSendTextMsgRespDTO data = wxWorkSendTextMsgRespDTOWxWorkResponseDTO.getData();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
String getExtId(Long id,String uid,Long serverId){
|
|
|
WxWorkVid2UserIdDTO wxWorkVid2UserIdDTO = new WxWorkVid2UserIdDTO();
|
|
|
wxWorkVid2UserIdDTO.setUser_id(Arrays.asList(id));
|