|
|
@ -236,8 +236,11 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
map.put("staffSid", userOrgInfoVo.getStaffSid()); |
|
|
|
if (StringUtils.isBlank(dto.getSid())) { // 新增
|
|
|
|
if (StringUtils.isNotBlank(dto.getMobile())) { // 有手机号
|
|
|
|
map.put("mobile", dto.getMobile()); |
|
|
|
CrmCustomerTempVo customerTempVo = baseMapper.selectByMobileOrWx(map); |
|
|
|
//查询业务员的分公司简称和部门简称
|
|
|
|
String customerNo = getPrefix(userOrgInfoVo.getStaffSid(), dto.getName(), dto.getMobile()); |
|
|
|
CrmCustomerTempVo customerTempVo = baseMapper.selectNo(customerNo); |
|
|
|
// map.put("mobile", dto.getMobile());
|
|
|
|
// CrmCustomerTempVo customerTempVo = baseMapper.selectByMobileOrWx(map);
|
|
|
|
if (customerTempVo != null) { |
|
|
|
// 是否为当前用户的客户
|
|
|
|
if (customerTempVo.getStaffSid().equals(userOrgInfoVo.getStaffSid())) { |
|
|
@ -267,14 +270,20 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
} |
|
|
|
} else { // 修改
|
|
|
|
if (StringUtils.isNotBlank(dto.getMobile())) { |
|
|
|
AppCrmCustomerTempInfoVo appCrmCustomerTempInfoVo = baseMapper.selectBySid(dto.getSid()); |
|
|
|
//查询业务员的分公司简称和部门简称
|
|
|
|
String customerNo = getPrefix(userOrgInfoVo.getStaffSid(), dto.getName(), dto.getMobile()); |
|
|
|
CrmCustomerTempVo customerTempVo = baseMapper.selectNo1(customerNo,dto.getSid()); |
|
|
|
if(customerTempVo != null){ |
|
|
|
return new ResultBean().fail().setMsg("该手机号已绑定其它客户,请重新添加"); |
|
|
|
} |
|
|
|
/* AppCrmCustomerTempInfoVo appCrmCustomerTempInfoVo = baseMapper.selectBySid(dto.getSid()); |
|
|
|
String mobile = appCrmCustomerTempInfoVo.getMobile(); |
|
|
|
if (!mobile.equals(dto.getMobile())) { |
|
|
|
int count = baseMapper.selBySidAndMobile(dto.getSid(), dto.getMobile()); |
|
|
|
if (count > 0) { |
|
|
|
return new ResultBean().fail().setMsg("该手机号已绑定其它客户,请重新添加"); |
|
|
|
} |
|
|
|
} |
|
|
|
}*/ |
|
|
|
} |
|
|
|
// if (StringUtils.isNotBlank(dto.getWeixin())) {
|
|
|
|
// AppCrmCustomerTempInfoVo appCrmCustomerTempInfoVo = baseMapper.selectBySid(dto.getSid());
|
|
|
@ -832,7 +841,10 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
String staffSid = sysUserInfoVo.getStaffSid(); |
|
|
|
//根据客户的手机号以及当前登录者所在部门的sid查询该部门内是否有重复的
|
|
|
|
if (StringUtils.isNotBlank(mobile)) { |
|
|
|
CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectByMobile(staffSid, mobile); |
|
|
|
//客户编码
|
|
|
|
String customerNo = getPrefix(staffSid, dto.getName(), dto.getMobile()); |
|
|
|
CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectNo(customerNo); |
|
|
|
// CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectByMobile(staffSid, mobile);
|
|
|
|
if (crmCustomerTempVo == null) { |
|
|
|
//新增潜在客户信息
|
|
|
|
CrmCustomerTemp crmCustomerTemp = saveCrmCustomerTemp(dto, sysUserInfoVo); |
|
|
@ -891,7 +903,7 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
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(); |
|
|
@ -916,7 +928,7 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
} |
|
|
|
} |
|
|
|
//客户编码
|
|
|
|
String customerNo = customerNoPrefix + HanZiConverterPinYin.getPinYinFirst(crmCustomerTemp.getName()) + crmCustomerTemp.getMobile(); |
|
|
|
String customerNo = getPrefix(crmCustomerTemp.getStaffSid(), crmCustomerTemp.getName(), crmCustomerTemp.getMobile()); |
|
|
|
crmCustomerTemp.setCustomerNo(customerNo); |
|
|
|
save(crmCustomerTemp); |
|
|
|
// 增加跟进记录
|
|
|
@ -939,6 +951,36 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public String getPrefix(String staffSid, String name, String mobile) { |
|
|
|
String customerNoPrefix = ""; |
|
|
|
//查询业务员的分公司简称和部门编码
|
|
|
|
ResultBean<SysStaffOrg> staffOrgResultBean = sysStaffOrgFeign.getOrgByStaffSid(staffSid); |
|
|
|
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(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
customerNoPrefix = customerNoPrefix + HanZiConverterPinYin.getPinYinFirst(name) + mobile; |
|
|
|
return customerNoPrefix; |
|
|
|
} |
|
|
|
|
|
|
|
private Map<String, String> genetrateCustomerNumO(String customerTypeKey, SysUserInfoVo sysUserInfoVo) { |
|
|
|
// 流水号
|
|
|
|
int i = selectCountByOrgSid(sysUserInfoVo.getOrgCode()); |
|
|
@ -977,7 +1019,9 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
return rb.setMsg("联系电话和微信号二选一必填"); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(mobile)) { |
|
|
|
CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectByMobile(staffSid, mobile); |
|
|
|
String customerNo = getPrefix(staffSid, dto.getName(), dto.getMobile()); |
|
|
|
CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectNo1(customerNo,sid); |
|
|
|
// CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectByMobile(staffSid, mobile);
|
|
|
|
if (crmCustomerTempVo != null && !crmCustomerTempVo.getStaffSid().equals(sysUserInfoVo.getStaffSid())) { |
|
|
|
return rb.setMsg("该手机号已绑定其他客户,请重新添加"); |
|
|
|
} |
|
|
@ -996,30 +1040,9 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa |
|
|
|
//客户编码
|
|
|
|
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 = customerNoPrefix + HanZiConverterPinYin.getPinYinFirst(customerTemp.getName()) + customerTemp.getMobile(); |
|
|
|
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); |
|
|
|
//更新运营信息
|
|
|
|