public ResultInfo <string> GetRegistCode(RequestParam <SmsEntity> reqst) { var ri = new ResultInfo <string>("99999"); try { var mobile = reqst.body.mobile.ToString(); if (string.IsNullOrEmpty(mobile)) { ri.code = "1000000000"; } else if (!ValidateHelper.IsHandset(mobile)) { ri.code = "1000000001"; } else if (!_logic.CheckMobile(mobile)) { // 手机号可以注册用户 var res = SendSms(mobile, 1, 8); return(res); } else { ri.code = "1000000002"; //手机号已经被注册 } ri.message = Settings.Instance.GetErrorMsg(ri.code); return(ri); } catch (Exception ex) { LoggerHelper.Error(ex.ToString()); LoggerHelper.Error(JsonHelper.Entity2Json(reqst)); ri.code = "500"; ri.message = Settings.Instance.GetErrorMsg(ri.code); return(ri); } }
public ResultInfo <MemberEntity> Regist(RequestParam <RequestRegistMember> reqst) { //todo 添加注册代码 var ri = new ResultInfo <MemberEntity>("99999"); try { var mobile = reqst.body.userMobile.ToString(); if (string.IsNullOrEmpty(mobile)) { ri.code = "1000000000"; } else if (!ValidateHelper.IsHandset(mobile)) { ri.code = "1000000001"; } else if (!_logic.CheckMobile(mobile)) { // true 存在 false 不存在 #region 验证code var code = reqst.body.code.ToString(); var w = 8; //if (_recordLogic.CheckCode(code, w, mobile) || 1 == 1) if (_recordLogic.CheckCode(code, w, mobile)) { #region 注册方法 var ent = new MemberEntity { username = mobile, password = EncryptHelper.Encrypt(reqst.body.userPass.ToString(), Settings.Instance.EncryptKey), mobile = mobile }; string me = _logic.Regist(ent, reqst.body.code.ToString(), reqst.header.appId); ent.registerid = ConvertHelper.ParseValue(me, 0); if (ent.registerid > 0) { //#region 发送注册成功短信 //var smstype = (int)Enum.Parse(typeof(SmsType), SmsType.注册成功.ToString()); //var messageId = 18; //短信注册成功 //var smsEntity = _logic.GetSmsEmailEntity(1, messageId); // 获取注册成功邮件内容 //if (smsEntity != null) //{ // var cnt = smsEntity.SEContext.Replace("#USERANEM#", mobile); // // var rx = SmsHelper.Send(mobile, cnt); // var pm = new SmsRecordEntity // { // phone_number = mobile, // sendtime = DateTime.Now, // senduserid = ent.registerid, // smstype = smstype, // smscontext = cnt.ToString(), // orderid = 1, // vcode = "", // ip = Settings.Instance.ClientIp // }; // _recordLogic.AddRecord(pm); //} //#endregion try { var sf = reqst.body.sourceFrom; LoggerHelper.Info(ent.registerid + ":" + sf); //参与活动 // using (ActFacade actFacade = new ActFacade()) //{ // actFacade.SendBonusAfterRegister(ent.registerid.Value); //} } catch (Exception ex) { LoggerHelper.Info(ent.registerid + ":3"); } ri.code = "1000000099"; ri.body = ent; } else { ri.code = "99999"; } #endregion } else { ri.code = "1000000011"; //验证码不存在或已过期 } #endregion } else { // 用户已存在 ri.code = "1000000002"; } ri.message = Settings.Instance.GetErrorMsg(ri.code); return(ri); } catch (Exception ex) { LoggerHelper.Error(ex.ToString()); LoggerHelper.Error(JsonHelper.Entity2Json(reqst)); ri.code = "500"; ri.message = Settings.Instance.GetErrorMsg(ri.code); return(ri); } }