Commit 7bf449e9 authored by hezhen's avatar hezhen

添加code

parent 63c74fec
......@@ -73,5 +73,5 @@ public class AppUserDetail {
@ApiModelProperty(value = "邀请人账号:")
@Column(name = "inviter_account")
private String inviterAccount;
private Integer inviterAccount;
}
......@@ -53,6 +53,22 @@ public class AppUserDetailBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail
return null;
}
/**
* 根据用户id获取父id
*
* @param code
* @return
*/
public Integer getUserByCode(String code) {
Example example = new Example(AppUserDetail.class);
example.createCriteria().andEqualTo("code", code).andEqualTo("isdel", 0);
List<AppUserDetail> list = mapper.selectByExample(example);
if (list != null && list.size() != 0) {
return list.get(0).getUserid();
}
return 0;
}
/**
* 获取用户信息
*
......
......@@ -37,7 +37,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
* @param userId
* @param parentId
*/
public void bindRelation(Integer userId,Integer parentId){
public void bindRelation(Integer userId,Integer parentId,Integer type){
AppUserRelation relation=getMyBiz().getRelationByUserId(parentId);
if(relation==null){
relation=new AppUserRelation();
......@@ -50,13 +50,13 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
relation=new AppUserRelation();
relation.setUserId(userId);
relation.setParentId(parentId);
relation.setBindType(2);
relation.setBindType(type);
relation.setBindTime(time);
insertSelective(relation);
}else {
if(relation.getParentId()==null||relation.getParentId()==0||(relation.getIsForever()!=1&&(time-relation.getBindTime())>3600)){
relation.setParentId(parentId);
relation.setBindType(2);
relation.setBindType(type);
relation.setBindTime(time);
getMyBiz().updRelation(relation);
}
......@@ -80,7 +80,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
if(userVo==null){
upRelationTemp(pid,userid);
}else {
bindRelation(platform_userid,pid);
bindRelation(platform_userid,pid,2);
}
}
return ObjectRestResponse.succ();
......@@ -125,7 +125,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
return;
}
Integer parentId=relationTemp.getUserId();
bindRelation(platform_userid,parentId);
bindRelation(platform_userid,parentId,2);
}
......
......@@ -84,12 +84,13 @@ public class AppUserRest {
JSONObject register(
@RequestParam(value="username",defaultValue="")String username,
@RequestParam(value="mobilecode",defaultValue="")String mobilecode,
@RequestParam(value="password",defaultValue="")String password
@RequestParam(value="password",defaultValue="")String password,
@RequestParam(value="code",defaultValue="")String code
){
//默认昵称
String nickname=SystemConfig.USER_NIKENAME_DEFAULT+(int)((Math.random()*9+1)*100000);
return appPermissionService.register(username, password, SystemConfig.USER_HEADER_URL_DEFAULT,nickname,
mobilecode, null, null,0);
mobilecode, null, null,0,code);
}
......@@ -116,7 +117,8 @@ public class AppUserRest {
@RequestParam(value="openid",defaultValue="")String openid,
@RequestParam(value="unionid",defaultValue="")String unionid,
@RequestParam(value="type",defaultValue="0")Integer type,
@RequestParam(value="isQQ",defaultValue="0")Integer isQQ
@RequestParam(value="isQQ",defaultValue="0")Integer isQQ,
@RequestParam(value="code",defaultValue="")String code
){
if(StringUtils.isBlank(headimgurl)){
headimgurl=SystemConfig.USER_HEADER_URL_DEFAULT;
......@@ -124,7 +126,7 @@ public class AppUserRest {
if(StringUtils.isBlank(nickname)){
nickname=SystemConfig.USER_NIKENAME_DEFAULT+(int)((Math.random()*9+1)*100000);
}
return appPermissionService.weCahtRegister(username,password,openid, unionid,nickname,headimgurl,type,mobilecode,isQQ);
return appPermissionService.weCahtRegister(username,password,openid, unionid,nickname,headimgurl,type,mobilecode,isQQ,code);
}
/**
* 手机号码检测是否已绑定
......
......@@ -204,7 +204,7 @@ public class AppPermissionService {
*/
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public JSONObject register(String username, String password, String headimgurl,
String nickname, String mobilecode, String openId, String unionid, Integer type) {
String nickname, String mobilecode, String openId, String unionid, Integer type,String code) {
// 判断参数和验证码
if (StringUtils.isBlank(username) || StringUtils.isBlank(password) || StringUtils.isBlank(mobilecode)) {
return JsonResultUtil.createFailedResult(ResultCode.NULL_CODE, "参数为空");
......@@ -257,12 +257,22 @@ public class AppPermissionService {
rsUserDetail.setIsdel(0);
rsUserDetail.setCrtHost(getIp());
setCreateIPInfo(rsUserDetail);
//邀请人id关系绑定
Integer parentId=0;
if (StringUtils.isNotBlank(code)){
parentId=appUserDetailBiz.getUserByCode(code);
}
if(parentId!=null&&parentId>0){
rsUserDetail.setInviterAccount(parentId);
}
//生成邀请码 长度改为8 不然重复率太高
rsUserDetail.setCode(UUIDUtils.genCodes(8));
appUserDetailBiz.insertSelective(rsUserDetail);
log.error("注册:新增用户详情: " + userid);
//临时会员绑定
insertUserMemberByUserIdAndPhone(userid, username);
//绑定上下线关系
if(parentId!=null&&parentId>0){
relationBiz.bindRelation(userid,parentId,1);
}
//参加新人活动
jionActivity(userid);
//创建钱包
......@@ -324,6 +334,7 @@ public class AppPermissionService {
data.put("username", StringUtils.isNotEmpty(username) ? username : userVo.getUsername());
data.put("userId", userid);
data.put("imUserId", userVo.getImUserid());
data.put("code", userVo.getCode());
//更新登录时间 和 ip
String clientIp = getIp();
appUserLoginBiz.updateLoginInfo(userid, clientIp);
......@@ -353,7 +364,7 @@ public class AppPermissionService {
*/
@Transactional
public JSONObject weCahtRegister(String username, String password, String openId,
String unionid, String nickname, String headimgurl, int type, String mobilecode, Integer isQQ) {
String unionid, String nickname, String headimgurl, int type, String mobilecode, Integer isQQ,String code) {
// 校验参数和验证码
if (StringUtils.isBlank(username) || StringUtils.isBlank(mobilecode)) {
return JsonResultUtil.createFailedResult(ResultCode.NULL_CODE, "参数为空");
......@@ -435,7 +446,7 @@ public class AppPermissionService {
}
} else if (type == 2) { // 新增
JSONObject register = register(username, password, headimgurl, nickname, mobilecode,
openId, unionid, isQQ);
openId, unionid, isQQ,code);
if (register.getInteger("status") != ResultCode.SUCCESS_CODE) {
if (register.getInteger("status") == ResultCode.EXIST_CODE) {
return JsonResultUtil.createFailedResult(ResultCode.EXIST_CODE, "用户已存在");
......@@ -959,4 +970,5 @@ public class AppPermissionService {
public static final String BASE_DATA = "data";
public static final String CITY_NAME = "city";
}
}
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