/// <summary> /// 创建推广的用户 /// </summary> /// <param name="userParamModel"></param> /// <returns></returns> public int CreateSpreadUser(RegisterParamModel userParamModel) { //判断手机号是否已经存在 if (user.GetUser(userParamModel.Mobile) != null) { return(-1); } LoanMarketUser loanMarketUser = new LoanMarketUser() { Mobile = userParamModel.Mobile, Password = userParamModel.Password, NickName = userParamModel.NickName, RealName = userParamModel.RealName, Sex = userParamModel.Sex }; loanMarketUser.Id = GuidTool.GenerateKey(); loanMarketUser.Icon = ""; loanMarketUser.Sex = ""; var list = user.FindUser(); loanMarketUser.No = list == null ? 1 : list.Count + 1; loanMarketUser.IsPeculiarUser = 0; int userNo = user.CreateUser(loanMarketUser); log.Info("创建推广的用户,创建用户成功,新创建的用户编号为:" + userNo); if (userNo > 0) { SpreadBLL spreadBLL = new SpreadBLL(); if (spreadBLL.CreateSpread(userParamModel.FromUserNo, userNo) > 0) { log.Info("创建推广的用户,创建用户成功,绑定上级成功。"); return(userNo); } else { log.Info("创建推广的用户,创建用户成功,绑定上级失败。"); return(-2); } } else { log.Info("创建推广的用户,创建用户失败。"); return(0); } }
/// <summary> /// 注册 - 通过推广的链接 /// </summary> /// <param name="userParamModel"></param> /// <returns></returns> public string Post([FromBody] RegisterParamModel userParamModel) { if (userParamModel == null) { return("手机号不可为空"); } if (string.IsNullOrEmpty(userParamModel.Mobile)) { return("手机号不可为空"); } if (string.IsNullOrEmpty(userParamModel.NickName)) { return("昵称不可为空"); } if (string.IsNullOrEmpty(userParamModel.RealName)) { return("真实姓名不可为空"); } if (string.IsNullOrEmpty(userParamModel.userpwd)) { return("密码不可为空"); } if (string.IsNullOrEmpty(userParamModel.Password)) { return("密码不可为空"); } if (userParamModel.userpwd != userParamModel.Password) { return("两次密码不一致"); } if (string.IsNullOrEmpty(userParamModel.smscode)) { return("短信验证码不可为空"); } if (SessionTool.Get <string>("SmsCode") != userParamModel.smscode) { return("短信验证码错误"); } if (userParamModel.FromUserNo == 0) { return("获取上级推广人失败"); } int no = user.CreateSpreadUser(userParamModel); if (no > 0) { return("注册成功"); } else if (no == 0) { return("注册失败"); } else if (no == -1) { return("手机号已经注册"); } else if (no == -2) { return("注册成功,绑定上级推广人失败。"); } else { log.Info("注册,逻辑异常,bll返回值为" + no); return("注册失败,服务异常"); } }