|
|
@@ -7,8 +7,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fs.common.CluesUtils;
|
|
|
import com.fs.common.OrderUtils;
|
|
|
import com.fs.common.annotation.DataScope;
|
|
|
+import com.fs.common.constant.HttpStatus;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.domain.entity.SysDictData;
|
|
|
+import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
@@ -27,6 +29,7 @@ import com.fs.crm.mapper.*;
|
|
|
import com.fs.crm.param.*;
|
|
|
import com.fs.crm.service.ICrmBusinessService;
|
|
|
import com.fs.crm.service.ICrmCustomerService;
|
|
|
+import com.fs.crm.service.ICrmExtDetailService;
|
|
|
import com.fs.crm.service.ICrmMsgService;
|
|
|
import com.fs.crm.utils.CidUserOrderExtractor;
|
|
|
import com.fs.crm.vo.*;
|
|
|
@@ -38,6 +41,7 @@ import com.fs.system.config.SystemConfig;
|
|
|
import com.fs.system.service.ISysDictDataService;
|
|
|
import com.fs.system.service.ISysDictTypeService;
|
|
|
import com.fs.wx.sop.service.IWxSopExecuteService;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import lombok.Synchronized;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
@@ -46,9 +50,12 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+
|
|
|
+import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -101,6 +108,14 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
|
|
|
|
|
|
@Autowired
|
|
|
private ICrmBusinessService crmBusinessService;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICrmExtDetailService crmExtDetailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CrmCustomerLogsMapper crmCustomerLogsMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询客户
|
|
|
*
|
|
|
@@ -320,6 +335,48 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
|
|
|
return crmCustomerMapper.selectCrmMyCustomerListQuery(param);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public TableDataInfo selectCrmMyCustomerListQueryInfo(CrmMyCustomerListQueryParam param) {
|
|
|
+ List<CrmMyCustomerListQueryVO> list = crmCustomerMapper.selectCrmMyCustomerListQueryInfo(param);
|
|
|
+ TableDataInfo tableDataInfo = getDataTable(list);
|
|
|
+ ArrayList<Map<String, Object>> res = new ArrayList<>();
|
|
|
+ for (CrmMyCustomerListQueryVO vo : list) {
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("correlate_id", vo.getCustomerId());
|
|
|
+ map.put("correlate_type", "customer_id");
|
|
|
+ Map<String, Object> ext = crmExtDetailService.selectCrmExtDetailByCondition(map);
|
|
|
+ HashMap<String, Object> re = new HashMap<>();
|
|
|
+
|
|
|
+ // 使用反射获取所有字段
|
|
|
+ Field[] fields = CrmMyCustomerListQueryVO.class.getDeclaredFields();
|
|
|
+
|
|
|
+ // 遍历字段并将字段名和字段值放入 HashMap
|
|
|
+ for (Field field : fields) {
|
|
|
+ field.setAccessible(true); // 允许访问私有字段
|
|
|
+
|
|
|
+ try {
|
|
|
+ Object value = field.get(vo); // 获取字段的值
|
|
|
+ re.put(field.getName(), value); // 将字段名和值放入 HashMap
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ re.put("receiveTime", vo.getReceiveTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getReceiveTime()));
|
|
|
+ re.put("poolTime", vo.getPoolTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getPoolTime()));
|
|
|
+ re.put("createTime", vo.getCreateTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getCreateTime()));
|
|
|
+ re.put("customerCreateTime", vo.getCustomerCreateTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getCustomerCreateTime()));
|
|
|
+ re.put("startTime", vo.getStartTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd", vo.getStartTime()));
|
|
|
+ re.put("nextTime", vo.getNextTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd", vo.getNextTime()));
|
|
|
+ re.put("visitTime", vo.getVisitTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getVisitTime()));
|
|
|
+ if (ext != null) {
|
|
|
+ re.putAll(ext); // 将 extraFields 中的键值对添加到 re 中
|
|
|
+ }
|
|
|
+ res.add(re);
|
|
|
+ }
|
|
|
+ tableDataInfo.setRows(res);
|
|
|
+ return tableDataInfo;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@DataScope(deptAlias = "c",userAlias = "c")
|
|
|
public List<CrmCustomerListQueryVO> selectCrmCustomerListQuery(CrmCustomerListQueryParam param) {
|
|
|
@@ -344,6 +401,61 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
|
|
|
return crmCustomerMapper.selectCrmLineCustomerListQuery(param);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 响应请求分页数据
|
|
|
+ */
|
|
|
+ @SuppressWarnings({"rawtypes", "unchecked"})
|
|
|
+ protected TableDataInfo getDataTable(List<?> list) {
|
|
|
+ TableDataInfo rspData = new TableDataInfo();
|
|
|
+ rspData.setCode(HttpStatus.SUCCESS);
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
+ rspData.setRows(list);
|
|
|
+ rspData.setTotal(new PageInfo(list).getTotal());
|
|
|
+ return rspData;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TableDataInfo selectCrmLineCustomerListQueryInfo(CrmLineCustomerListQueryParam param) {
|
|
|
+
|
|
|
+ List<CrmLineCustomerListQueryVO> list = crmCustomerMapper.selectCrmLineCustomerListQueryInfo(param);
|
|
|
+ TableDataInfo resTable = getDataTable(list);
|
|
|
+ ArrayList<Map<String, Object>> res = new ArrayList<>();
|
|
|
+ for (CrmLineCustomerListQueryVO vo : list) {
|
|
|
+
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("correlate_id", vo.getCustomerId());
|
|
|
+ map.put("correlate_type", "customer_id");
|
|
|
+ Map<String, Object> ext = crmExtDetailService.selectCrmExtDetailByCondition(map);
|
|
|
+ HashMap<String, Object> re = new HashMap<>();
|
|
|
+
|
|
|
+ // 使用反射获取所有字段
|
|
|
+ Field[] fields = CrmLineCustomerListQueryVO.class.getDeclaredFields();
|
|
|
+
|
|
|
+ // 遍历字段并将字段名和字段值放入 HashMap
|
|
|
+ for (Field field : fields) {
|
|
|
+ field.setAccessible(true); // 允许访问私有字段
|
|
|
+
|
|
|
+ try {
|
|
|
+ Object value = field.get(vo); // 获取字段的值
|
|
|
+ re.put(field.getName(), value); // 将字段名和值放入 HashMap
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ re.put("receiveTime", vo.getReceiveTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getReceiveTime()));
|
|
|
+ re.put("poolTime", vo.getPoolTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getPoolTime()));
|
|
|
+ re.put("createTime", vo.getCreateTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getCreateTime()));
|
|
|
+ re.put("visitTime", vo.getVisitTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getVisitTime()));
|
|
|
+ re.put("nextTime", vo.getNextTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd", vo.getNextTime()));
|
|
|
+ if (ext != null) {
|
|
|
+ re.putAll(ext); // 将 extraFields 中的键值对添加到 re 中
|
|
|
+ }
|
|
|
+ res.add(re);
|
|
|
+ }
|
|
|
+ resTable.setRows(res);
|
|
|
+ return resTable;
|
|
|
+ }
|
|
|
+
|
|
|
// @Override
|
|
|
// @Transactional
|
|
|
// public R assignDept(CrmCustomeAssignParam param, String operName) {
|
|
|
@@ -583,6 +695,59 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R recoverR(CrmCustomerRecoverParam param, String operName) {
|
|
|
+ CrmCustomerUser crmCustomerUser = crmCustomerUserMapper.selectCrmCustomerUserById(param.getCustomerUserId());
|
|
|
+ CrmCustomer customer = null;
|
|
|
+ if (crmCustomerUser == null) {
|
|
|
+ customer = crmCustomerMapper.selectCrmCustomerById(param.getCustomerId());
|
|
|
+ } else {
|
|
|
+ customer = crmCustomerMapper.selectCrmCustomerById(crmCustomerUser.getCustomerId());
|
|
|
+ if (crmCustomerUser != null && crmCustomerUser.getIsPool() == 1) {
|
|
|
+ return R.error("客户已在公海中");
|
|
|
+ }
|
|
|
+ if (customer != null && customer.getStatus() == 0) {
|
|
|
+ return R.error("已锁定");
|
|
|
+ }
|
|
|
+ crmCustomerUser.setIsPool(1);
|
|
|
+ crmCustomerUser.setPoolTime(new Date());
|
|
|
+ crmCustomerUserMapper.updateCrmCustomerUser(crmCustomerUser);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (customer != null && customer.getStatus() == 0) {
|
|
|
+ return R.error("已锁定");
|
|
|
+ }
|
|
|
+ customer.setIsPool(1);
|
|
|
+ customer.setIsReceive(0);
|
|
|
+ customer.setPoolTime(new Date());
|
|
|
+ customer.setCustomerUserId(null);
|
|
|
+ crmCustomerMapper.updateCrmCustomer(customer);
|
|
|
+ //写日志
|
|
|
+ CrmCustomerLogs logs = new CrmCustomerLogs();
|
|
|
+ logs.setCustomerId(customer.getCustomerId());
|
|
|
+ logs.setCreateTime(new Date());
|
|
|
+ logs.setLogsType(CustomerLogEnum.RECOVER.getValue());
|
|
|
+ logs.setTitle(CustomerLogEnum.RECOVER.getDesc());
|
|
|
+ logs.setRemark(operName + "回收客户" + customer.getCustomerName());
|
|
|
+ logs.setCompanyUserId(param.getCompanyUserId());
|
|
|
+ logsMapper.insertCrmCustomerLogs(logs);
|
|
|
+ msgService.insertCrmMsg(new CrmMsg(1, "回收客户", "客户:" + customer.getCustomerName() + "已回收", customer.getCompanyId(), param.getCompanyUserId(), customer.getCustomerId()));
|
|
|
+ CompanyUser companyUser = companyUserMapper.selectCompanyUserById(param.getCompanyUserId());
|
|
|
+ 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) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public R assignUser(CrmCustomeAssignUserParam param, String operName) {
|
|
|
CompanyUser companyUser=companyUserMapper.selectCompanyUserById(param.getCompanyUserId());
|
|
|
@@ -802,6 +967,155 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
|
|
|
return importMsg.toString();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String importCompanyLineCustomerType(List<CrmCompanyLineCustomerImportParam> list, String operName, Long companyId, Long companyUserId, Integer type) {
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+ if (StringUtils.isNull(list) || list.size() == 0) {
|
|
|
+ throw new CustomException("导入数据不能为空!");
|
|
|
+ }
|
|
|
+ AtomicInteger successNum = new AtomicInteger();
|
|
|
+ AtomicInteger failureNum = new AtomicInteger();
|
|
|
+ StringBuffer successMsg = new StringBuffer();
|
|
|
+ StringBuffer failureMsg = new StringBuffer();
|
|
|
+ StringBuffer importMsg = new StringBuffer();
|
|
|
+ List<CompletableFuture<Void>> futures = new ArrayList<>();
|
|
|
+ for (CrmCompanyLineCustomerImportParam customer : list) {
|
|
|
+ CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
|
|
+ try {
|
|
|
+// String regex = "^1[3456789]\\d{9}$";
|
|
|
+// if(!customer.getMobile().matches(regex)){
|
|
|
+// failureNum++;
|
|
|
+// String msg = "<br/>" + failureNum + "、客户 " + customer.getMobile() + " 导入失败:电话号码格式不正确";
|
|
|
+// failureMsg.append(msg );
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+ CrmCustomerUpdateOrAddParam crmCustomer = new CrmCustomerUpdateOrAddParam();
|
|
|
+ BeanUtils.copyProperties(customer, crmCustomer);
|
|
|
+ CompanyUser companyUser = companyUserMapper.selectCompanyUserById(companyUserId);
|
|
|
+ crmCustomer.setDeptId(companyUser == null ? null : companyUser.getDeptId());
|
|
|
+ //导入类型
|
|
|
+ switch (type) {
|
|
|
+ case 0:
|
|
|
+ crmCustomer.setIsReceive(0);
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ crmCustomer.setIsReceive(1);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(customer.getSource())) {
|
|
|
+ crmCustomer.setSource(customer.getSource());
|
|
|
+ //业务场景 多选
|
|
|
+
|
|
|
+ //电话或者公司名字重复 不能新增
|
|
|
+ CrmCustomer condition = new CrmCustomer();
|
|
|
+ condition.setCustomerCompanyName(crmCustomer.getCustomerCompanyName());
|
|
|
+ condition.setMobile(crmCustomer.getMobile());
|
|
|
+ List<CrmCustomer> temp = crmCustomerMapper.selectCrmCustomerByCondition(condition);
|
|
|
+ if (temp != null && !temp.isEmpty()) {
|
|
|
+ failureNum.getAndIncrement();
|
|
|
+ String msg = "<br/>" + failureNum + "、客户 " + customer.getCustomerName() + ",电话:" + customer.getMobile() + " 导入失败:已经存在";
|
|
|
+ failureMsg.append(msg);
|
|
|
+ } else {
|
|
|
+ crmCustomer.setIsDel(0);
|
|
|
+ crmCustomer.setIsLine(1);
|
|
|
+ crmCustomer.setCompanyId(companyId);
|
|
|
+ crmCustomer.setStatus(1);
|
|
|
+ crmCustomer.setImportType(0); //表格导入
|
|
|
+ // crmCustomer.setIsReceive(1);
|
|
|
+ crmCustomer.setCustomerCode(OrderUtils.getOrderNo());
|
|
|
+ crmCustomer.setCreateTime(new Date());
|
|
|
+ crmCustomer.setCreateUserId(companyUserId);
|
|
|
+ crmCustomerMapper.insertCrmCustomer(crmCustomer);
|
|
|
+ //添加客户日志
|
|
|
+ CrmCustomerLogs log=new CrmCustomerLogs();
|
|
|
+ log.setCustomerId(crmCustomer.getCustomerId());
|
|
|
+ log.setCreateTime(crmCustomer.getCreateTime());
|
|
|
+ log.setLogsType(CustomerLogEnum.CREATE.getValue());
|
|
|
+ log.setTitle(CustomerLogEnum.CREATE.getDesc());
|
|
|
+ log.setRemark(operName+"表格导入创建客户");
|
|
|
+ crmCustomerLogsMapper.insertCrmCustomerLogs(log);
|
|
|
+ //新增 扩展字段
|
|
|
+ Map<String, Object> ext = crmCustomer.getExt();
|
|
|
+ if (ext != null && !ext.isEmpty()) {
|
|
|
+ ext.put("correlate_id", crmCustomer.getCustomerId());
|
|
|
+ ext.put("correlate_type", "customer_id");
|
|
|
+ crmExtDetailService.insertCrmExtDetail(ext);
|
|
|
+ }
|
|
|
+ //是否为商机
|
|
|
+ String isBusiness = customer.getIsBusiness();
|
|
|
+ if (StringUtils.isNotBlank(isBusiness) && "是".equals(isBusiness)) {
|
|
|
+ //建立商机
|
|
|
+ CrmBusinessAddAndUpdateParam crmBusiness = new CrmBusinessAddAndUpdateParam();
|
|
|
+ crmBusiness.setCustomerId(crmCustomer.getCustomerId());
|
|
|
+ crmBusiness.setSource(Integer.valueOf(crmCustomer.getSource()));
|
|
|
+ crmBusiness.setManager(crmCustomer.getCustomerName());
|
|
|
+ String customerCompanyName = crmCustomer.getCustomerCompanyName();
|
|
|
+ crmBusiness.setCompanyName(StringUtils.isNotBlank(customerCompanyName) ? customerCompanyName : crmCustomer.getCustomerName());
|
|
|
+ crmBusiness.setBusinessScenario(crmCustomer.getBusinessScenario());
|
|
|
+ crmBusiness.setProduct(crmCustomer.getProduct());
|
|
|
+ crmBusiness.setCreateBy(operName);
|
|
|
+ crmBusiness.setRemark("表格导入");
|
|
|
+ crmBusiness.setOpeName(operName);
|
|
|
+ crmBusinessService.insertCrmBusiness(crmBusiness);
|
|
|
+ }
|
|
|
+
|
|
|
+ successNum.getAndIncrement();
|
|
|
+ successMsg.append("<br/>" + successNum + "、客户 " + customer.getCustomerName() + " 导入成功");
|
|
|
+ //若存在归属员工编号 就将线索客户分配给该业务员 updated by qxj 2023年05月12日16:51:37
|
|
|
+ if (StringUtils.isNotEmpty(customer.getOwnerCompanyUserCode())) {
|
|
|
+ companyUser = companyUserMapper.selectUserByUserName(customer.getOwnerCompanyUserCode());
|
|
|
+ if (companyUser != null) {
|
|
|
+ Boolean isSuccess = assignUserAfterImport(operName, crmCustomer.getCustomerId(), companyUser);
|
|
|
+ if (isSuccess) {
|
|
|
+ successMsg.append(" <br/> " + customer.getOwnerCompanyUserCode() + "客户分配成功");
|
|
|
+ } else {
|
|
|
+ successMsg.append(" <br/> " + customer.getOwnerCompanyUserCode() + "客户分配失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (type == 1) {
|
|
|
+ if (companyUser != null) {
|
|
|
+ Boolean isSuccess = assignUserAfterImport(operName, crmCustomer.getCustomerId(), companyUser);
|
|
|
+ if (isSuccess) {
|
|
|
+ successMsg.append(" <br/> " + customer.getOwnerCompanyUserCode() + "客户分配成功");
|
|
|
+ } else {
|
|
|
+ successMsg.append(" <br/> " + customer.getOwnerCompanyUserCode() + "客户分配失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ failureNum.getAndIncrement();
|
|
|
+ String msg = "<br/>" + failureNum + "、客户 " + customer.getCustomerName() + ",电话:" + customer.getMobile() + " 导入失败:客户来源必填";
|
|
|
+ failureMsg.append(msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ failureNum.getAndIncrement();
|
|
|
+ String msg = "<br/>" + failureNum + "、客户 " + customer.getCustomerName() + ",电话:" + customer.getMobile() + " 导入失败:";
|
|
|
+ failureMsg.append(msg + e.getMessage());
|
|
|
+ }
|
|
|
+ }, threadPoolTaskExecutor);
|
|
|
+ futures.add(future);
|
|
|
+
|
|
|
+ }
|
|
|
+ // 等待所有任务完成
|
|
|
+ CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
|
|
|
+
|
|
|
+ if (failureNum.get() > 0) {
|
|
|
+ failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
+ //throw new CustomException(failureMsg.toString());
|
|
|
+ } else {
|
|
|
+ successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
+ }
|
|
|
+ importMsg.append(failureMsg);
|
|
|
+ importMsg.append(successMsg);
|
|
|
+ log.info("导入所花时间: {} ms", System.currentTimeMillis() - startTime);
|
|
|
+ return importMsg.toString();
|
|
|
+ }
|
|
|
+
|
|
|
// 导入线索客户后给指定业务员分配客户 updated by qxj 2023年05月12日16:51:37
|
|
|
public Boolean assignUserAfterImport(String operName,Long customerId, CompanyUser companyUser) {
|
|
|
|
|
|
@@ -1315,4 +1629,185 @@ public class CrmCustomerServiceImpl extends ServiceImpl<CrmCustomerMapper, CrmCu
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public TableDataInfo selectTransferCustomerList(CrmLineCustomerListQueryParam param) {
|
|
|
+ List<CrmLineCustomerListQueryVO> list = crmCustomerMapper.selectTransferCustomerList(param);
|
|
|
+ TableDataInfo resTable = getDataTable(list);
|
|
|
+ ArrayList<Map<String, Object>> res = new ArrayList<>();
|
|
|
+ for (CrmLineCustomerListQueryVO vo : list) {
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("correlate_id", vo.getCustomerId());
|
|
|
+ map.put("correlate_type", "customer_id");
|
|
|
+ Map<String, Object> ext = crmExtDetailService.selectCrmExtDetailByCondition(map);
|
|
|
+ HashMap<String, Object> re = new HashMap<>();
|
|
|
+
|
|
|
+ // 使用反射获取所有字段
|
|
|
+ Field[] fields = CrmLineCustomerListQueryVO.class.getDeclaredFields();
|
|
|
+
|
|
|
+ // 遍历字段并将字段名和字段值放入 HashMap
|
|
|
+ for (Field field : fields) {
|
|
|
+ field.setAccessible(true); // 允许访问私有字段
|
|
|
+
|
|
|
+ try {
|
|
|
+ Object value = field.get(vo); // 获取字段的值
|
|
|
+ re.put(field.getName(), value); // 将字段名和值放入 HashMap
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ re.put("receiveTime", vo.getReceiveTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getReceiveTime()));
|
|
|
+ re.put("poolTime", vo.getPoolTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getPoolTime()));
|
|
|
+ re.put("createTime", vo.getCreateTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getCreateTime()));
|
|
|
+ re.put("visitTime", vo.getVisitTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getVisitTime()));
|
|
|
+ re.put("nextTime", vo.getNextTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd", vo.getNextTime()));
|
|
|
+ if (ext != null) {
|
|
|
+ re.putAll(ext);
|
|
|
+ }
|
|
|
+ res.add(re);
|
|
|
+ }
|
|
|
+ resTable.setRows(res);
|
|
|
+ return resTable;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TableDataInfo selectUnPoolCrmCustomerList(CrmUnPoolListQueryParam param) {
|
|
|
+
|
|
|
+ //区分公司 查询配置文件
|
|
|
+ CompanyConfig companyConfig = companyConfigService.selectCompanyConfigByKey(param.getCompanyId(), "sys:config");
|
|
|
+ if (companyConfig != null) {
|
|
|
+ String configValue = companyConfig.getConfigValue();
|
|
|
+ SystemConfig config = JSON.parseObject(configValue, SystemConfig.class);
|
|
|
+ if (config != null) {
|
|
|
+ LinkedHashSet<CrmCustomerUnPoolListQueryVO> vos = new LinkedHashSet<>();
|
|
|
+ //1.查询 新增/导入 n天内没有跟进的线索
|
|
|
+ Integer visitLimit = config.getVisitLimt();
|
|
|
+ CrmUnPoolListQueryParam param1 = null;
|
|
|
+ if (visitLimit != null && visitLimit > 0) {
|
|
|
+ param1 = new CrmUnPoolListQueryParam();
|
|
|
+ BeanUtils.copyProperties(param, param1);
|
|
|
+ param1.setLimitDay(visitLimit);
|
|
|
+ }
|
|
|
+ //2.查询 有跟进的线索n天内没有跟进的线索
|
|
|
+ Integer visitLimit1 = config.getVisitLimt1();
|
|
|
+ CrmUnPoolListQueryParam param2 = null;
|
|
|
+ if (visitLimit1 != null && visitLimit1 > 0) {
|
|
|
+ param2 = new CrmUnPoolListQueryParam();
|
|
|
+ BeanUtils.copyProperties(param, param2);
|
|
|
+ param2.setLimitDay(visitLimit1);
|
|
|
+ }
|
|
|
+ //3.查询 n天无商机
|
|
|
+ Integer visitLimit2 = config.getVisitLimt2();
|
|
|
+ CrmUnPoolListQueryParam param3 = null;
|
|
|
+ if (visitLimit2 != null && visitLimit2 > 0) {
|
|
|
+ param3 = new CrmUnPoolListQueryParam();
|
|
|
+ BeanUtils.copyProperties(param, param3);
|
|
|
+ param3.setLimitDay(visitLimit2);
|
|
|
+ }
|
|
|
+ Integer pageSize = param.getPageSize();
|
|
|
+ Integer pageNum = param.getPageNum();
|
|
|
+ param.setStart((pageNum - 1) * pageSize);
|
|
|
+ vos = crmCustomerMapper.selectCrmCustomerListByUnPool(param1, param2, param3, param);
|
|
|
+ ArrayList<Map<String, Object>> res = new ArrayList<>();
|
|
|
+ for (CrmCustomerUnPoolListQueryVO vo : vos) {
|
|
|
+// if(StringUtils.isNotBlank(vo.getMobile())){
|
|
|
+// vo.setMobile(vo.getMobile().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
|
|
|
+// }
|
|
|
+
|
|
|
+ HashMap<String, Object> re = new HashMap<>();
|
|
|
+ // 使用反射获取所有字段
|
|
|
+ Field[] fields = CrmCustomerUnPoolListQueryVO.class.getDeclaredFields();
|
|
|
+
|
|
|
+ // 遍历字段并将字段名和字段值放入 HashMap
|
|
|
+ for (Field field : fields) {
|
|
|
+ field.setAccessible(true); // 允许访问私有字段
|
|
|
+ try {
|
|
|
+ Object value = field.get(vo); // 获取字段的值
|
|
|
+ re.put(field.getName(), value); // 将字段名和值放入 HashMap
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ re.put("receiveTime", vo.getReceiveTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getReceiveTime()));
|
|
|
+ re.put("poolTime", vo.getPoolTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getPoolTime()));
|
|
|
+ re.put("createTime", vo.getCreateTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getCreateTime()));
|
|
|
+ re.put("visitTime", vo.getVisitTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getVisitTime()));
|
|
|
+ re.put("nextTime", vo.getNextTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd", vo.getNextTime()));
|
|
|
+ re.put("sysVisitTime", vo.getSysVisitTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", vo.getSysVisitTime()));
|
|
|
+ re.put("timeStr", vo.getTime() / (24 * 60) + "天" + (vo.getTime() % (24 * 60)) / 60 + "小时");
|
|
|
+ res.add(re);
|
|
|
+ }
|
|
|
+ TableDataInfo rspData = new TableDataInfo();
|
|
|
+ rspData.setCode(HttpStatus.SUCCESS);
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
+ rspData.setRows(res);
|
|
|
+ rspData.setTotal(crmCustomerMapper.countCrmCustomerListByUnPool(param1, param2, param3, param));
|
|
|
+ return rspData;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R batchReceive(CrmCustomerBatchReceiveParam param, String operName) {
|
|
|
+ List<Long> customerIds = param.getCustomerIds();
|
|
|
+ if (customerIds != null && !customerIds.isEmpty()) {
|
|
|
+ for (Long customerId : customerIds) {
|
|
|
+ CrmCustomeReceiveParam receiveParam = new CrmCustomeReceiveParam();
|
|
|
+ BeanUtils.copyProperties(param, receiveParam);
|
|
|
+ receiveParam.setCustomerId(customerId);
|
|
|
+ R receive = receive(receiveParam, operName);
|
|
|
+ if (Integer.parseInt(receive.get("code").toString()) != 200) {
|
|
|
+ String msg = customerIds.toString() + " 其中" + customerId + "及其后所有失败,原因:" + receive.get("msg").toString();
|
|
|
+ return R.error(msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R recoverClueBatch(CrmLineCustomerListQueryParam param) {
|
|
|
+ crmCustomerMapper.recoverCrmLineCustomerList(param);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 未分配线索投入公海池
|
|
|
+ *
|
|
|
+ * @param customerIds
|
|
|
+ * @return r
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R recoverBatchByIds(Long[] customerIds,Long companyId,String opeName,Long opeUserId) {
|
|
|
+// int i = crmCustomerMapper.recoverBatchByIds(customerIds, companyId);
|
|
|
+// return i == customerIds.length ? R.ok() : R.error("未全部投入公海池");
|
|
|
+ if (customerIds == null || customerIds.length < 1) {
|
|
|
+ return R.error("请选择需要回收的线索客户");
|
|
|
+ }
|
|
|
+ for (Long customerId : customerIds) {
|
|
|
+ CrmCustomerRecoverParam recoverParam = new CrmCustomerRecoverParam();
|
|
|
+ recoverParam.setCustomerId(customerId);
|
|
|
+ recoverParam.setCompanyId(companyId);
|
|
|
+ recoverParam.setCompanyUserId(opeUserId);
|
|
|
+ recoverR(recoverParam, opeName);
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R recoverCustomerBatchByIds(CrmCustomerBatchRecoverParam param, String operName) {
|
|
|
+ Long[] customerUserIds = param.getCustomerUserIds();
|
|
|
+ if (customerUserIds == null || customerUserIds.length < 1) {
|
|
|
+ return R.error("请选择需要回收的客户");
|
|
|
+ }
|
|
|
+ for (Long customerUserId : customerUserIds) {
|
|
|
+ CrmCustomerRecoverParam recoverParam = new CrmCustomerRecoverParam();
|
|
|
+ BeanUtils.copyProperties(param, recoverParam);
|
|
|
+ recoverParam.setCustomerUserId(customerUserId);
|
|
|
+ recoverR(recoverParam, operName);
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|