| 
					
				 | 
			
			
				@@ -1,39 +1,33 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.fs.qw.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.common.core.domain.R; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.common.exception.CustomException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.common.utils.DateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.fs.company.service.ICompanyConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.fs.course.service.IFsCourseLinkService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.fs.qw.domain.QwCompany; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.fs.qw.domain.QwGroupChat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.fs.qw.domain.QwGroupChatUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.company.domain.CompanyUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.qw.domain.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qw.mapper.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.qw.param.ChatParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qw.param.QwGroupChatParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.qw.param.TransferChatParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.qw.result.ResultMessage; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qw.service.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qw.vo.QwGroupChatOptionsVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.qw.vo.QwGroupChatTransferVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qw.vo.QwGroupChatVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qwApi.Result.QwGroupChatDetailsResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qwApi.Result.QwGroupChatListResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.qwApi.domain.QwGroupChatTransferResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.qwApi.param.QwGroupChatTransferParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qwApi.service.QwApiService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.fs.sop.mapper.QwSopMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.fs.sop.mapper.SopUserLogsInfoMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.fs.sop.service.IQwSopLogsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.fs.sop.service.IQwSopService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.fs.sop.service.ISopUserLogsInfoService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.fs.sop.service.ISopUserLogsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.fs.sop.service.impl.QwSopLogsServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.fs.sop.service.impl.QwSopServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.voice.utils.StringUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Arrays; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.time.LocalDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * 客户群详情Service业务层处理 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -44,80 +38,18 @@ import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class QwGroupChatServiceImpl implements IQwGroupChatService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private static final Logger log = LoggerFactory.getLogger(QwGroupChatServiceImpl.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private QwGroupChatMapper qwGroupChatMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private QwGroupChatUserMapper qwGroupChatUserMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private QwApiService qwApiService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private ICompanyConfigService companyConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private IFsCourseLinkService iFsCourseLinkService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    IQwExternalContactService qwExternalContactService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    IQwCompanyService iQwCompanyService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private ISopUserLogsInfoService sopUserLogsInfoService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private IQwSopService iQwSopService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private IQwSopLogsService iQwSopLogsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private IQwGroupMsgService iQwGroupMsgService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private QwSopLogsServiceImpl qwSopLogsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private QwSopServiceImpl qwSopService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    QwAutoTagsMapper qwAutoTagsMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    QwCompanyMapper qwCompanyMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private QwSopMapper qwSopMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private QwCompanyMapper qwCompanyMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private QwUserMapper qwUserMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private QwExternalContactMapper qwExternalContactMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private ISopUserLogsService sopUserLogsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private ISopUserLogsInfoService iSopUserLogsInfoService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private QwAppContactWayMapper  qwAppContactWayMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private QwAppContactWayLogsMapper qwAppContactWayLogsMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private IQwExternalErrRetryService errRetryService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private SopUserLogsInfoMapper sopUserLogsInfoMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//    private IQwGetJsapiTicketService qwGetJsapiTicketService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private IQwGroupChatTransferLogService qwGroupChatTransferLogService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 查询客户群详情 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -416,6 +348,15 @@ public class QwGroupChatServiceImpl implements IQwGroupChatService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 处理离职查询不到详情的情况 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (list.getStatus() == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        QwGroupChat qwGroupChatResigned = qwGroupChatMapper.selectQwGroupChatByChatId(list.getChat_id()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        qwGroupChatResigned.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        qwGroupChatResigned.setStatus(String.valueOf(list.getStatus())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        qwGroupChatMapper.updateQwGroupChat(qwGroupChatResigned); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (!StringUtil.strIsNullOrEmpty(qwGroupChatListResult.getNext_cursor())){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -440,4 +381,136 @@ public class QwGroupChatServiceImpl implements IQwGroupChatService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return qwGroupChatMapper.selectQwGroupChatByChatIds(ids); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 查询客户群列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param qwGroupChat 参数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return  list 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<QwGroupChatTransferVO> selectQwGroupChatTransferList(QwGroupChatParam qwGroupChat) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return qwGroupChatMapper.selectQwGroupChatTransferList(qwGroupChat); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 客户群转移 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param param         参数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param user          当前销售 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param isResigned    是否转移离职员工客户群 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return  message 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ResultMessage processTransfer(TransferChatParam param, CompanyUser user, boolean isResigned) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ResultMessage resultMessage = new ResultMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        QwUser qwUser = qwUserMapper.selectQwUserById(param.getQwId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (Objects.isNull(qwUser)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new CustomException("接替群主不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 准备转移参数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        QwGroupChatTransferParam transferParam = new QwGroupChatTransferParam(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferParam.setChat_id_list(param.getChatIds().stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .map(ChatParam::getChatId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .collect(Collectors.toList())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferParam.setNew_owner(qwUser.getQwUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 调用不同的API 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        QwGroupChatTransferResult result = isResigned ? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                qwApiService.resignedGroupChatTransfer(transferParam, param.getCorpId()) : 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                qwApiService.groupChatTransfer(transferParam, param.getCorpId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (result.getErrcode() != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new CustomException(result.getErrmsg()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 处理失败结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        result.getFailed_chat_list().forEach(failed -> resultMessage.addFailure(failed.getChat_id(), failed.getErrmsg())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 过滤掉转移失败的群聊 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<ChatParam> successChatParams = filterSuccessChats(param.getChatIds(), result.getFailed_chat_list()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 处理成功的转移记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        processSuccessTransfers(successChatParams, user, qwUser, resultMessage, isResigned); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return resultMessage; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 过滤转移失败客户群 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param chatParams    入参 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param failedChats   失败列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return  客户群 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private List<ChatParam> filterSuccessChats(List<ChatParam> chatParams, List<QwGroupChatTransferResult.FailedChat> failedChats) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Set<String> failedChatIds = failedChats.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .map(QwGroupChatTransferResult.FailedChat::getChat_id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .collect(Collectors.toSet()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return chatParams.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .filter(c -> !failedChatIds.contains(c.getChatId())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 处理转移成功客户群 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param successChatParams 转移成功客户群 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param user              当前销售账户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param newOwner          新群主 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param resultMessage     消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param isResigned        是否转移离职员工客户群 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void processSuccessTransfers(List<ChatParam> successChatParams, CompanyUser user, QwUser newOwner, ResultMessage resultMessage, boolean isResigned) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<QwGroupChatTransferLog> transferLogs = successChatParams.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .map(chatParam -> createTransferLog(chatParam, user, newOwner, isResigned)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!transferLogs.isEmpty()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            qwGroupChatTransferLogService.saveBatch(transferLogs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            transferLogs.forEach(log -> resultMessage.addSuccess()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 保存转移记录修改群主 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param chatParam  客户群 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param user       当前销售 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param newOwner   新群主 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param isResigned 是否转移离职员工客户群 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return  log 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private QwGroupChatTransferLog createTransferLog(ChatParam chatParam, CompanyUser user, QwUser newOwner, boolean isResigned) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        QwGroupChat qwGroupChat = qwGroupChatMapper.selectQwGroupChatByChatId(chatParam.getChatId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        QwUser oldOwner = qwUserMapper.selectQwUserById(chatParam.getQwId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 更新群主信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        qwGroupChat.setOwner(newOwner.getQwUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        qwGroupChat.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (isResigned) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            qwGroupChat.setStatus("3"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        qwGroupChatMapper.updateQwGroupChat(qwGroupChat); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 创建转移日志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        QwGroupChatTransferLog transferLog = new QwGroupChatTransferLog(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setChatName(qwGroupChat.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setCorpId(qwGroupChat.getCorpId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setTransferType(isResigned ? 1 : 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setCompanyId(user.getCompanyId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setCompanyUserId(user.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setOldOwner(oldOwner.getQwUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setOldCompanyUserId(oldOwner.getCompanyUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setOldQwUserName(oldOwner.getQwUserName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setOldQwUserId(oldOwner.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setNewOwner(newOwner.getQwUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setNewCompanyUserId(newOwner.getCompanyUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setNewQwUserName(newOwner.getQwUserName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setNewQwUserId(newOwner.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setChatId(chatParam.getChatId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        transferLog.setCreateTime(LocalDateTime.now()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return transferLog; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |