Browse Source

客户逻辑修改

master
dimengzhe 2 years ago
parent
commit
7a4b52e7a1
  1. 5
      anrui-base/anrui-base-biz/src/main/java/com/yxt/anrui/base/biz/commoncontract/CommonContractService.java
  2. 2
      anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorder/app/order/AppOrderTopInfoVo.java
  3. 7
      anrui-crm/anrui-crm-biz/src/main/java/com/yxt/anrui/crm/biz/crmcustomertemp/CrmCustomerTempMapper.java
  4. 4
      anrui-crm/anrui-crm-biz/src/main/java/com/yxt/anrui/crm/biz/crmcustomertemp/CrmCustomerTempMapper.xml
  5. 364
      anrui-crm/anrui-crm-biz/src/main/java/com/yxt/anrui/crm/biz/crmcustomertemp/CrmCustomerTempService.java

5
anrui-base/anrui-base-biz/src/main/java/com/yxt/anrui/base/biz/commoncontract/CommonContractService.java

@ -1756,7 +1756,10 @@ public class CommonContractService extends MybatisBaseService<CommonContractMapp
AppOrderTopInfoVo topInfo = appOrderDetailsVo.getTopInfo();
String topName = appOrderDetailsVo.getTopMessage();
topName = "上装:" + topName + "。";
map.put("topName", topName);
//只有为公司采购时才显示
if("01".equals(topInfo.getBuyTypeKey())){
map.put("topName", topName);
}
}
AppOrderPriceInfoVo priceInfo = appOrderDetailsVo.getPriceInfo();
//查询台数

2
anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorder/app/order/AppOrderTopInfoVo.java

@ -32,4 +32,6 @@ public class AppOrderTopInfoVo implements Vo {
private String topName;
@JsonIgnore
private String remarks;
@ApiModelProperty("01公司采购02客户自购")
private String buyTypeKey;
}

7
anrui-crm/anrui-crm-biz/src/main/java/com/yxt/anrui/crm/biz/crmcustomertemp/CrmCustomerTempMapper.java

@ -129,4 +129,11 @@ public interface CrmCustomerTempMapper extends BaseMapper<CrmCustomerTemp> {
int updateEmail(@Param("sid") String sid, @Param("email") String email);
int updateRemarks(@Param("sid") String sid, @Param("remarks") String remarks);
/**
* 根据客户编码查询客户信息
* @param customerNo 客户编码
* @return
*/
CrmCustomerTemp selectByCustomerNo(String customerNo);
}

4
anrui-crm/anrui-crm-biz/src/main/java/com/yxt/anrui/crm/biz/crmcustomertemp/CrmCustomerTempMapper.xml

@ -231,4 +231,8 @@
<update id="updateRemarks">
update crm_customer_temp set remarks = #{remarks} where sid = #{sid}
</update>
<select id="selectByCustomerNo" resultType="com.yxt.anrui.crm.api.crmcustomertemp.CrmCustomerTemp">
select * from crm_customer_temp where customerNo = #{customerNo}
</select>
</mapper>

364
anrui-crm/anrui-crm-biz/src/main/java/com/yxt/anrui/crm/biz/crmcustomertemp/CrmCustomerTempService.java

@ -270,83 +270,66 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa
* 513该微信号的客户已是当前用户的客户
*/
public ResultBean saveOrUpdateAppCustomerTemp(AppCrmCustomerTempDto dto) {
AppUserOrgInfoVo userOrgInfoVo = sysUserFeign.getUserOrgInfoByUserSid(dto.getUserSid()).getData();
if (StringUtils.isBlank(userOrgInfoVo.getOrgSid())) {
return new ResultBean().fail().setMsg("请先设置该员工所属部门");
ResultBean rb = ResultBean.fireFail();
/**
* 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<>();
map.put("staffSid", userOrgInfoVo.getStaffSid());
if (StringUtils.isBlank(dto.getSid())) { // 新增
if (StringUtils.isNotBlank(dto.getMobile())) { // 有手机号
//查询业务员的分公司简称和部门简称
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())) {
// 返回潜在客户sid,跳转维护信息页面
return new ResultBean().fail().setCode(HttpStatusEnum.CRM_ERROR_EXIST.getCode()).setMsg(HttpStatusEnum.CRM_ERROR_EXIST.getMsg()).setData(customerTempVo.getSid());
} else {
// 不是当前用户的客户,提示
SysUserVo userVo = sysUserFeign.selectByStaffsid(customerTempVo.getStaffSid()).getData();
return new ResultBean().fail().setCode(HttpStatusEnum.CRM_ERROR_NOTBELONG.getCode()).setMsg("该手机号客户为" + userVo.getName()
+ "的客户,如需更改,请联系" + userVo.getName());
String sid = dto.getSid();
//业务员sid
String staffSid = sysUserVo.getStaffSid();
//姓名
String name = dto.getName();
String mobile = dto.getMobile();
if(StringUtils.isBlank(sid)){//新增
//生成客户编码:分公司简称+部门编码+手机号+姓名首字母大写拼写
String customerNo = getPrefix(staffSid,name,mobile);
//查询该客户编码是否存在
CrmCustomerTemp crmCustomerTemp = baseMapper.selectByCustomerNo(customerNo);
if(crmCustomerTemp != null){//存在
//查询是否是当前用户客户
if(!dto.getUserSid().equals(crmCustomerTemp.getCreateBySid())){
String staffName = "";
SysUserVo sysCrmVo = sysUserFeign.fetchBySid(crmCustomerTemp.getCreateBySid()).getData();
if(sysCrmVo != null){
staffName = sysCrmVo.getName();
return rb.setCode(HttpStatusEnum.CRM_ERROR_NOTBELONG.getCode()).setMsg("为"+staffName+"销售专员客户");
}
} else {
// 新增
CrmCustomerTemp customerTemp = insertCrmCustomerTemp(dto, userOrgInfoVo);
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{
// 返回潜在客户sid,跳转维护信息页面
return rb.setCode(HttpStatusEnum.CRM_ERROR_EXIST.getCode()).setMsg(HttpStatusEnum.CRM_ERROR_EXIST.getMsg()).setData(crmCustomerTemp.getSid());
}
}else{//不存在
// 新增
CrmCustomerTemp customerTemp = insertCrmCustomerTemp(dto, sysUserVo);
sid = customerTemp.getSid();
}
} else { // 修改
if (StringUtils.isNotBlank(dto.getMobile())) {
//查询业务员的分公司简称和部门简称
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("该手机号已绑定其它客户,请重新添加");
}
}*/
}else{//修改
CrmCustomerTemp customerTemp = fetchBySid(sid);
if(customerTemp == null){
return rb.setMsg("该客户不存在");
}
//对比客户名称以及手机号是否变化
if(!customerTemp.getName().equals(dto.getName())){
return rb.setMsg("客户名称不允许修改");
}
if(!customerTemp.getMobile().equals(dto.getMobile())){
return rb.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);
String adCode = dto.getAdCode();
if (StringUtils.isNotBlank(adCode)) {
@ -358,46 +341,12 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa
customerTemp.setCustomerPhoto(customerTemp.getCustomerPhoto().replace(fileUploadComponent.getUrlPrefix(), ""));
}
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);
if (updateBoolean) {
// 更新附件表
// if (!dto.getFilePaths().isEmpty()) {
// updateCrmFile(dto, customerTemp);
// }
return new ResultBean().success().setMsg("更新成功").setData(customerTemp.getSid());
} else {
return new ResultBean().fail().setMsg("更新失败");
if (!updateBoolean) {
return rb.fail().setMsg("更新失败");
}
}
return rb.success().setData(sid);
}
/**
@ -708,7 +657,7 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa
* @return
*/
@Transactional(rollbackFor = Exception.class)
protected CrmCustomerTemp insertCrmCustomerTemp(AppCrmCustomerTempDto dto, AppUserOrgInfoVo userOrgInfoVo) {
protected CrmCustomerTemp insertCrmCustomerTemp(AppCrmCustomerTempDto dto, SysUserVo userOrgInfoVo) {
CrmCustomerTemp customerTemp = new CrmCustomerTemp();
String orgPath = dto.getOrgPath();
String useOrgSid = "";
@ -723,13 +672,8 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa
if (StringUtils.isNotBlank(customerTemp.getCustomerPhoto())) {
customerTemp.setCustomerPhoto(customerTemp.getCustomerPhoto().replace(fileUploadComponent.getUrlPrefix(), ""));
}
// Map<String, String> map = genetrateCustomerNum(dto.getCustomerTypeKey(), userOrgInfoVo);
customerTemp.setCreateBySid(dto.getUserSid());
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.setCertificateType(customerTemp.getCustomerTypeKey().equals("1") ? "身份证" : "营业执照");
ResultBean resultBean = dictCommonFeign.getFirstDictKeyByType(DictCommonType.FOLLOW_STATE, "0");
@ -750,34 +694,7 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa
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 = customerNoPrefix + HanZiConverterPinYin.getPinYinFirst(customerTemp.getName()) + customerTemp.getMobile();
customerTemp.setCustomerNo(customerNo);
save(customerTemp);
// 增加跟进记录
@ -839,27 +756,13 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa
*/
public ResultBean saveCrmCustomer(CrmCustomerTempDto dto) {
ResultBean rb = ResultBean.fireFail();
//当前登录用户的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 sid = "";
//手机号
String mobile = dto.getMobile();
//微信号
String weixin = dto.getWeixin();
if (StringUtils.isBlank(mobile)) {
return rb.setMsg("请输入联系电话");
}
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("手机号格式不正确");
}
if (StringUtils.isNotBlank(dto.getIDNumber())) {
@ -891,46 +794,37 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa
return rb.setMsg("紧急联系电话格式不正确");
}
}
//当前登录用户的所在部门sid
String staffSid = sysUserInfoVo.getStaffSid();
//根据客户的手机号以及当前登录者所在部门的sid查询该部门内是否有重复的
if (StringUtils.isNotBlank(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);
return rb.success().setData(crmCustomerTemp.getSid());
} else {
//是否为当前用户的客户
if (crmCustomerTempVo.getStaffSid().equals(sysUserInfoVo.getStaffSid())) {
return rb.setCode(HttpStatusEnum.CRM_ERROR_EXIST.getCode()).setMsg(HttpStatusEnum.CRM_ERROR_EXIST.getMsg()).setData(crmCustomerTempVo.getSid());
} else {
//不是当前用户的客户,提示信息。
ResultBean<SysUserVo> sysUserVoResultBean = sysUserFeign.selectByStaffsid(crmCustomerTempVo.getStaffSid());
if (sysUserVoResultBean.getSuccess()) {
return rb.setMsg("该手机号客户为" + sysUserVoResultBean.getData().getName() + "的客户,如需更改,请联系" + sysUserVoResultBean.getData().getName());
} else {
return rb.setMsg(sysUserInfoVoResultBean.getMsg());
}
//根据用户sid获取业务员信息
SysUserVo sysUserVo = sysUserFeign.fetchBySid(dto.getUserSid()).getData();
if(sysUserVo == null){
return rb.setMsg("该用户不存在");
}
String staffSid = sysUserVo.getStaffSid();
String name = dto.getName();
//生成客户编码:分公司简称+部门编码+手机号+姓名首字母大写拼写
String customerNo = getPrefix(staffSid,name,mobile);
//查询该客户编码是否存在
CrmCustomerTemp crmCustomerTemp = baseMapper.selectByCustomerNo(customerNo);
if(crmCustomerTemp != null){//存在
//查询是否是当前用户客户
if(!dto.getUserSid().equals(crmCustomerTemp.getCreateBySid())){
String staffName = "";
SysUserVo sysCrmVo = sysUserFeign.fetchBySid(crmCustomerTemp.getCreateBySid()).getData();
if(sysCrmVo != null){
staffName = sysCrmVo.getName();
return rb.setCode(HttpStatusEnum.CRM_ERROR_NOTBELONG.getCode()).setMsg("为"+staffName+"销售专员客户");
}
}
} else if (StringUtils.isNotBlank(weixin)) {
// 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{
// 返回潜在客户sid,跳转维护信息页面
return rb.setCode(HttpStatusEnum.CRM_ERROR_EXIST.getCode()).setMsg(HttpStatusEnum.CRM_ERROR_EXIST.getMsg()).setData(crmCustomerTemp.getSid());
}
}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 当前登录者的组织信息
* @return
*/
private CrmCustomerTemp saveCrmCustomerTemp(CrmCustomerTempDto dto, SysUserInfoVo sysUserInfoVo) {
private CrmCustomerTemp saveCrmCustomerTemp(CrmCustomerTempDto dto, SysUserVo sysUserInfoVo) {
CrmCustomerTemp crmCustomerTemp = new CrmCustomerTemp();
dto.fillEntity(crmCustomerTemp);
crmCustomerTemp.setCreateBySid(dto.getUserSid());
crmCustomerTemp.setStaffSid(sysUserInfoVo.getStaffSid());
String orgSid = sysStaffOrgFeign.getPathSidByUserSid(dto.getUserSid()).getData();
// crmCustomerTemp.setCreateOrgSid(sysUserInfoVo.getOrgSid());
crmCustomerTemp.setCreateOrgSid(orgSid);
/*Map<String, String> map = genetrateCustomerNumO(dto.getCustomerTypeKey(), sysUserInfoVo);
crmCustomerTemp.setCustomerNo(map.get("code"));*/
ResultBean resultBean = dictCommonFeign.getFirstDictKeyByType(DictCommonType.FOLLOW_STATE, "0");
if (resultBean.getSuccess() && resultBean.getData() != null) {
String key = resultBean.getData().toString();
crmCustomerTemp.setFollow_state_key(key);
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());
crmCustomerTemp.setCustomerNo(customerNo);
@ -1055,55 +921,23 @@ public class CrmCustomerTempService extends MybatisBaseService<CrmCustomerTempMa
*/
public ResultBean updateCrmCustomer(CrmCustomerTempUpdateDto dto, String sid) {
ResultBean rb = ResultBean.fireFail();
//当前登录用户的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 staffSid = sysUserInfoVo.getStaffSid();
String mobile = dto.getMobile();
String weixin = dto.getWeixin();
if (StringUtils.isBlank(mobile) && StringUtils.isBlank(weixin)) {
return rb.setMsg("联系电话和微信号二选一必填");
CrmCustomerTemp customerTemp = fetchBySid(sid);
if(customerTemp == null){
return rb.setMsg("该客户不存在");
}
if (StringUtils.isNotBlank(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("该手机号已绑定其他客户,请重新添加");
}
} else {
//根据客户的微信号以及当前登录者所在部门的sid和登录者所关联的员工sid查询
CrmCustomerTempVo crmCustomerTempVo = baseMapper.selectByWx(staffSid, weixin);
if (crmCustomerTempVo != null && !crmCustomerTempVo.getStaffSid().equals(sysUserInfoVo.getStaffSid())) {
return rb.setMsg("该微信号已绑定其他客户,请重新添加");
}
//对比客户名称以及手机号是否变化
if(!customerTemp.getName().equals(dto.getName())){
return rb.setMsg("客户名称不允许修改");
}
CrmCustomerTemp customerTemp = fetchBySid(sid);
if (customerTemp == null) {
return rb.setMsg("该客户信息不存在");
if(!customerTemp.getMobile().equals(dto.getMobile())){
return rb.setMsg("客户手机号不允许修改");
}
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);
//更新运营信息
CrmBusinessDto crmBusinessDto = dto.getCrmBusinessDto();
crmBusinessService.updateByCusSid(crmBusinessDto, sid);
return rb.success().setMsg("更新成功");
return rb.success();
}
/**

Loading…
Cancel
Save