|
@@ -797,17 +797,28 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
|
|
|
}
|
|
|
|
|
|
@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.setCompanyId(param.getCompanyId());
|
|
|
+ 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.setCustomerId(customer.getCustomerId());
|
|
|
customerAssist.setCreateTime(new Date());
|
|
|
assistMapper.insertCrmCustomerAssist(customerAssist);
|
|
|
//写日志
|