| 
														
															@@ -1,8 +1,5 @@ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 package com.fs.qw.service.impl; 
														 | 
														
														 | 
														
															 package com.fs.qw.service.impl; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import java.util.*; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import cn.hutool.core.lang.Pair; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import cn.hutool.core.util.ObjectUtil; 
														 | 
														
														 | 
														
															 import cn.hutool.core.util.ObjectUtil; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.alibaba.fastjson.JSON; 
														 | 
														
														 | 
														
															 import com.alibaba.fastjson.JSON; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; 
														 | 
														
														 | 
														
															 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -11,16 +8,19 @@ import com.fs.company.cache.ICompanyCacheService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.company.cache.ICompanyUserCacheService; 
														 | 
														
														 | 
														
															 import com.fs.company.cache.ICompanyUserCacheService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.company.domain.Company; 
														 | 
														
														 | 
														
															 import com.fs.company.domain.Company; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.company.domain.CompanyUser; 
														 | 
														
														 | 
														
															 import com.fs.company.domain.CompanyUser; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.fs.company.dto.UserProjectDTO; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.qw.domain.CustomerTransferApproval; 
														 | 
														
														 | 
														
															 import com.fs.qw.domain.CustomerTransferApproval; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.qw.mapper.CustomerTransferApprovalMapper; 
														 | 
														
														 | 
														
															 import com.fs.qw.mapper.CustomerTransferApprovalMapper; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.qw.service.ICustomerTransferApprovalService; 
														 | 
														
														 | 
														
															 import com.fs.qw.service.ICustomerTransferApprovalService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.qw.vo.TransferCustomDTO; 
														 | 
														
														 | 
														
															 import com.fs.qw.vo.TransferCustomDTO; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.store.domain.FsUser; 
														 | 
														
														 | 
														
															 import com.fs.store.domain.FsUser; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.fs.store.domain.FsUserCompanyUser; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.store.dto.FsUserTransferParamDTO; 
														 | 
														
														 | 
														
															 import com.fs.store.dto.FsUserTransferParamDTO; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.fs.store.service.IFsUserCompanyUserService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.store.service.IFsUserService; 
														 | 
														
														 | 
														
															 import com.fs.store.service.IFsUserService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.fs.store.service.cache.IFsUserCacheService; 
														 | 
														
														 | 
														
															 import com.fs.store.service.cache.IFsUserCacheService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.hc.openapi.tool.util.StringUtils; 
														 | 
														
														 | 
														
															 import com.hc.openapi.tool.util.StringUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import org.apache.http.util.Asserts; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.apache.hc.core5.util.Asserts; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.aop.framework.AopContext; 
														 | 
														
														 | 
														
															 import org.springframework.aop.framework.AopContext; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.beans.factory.annotation.Autowired; 
														 | 
														
														 | 
														
															 import org.springframework.beans.factory.annotation.Autowired; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.context.annotation.EnableAspectJAutoProxy; 
														 | 
														
														 | 
														
															 import org.springframework.context.annotation.EnableAspectJAutoProxy; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -28,6 +28,11 @@ import org.springframework.stereotype.Service; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.transaction.annotation.Propagation; 
														 | 
														
														 | 
														
															 import org.springframework.transaction.annotation.Propagation; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.transaction.annotation.Transactional; 
														 | 
														
														 | 
														
															 import org.springframework.transaction.annotation.Transactional; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import java.util.ArrayList; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import java.util.Date; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import java.util.List; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import java.util.Objects; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 /** 
														 | 
														
														 | 
														
															 /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  * 客户转移审批Service业务层处理 
														 | 
														
														 | 
														
															  * 客户转移审批Service业务层处理 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  * 
														 | 
														
														 | 
														
															  * 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -52,6 +57,8 @@ public class CustomerTransferApprovalServiceImpl implements ICustomerTransferApp 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     @Autowired 
														 | 
														
														 | 
														
															     @Autowired 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     private IFsUserService fsUserService; 
														 | 
														
														 | 
														
															     private IFsUserService fsUserService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    @Autowired 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private IFsUserCompanyUserService userCompanyUserService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     /** 
														 | 
														
														 | 
														
															     /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * 查询客户转移审批 
														 | 
														
														 | 
														
															      * 查询客户转移审批 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -107,7 +114,7 @@ public class CustomerTransferApprovalServiceImpl implements ICustomerTransferApp 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if(StringUtils.isBlank(item.getTransferBefore()) && StringUtils.isNotBlank(item.getCustomerIds())){ 
														 | 
														
														 | 
														
															         if(StringUtils.isBlank(item.getTransferBefore()) && StringUtils.isNotBlank(item.getCustomerIds())){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            List<Long> customerIds = JSON.parseArray(item.getCustomerIds(), Long.class); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            List<UserProjectDTO> customerIds = JSON.parseArray(item.getCustomerIds(), UserProjectDTO.class); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             List<TransferCustomDTO> customerList = getCustomerList(customerIds, item); 
														 | 
														
														 | 
														
															             List<TransferCustomDTO> customerList = getCustomerList(customerIds, item); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             item.setCustomerList(customerList); 
														 | 
														
														 | 
														
															             item.setCustomerList(customerList); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } else { 
														 | 
														
														 | 
														
															         } else { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -134,27 +141,28 @@ public class CustomerTransferApprovalServiceImpl implements ICustomerTransferApp 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    private List<TransferCustomDTO> getCustomerList(List<Long> customerIds, CustomerTransferApproval item) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private List<TransferCustomDTO> getCustomerList(List<UserProjectDTO> customerIds, CustomerTransferApproval item) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         List<TransferCustomDTO> customerList = new ArrayList<>(); 
														 | 
														
														 | 
														
															         List<TransferCustomDTO> customerList = new ArrayList<>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        for (Long customerId : customerIds) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        for (UserProjectDTO customerId : customerIds) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            FsUser fsUser = fsUserCacheService.selectFsUserById(customerId); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            FsUser fsUser = fsUserCacheService.selectFsUserById(customerId.getUserId()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if(ObjectUtils.isNotNull(fsUser)){ 
														 | 
														
														 | 
														
															             if(ObjectUtils.isNotNull(fsUser)){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                String companyUserName = "无"; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                if(ObjectUtils.isNotNull(fsUser.getCompanyUserId())){ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    CompanyUser companyUser = companyUserCacheService.selectCompanyUserById(fsUser.getCompanyUserId()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    companyUserName = String.format("%s_%d", companyUser.getUserName(), companyUser.getUserId()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(customerId.getUserId(), customerId.getProjectId()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if(Objects.nonNull(userCompanyUser)){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    CompanyUser companyUser = companyUserCacheService.selectCompanyUserById(userCompanyUser.getCompanyUserId()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    String companyUserName = String.format("%s_%d", companyUser.getUserName(), companyUser.getUserId()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                customerList.add(TransferCustomDTO.builder() 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        .userName(String.format("%s_%d", fsUser.getNickname(), fsUser.getUserId())) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        .userId(fsUser.getUserId()) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        .beforeCompanyUserName(companyUserName) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        .beforeCompanyUserId(fsUser.getCompanyUserId()) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        .afterCompanyUserName(item.getTargetUserName()) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        .afterCompanyUserId(item.getTargetUserId()) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        .build()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    customerList.add(TransferCustomDTO.builder() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                            .userName(String.format("%s_%d", fsUser.getNickname(), fsUser.getUserId())) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                            .userId(fsUser.getUserId()) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                            .projectId(customerId.getProjectId()) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                            .beforeCompanyUserName(companyUserName) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                            .beforeCompanyUserId(companyUser.getUserId()) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                            .afterCompanyUserName(item.getTargetUserName()) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                            .afterCompanyUserId(item.getTargetUserId()) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                            .build()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return customerList; 
														 | 
														
														 | 
														
															         return customerList; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -239,7 +247,7 @@ public class CustomerTransferApprovalServiceImpl implements ICustomerTransferApp 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         item.setProcessedAt(new Date()); 
														 | 
														
														 | 
														
															         item.setProcessedAt(new Date()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 //        审批状态: 0=待审批, 1=审批通过, 2=审批驳回, 3=已撤销 
														 | 
														
														 | 
														
															 //        审批状态: 0=待审批, 1=审批通过, 2=审批驳回, 3=已撤销 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         // 如果审批通过 进行转移 
														 | 
														
														 | 
														
															         // 如果审批通过 进行转移 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        List<Long> customerIds1 = JSON.parseArray(item.getCustomerIds(), Long.class); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        List<UserProjectDTO> customerIds1 = JSON.parseArray(item.getCustomerIds(), UserProjectDTO.class); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         List<TransferCustomDTO> customerList = getCustomerList(customerIds1, item); 
														 | 
														
														 | 
														
															         List<TransferCustomDTO> customerList = getCustomerList(customerIds1, item); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         item.setTransferBefore(JSON.toJSONString(customerList)); 
														 | 
														
														 | 
														
															         item.setTransferBefore(JSON.toJSONString(customerList)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -249,11 +257,14 @@ public class CustomerTransferApprovalServiceImpl implements ICustomerTransferApp 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             transferParam.setTargetCompanyUserId(item.getTargetUserId()); 
														 | 
														
														 | 
														
															             transferParam.setTargetCompanyUserId(item.getTargetUserId()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															             Asserts.check(StringUtils.isNotBlank(item.getCustomerIds()),"转移客户不能为空!"); 
														 | 
														
														 | 
														
															             Asserts.check(StringUtils.isNotBlank(item.getCustomerIds()),"转移客户不能为空!"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            List<Long> customerIds = JSON.parseArray(item.getCustomerIds(), Long.class); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            List<UserProjectDTO> customerIds = JSON.parseArray(item.getCustomerIds(), UserProjectDTO.class); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             transferParam.setUserIds(customerIds); 
														 | 
														
														 | 
														
															             transferParam.setUserIds(customerIds); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             transferParam.setSourceCompanyUserId(item.getOriginalUserId()); 
														 | 
														
														 | 
														
															             transferParam.setSourceCompanyUserId(item.getOriginalUserId()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            fsUserService.transfer(transferParam); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            for (UserProjectDTO customerId : customerIds) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                CompanyUser companyUser = companyUserCacheService.selectCompanyUserById(item.getTargetUserId()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                userCompanyUserService.changeRelationship(customerId.getUserId(), customerId.getProjectId(), companyUser.getCompanyId(), companyUser.getUserId()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return customerTransferApprovalMapper.updateCustomerTransferApproval(item); 
														 | 
														
														 | 
														
															         return customerTransferApprovalMapper.updateCustomerTransferApproval(item); 
														 |