|
@ -270,83 +270,66 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
* 513:该微信号的客户已是当前用户的客户 |
|
|
* 513:该微信号的客户已是当前用户的客户 |
|
|
*/ |
|
|
*/ |
|
|
public ResultBean saveOrUpdateAppCustomerTemp(AppCrmCustomerTempDto dto) { |
|
|
public ResultBean saveOrUpdateAppCustomerTemp(AppCrmCustomerTempDto dto) { |
|
|
AppUserOrgInfoVo userOrgInfoVo = sysUserFeign.getUserOrgInfoByUserSid(dto.getUserSid()).getData(); |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
if (StringUtils.isBlank(userOrgInfoVo.getOrgSid())) { |
|
|
/** |
|
|
return new ResultBean().fail().setMsg("请先设置该员工所属部门"); |
|
|
* 2023-02-10: |
|
|
|
|
|
* 先查询客户编码是否存在: |
|
|
|
|
|
* 1、存在 |
|
|
|
|
|
* 1.1、是否是当前用户的客户: |
|
|
|
|
|
* 1.1.1、是,提示客户已存在,不能新增 |
|
|
|
|
|
* 1.1.2、否,提示:为xxx销售专员客户 |
|
|
|
|
|
* 2、不存在 |
|
|
|
|
|
* 2.1、新增客户信息(新增跟进记录),保存时添加二次提醒:保存后客户名称、手机号码将不能修改 |
|
|
|
|
|
*/ |
|
|
|
|
|
//根据用户sid获取业务员信息
|
|
|
|
|
|
SysUserVo sysUserVo = sysUserFeign.fetchBySid(dto.getUserSid()).getData(); |
|
|
|
|
|
if(sysUserVo == null){ |
|
|
|
|
|
return rb.setMsg("该用户不存在"); |
|
|
} |
|
|
} |
|
|
Map<String, String> map = new HashMap<>(); |
|
|
String sid = dto.getSid(); |
|
|
map.put("staffSid", userOrgInfoVo.getStaffSid()); |
|
|
//业务员sid
|
|
|
if (StringUtils.isBlank(dto.getSid())) { // 新增
|
|
|
String staffSid = sysUserVo.getStaffSid(); |
|
|
if (StringUtils.isNotBlank(dto.getMobile())) { // 有手机号
|
|
|
//姓名
|
|
|
//查询业务员的分公司简称和部门简称
|
|
|
String name = dto.getName(); |
|
|
String customerNo = getPrefix(userOrgInfoVo.getStaffSid(), dto.getName(), dto.getMobile()); |
|
|
String mobile = dto.getMobile(); |
|
|
CrmCustomerTempVo customerTempVo = baseMapper.selectNo(customerNo); |
|
|
if(StringUtils.isBlank(sid)){//新增
|
|
|
// map.put("mobile", dto.getMobile());
|
|
|
//生成客户编码:分公司简称+部门编码+手机号+姓名首字母大写拼写
|
|
|
// CrmCustomerTempVo customerTempVo = baseMapper.selectByMobileOrWx(map);
|
|
|
String customerNo = getPrefix(staffSid,name,mobile); |
|
|
if (customerTempVo != null) { |
|
|
//查询该客户编码是否存在
|
|
|
// 是否为当前用户的客户
|
|
|
CrmCustomerTemp crmCustomerTemp = baseMapper.selectByCustomerNo(customerNo); |
|
|
if (customerTempVo.getStaffSid().equals(userOrgInfoVo.getStaffSid())) { |
|
|
if(crmCustomerTemp != null){//存在
|
|
|
// 返回潜在客户sid,跳转维护信息页面
|
|
|
//查询是否是当前用户客户
|
|
|
return new ResultBean().fail().setCode(HttpStatusEnum.CRM_ERROR_EXIST.getCode()).setMsg(HttpStatusEnum.CRM_ERROR_EXIST.getMsg()).setData(customerTempVo.getSid()); |
|
|
if(!dto.getUserSid().equals(crmCustomerTemp.getCreateBySid())){ |
|
|
} else { |
|
|
String staffName = ""; |
|
|
// 不是当前用户的客户,提示
|
|
|
SysUserVo sysCrmVo = sysUserFeign.fetchBySid(crmCustomerTemp.getCreateBySid()).getData(); |
|
|
SysUserVo userVo = sysUserFeign.selectByStaffsid(customerTempVo.getStaffSid()).getData(); |
|
|
if(sysCrmVo != null){ |
|
|
return new ResultBean().fail().setCode(HttpStatusEnum.CRM_ERROR_NOTBELONG.getCode()).setMsg("该手机号客户为" + userVo.getName() |
|
|
staffName = sysCrmVo.getName(); |
|
|
+ "的客户,如需更改,请联系" + userVo.getName()); |
|
|
return rb.setCode(HttpStatusEnum.CRM_ERROR_NOTBELONG.getCode()).setMsg("为"+staffName+"销售专员客户"); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
}else{ |
|
|
// 新增
|
|
|
// 返回潜在客户sid,跳转维护信息页面
|
|
|
CrmCustomerTemp customerTemp = insertCrmCustomerTemp(dto, userOrgInfoVo); |
|
|
return rb.setCode(HttpStatusEnum.CRM_ERROR_EXIST.getCode()).setMsg(HttpStatusEnum.CRM_ERROR_EXIST.getMsg()).setData(crmCustomerTemp.getSid()); |
|
|
return new ResultBean().success().setMsg("添加成功").setData(customerTemp.getSid()); |
|
|
|
|
|
} |
|
|
|
|
|
} else { // 无手机号,有微信号
|
|
|
|
|
|
map.put("weixin", dto.getWeixin()); |
|
|
|
|
|
CrmCustomerTempVo customerTempVo = baseMapper.selectByMobileOrWx(map); |
|
|
|
|
|
if (customerTempVo != null) { |
|
|
|
|
|
return new ResultBean().fail().setCode(HttpStatusEnum.CRM_ERROR_WXEXIST.getCode()).setMsg(HttpStatusEnum.CRM_ERROR_WXEXIST.getMsg()); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 新增
|
|
|
|
|
|
CrmCustomerTemp customerTemp = insertCrmCustomerTemp(dto, userOrgInfoVo); |
|
|
|
|
|
return new ResultBean().success().setMsg("添加成功").setData(customerTemp.getSid()); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}else{//不存在
|
|
|
|
|
|
// 新增
|
|
|
|
|
|
CrmCustomerTemp customerTemp = insertCrmCustomerTemp(dto, sysUserVo); |
|
|
|
|
|
sid = customerTemp.getSid(); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} else { // 修改
|
|
|
|
|
|
if (StringUtils.isNotBlank(dto.getMobile())) { |
|
|
}else{//修改
|
|
|
//查询业务员的分公司简称和部门简称
|
|
|
CrmCustomerTemp customerTemp = fetchBySid(sid); |
|
|
String customerNo = getPrefix(userOrgInfoVo.getStaffSid(), dto.getName(), dto.getMobile()); |
|
|
if(customerTemp == null){ |
|
|
CrmCustomerTempVo customerTempVo = baseMapper.selectNo1(customerNo, dto.getSid()); |
|
|
return rb.setMsg("该客户不存在"); |
|
|
if (customerTempVo != null) { |
|
|
} |
|
|
return new ResultBean().fail().setMsg("该手机号已绑定其它客户,请重新添加"); |
|
|
//对比客户名称以及手机号是否变化
|
|
|
} |
|
|
if(!customerTemp.getName().equals(dto.getName())){ |
|
|
/* AppCrmCustomerTempInfoVo appCrmCustomerTempInfoVo = baseMapper.selectBySid(dto.getSid()); |
|
|
return rb.setMsg("客户名称不允许修改"); |
|
|
String mobile = appCrmCustomerTempInfoVo.getMobile(); |
|
|
} |
|
|
if (!mobile.equals(dto.getMobile())) { |
|
|
if(!customerTemp.getMobile().equals(dto.getMobile())){ |
|
|
int count = baseMapper.selBySidAndMobile(dto.getSid(), dto.getMobile()); |
|
|
return rb.setMsg("客户手机号不允许修改"); |
|
|
if (count > 0) { |
|
|
|
|
|
return new ResultBean().fail().setMsg("该手机号已绑定其它客户,请重新添加"); |
|
|
|
|
|
} |
|
|
|
|
|
}*/ |
|
|
|
|
|
} |
|
|
} |
|
|
// if (StringUtils.isNotBlank(dto.getWeixin())) {
|
|
|
|
|
|
// AppCrmCustomerTempInfoVo appCrmCustomerTempInfoVo = baseMapper.selectBySid(dto.getSid());
|
|
|
|
|
|
// String weiXin = appCrmCustomerTempInfoVo.getWeiXin();
|
|
|
|
|
|
// if (!weiXin.equals(dto.getWeixin())) {
|
|
|
|
|
|
// int count = baseMapper.selBySidAndWeixin(dto.getSid(), dto.getWeixin());
|
|
|
|
|
|
// if (count > 0) {
|
|
|
|
|
|
// return new ResultBean().fail().setMsg("该微信已绑定其它客户,请重新添加");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (StringUtils.isNotBlank(dto.getWeixin())) {
|
|
|
|
|
|
// map.put("weixin", dto.getWeixin());
|
|
|
|
|
|
// CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectByMobileOrWx(map);
|
|
|
|
|
|
// if (crmCustomerTempVo != null && crmCustomerTempVo.getStaffSid().equals(userOrgInfoVo.getStaffSid())) {
|
|
|
|
|
|
// if (crmCustomerTempVo.getWeixin().equals(dto.getWeixin())) {
|
|
|
|
|
|
// return new ResultBean().fail().setMsg("该微信号已绑定其它客户,请重新添加");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
CrmCustomerTemp customerTemp = fetchBySid(dto.getSid()); |
|
|
|
|
|
BeanUtil.copyProperties(dto, customerTemp); |
|
|
BeanUtil.copyProperties(dto, customerTemp); |
|
|
String adCode = dto.getAdCode(); |
|
|
String adCode = dto.getAdCode(); |
|
|
if (StringUtils.isNotBlank(adCode)) { |
|
|
if (StringUtils.isNotBlank(adCode)) { |
|
@ -358,46 +341,12 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
customerTemp.setCustomerPhoto(customerTemp.getCustomerPhoto().replace(fileUploadComponent.getUrlPrefix(), "")); |
|
|
customerTemp.setCustomerPhoto(customerTemp.getCustomerPhoto().replace(fileUploadComponent.getUrlPrefix(), "")); |
|
|
} |
|
|
} |
|
|
customerTemp.setUpdateBySid(dto.getUserSid()); |
|
|
customerTemp.setUpdateBySid(dto.getUserSid()); |
|
|
//客户编码
|
|
|
|
|
|
String customerNoPrefix = ""; |
|
|
|
|
|
//查询业务员的分公司简称和部门简称
|
|
|
|
|
|
ResultBean<SysStaffOrg> staffOrgResultBean = sysStaffOrgFeign.getOrgByStaffSid(customerTemp.getStaffSid()); |
|
|
|
|
|
if (staffOrgResultBean.getSuccess()) { |
|
|
|
|
|
SysStaffOrg sysStaffOrg = staffOrgResultBean.getData(); |
|
|
|
|
|
if (sysStaffOrg != null) { |
|
|
|
|
|
ResultBean<String> resultBean1 = sysStaffOrgFeign.getOrgSidByPath(sysStaffOrg.getOrgSidPath()); |
|
|
|
|
|
if (resultBean1.getSuccess()) { |
|
|
|
|
|
String osid = resultBean1.getData(); |
|
|
|
|
|
if (StringUtils.isNotBlank(osid)) { |
|
|
|
|
|
ResultBean<SysOrganizationVo> sysOrganizationVoResultBean = sysOrganizationFeign.fetchBySid(osid); |
|
|
|
|
|
if (sysOrganizationVoResultBean.getSuccess()) { |
|
|
|
|
|
SysOrganizationVo sysOrganizationVo = sysOrganizationVoResultBean.getData(); |
|
|
|
|
|
customerNoPrefix = customerNoPrefix + sysOrganizationVo.getOrgAbbre(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
String orgSid1 = sysStaffOrg.getOrgSid(); |
|
|
|
|
|
ResultBean<SysOrganizationVo> sysOrganizationVoResultBean = sysOrganizationFeign.fetchBySid(orgSid1); |
|
|
|
|
|
if (sysOrganizationVoResultBean.getSuccess()) { |
|
|
|
|
|
SysOrganizationVo sysOrganizationVo = sysOrganizationVoResultBean.getData(); |
|
|
|
|
|
customerNoPrefix = customerNoPrefix + sysOrganizationVo.getOrgCode(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
String customerNo = getPrefix(customerTemp.getStaffSid(),customerTemp.getName(),customerTemp.getMobile()); |
|
|
|
|
|
// String customerNo = customerNoPrefix + HanZiConverterPinYin.getPinYinFirst(customerTemp.getName()) + customerTemp.getMobile();
|
|
|
|
|
|
customerTemp.setCustomerNo(customerNo); |
|
|
|
|
|
boolean updateBoolean = updateById(customerTemp); |
|
|
boolean updateBoolean = updateById(customerTemp); |
|
|
if (updateBoolean) { |
|
|
if (!updateBoolean) { |
|
|
// 更新附件表
|
|
|
return rb.fail().setMsg("更新失败"); |
|
|
// if (!dto.getFilePaths().isEmpty()) {
|
|
|
|
|
|
// updateCrmFile(dto, customerTemp);
|
|
|
|
|
|
// }
|
|
|
|
|
|
return new ResultBean().success().setMsg("更新成功").setData(customerTemp.getSid()); |
|
|
|
|
|
} else { |
|
|
|
|
|
return new ResultBean().fail().setMsg("更新失败"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
return rb.success().setData(sid); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -708,7 +657,7 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
protected CrmCustomerTemp insertCrmCustomerTemp(AppCrmCustomerTempDto dto, AppUserOrgInfoVo userOrgInfoVo) { |
|
|
protected CrmCustomerTemp insertCrmCustomerTemp(AppCrmCustomerTempDto dto, SysUserVo userOrgInfoVo) { |
|
|
CrmCustomerTemp customerTemp = new CrmCustomerTemp(); |
|
|
CrmCustomerTemp customerTemp = new CrmCustomerTemp(); |
|
|
String orgPath = dto.getOrgPath(); |
|
|
String orgPath = dto.getOrgPath(); |
|
|
String useOrgSid = ""; |
|
|
String useOrgSid = ""; |
|
@ -723,13 +672,8 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
if (StringUtils.isNotBlank(customerTemp.getCustomerPhoto())) { |
|
|
if (StringUtils.isNotBlank(customerTemp.getCustomerPhoto())) { |
|
|
customerTemp.setCustomerPhoto(customerTemp.getCustomerPhoto().replace(fileUploadComponent.getUrlPrefix(), "")); |
|
|
customerTemp.setCustomerPhoto(customerTemp.getCustomerPhoto().replace(fileUploadComponent.getUrlPrefix(), "")); |
|
|
} |
|
|
} |
|
|
// Map<String, String> map = genetrateCustomerNum(dto.getCustomerTypeKey(), userOrgInfoVo);
|
|
|
|
|
|
customerTemp.setCreateBySid(dto.getUserSid()); |
|
|
customerTemp.setCreateBySid(dto.getUserSid()); |
|
|
customerTemp.setStaffSid(userOrgInfoVo.getStaffSid()); |
|
|
customerTemp.setStaffSid(userOrgInfoVo.getStaffSid()); |
|
|
// String orgSid = sysStaffOrgFeign.getPathSidByUserSid(dto.getUserSid()).getData();
|
|
|
|
|
|
// customerTemp.setCreateOrgSid(orgSid);
|
|
|
|
|
|
// customerTemp.setCreateOrgSid(userOrgInfoVo.getOrgSid());
|
|
|
|
|
|
// customerTemp.setCustomerNo(map.get("code"));
|
|
|
|
|
|
customerTemp.setCertificateTypeKey(customerTemp.getCustomerTypeKey().equals("1") ? "01" : "02"); |
|
|
customerTemp.setCertificateTypeKey(customerTemp.getCustomerTypeKey().equals("1") ? "01" : "02"); |
|
|
customerTemp.setCertificateType(customerTemp.getCustomerTypeKey().equals("1") ? "身份证" : "营业执照"); |
|
|
customerTemp.setCertificateType(customerTemp.getCustomerTypeKey().equals("1") ? "身份证" : "营业执照"); |
|
|
ResultBean resultBean = dictCommonFeign.getFirstDictKeyByType(DictCommonType.FOLLOW_STATE, "0"); |
|
|
ResultBean resultBean = dictCommonFeign.getFirstDictKeyByType(DictCommonType.FOLLOW_STATE, "0"); |
|
@ -750,34 +694,7 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
customerTemp.setRemind_day(dto.getRemind_day()); |
|
|
customerTemp.setRemind_day(dto.getRemind_day()); |
|
|
} |
|
|
} |
|
|
//客户编码
|
|
|
//客户编码
|
|
|
String customerNoPrefix = ""; |
|
|
|
|
|
//查询业务员的分公司简称和部门简称
|
|
|
|
|
|
ResultBean<SysStaffOrg> staffOrgResultBean = sysStaffOrgFeign.getOrgByStaffSid(customerTemp.getStaffSid()); |
|
|
|
|
|
if (staffOrgResultBean.getSuccess()) { |
|
|
|
|
|
SysStaffOrg sysStaffOrg = staffOrgResultBean.getData(); |
|
|
|
|
|
if (sysStaffOrg != null) { |
|
|
|
|
|
ResultBean<String> resultBean1 = sysStaffOrgFeign.getOrgSidByPath(sysStaffOrg.getOrgSidPath()); |
|
|
|
|
|
if (resultBean1.getSuccess()) { |
|
|
|
|
|
String osid = resultBean1.getData(); |
|
|
|
|
|
if (StringUtils.isNotBlank(osid)) { |
|
|
|
|
|
ResultBean<SysOrganizationVo> sysOrganizationVoResultBean = sysOrganizationFeign.fetchBySid(osid); |
|
|
|
|
|
if (sysOrganizationVoResultBean.getSuccess()) { |
|
|
|
|
|
SysOrganizationVo sysOrganizationVo = sysOrganizationVoResultBean.getData(); |
|
|
|
|
|
customerNoPrefix = customerNoPrefix + sysOrganizationVo.getOrgAbbre(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
String orgSid1 = sysStaffOrg.getOrgSid(); |
|
|
|
|
|
ResultBean<SysOrganizationVo> sysOrganizationVoResultBean = sysOrganizationFeign.fetchBySid(orgSid1); |
|
|
|
|
|
if (sysOrganizationVoResultBean.getSuccess()) { |
|
|
|
|
|
SysOrganizationVo sysOrganizationVo = sysOrganizationVoResultBean.getData(); |
|
|
|
|
|
customerNoPrefix = customerNoPrefix + sysOrganizationVo.getOrgCode(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//客户编码
|
|
|
|
|
|
String customerNo = getPrefix(customerTemp.getStaffSid(),customerTemp.getName(),customerTemp.getMobile()); |
|
|
String customerNo = getPrefix(customerTemp.getStaffSid(),customerTemp.getName(),customerTemp.getMobile()); |
|
|
// String customerNo = customerNoPrefix + HanZiConverterPinYin.getPinYinFirst(customerTemp.getName()) + customerTemp.getMobile();
|
|
|
|
|
|
customerTemp.setCustomerNo(customerNo); |
|
|
customerTemp.setCustomerNo(customerNo); |
|
|
save(customerTemp); |
|
|
save(customerTemp); |
|
|
// 增加跟进记录
|
|
|
// 增加跟进记录
|
|
@ -839,27 +756,13 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
*/ |
|
|
*/ |
|
|
public ResultBean saveCrmCustomer(CrmCustomerTempDto dto) { |
|
|
public ResultBean saveCrmCustomer(CrmCustomerTempDto dto) { |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
//当前登录用户的sid
|
|
|
String sid = ""; |
|
|
String userSid = dto.getUserSid(); |
|
|
|
|
|
//根据登录用户sid查询该用户是否已设置部门
|
|
|
|
|
|
ResultBean<SysUserInfoVo> sysUserInfoVoResultBean = sysUserFeign.selectUserInfoByUserSid(userSid); |
|
|
|
|
|
if (!sysUserInfoVoResultBean.getSuccess()) { |
|
|
|
|
|
return rb.setMsg(sysUserInfoVoResultBean.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
//用户所属组织信息
|
|
|
|
|
|
SysUserInfoVo sysUserInfoVo = sysUserInfoVoResultBean.getData(); |
|
|
|
|
|
if (StringUtils.isBlank(sysUserInfoVo.getOrgSid())) { |
|
|
|
|
|
return rb.setMsg("请先设置该员工所属部门"); |
|
|
|
|
|
} |
|
|
|
|
|
//手机号
|
|
|
//手机号
|
|
|
String mobile = dto.getMobile(); |
|
|
String mobile = dto.getMobile(); |
|
|
//微信号
|
|
|
//微信号
|
|
|
String weixin = dto.getWeixin(); |
|
|
String weixin = dto.getWeixin(); |
|
|
if (StringUtils.isBlank(mobile)) { |
|
|
|
|
|
return rb.setMsg("请输入联系电话"); |
|
|
|
|
|
} |
|
|
|
|
|
if ("1".equals(dto.getCustomerType())) { |
|
|
if ("1".equals(dto.getCustomerType())) { |
|
|
if (!weixin.matches("^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\\d{8}$")) { |
|
|
if (!mobile.matches("^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\\d{8}$")) { |
|
|
return rb.setMsg("手机号格式不正确"); |
|
|
return rb.setMsg("手机号格式不正确"); |
|
|
} |
|
|
} |
|
|
if (StringUtils.isNotBlank(dto.getIDNumber())) { |
|
|
if (StringUtils.isNotBlank(dto.getIDNumber())) { |
|
@ -891,46 +794,37 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
return rb.setMsg("紧急联系电话格式不正确"); |
|
|
return rb.setMsg("紧急联系电话格式不正确"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//当前登录用户的所在部门sid
|
|
|
//根据用户sid获取业务员信息
|
|
|
String staffSid = sysUserInfoVo.getStaffSid(); |
|
|
SysUserVo sysUserVo = sysUserFeign.fetchBySid(dto.getUserSid()).getData(); |
|
|
//根据客户的手机号以及当前登录者所在部门的sid查询该部门内是否有重复的
|
|
|
if(sysUserVo == null){ |
|
|
if (StringUtils.isNotBlank(mobile)) { |
|
|
return rb.setMsg("该用户不存在"); |
|
|
//客户编码
|
|
|
} |
|
|
String customerNo = getPrefix(staffSid, dto.getName(), dto.getMobile()); |
|
|
String staffSid = sysUserVo.getStaffSid(); |
|
|
CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectNo(customerNo); |
|
|
String name = dto.getName(); |
|
|
// CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectByMobile(staffSid, mobile);
|
|
|
//生成客户编码:分公司简称+部门编码+手机号+姓名首字母大写拼写
|
|
|
if (crmCustomerTempVo == null) { |
|
|
String customerNo = getPrefix(staffSid,name,mobile); |
|
|
//新增潜在客户信息
|
|
|
//查询该客户编码是否存在
|
|
|
CrmCustomerTemp crmCustomerTemp = saveCrmCustomerTemp(dto, sysUserInfoVo); |
|
|
CrmCustomerTemp crmCustomerTemp = baseMapper.selectByCustomerNo(customerNo); |
|
|
return rb.success().setData(crmCustomerTemp.getSid()); |
|
|
if(crmCustomerTemp != null){//存在
|
|
|
} else { |
|
|
//查询是否是当前用户客户
|
|
|
//是否为当前用户的客户
|
|
|
if(!dto.getUserSid().equals(crmCustomerTemp.getCreateBySid())){ |
|
|
if (crmCustomerTempVo.getStaffSid().equals(sysUserInfoVo.getStaffSid())) { |
|
|
String staffName = ""; |
|
|
return rb.setCode(HttpStatusEnum.CRM_ERROR_EXIST.getCode()).setMsg(HttpStatusEnum.CRM_ERROR_EXIST.getMsg()).setData(crmCustomerTempVo.getSid()); |
|
|
SysUserVo sysCrmVo = sysUserFeign.fetchBySid(crmCustomerTemp.getCreateBySid()).getData(); |
|
|
} else { |
|
|
if(sysCrmVo != null){ |
|
|
//不是当前用户的客户,提示信息。
|
|
|
staffName = sysCrmVo.getName(); |
|
|
ResultBean<SysUserVo> sysUserVoResultBean = sysUserFeign.selectByStaffsid(crmCustomerTempVo.getStaffSid()); |
|
|
return rb.setCode(HttpStatusEnum.CRM_ERROR_NOTBELONG.getCode()).setMsg("为"+staffName+"销售专员客户"); |
|
|
if (sysUserVoResultBean.getSuccess()) { |
|
|
|
|
|
return rb.setMsg("该手机号客户为" + sysUserVoResultBean.getData().getName() + "的客户,如需更改,请联系" + sysUserVoResultBean.getData().getName()); |
|
|
|
|
|
} else { |
|
|
|
|
|
return rb.setMsg(sysUserInfoVoResultBean.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
}else{ |
|
|
} |
|
|
// 返回潜在客户sid,跳转维护信息页面
|
|
|
} else if (StringUtils.isNotBlank(weixin)) { |
|
|
return rb.setCode(HttpStatusEnum.CRM_ERROR_EXIST.getCode()).setMsg(HttpStatusEnum.CRM_ERROR_EXIST.getMsg()).setData(crmCustomerTemp.getSid()); |
|
|
// String staffSid = sysUserInfoVo.getStaffSid();
|
|
|
|
|
|
//根据客户的微信号以及当前登录者所在部门的sid和登录者所关联的员工sid查询
|
|
|
|
|
|
CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectByWx(staffSid, weixin); |
|
|
|
|
|
if (crmCustomerTempVo == null) { |
|
|
|
|
|
//新增潜在客户信息
|
|
|
|
|
|
CrmCustomerTemp crmCustomerTemp = saveCrmCustomerTemp(dto, sysUserInfoVo); |
|
|
|
|
|
return rb.success().setData(crmCustomerTemp.getSid()); |
|
|
|
|
|
} else { |
|
|
|
|
|
return rb.setCode(HttpStatusEnum.CRM_ERROR_WXEXIST.getCode()).setMsg(HttpStatusEnum.CRM_ERROR_WXEXIST.getMsg()); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}else{//不存在
|
|
|
|
|
|
// 新增
|
|
|
|
|
|
CrmCustomerTemp customerTemp = saveCrmCustomerTemp(dto, sysUserVo); |
|
|
|
|
|
sid = customerTemp.getSid(); |
|
|
} |
|
|
} |
|
|
return rb.success(); |
|
|
return rb.success().setData(crmCustomerTemp.getSid()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -940,47 +834,19 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
* @param sysUserInfoVo 当前登录者的组织信息 |
|
|
* @param sysUserInfoVo 当前登录者的组织信息 |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
private CrmCustomerTemp saveCrmCustomerTemp(CrmCustomerTempDto dto, SysUserInfoVo sysUserInfoVo) { |
|
|
private CrmCustomerTemp saveCrmCustomerTemp(CrmCustomerTempDto dto, SysUserVo sysUserInfoVo) { |
|
|
CrmCustomerTemp crmCustomerTemp = new CrmCustomerTemp(); |
|
|
CrmCustomerTemp crmCustomerTemp = new CrmCustomerTemp(); |
|
|
dto.fillEntity(crmCustomerTemp); |
|
|
dto.fillEntity(crmCustomerTemp); |
|
|
crmCustomerTemp.setCreateBySid(dto.getUserSid()); |
|
|
crmCustomerTemp.setCreateBySid(dto.getUserSid()); |
|
|
crmCustomerTemp.setStaffSid(sysUserInfoVo.getStaffSid()); |
|
|
crmCustomerTemp.setStaffSid(sysUserInfoVo.getStaffSid()); |
|
|
String orgSid = sysStaffOrgFeign.getPathSidByUserSid(dto.getUserSid()).getData(); |
|
|
String orgSid = sysStaffOrgFeign.getPathSidByUserSid(dto.getUserSid()).getData(); |
|
|
// crmCustomerTemp.setCreateOrgSid(sysUserInfoVo.getOrgSid());
|
|
|
|
|
|
crmCustomerTemp.setCreateOrgSid(orgSid); |
|
|
crmCustomerTemp.setCreateOrgSid(orgSid); |
|
|
/*Map<String, String> map = genetrateCustomerNumO(dto.getCustomerTypeKey(), sysUserInfoVo); |
|
|
|
|
|
crmCustomerTemp.setCustomerNo(map.get("code"));*/ |
|
|
|
|
|
ResultBean resultBean = dictCommonFeign.getFirstDictKeyByType(DictCommonType.FOLLOW_STATE, "0"); |
|
|
ResultBean resultBean = dictCommonFeign.getFirstDictKeyByType(DictCommonType.FOLLOW_STATE, "0"); |
|
|
if (resultBean.getSuccess() && resultBean.getData() != null) { |
|
|
if (resultBean.getSuccess() && resultBean.getData() != null) { |
|
|
String key = resultBean.getData().toString(); |
|
|
String key = resultBean.getData().toString(); |
|
|
crmCustomerTemp.setFollow_state_key(key); |
|
|
crmCustomerTemp.setFollow_state_key(key); |
|
|
crmCustomerTemp.setFollow_state(dictCommonFeign.selectBykey(key, DictCommonType.FOLLOW_STATE).getData().getDictValue()); |
|
|
crmCustomerTemp.setFollow_state(dictCommonFeign.selectBykey(key, DictCommonType.FOLLOW_STATE).getData().getDictValue()); |
|
|
} |
|
|
} |
|
|
String customerNoPrefix = ""; |
|
|
|
|
|
//查询业务员的分公司简称和部门编码
|
|
|
|
|
|
ResultBean<SysStaffOrg> staffOrgResultBean = sysStaffOrgFeign.getOrgByStaffSid(sysUserInfoVo.getStaffSid()); |
|
|
|
|
|
if (staffOrgResultBean.getSuccess()) { |
|
|
|
|
|
SysStaffOrg sysStaffOrg = staffOrgResultBean.getData(); |
|
|
|
|
|
if (sysStaffOrg != null) { |
|
|
|
|
|
ResultBean<String> resultBean1 = sysStaffOrgFeign.getOrgSidByPath(sysStaffOrg.getOrgSidPath()); |
|
|
|
|
|
if (resultBean1.getSuccess()) { |
|
|
|
|
|
String osid = resultBean1.getData(); |
|
|
|
|
|
if (StringUtils.isNotBlank(osid)) { |
|
|
|
|
|
ResultBean<SysOrganizationVo> sysOrganizationVoResultBean = sysOrganizationFeign.fetchBySid(osid); |
|
|
|
|
|
if (sysOrganizationVoResultBean.getSuccess()) { |
|
|
|
|
|
SysOrganizationVo sysOrganizationVo = sysOrganizationVoResultBean.getData(); |
|
|
|
|
|
customerNoPrefix = customerNoPrefix + sysOrganizationVo.getOrgAbbre(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
String orgSid1 = sysStaffOrg.getOrgSid(); |
|
|
|
|
|
ResultBean<SysOrganizationVo> sysOrganizationVoResultBean = sysOrganizationFeign.fetchBySid(orgSid1); |
|
|
|
|
|
if (sysOrganizationVoResultBean.getSuccess()) { |
|
|
|
|
|
SysOrganizationVo sysOrganizationVo = sysOrganizationVoResultBean.getData(); |
|
|
|
|
|
customerNoPrefix = customerNoPrefix + sysOrganizationVo.getOrgCode(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//客户编码
|
|
|
//客户编码
|
|
|
String customerNo = getPrefix(crmCustomerTemp.getStaffSid(), crmCustomerTemp.getName(), crmCustomerTemp.getMobile()); |
|
|
String customerNo = getPrefix(crmCustomerTemp.getStaffSid(), crmCustomerTemp.getName(), crmCustomerTemp.getMobile()); |
|
|
crmCustomerTemp.setCustomerNo(customerNo); |
|
|
crmCustomerTemp.setCustomerNo(customerNo); |
|
@ -1055,55 +921,23 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
*/ |
|
|
*/ |
|
|
public ResultBean updateCrmCustomer(CrmCustomerTempUpdateDto dto, String sid) { |
|
|
public ResultBean updateCrmCustomer(CrmCustomerTempUpdateDto dto, String sid) { |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
//当前登录用户的sid
|
|
|
CrmCustomerTemp customerTemp = fetchBySid(sid); |
|
|
String userSid = dto.getUserSid(); |
|
|
if(customerTemp == null){ |
|
|
//根据登录用户sid查询该用户是否已设置部门
|
|
|
return rb.setMsg("该客户不存在"); |
|
|
ResultBean<SysUserInfoVo> sysUserInfoVoResultBean = sysUserFeign.selectUserInfoByUserSid(userSid); |
|
|
|
|
|
if (!sysUserInfoVoResultBean.getSuccess()) { |
|
|
|
|
|
return rb.setMsg(sysUserInfoVoResultBean.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
//用户所属组织信息
|
|
|
|
|
|
SysUserInfoVo sysUserInfoVo = sysUserInfoVoResultBean.getData(); |
|
|
|
|
|
if (StringUtils.isBlank(sysUserInfoVo.getOrgSid())) { |
|
|
|
|
|
return rb.setMsg("请先设置该员工所属部门"); |
|
|
|
|
|
} |
|
|
|
|
|
String staffSid = sysUserInfoVo.getStaffSid(); |
|
|
|
|
|
String mobile = dto.getMobile(); |
|
|
|
|
|
String weixin = dto.getWeixin(); |
|
|
|
|
|
if (StringUtils.isBlank(mobile) && StringUtils.isBlank(weixin)) { |
|
|
|
|
|
return rb.setMsg("联系电话和微信号二选一必填"); |
|
|
|
|
|
} |
|
|
} |
|
|
if (StringUtils.isNotBlank(mobile)) { |
|
|
//对比客户名称以及手机号是否变化
|
|
|
String customerNo = getPrefix(staffSid, dto.getName(), dto.getMobile()); |
|
|
if(!customerTemp.getName().equals(dto.getName())){ |
|
|
CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectNo1(customerNo, sid); |
|
|
return rb.setMsg("客户名称不允许修改"); |
|
|
// CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectByMobile(staffSid, mobile);
|
|
|
|
|
|
if (crmCustomerTempVo != null && !crmCustomerTempVo.getStaffSid().equals(sysUserInfoVo.getStaffSid())) { |
|
|
|
|
|
return rb.setMsg("该手机号已绑定其他客户,请重新添加"); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
//根据客户的微信号以及当前登录者所在部门的sid和登录者所关联的员工sid查询
|
|
|
|
|
|
CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectByWx(staffSid, weixin); |
|
|
|
|
|
if (crmCustomerTempVo != null && !crmCustomerTempVo.getStaffSid().equals(sysUserInfoVo.getStaffSid())) { |
|
|
|
|
|
return rb.setMsg("该微信号已绑定其他客户,请重新添加"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
CrmCustomerTemp customerTemp = fetchBySid(sid); |
|
|
if(!customerTemp.getMobile().equals(dto.getMobile())){ |
|
|
if (customerTemp == null) { |
|
|
return rb.setMsg("客户手机号不允许修改"); |
|
|
return rb.setMsg("该客户信息不存在"); |
|
|
|
|
|
} |
|
|
} |
|
|
BeanUtil.copyProperties(dto, customerTemp); |
|
|
BeanUtil.copyProperties(dto, customerTemp); |
|
|
//客户编码
|
|
|
|
|
|
String customerNoPrefix = ""; |
|
|
|
|
|
//查询业务员的分公司简称和部门简称
|
|
|
|
|
|
String customerNo = getPrefix(staffSid, dto.getName(), dto.getMobile()); |
|
|
|
|
|
// CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectNo(customerNo);
|
|
|
|
|
|
// String customerNo = customerNoPrefix + HanZiConverterPinYin.getPinYinFirst(customerTemp.getName()) + customerTemp.getMobile();
|
|
|
|
|
|
customerTemp.setCustomerNo(customerNo); |
|
|
|
|
|
baseMapper.updateById(customerTemp); |
|
|
baseMapper.updateById(customerTemp); |
|
|
//更新运营信息
|
|
|
//更新运营信息
|
|
|
CrmBusinessDto crmBusinessDto = dto.getCrmBusinessDto(); |
|
|
CrmBusinessDto crmBusinessDto = dto.getCrmBusinessDto(); |
|
|
crmBusinessService.updateByCusSid(crmBusinessDto, sid); |
|
|
crmBusinessService.updateByCusSid(crmBusinessDto, sid); |
|
|
return rb.success().setMsg("更新成功"); |
|
|
return rb.success(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|