Commit 9f013ba8 authored by hanfeng's avatar hanfeng

Merge branch 'master-customer-management' into dev

# Conflicts:
#	ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/AppUserRelationBiz.java
parents 57702f43 f6425a20
...@@ -54,26 +54,35 @@ public class AppStaffUserBiz extends BaseBiz<AppStaffUserMapper, AppStaffUser> { ...@@ -54,26 +54,35 @@ public class AppStaffUserBiz extends BaseBiz<AppStaffUserMapper, AppStaffUser> {
criteria.andEqualTo("isDel", 0); criteria.andEqualTo("isDel", 0);
if (appStaffUser.getId() != null) { if (appStaffUser.getId() != null) {
criteria.andEqualTo("id", appStaffUser.getId()); criteria.andEqualTo("id", appStaffUser.getId());
return mapper.selectOneByExample(example);
} }
if (appStaffUser.getPhone() != null) { if (appStaffUser.getPhone() != null) {
criteria.andEqualTo("phone", appStaffUser.getPhone()); criteria.andEqualTo("phone", appStaffUser.getPhone());
}
List<AppStaffUser> appStaffUsers = mapper.selectByExample(example); List<AppStaffUser> appStaffUsers = mapper.selectByExample(example);
if (CollectionUtil.isNotEmpty(appStaffUsers)) { if (CollectionUtil.isNotEmpty(appStaffUsers)) {
AppStaffUser staffUser = appStaffUsers.get(0); AppStaffUser staffUser = appStaffUsers.get(0);
AppStaffUserVo appStaffUserVo = new AppStaffUserVo(); AppStaffUserVo appStaffUserVo = new AppStaffUserVo();
BeanUtils.copyProperties(staffUser, appStaffUserVo); BeanUtils.copyProperties(staffUser, appStaffUserVo);
Integer suId = staffUser.getSuId(); Integer suId = staffUser.getSuId();
AppUserVo userInfoById = appUserDetailBiz.getUserInfoById(suId); //上级员工信息
appStaffUserVo.setEmployeeName(userInfoById.getRealname()); if (suId!=null||suId!=0||appStaffUser.getPhone()!=null){
appStaffUserVo.setEmployeePhone(userInfoById.getUsername()); AppUserVo spuser = appUserDetailBiz.getUserInfoById(suId);
return appStaffUserVo; appStaffUserVo.setEmployeeName(spuser.getRealname());
appStaffUserVo.setEmployeePhone(spuser.getUsername());
} }
//客户信息
Integer uid = staffUser.getUid();
if (uid!=null||uid!=0){
AppUserVo user = appUserDetailBiz.getUserInfoById(uid);
appStaffUserVo.setUName(StringUtil.isEmpty(user.getRealname())?user.getNickname():user.getRealname());
appStaffUserVo.setPhone(user.getUsername());
} }
return null;
return appStaffUserVo;
}
return null;
} }
public boolean select(AppStaffUser appStaffUser) { public boolean select(AppStaffUser appStaffUser) {
...@@ -115,9 +124,6 @@ public class AppStaffUserBiz extends BaseBiz<AppStaffUserMapper, AppStaffUser> { ...@@ -115,9 +124,6 @@ public class AppStaffUserBiz extends BaseBiz<AppStaffUserMapper, AppStaffUser> {
appStaffUser.setPhone(userInfoById.getUsername()); appStaffUser.setPhone(userInfoById.getUsername());
appStaffUser.setStatus(1); appStaffUser.setStatus(1);
if (POSITION_ID.equals(staffUserDTO.getPositionId())) {
throw new BaseException("绑定的是员工");
}
if (select(appStaffUser)) { if (select(appStaffUser)) {
insertSelective(appStaffUser); insertSelective(appStaffUser);
}else { }else {
......
...@@ -67,45 +67,47 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe ...@@ -67,45 +67,47 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
* @param userId * @param userId
* @param parentId * @param parentId
*/ */
public void bindRelation(Integer userId, Integer parentId, Integer type) { public void bindRelation(Integer userId,Integer parentId,Integer type){
if (userId.equals(parentId)) { try {
log.info("----userId===" + userId + "----parentId====" + parentId + "----自己不能成为自己的上线"); if (userId.equals(parentId)){
log.info("----userId==="+userId+"----parentId===="+parentId+"----自己不能成为自己的上线");
return; return;
} }
/* AppUserVo appUserVo=userDetailBiz.getUserInfoById(userId); /* AppUserVo appUserVo=userDetailBiz.getUserInfoById(userId);
if (appUserVo==null){ if (appUserVo==null){
log.info("----userId==="+userId+"----parentId===="+parentId+"----该用户不存在"); log.info("----userId==="+userId+"----parentId===="+parentId+"----该用户不存在");
return; return;
}*/ }*/
AppUserVo appUserVo = userDetailBiz.getUserInfoById(parentId); AppUserVo appUserVo=userDetailBiz.getUserInfoById(parentId);
if (appUserVo == null) { if (appUserVo==null){
log.info("----userId===" + userId + "----parentId====" + parentId + "----该上线用户不存在"); log.info("----userId==="+userId+"----parentId===="+parentId+"----该上线用户不存在");
return; return;
} }
AppUserRelation relation = getMyBiz().getRelationByUserId(parentId); AppUserRelation relation=getMyBiz().getRelationByUserId(parentId);
Long time = System.currentTimeMillis(); Long time=System.currentTimeMillis();
if (relation == null) { if(relation==null){
relation = new AppUserRelation(); relation=new AppUserRelation();
relation.setUserId(parentId); relation.setUserId(parentId);
relation.setBindType(type); relation.setBindType(type);
insertSelective(relation); insertSelective(relation);
} }
Long bindTime = time - validTime; Long bindTime=time-validTime;
//判断用户是否有有效的下线 //判断用户是否有有效的下线
if (getCountByParentId(userId, bindTime) == 0L) { if (getCountByParentId(userId,bindTime)==0L){
relation = getMyBiz().getRelationByUserId(userId); relation=getMyBiz().getRelationByUserId(userId);
if (relation == null) { if(relation==null){
relation = new AppUserRelation(); relation=new AppUserRelation();
relation.setUserId(userId); relation.setUserId(userId);
relation.setParentId(parentId); relation.setParentId(parentId);
relation.setBindType(type); relation.setBindType(type);
relation.setBindTime(time); relation.setBindTime(time);
insertSelective(relation); insertSelective(relation);
} else { }else {
//判断用户是否有有效的上线 //判断用户是否有有效的上线
log.info("----userId===" + userId + "----bindTime====" + bindTime + "----relation.getBindTime()===" + relation.getBindTime()); log.info("----userId==="+userId+"----bindTime===="+bindTime+"----relation.getBindTime()==="+relation.getBindTime());
if (relation.getParentId() == null || relation.getParentId() == 0 || (relation.getIsForever() != 1 && validTime > 0 && relation.getBindTime() < bindTime)) { if(relation.getParentId()==null||relation.getParentId()==0||(relation.getIsForever()!=1&&validTime>0&&relation.getBindTime()<bindTime)){
relation.setParentId(parentId); relation.setParentId(parentId);
relation.setBindType(type); relation.setBindType(type);
relation.setBindTime(time); relation.setBindTime(time);
...@@ -119,6 +121,10 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe ...@@ -119,6 +121,10 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
staffUserBiz.addAppStaffUser(staffUserDTO); staffUserBiz.addAppStaffUser(staffUserDTO);
} }
} }
}catch (Exception e){
log.info("网络异常===" + e.getMessage());
}
} }
//首页关系绑定 //首页关系绑定
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment