|  | @@ -931,4 +931,56 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
 | 
	
		
			
				|  |  |      public CrmCustomer selectFscrmByMobile(String mobile){
 | 
	
		
			
				|  |  |          return crmCustomerMapper.selectFscrmByMobile(mobile);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional
 | 
	
		
			
				|  |  | +    public R assistToUser(String opeUserName, Long opeUserId, CrmCustomeAssignParam param) {
 | 
	
		
			
				|  |  | +        Integer index=0;
 | 
	
		
			
				|  |  | +        for(CrmCustomerAssignUserDTO userDTO:param.getUsers()){
 | 
	
		
			
				|  |  | +            CompanyUser companyUser=companyUserMapper.selectCompanyUserById(userDTO.getCompanyUserId());
 | 
	
		
			
				|  |  | +            for(int i=0;i<userDTO.getCount();i++){
 | 
	
		
			
				|  |  | +                CrmCustomer customer=crmCustomerMapper.selectCrmCustomerById(param.getCustomerIds().get(index));
 | 
	
		
			
				|  |  | +                //不能选择客户拥有者本人
 | 
	
		
			
				|  |  | +                CrmCustomerUser crmCustomerUser = crmCustomerUserMapper.selectCrmCustomerUserById(customer.getCustomerUserId());
 | 
	
		
			
				|  |  | +                if (Objects.equals(crmCustomerUser.getCompanyUserId(), userDTO.getCompanyUserId())){
 | 
	
		
			
				|  |  | +                    return R.error("不能选择自己来协作!");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                //查询协作客户
 | 
	
		
			
				|  |  | +                CrmCustomerAssist customerAssist=new CrmCustomerAssist();
 | 
	
		
			
				|  |  | +                customerAssist.setCustomerId(customer.getCustomerId());
 | 
	
		
			
				|  |  | +                customerAssist.setCompanyUserId(userDTO.getCompanyUserId());
 | 
	
		
			
				|  |  | +                List<CrmCustomerAssist> tempList = assistMapper.selectCrmCustomerAssistList(customerAssist);
 | 
	
		
			
				|  |  | +                if(tempList!=null && !tempList.isEmpty()){
 | 
	
		
			
				|  |  | +                    return R.error("销售:" + companyUser.getNickName() +"(" + userDTO.getCompanyUserId() + ")已拥有改该协作客户:" + customer.getCustomerName());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                customerAssist.setCompanyId(param.getCompanyId());
 | 
	
		
			
				|  |  | +                customerAssist.setCompanyUserName(companyUser.getNickName());
 | 
	
		
			
				|  |  | +                customerAssist.setCreateTime(new Date());
 | 
	
		
			
				|  |  | +                assistMapper.insertCrmCustomerAssist(customerAssist);
 | 
	
		
			
				|  |  | +                //写日志
 | 
	
		
			
				|  |  | +                CrmCustomerLogs logs=new CrmCustomerLogs();
 | 
	
		
			
				|  |  | +                logs.setCustomerId(customer.getCustomerId());
 | 
	
		
			
				|  |  | +                logs.setCreateTime(new Date());
 | 
	
		
			
				|  |  | +                logs.setLogsType(CustomerLogEnum.ASSIST_USER.getValue());
 | 
	
		
			
				|  |  | +                logs.setTitle(CustomerLogEnum.ASSIST_USER.getDesc());
 | 
	
		
			
				|  |  | +                logs.setRemark(opeUserName+"为客户"+customer.getCustomerName()+"添加协作人:" + companyUser.getNickName());
 | 
	
		
			
				|  |  | +                logs.setCompanyUserId(userDTO.getCompanyUserId());
 | 
	
		
			
				|  |  | +                logsMapper.insertCrmCustomerLogs(logs);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                if(StringUtils.isNotEmpty(companyUser.getJpushId())){
 | 
	
		
			
				|  |  | +                    Map<String, String> extrasMap=new HashMap<>();
 | 
	
		
			
				|  |  | +                    extrasMap.put("customerId",customer.getCustomerId().toString());
 | 
	
		
			
				|  |  | +                    extrasMap.put("type","1");
 | 
	
		
			
				|  |  | +                    try {
 | 
	
		
			
				|  |  | +                        jpushService.sendRegisterIdPush("客户消息","您收到 一个客户协作邀请",extrasMap,companyUser.getJpushId());
 | 
	
		
			
				|  |  | +                    } catch (APIConnectionException e) {
 | 
	
		
			
				|  |  | +                    } catch (APIRequestException e) {
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                index++;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return R.ok();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |