|
|
@ -180,9 +180,9 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
//根据用户的组织机构查询分公司
|
|
|
|
String orgSidPath = query.getOrgSidPath(); |
|
|
|
String orgSid = "";//分公司sid
|
|
|
|
if(StringUtils.isNotBlank(orgSidPath)){ |
|
|
|
if (StringUtils.isNotBlank(orgSidPath)) { |
|
|
|
orgSid = sysStaffOrgFeign.getOrgSidByPath(orgSidPath).getData(); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
SysOrganizationVo sysOrganizationVo = sysOrganizationFeign.getUseOrgByUserSid(userSid).getData(); |
|
|
|
if (sysOrganizationVo != null) { |
|
|
|
orgSid = sysOrganizationVo.getSid(); |
|
|
@ -283,7 +283,7 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
*/ |
|
|
|
//根据用户sid获取业务员信息
|
|
|
|
SysUserVo sysUserVo = sysUserFeign.fetchBySid(dto.getUserSid()).getData(); |
|
|
|
if(sysUserVo == null){ |
|
|
|
if (sysUserVo == null) { |
|
|
|
return rb.setMsg("该用户不存在"); |
|
|
|
} |
|
|
|
String sid = dto.getSid(); |
|
|
@ -292,42 +292,42 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
//姓名
|
|
|
|
String name = dto.getName(); |
|
|
|
String mobile = dto.getMobile(); |
|
|
|
if(StringUtils.isBlank(sid)){//新增
|
|
|
|
if (StringUtils.isBlank(sid)) {//新增
|
|
|
|
//生成客户编码:分公司简称+部门编码+手机号+姓名首字母大写拼写
|
|
|
|
String customerNo = getPrefix(staffSid,name,mobile); |
|
|
|
String customerNo = getPrefix(staffSid, name, mobile); |
|
|
|
//查询该客户编码是否存在
|
|
|
|
CrmCustomerTemp crmCustomerTemp = baseMapper.selectByCustomerNo(customerNo); |
|
|
|
if(crmCustomerTemp != null){//存在
|
|
|
|
if (crmCustomerTemp != null) {//存在
|
|
|
|
//查询是否是当前用户客户
|
|
|
|
if(!dto.getUserSid().equals(crmCustomerTemp.getCreateBySid())){ |
|
|
|
if (!dto.getUserSid().equals(crmCustomerTemp.getCreateBySid())) { |
|
|
|
String staffName = ""; |
|
|
|
SysUserVo sysCrmVo = sysUserFeign.fetchBySid(crmCustomerTemp.getCreateBySid()).getData(); |
|
|
|
if(sysCrmVo != null){ |
|
|
|
if (sysCrmVo != null) { |
|
|
|
staffName = sysCrmVo.getName(); |
|
|
|
return rb.setCode(HttpStatusEnum.CRM_ERROR_NOTBELONG.getCode()).setMsg("为"+staffName+"销售专员客户"); |
|
|
|
return rb.setCode(HttpStatusEnum.CRM_ERROR_NOTBELONG.getCode()).setMsg("为" + staffName + "销售专员客户"); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
// 返回潜在客户sid,跳转维护信息页面
|
|
|
|
return rb.setCode(HttpStatusEnum.CRM_ERROR_EXIST.getCode()).setMsg(HttpStatusEnum.CRM_ERROR_EXIST.getMsg()).setData(crmCustomerTemp.getSid()); |
|
|
|
} |
|
|
|
|
|
|
|
}else{//不存在
|
|
|
|
} else {//不存在
|
|
|
|
// 新增
|
|
|
|
CrmCustomerTemp customerTemp = insertCrmCustomerTemp(dto, sysUserVo); |
|
|
|
sid = customerTemp.getSid(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{//修改
|
|
|
|
} else {//修改
|
|
|
|
CrmCustomerTemp customerTemp = fetchBySid(sid); |
|
|
|
if(customerTemp == null){ |
|
|
|
if (customerTemp == null) { |
|
|
|
return rb.setMsg("该客户不存在"); |
|
|
|
} |
|
|
|
//对比客户名称以及手机号是否变化
|
|
|
|
if(!customerTemp.getName().equals(dto.getName())){ |
|
|
|
if (!customerTemp.getName().equals(dto.getName())) { |
|
|
|
return rb.setMsg("客户名称不允许修改"); |
|
|
|
} |
|
|
|
if(!customerTemp.getMobile().equals(dto.getMobile())){ |
|
|
|
if (!customerTemp.getMobile().equals(dto.getMobile())) { |
|
|
|
return rb.setMsg("客户手机号不允许修改"); |
|
|
|
} |
|
|
|
BeanUtil.copyProperties(dto, customerTemp); |
|
|
@ -694,7 +694,7 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
customerTemp.setRemind_day(dto.getRemind_day()); |
|
|
|
} |
|
|
|
//客户编码
|
|
|
|
String customerNo = getPrefix(customerTemp.getStaffSid(),customerTemp.getName(),customerTemp.getMobile()); |
|
|
|
String customerNo = getPrefix(customerTemp.getStaffSid(), customerTemp.getName(), customerTemp.getMobile()); |
|
|
|
customerTemp.setCustomerNo(customerNo); |
|
|
|
save(customerTemp); |
|
|
|
// 增加跟进记录
|
|
|
@ -796,30 +796,30 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
} |
|
|
|
//根据用户sid获取业务员信息
|
|
|
|
SysUserVo sysUserVo = sysUserFeign.fetchBySid(dto.getUserSid()).getData(); |
|
|
|
if(sysUserVo == null){ |
|
|
|
if (sysUserVo == null) { |
|
|
|
return rb.setMsg("该用户不存在"); |
|
|
|
} |
|
|
|
String staffSid = sysUserVo.getStaffSid(); |
|
|
|
String name = dto.getName(); |
|
|
|
//生成客户编码:分公司简称+部门编码+手机号+姓名首字母大写拼写
|
|
|
|
String customerNo = getPrefix(staffSid,name,mobile); |
|
|
|
String customerNo = getPrefix(staffSid, name, mobile); |
|
|
|
//查询该客户编码是否存在
|
|
|
|
CrmCustomerTemp crmCustomerTemp = baseMapper.selectByCustomerNo(customerNo); |
|
|
|
if(crmCustomerTemp != null){//存在
|
|
|
|
if (crmCustomerTemp != null) {//存在
|
|
|
|
//查询是否是当前用户客户
|
|
|
|
if(!dto.getUserSid().equals(crmCustomerTemp.getCreateBySid())){ |
|
|
|
if (!dto.getUserSid().equals(crmCustomerTemp.getCreateBySid())) { |
|
|
|
String staffName = ""; |
|
|
|
SysUserVo sysCrmVo = sysUserFeign.fetchBySid(crmCustomerTemp.getCreateBySid()).getData(); |
|
|
|
if(sysCrmVo != null){ |
|
|
|
if (sysCrmVo != null) { |
|
|
|
staffName = sysCrmVo.getName(); |
|
|
|
return rb.setCode(HttpStatusEnum.CRM_ERROR_NOTBELONG.getCode()).setMsg("为"+staffName+"销售专员客户"); |
|
|
|
return rb.setCode(HttpStatusEnum.CRM_ERROR_NOTBELONG.getCode()).setMsg("为" + staffName + "销售专员客户"); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
// 返回潜在客户sid,跳转维护信息页面
|
|
|
|
return rb.setCode(HttpStatusEnum.CRM_ERROR_EXIST.getCode()).setMsg(HttpStatusEnum.CRM_ERROR_EXIST.getMsg()).setData(crmCustomerTemp.getSid()); |
|
|
|
} |
|
|
|
|
|
|
|
}else{//不存在
|
|
|
|
} else {//不存在
|
|
|
|
// 新增
|
|
|
|
CrmCustomerTemp customerTemp = saveCrmCustomerTemp(dto, sysUserVo); |
|
|
|
sid = customerTemp.getSid(); |
|
|
@ -839,7 +839,12 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
dto.fillEntity(crmCustomerTemp); |
|
|
|
crmCustomerTemp.setCreateBySid(dto.getUserSid()); |
|
|
|
crmCustomerTemp.setStaffSid(sysUserInfoVo.getStaffSid()); |
|
|
|
String orgSid = sysStaffOrgFeign.getPathSidByUserSid(dto.getUserSid()).getData(); |
|
|
|
String orgSid = ""; |
|
|
|
if (StringUtils.isNotBlank(dto.getOrgPath())) { |
|
|
|
orgSid = sysStaffOrgFeign.getOrgSidByPath(dto.getOrgPath()).getData(); |
|
|
|
} else { |
|
|
|
orgSid = sysStaffOrgFeign.getPathSidByUserSid(dto.getUserSid()).getData(); |
|
|
|
} |
|
|
|
crmCustomerTemp.setCreateOrgSid(orgSid); |
|
|
|
ResultBean resultBean = dictCommonFeign.getFirstDictKeyByType(DictCommonType.FOLLOW_STATE, "0"); |
|
|
|
if (resultBean.getSuccess() && resultBean.getData() != null) { |
|
|
@ -922,14 +927,14 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
public ResultBean updateCrmCustomer(CrmCustomerTempUpdateDto dto, String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
CrmCustomerTemp customerTemp = fetchBySid(sid); |
|
|
|
if(customerTemp == null){ |
|
|
|
if (customerTemp == null) { |
|
|
|
return rb.setMsg("该客户不存在"); |
|
|
|
} |
|
|
|
//对比客户名称以及手机号是否变化
|
|
|
|
if(!customerTemp.getName().equals(dto.getName())){ |
|
|
|
if (!customerTemp.getName().equals(dto.getName())) { |
|
|
|
return rb.setMsg("客户名称不允许修改"); |
|
|
|
} |
|
|
|
if(!customerTemp.getMobile().equals(dto.getMobile())){ |
|
|
|
if (!customerTemp.getMobile().equals(dto.getMobile())) { |
|
|
|
return rb.setMsg("客户手机号不允许修改"); |
|
|
|
} |
|
|
|
BeanUtil.copyProperties(dto, customerTemp); |
|
|
@ -981,17 +986,17 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
// String orgSid = sysStaffOrgFeign.getPathSidByUserSid(query.getUserSid()).getData();
|
|
|
|
QueryWrapper<CrmCustomerTempListQuery> qw = new QueryWrapper<>(); |
|
|
|
String orgSid = ""; |
|
|
|
if(StringUtils.isNotBlank(query.getOrgPath())){ |
|
|
|
if (StringUtils.isNotBlank(query.getOrgPath())) { |
|
|
|
orgSid = sysStaffOrgFeign.getOrgSidByPath(query.getOrgPath()).getData(); |
|
|
|
qw.eq("ct.createOrgSid",orgSid); |
|
|
|
qw.eq("ct.createOrgSid", orgSid); |
|
|
|
} |
|
|
|
qw.eq("ct.staffSid",staffSid); |
|
|
|
qw.eq("ct.staffSid", staffSid); |
|
|
|
List<CrmCustomerTempListVo> list = baseMapper.selectCustomerList(qw); |
|
|
|
list.removeAll(Collections.singleton(null)); |
|
|
|
return rb.success().setData(list); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean sendFinCustomer(String[] customerSids,String orgCode) { |
|
|
|
public ResultBean sendFinCustomer(String[] customerSids, String orgCode) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
List<BdCustomer> bdCustomers = new ArrayList<>(); |
|
|
|
for (String customerSid : customerSids) { |
|
|
@ -1019,9 +1024,9 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
BaseVehicle baseVehicle = baseVehicleFeign.selectByVinNoAndOrgSid(crmCustomerTempToFin.getVinNo(), createOrgSid).getData(); |
|
|
|
BdCustomer bdCustomer = new BdCustomer(); |
|
|
|
BasePurchaseSystemDetailsVo data = basePurchaseSystemFeign.fetchDetailsByDeptSid(baseVehicle.getPurchaseSystemSid()).getData(); |
|
|
|
if (data != null){ |
|
|
|
if (data != null) { |
|
|
|
bdCustomer.setTOrgIds(data.getOrgCode()); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
bdCustomer.setTOrgIds(sysOrganizationVo.getOrgCode()); |
|
|
|
} |
|
|
|
bdCustomer.setFName(crmCustomerTemp.getName() + crmCustomerTempToFin.getVinNo().substring(crmCustomerTempToFin.getVinNo().length() - 8)); |
|
|
|