|
@@ -13,13 +13,7 @@ import com.fjhx.customer.lable.entity.CustomerCompanyLabel;
|
|
import com.fjhx.customer.lable.entity.CustomerLabel;
|
|
import com.fjhx.customer.lable.entity.CustomerLabel;
|
|
import com.fjhx.customer.level.entity.CustomerLevel;
|
|
import com.fjhx.customer.level.entity.CustomerLevel;
|
|
import com.fjhx.customer.mapper.CustomerMapper;
|
|
import com.fjhx.customer.mapper.CustomerMapper;
|
|
-import com.fjhx.customer.service.ICustomerCompanyLabelService;
|
|
|
|
-import com.fjhx.customer.service.ICustomerContactsService;
|
|
|
|
-import com.fjhx.customer.service.ICustomerFollowLogService;
|
|
|
|
-import com.fjhx.customer.service.ICustomerGroupService;
|
|
|
|
-import com.fjhx.customer.service.ICustomerLabelService;
|
|
|
|
-import com.fjhx.customer.service.ICustomerLevelService;
|
|
|
|
-import com.fjhx.customer.service.ICustomerService;
|
|
|
|
|
|
+import com.fjhx.customer.service.*;
|
|
import com.fjhx.customer.starmark.entity.CustomerStarMark;
|
|
import com.fjhx.customer.starmark.entity.CustomerStarMark;
|
|
import com.fjhx.excel.CustomerDuplicateCheckExcel;
|
|
import com.fjhx.excel.CustomerDuplicateCheckExcel;
|
|
import com.fjhx.excel.CustomerExcel;
|
|
import com.fjhx.excel.CustomerExcel;
|
|
@@ -52,12 +46,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -180,59 +169,66 @@ public class CustomerServiceImpl extends BasicsServiceImpl<CustomerMapper, Custo
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
@Override
|
|
@Override
|
|
public String insert(Customer customer) {
|
|
public String insert(Customer customer) {
|
|
- //如果是从邮箱页面新增客户
|
|
|
|
- if (customer == null || (customer.getAddType() != null && customer.getAddType() == mail_list_add)
|
|
|
|
- && customer.getIsCustomer() == null) {
|
|
|
|
- throw new ServiceException("参数缺失");
|
|
|
|
- }
|
|
|
|
- //是否客户 0=非客户 1=客户
|
|
|
|
- if (customer.getIsCustomer() != 0 && customer.getIsCustomer() != 1) {
|
|
|
|
- throw new ServiceException("参数格式错误");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (customer.getIsCustomer() == 1 && StringUtils.isBlank(customer.getUserMailbox())) {
|
|
|
|
- customer.setUserMailbox("0");
|
|
|
|
- customer.setUserId("0");
|
|
|
|
- } else if (customer.getIsCustomer() == 1 && StringUtils.isNotBlank(customer.getUserMailbox())) {
|
|
|
|
- //客户所述业务员ID=登录账号ID
|
|
|
|
- customer.setUserId(AuthUtil.getUserIdStr());
|
|
|
|
- } else if (customer.getIsCustomer() == 0) {
|
|
|
|
- //非客户不设置客户所属业务员信息
|
|
|
|
- customer.setUserId("0");
|
|
|
|
- customer.setUserMailbox("0");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //如果是从客户管理页面新增客户
|
|
|
|
|
|
+ // 如果是从邮箱页面新增客户
|
|
|
|
+ // if (customer == null || (customer.getAddType() != null && customer.getAddType() == mail_list_add)
|
|
|
|
+ // && customer.getIsCustomer() == null) {
|
|
|
|
+ // throw new ServiceException("参数缺失");
|
|
|
|
+ // }
|
|
|
|
+ // 是否客户 0=非客户 1=客户
|
|
|
|
+ // if (customer.getIsCustomer() != 0 && customer.getIsCustomer() != 1) {
|
|
|
|
+ // throw new ServiceException("参数格式错误");
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // if (customer.getIsCustomer() == 1 && StringUtils.isBlank(customer.getUserMailbox())) {
|
|
|
|
+ // customer.setUserMailbox("0");
|
|
|
|
+ // customer.setUserId("0");
|
|
|
|
+ // } else if (customer.getIsCustomer() == 1 && StringUtils.isNotBlank(customer.getUserMailbox())) {
|
|
|
|
+ // //客户所述业务员ID=登录账号ID
|
|
|
|
+ // customer.setUserId(AuthUtil.getUserIdStr());
|
|
|
|
+ // } else if (customer.getIsCustomer() == 0) {
|
|
|
|
+ // //非客户不设置客户所属业务员信息
|
|
|
|
+ // customer.setUserId("0");
|
|
|
|
+ // customer.setUserMailbox("0");
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ customer.setUserId(AuthUtil.getUserIdStr());
|
|
|
|
+ String userMailbox = customer.getUserMailbox();
|
|
|
|
+ if (StringUtils.isBlank(userMailbox)) {
|
|
|
|
+ throw new ServiceException("未绑定邮箱,请联系管理员");
|
|
|
|
+ }
|
|
|
|
+ customer.setUserMailbox(userMailbox);
|
|
|
|
+
|
|
|
|
+ // 如果是从客户管理页面新增客户
|
|
if (customer.getAddType() != null && customer.getAddType() == customer_list_add) {
|
|
if (customer.getAddType() != null && customer.getAddType() == customer_list_add) {
|
|
- //判断公司名称是否重复(去除所有空格)
|
|
|
|
|
|
+ // 判断公司名称是否重复(去除所有空格)
|
|
boolean exist = getCorporateNameIsExist(null, customer.getCorporateName());
|
|
boolean exist = getCorporateNameIsExist(null, customer.getCorporateName());
|
|
if (exist) {
|
|
if (exist) {
|
|
throw new ServiceException("公司名称已存在");
|
|
throw new ServiceException("公司名称已存在");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //多个连续空格替换为一个空格,并去除前后空格
|
|
|
|
|
|
+ // 多个连续空格替换为一个空格,并去除前后空格
|
|
customer.setCorporateName(customer.getCorporateName().trim().replaceAll(" +", " "));
|
|
customer.setCorporateName(customer.getCorporateName().trim().replaceAll(" +", " "));
|
|
// 表名
|
|
// 表名
|
|
customer.setTableName(Customer.getTableName(AuthUtil.getTenantId()));
|
|
customer.setTableName(Customer.getTableName(AuthUtil.getTenantId()));
|
|
|
|
|
|
- if (customer.getAddType() != null && customer.getAddType() == customer_list_add) {
|
|
|
|
- //=================从客户管理列表新增客户=================
|
|
|
|
- // 查询当前登入人的邮箱
|
|
|
|
- List<Mailbox> mailboxes = iMailboxApi.getByUserId(AuthUtil.getUserIdStr());
|
|
|
|
- if (CollectionUtils.isNotEmpty(mailboxes)) {
|
|
|
|
- //获取出默认邮箱
|
|
|
|
- List<Mailbox> defaults = mailboxes.stream().filter(obj -> obj.getIsDefault() == 1).collect(Collectors.toList());
|
|
|
|
- if (CollectionUtils.isNotEmpty(defaults)) {
|
|
|
|
- //如果有存在默认邮箱
|
|
|
|
- Mailbox mailbox = defaults.get(0);
|
|
|
|
- customer.setUserMailbox(mailbox.getMailboxName());
|
|
|
|
- } else {
|
|
|
|
- //如果不存在默认邮箱,随机取一条
|
|
|
|
- Mailbox mailbox = mailboxes.get(0);
|
|
|
|
- customer.setUserMailbox(mailbox.getMailboxName());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // if (customer.getAddType() != null && customer.getAddType() == customer_list_add) {
|
|
|
|
+ // //=================从客户管理列表新增客户=================
|
|
|
|
+ // // 查询当前登入人的邮箱
|
|
|
|
+ // List<Mailbox> mailboxes = iMailboxApi.getByUserId(AuthUtil.getUserIdStr());
|
|
|
|
+ // if (CollectionUtils.isNotEmpty(mailboxes)) {
|
|
|
|
+ // //获取出默认邮箱
|
|
|
|
+ // List<Mailbox> defaults = mailboxes.stream().filter(obj -> obj.getIsDefault() == 1).collect(Collectors.toList());
|
|
|
|
+ // if (CollectionUtils.isNotEmpty(defaults)) {
|
|
|
|
+ // //如果有存在默认邮箱
|
|
|
|
+ // Mailbox mailbox = defaults.get(0);
|
|
|
|
+ // customer.setUserMailbox(mailbox.getMailboxName());
|
|
|
|
+ // } else {
|
|
|
|
+ // //如果不存在默认邮箱,随机取一条
|
|
|
|
+ // Mailbox mailbox = mailboxes.get(0);
|
|
|
|
+ // customer.setUserMailbox(mailbox.getMailboxName());
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
|
|
// 分组如果为空默认为0
|
|
// 分组如果为空默认为0
|
|
if (StringUtils.isBlank(customer.getGroupId())) {
|
|
if (StringUtils.isBlank(customer.getGroupId())) {
|
|
@@ -242,7 +238,7 @@ public class CustomerServiceImpl extends BasicsServiceImpl<CustomerMapper, Custo
|
|
|
|
|
|
customer.setId(IdUtils.fastSimpleUUID());
|
|
customer.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
|
- //异常状态=正常
|
|
|
|
|
|
+ // 异常状态=正常
|
|
customer.setAbnormalStatus(CustomerAbnormalStatusEnum.ABNORMAL_STATUS_NORMAL.getKey());
|
|
customer.setAbnormalStatus(CustomerAbnormalStatusEnum.ABNORMAL_STATUS_NORMAL.getKey());
|
|
//最后互动时间=当前时间
|
|
//最后互动时间=当前时间
|
|
customer.setLastInteractionTime(now);
|
|
customer.setLastInteractionTime(now);
|