Commit 483c3376 authored by hezhen's avatar hezhen

修改后台录入会员

parent 024eb36f
...@@ -178,6 +178,57 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe ...@@ -178,6 +178,57 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
} }
public void bindRelationV2(Integer userId,Integer parentId,Integer type){
if (userId.equals(parentId)){
log.info("----userId==="+userId+"----parentId===="+parentId+"----自己不能成为自己的上线");
throw new BaseException("自己不能成为自己的上线",ResultCode.FAILED_CODE);
}
AppUserVo appUserVo=userDetailBiz.getUserInfoById(parentId);
if (appUserVo==null){
log.info("----userId==="+userId+"----parentId===="+parentId+"----");
throw new BaseException("该上线用户不存在",ResultCode.FAILED_CODE);
}
AppUserRelation relation=getMyBiz().getRelationByUserId(parentId);
Long time=System.currentTimeMillis();
if(relation==null){
relation=new AppUserRelation();
relation.setUserId(parentId);
relation.setBindType(type);
insertSelective(relation);
}
Long bindTime=time-validTime;
//判断用户是否有有效的下线
if (getCountByParentId(userId,bindTime)==0L){
relation=getMyBiz().getRelationByUserId(userId);
if(relation==null){
relation=new AppUserRelation();
relation.setUserId(userId);
relation.setParentId(parentId);
relation.setBindType(type);
relation.setBindTime(time);
insertSelective(relation);
}else {
//判断用户是否有有效的上线
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)){
relation.setParentId(parentId);
relation.setBindType(type);
relation.setBindTime(time);
getMyBiz().updRelation(relation);
}
}
if (relation != null){
AppStaffUserDTO staffUserDTO=new AppStaffUserDTO();
staffUserDTO.setSuId(relation.getParentId());
staffUserDTO.setUid(relation.getUserId());
staffUserBiz.addAppStaffUser(staffUserDTO);
}
}else {
throw new BaseException("该用户已有下线无法成为别人下线",ResultCode.FAILED_CODE);
}
}
//首页关系绑定 //首页关系绑定
public ObjectRestResponse appBindRelation(Integer userId, String code) { public ObjectRestResponse appBindRelation(Integer userId, String code) {
Integer parentId = 0; Integer parentId = 0;
...@@ -207,7 +258,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe ...@@ -207,7 +258,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "该上级不存在"); return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "该上级不存在");
} }
Integer parentId = userLogin.getId(); Integer parentId = userLogin.getId();
getMyBiz().bindRelation(userId, parentId, 1); bindRelationV2(userId, parentId, 1);
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
......
...@@ -17,12 +17,7 @@ public class AdminUserRelationController extends BaseController<AppUserRelationB ...@@ -17,12 +17,7 @@ public class AdminUserRelationController extends BaseController<AppUserRelationB
@RequestMapping(value = "/bind",method = RequestMethod.POST) @RequestMapping(value = "/bind",method = RequestMethod.POST)
@ApiModelProperty("后台绑定") @ApiModelProperty("后台绑定")
public ObjectRestResponse bind(@RequestBody UserRelationDTO relationDTO){ public ObjectRestResponse bind(@RequestBody UserRelationDTO relationDTO){
try {
return baseBiz.adminBindRelation(relationDTO); return baseBiz.adminBindRelation(relationDTO);
} catch (Exception e) {
e.printStackTrace();
throw new BaseException(e);
}
} }
......
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