|
@@ -7,10 +7,13 @@ import com.management.platform.entity.*;
|
|
|
import com.management.platform.entity.vo.ContactsVo;
|
|
|
import com.management.platform.mapper.ContactsLogMapper;
|
|
|
import com.management.platform.mapper.ContactsMapper;
|
|
|
+import com.management.platform.mapper.TaskMapper;
|
|
|
import com.management.platform.mapper.UserMapper;
|
|
|
import com.management.platform.service.ContactsService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -38,6 +41,8 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
|
@Resource
|
|
|
private UserMapper userMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private TaskMapper taskMapper;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -47,14 +52,14 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
|
String token = String.valueOf(request.getHeader("Token"));
|
|
|
User user = userMapper.selectById(token);
|
|
|
Integer companyId = user.getCompanyId();
|
|
|
- if (contacts.getOwnerId()==null){
|
|
|
+ if (contacts.getOwnerId() == null) {
|
|
|
httpRespMsg.setError("负责人信息为空!");
|
|
|
}
|
|
|
|
|
|
LambdaQueryWrapper<Contacts> lqw_contacts = new LambdaQueryWrapper<>();
|
|
|
- lqw_contacts.eq(Contacts::getCustomId,contacts.getCustomId()).eq(Contacts::getName,contacts.getName());
|
|
|
+ lqw_contacts.eq(Contacts::getCustomId, contacts.getCustomId()).eq(Contacts::getName, contacts.getName());
|
|
|
Contacts selectedOne = contactsMapper.selectOne(lqw_contacts);
|
|
|
- if (selectedOne!=null){
|
|
|
+ if (selectedOne != null) {
|
|
|
httpRespMsg.setError("已存在该客户!");
|
|
|
}
|
|
|
contacts.setCompanyId(companyId)
|
|
@@ -77,7 +82,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg pageContacts(Integer pageIndex, Integer pageSize, String customName, String name,String email,String creatorName, String phone, String ownerName, HttpServletRequest request) {
|
|
|
+ public HttpRespMsg pageContacts(Integer pageIndex, Integer pageSize, String customName, String name, String email, String creatorName, String phone, String ownerName, HttpServletRequest request) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("customName", customName);
|
|
|
map.put("name", name);
|
|
@@ -87,16 +92,16 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
|
map.put("creatorName", creatorName);
|
|
|
String token = String.valueOf(request.getHeader("Token"));
|
|
|
User user = userMapper.selectById(token);
|
|
|
- map.put("companyId",user.getCompanyId());
|
|
|
- map.put("isDelete",0);
|
|
|
+ map.put("companyId", user.getCompanyId());
|
|
|
+ map.put("isDelete", 0);
|
|
|
Page<ContactsVo> pageContacts = contactsMapper.pageContacts(new Page(pageIndex, pageSize), map);
|
|
|
|
|
|
List<ContactsVo> records = pageContacts.getRecords();
|
|
|
long total = pageContacts.getTotal();
|
|
|
|
|
|
HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
- hashMap.put("records",records);
|
|
|
- hashMap.put("total",total);
|
|
|
+ hashMap.put("records", records);
|
|
|
+ hashMap.put("total", total);
|
|
|
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
msg.setData(hashMap);
|
|
@@ -104,12 +109,12 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg selectContactsByCustomId(Custom custom,HttpServletRequest request) {
|
|
|
+ public HttpRespMsg selectContactsByCustomId(Custom custom, HttpServletRequest request) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String token = String.valueOf(request.getHeader("Token"));
|
|
|
User user = userMapper.selectById(token);
|
|
|
LambdaQueryWrapper<Contacts> contactsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- contactsLambdaQueryWrapper.eq(Contacts::getCustomId,custom.getId()).eq(Contacts::getCompanyId,user.getCompanyId()).eq(Contacts::getIsDelete,0);
|
|
|
+ contactsLambdaQueryWrapper.eq(Contacts::getCustomId, custom.getId()).eq(Contacts::getCompanyId, user.getCompanyId()).eq(Contacts::getIsDelete, 0);
|
|
|
List<Contacts> contactsList = contactsMapper.selectList(contactsLambdaQueryWrapper);
|
|
|
msg.setData(contactsList);
|
|
|
return msg;
|
|
@@ -121,7 +126,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
|
String token = String.valueOf(request.getHeader("Token"));
|
|
|
User user = userMapper.selectById(token);
|
|
|
Integer companyId = user.getCompanyId();
|
|
|
- if (contacts==null||contacts.getId()==null){
|
|
|
+ if (contacts == null || contacts.getId() == null) {
|
|
|
msg.setError("关键信息为空");
|
|
|
}
|
|
|
contactsMapper.updateById(contacts);
|
|
@@ -143,8 +148,8 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
|
UpdateWrapper<Contacts> contactsUpdateWrapper = new UpdateWrapper<>();
|
|
|
//todo 删除联系人的时候要检查是否有关联的商机和任务
|
|
|
contactsUpdateWrapper.in("id", ids);
|
|
|
- contactsUpdateWrapper.set("is_delete",1);
|
|
|
- contactsMapper.update(null,contactsUpdateWrapper);
|
|
|
+ contactsUpdateWrapper.set("is_delete", 1);
|
|
|
+ contactsMapper.update(null, contactsUpdateWrapper);
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
@@ -154,16 +159,16 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
String token = String.valueOf(request.getHeader("Token"));
|
|
|
User user = userMapper.selectById(token);
|
|
|
- map.put("companyId",user.getCompanyId());
|
|
|
- map.put("isDelete",1);
|
|
|
+ map.put("companyId", user.getCompanyId());
|
|
|
+ map.put("isDelete", 1);
|
|
|
Page<ContactsVo> pageContacts = contactsMapper.pageContacts(new Page(pageIndex, pageSize), map);
|
|
|
|
|
|
List<ContactsVo> records = pageContacts.getRecords();
|
|
|
long total = pageContacts.getTotal();
|
|
|
|
|
|
HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
- hashMap.put("records",records);
|
|
|
- hashMap.put("total",total);
|
|
|
+ hashMap.put("records", records);
|
|
|
+ hashMap.put("total", total);
|
|
|
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
msg.setData(hashMap);
|
|
@@ -181,10 +186,51 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
UpdateWrapper<Contacts> contactsUpdateWrapper = new UpdateWrapper<>();
|
|
|
contactsUpdateWrapper.in("id", ids);
|
|
|
- contactsUpdateWrapper.set("is_delete",0);
|
|
|
- contactsMapper.update(null,contactsUpdateWrapper);
|
|
|
+ contactsUpdateWrapper.set("is_delete", 0);
|
|
|
+ contactsMapper.update(null, contactsUpdateWrapper);
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getContactsDetail(Contacts contacts, HttpServletRequest request) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ String token = String.valueOf(request.getHeader("Token"));
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
+
|
|
|
+ ContactsVo contactsVo = new ContactsVo();
|
|
|
+ Contacts contactsSelect = contactsMapper.selectById(contacts.getId());
|
|
|
+ if (contactsSelect != null) {
|
|
|
+ //操作记录
|
|
|
+ LambdaQueryWrapper<ContactsLog> cLoglqw = new LambdaQueryWrapper<>();
|
|
|
+ cLoglqw.eq(ContactsLog::getContactsId, contactsSelect.getId());
|
|
|
+ List<ContactsLog> contactsLogs = contactsLogMapper.selectList(cLoglqw);
|
|
|
+
|
|
|
+ //相关任务
|
|
|
+ LambdaQueryWrapper<Task> tLqw = new LambdaQueryWrapper<>();
|
|
|
+ tLqw.eq(Task::getContactsId, contactsSelect.getId());
|
|
|
+ List<Task> taskList = taskMapper.selectList(tLqw);
|
|
|
+ taskList.forEach(task -> {
|
|
|
+ if (StringUtils.isNotEmpty(task.getExecutorId())) {
|
|
|
+ String executorIdString = task.getExecutorId();
|
|
|
+ String[] executorIds = executorIdString.split(",");
|
|
|
+ for (int index = 0; index < executorIds.length; index++) {
|
|
|
+ User userSelect = userMapper.selectById(executorIds);
|
|
|
+ task.getExecutorNames().add(userSelect.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //相关商机
|
|
|
+
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(contactsSelect, contactsVo);
|
|
|
+ contactsVo.setContactsLogList(contactsLogs);
|
|
|
+ contactsVo.setTaskList(taskList);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|