public void ProcessRequest(HttpContext context) { string phone = context.Request["phone"]; string code = context.Request["code"]; string password = context.Request["pwd"]; string websiteOwner = bllUser.WebsiteOwner; if (string.IsNullOrWhiteSpace(password)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "请输入新密码"; bllUser.ContextResponse(context, apiResp); return; } UserInfo ouser = bllUser.GetUserInfoByPhone(phone, websiteOwner); if (ouser == null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "手机号未找到"; bllUser.ContextResponse(context, apiResp); return; } var lastSmsVerCode = bllSms.GetLastSmsVerificationCode(phone); if (lastSmsVerCode == null) { apiResp.code = (int)APIErrCode.CheckCodeErr; apiResp.msg = "请先获取手机验证码"; bllUser.ContextResponse(context, apiResp); return; } if (lastSmsVerCode.VerificationCode != code) { apiResp.code = (int)APIErrCode.CheckCodeErr; apiResp.msg = "手机验证码错误"; bllUser.ContextResponse(context, apiResp); return; } if ((DateTime.Now - lastSmsVerCode.InsertDate).TotalMinutes >= 5) { apiResp.code = (int)APIErrCode.CheckCodeErr; apiResp.msg = "手机验证码已过期,请重新获取"; bllUser.ContextResponse(context, apiResp); return; } ouser.Password = password; if (bllUser.Update(ouser, string.Format("Password='******'", ouser.Password), string.Format("AutoID={0}", ouser.AutoID)) <= 0) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "手机密码设置失败"; bllUser.ContextResponse(context, apiResp); return; } apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "手机密码设置完成"; bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { string phone = context.Request["phone"]; string vcode = context.Request["vcode"]; string websiteOwner = bllUser.WebsiteOwner; var lastSmsVerCode = bllSms.GetLastSmsVerificationCode(phone); if (lastSmsVerCode == null) { apiResp.code = (int)APIErrCode.CheckCodeErr; apiResp.msg = "请先获取手机验证码"; bllUser.ContextResponse(context, apiResp); return; } if (lastSmsVerCode.VerificationCode != vcode) { apiResp.code = (int)APIErrCode.CheckCodeErr; apiResp.msg = "手机验证码错误"; bllUser.ContextResponse(context, apiResp); return; } if ((DateTime.Now - lastSmsVerCode.InsertDate).TotalMinutes >= 5) { apiResp.code = (int)APIErrCode.CheckCodeErr; apiResp.msg = "手机验证码已过期,请重新获取"; bllUser.ContextResponse(context, apiResp); return; } BLLJIMP.Model.UserInfo ouser = bllUser.GetUserInfoByPhone(phone, websiteOwner); ouser.Password = ZentCloud.Common.Rand.Number(6); bool smsBool = false; string smsMsg = ""; BLLJIMP.Model.WebsiteInfo website = bllUser.GetWebsiteInfoModelFromDataBase(websiteOwner); bllSms.SendSmsMisson(ouser.Phone, "您的密码是:" + ouser.Password, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), website.SmsSignature, out smsBool, out smsMsg); if (!smsBool) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "发送短信密码失败"; bllUser.ContextResponse(context, apiResp); return; } if (bllUser.Update(ouser, string.Format("Password='******'", ouser.Password), string.Format("AutoID={0}", ouser.AutoID)) <= 0) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "重置失败"; bllUser.ContextResponse(context, apiResp); return; } apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "重置完成,新密码将发送到您的手机"; bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { string vcode = context.Request["vcode"]; string pay_pwd = context.Request["pay_pwd"]; string websiteOwner = bllUser.WebsiteOwner; if (string.IsNullOrWhiteSpace(pay_pwd)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请设置支付密码"; bllUser.ContextResponse(context, apiResp); return; } var lastSmsVerCode = bllSms.GetLastSmsVerificationCode(CurrentUserInfo.Phone); if (lastSmsVerCode == null) { apiResp.code = (int)APIErrCode.CheckCodeErr; apiResp.msg = "请先获取手机验证码"; bllUser.ContextResponse(context, apiResp); return; } if (lastSmsVerCode.VerificationCode != vcode) { apiResp.code = (int)APIErrCode.CheckCodeErr; apiResp.msg = "手机短信验证码错误"; bllUser.ContextResponse(context, apiResp); return; } if ((DateTime.Now - lastSmsVerCode.InsertDate).TotalMinutes >= 5) { apiResp.code = (int)APIErrCode.CheckCodeErr; apiResp.msg = "手机短信验证码已过期,请重新获取"; bllUser.ContextResponse(context, apiResp); return; } if (bllUser.Update(CurrentUserInfo, string.Format("PayPassword='******'", pay_pwd), string.Format("AutoID={0}", CurrentUserInfo.AutoID)) <= 0) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "修改支付密码失败"; bllUser.ContextResponse(context, apiResp); return; } apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "修改支付密码完成"; bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { string code = context.Request["code"]; string Phone = context.Request["Phone"]; UserInfo CurrentUserInfo = bllUser.GetCurrentUserInfo(); #region 检查是否已登录 if (CurrentUserInfo != null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "本功能仅供新用户使用"; bllUser.ContextResponse(context, apiResp); return; } #endregion #region 检查是否微信服务号 if (context.Session["currWXOpenId"] == null) { apiResp.code = (int)APIErrCode.UserIsNotLogin; apiResp.msg = "本功能仅供微信服务号使用"; bllUser.ContextResponse(context, apiResp); return; } #endregion string wxOpenId = context.Session["currWXOpenId"].ToString(); CurrentUserInfo = bllUser.GetUserInfoByOpenId(wxOpenId); if (CurrentUserInfo != null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "OpenId已被绑定"; bllUser.ContextResponse(context, apiResp); return; } #region 判断手机格式 if (!MyRegex.PhoneNumLogicJudge(Phone)) { apiResp.code = (int)APIErrCode.PhoneFormatError; apiResp.msg = "手机格式错误"; bllUser.ContextResponse(context, apiResp); return; } #endregion #region 判断手机是否已被使用 UserInfo model = bllUser.GetUserInfoByPhone(Phone); if (model != null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "手机号码已被其他账号使用,请联系管理员"; bllSms.ContextResponse(context, apiResp); return; } #endregion #region 判断验证码是否正确 SmsVerificationCode sms = bllSms.GetLastSmsVerificationCode(Phone); if (sms == null || sms.VerificationCode != code) { apiResp.code = (int)APIErrCode.CheckCodeErr; apiResp.msg = "验证码错误"; bllSms.ContextResponse(context, apiResp); return; } #endregion List <TableFieldMapping> listFieldList = bllTableFieldMap.GetTableFieldMapByWebsite(bllTableFieldMap.WebsiteOwner, "ZCJ_UserInfo", null, null, "0", null); List <string> defFields = new List <string>() { "AutoID", "UserID", "Password", "UserType", "TrueName", "Phone" }; #region 账号检查 未登录时检查已有账号 CurrentUserInfo = bllUser.GetUserInfoByAllPhone(Phone); if (CurrentUserInfo != null) { List <string> tempFields = new List <string>() { "Phone1", "Phone2", "Phone3" }; List <GetCompleteField.ResultField> resultList = new List <GetCompleteField.ResultField>(); #region 取姓名 TableFieldMapping AcountTrueNameField = listFieldList.FirstOrDefault(p => p.Field.Equals("TrueName")); if (AcountTrueNameField == null) { resultList.Add(new GetCompleteField.ResultField { field = "TrueName", field_name = "姓名", type = "txt", no_null = 1, value = CurrentUserInfo.TrueName, read_only = 0 }); } else { resultList.Add(new GetCompleteField.ResultField { field = "TrueName", field_name = AcountTrueNameField.MappingName, type = "txt", no_null = AcountTrueNameField.FieldIsNull, value = CurrentUserInfo.TrueName, read_only = AcountTrueNameField.IsReadOnly }); } #endregion #region 取手机 if (!string.IsNullOrWhiteSpace(CurrentUserInfo.Phone1)) { TableFieldMapping AcountPhone1Field = listFieldList.FirstOrDefault(p => p.Field.Equals("Phone1")); if (AcountPhone1Field == null) { resultList.Add(new GetCompleteField.ResultField { field = "TrueName", field_name = "手机", type = "txt", no_null = 1, value = CurrentUserInfo.Phone1, read_only = 0 }); } else { resultList.Add(new GetCompleteField.ResultField { field = "TrueName", field_name = AcountPhone1Field.MappingName, type = "txt", no_null = AcountPhone1Field.FieldIsNull, value = CurrentUserInfo.Phone1, read_only = AcountPhone1Field.IsReadOnly }); } } if (!string.IsNullOrWhiteSpace(CurrentUserInfo.Phone2)) { TableFieldMapping AcountPhone2Field = listFieldList.FirstOrDefault(p => p.Field.Equals("Phone2")); if (AcountPhone2Field == null) { resultList.Add(new GetCompleteField.ResultField { field = "Phone2", field_name = "手机", type = "txt", no_null = 1, value = CurrentUserInfo.Phone2, read_only = 0 }); } else { resultList.Add(new GetCompleteField.ResultField { field = "Phone2", field_name = AcountPhone2Field.MappingName, type = "txt", no_null = AcountPhone2Field.FieldIsNull, value = CurrentUserInfo.Phone2, read_only = AcountPhone2Field.IsReadOnly }); } } if (!string.IsNullOrWhiteSpace(CurrentUserInfo.Phone3)) { TableFieldMapping AcountPhone3Field = listFieldList.FirstOrDefault(p => p.Field.Equals("Phone3")); if (AcountPhone3Field == null) { resultList.Add(new GetCompleteField.ResultField { field = "Phone3", field_name = "手机", type = "txt", no_null = 1, value = CurrentUserInfo.Phone3, read_only = 0 }); } else { resultList.Add(new GetCompleteField.ResultField { field = "Phone3", field_name = AcountPhone3Field.MappingName, type = "txt", no_null = AcountPhone3Field.FieldIsNull, value = CurrentUserInfo.Phone3, read_only = AcountPhone3Field.IsReadOnly }); } } #endregion #region 取其他信息 JObject tCurUser = JObject.FromObject(CurrentUserInfo); foreach (var item in listFieldList.Where(p => !defFields.Contains(p.Field) && !tempFields.Contains(p.Field))) { if (tCurUser[item.Field] == null) { continue; } if (string.IsNullOrWhiteSpace(tCurUser[item.Field].ToString())) { continue; } string FieldType = string.IsNullOrWhiteSpace(item.FieldType) ? "txt" : item.FieldType; resultList.Add(new GetCompleteField.ResultField { field = item.Field, field_name = item.MappingName, type = FieldType, no_null = item.FieldIsNull, value = tCurUser[item.Field].ToString(), read_only = item.IsReadOnly }); } #endregion apiResp.code = (int)APIErrCode.HaveHistoryAcount; apiResp.msg = "注册手机已存在账号"; apiResp.result = new { have_acount = true, id = CurrentUserInfo.AutoID, info_list = resultList }; bllSms.ContextResponse(context, apiResp); return; } else { CurrentUserInfo = new UserInfo(); string guidString = Guid.NewGuid().ToString(); CurrentUserInfo.UserID = string.Format("WXUser{0}", guidString); //Guid CurrentUserInfo.Password = guidString.Substring(0, 8); //Guid CurrentUserInfo.WXHeadimgurl = string.Format("http://{0}", context.Request.Url.Authority) + "/img/persion.png"; CurrentUserInfo.WebsiteOwner = bllUser.WebsiteOwner; CurrentUserInfo.UserType = 2; CurrentUserInfo.WXOpenId = wxOpenId; CurrentUserInfo.Regtime = DateTime.Now; CurrentUserInfo.LastLoginDate = DateTime.Now; } #endregion //string oldPhone = CurrentUserInfo.Phone; CurrentUserInfo = bllTableFieldMap.ConvertRequestToModel <UserInfo>(CurrentUserInfo); //if(CurrentUserInfo.IsPhoneVerify == 1) CurrentUserInfo.Phone = oldPhone; #region 默认信息检查 姓名 TableFieldMapping TrueNameField = listFieldList.FirstOrDefault(p => p.Field.Equals("TrueName")); if ((TrueNameField == null || TrueNameField.FieldIsNull == 1) && string.IsNullOrWhiteSpace(CurrentUserInfo.TrueName)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "请完善姓名"; bllTableFieldMap.ContextResponse(context, apiResp); return; } #endregion JObject jtCurUser = JObject.FromObject(CurrentUserInfo); foreach (var item in listFieldList.Where(p => p.FieldIsNull == 1 && !defFields.Contains(p.Field)).OrderBy(p => p.Sort)) { if (jtCurUser[item.Field] == null) { continue; } if (string.IsNullOrWhiteSpace(jtCurUser[item.Field].ToString())) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "请完善" + item.MappingName; bllTableFieldMap.ContextResponse(context, apiResp); return; } if (!string.IsNullOrWhiteSpace(item.FormatValiFunc)) { #region 检查数据格式 //检查数据格式 if (item.FormatValiFunc == "number") { if (!MyRegex.IsNumber(jtCurUser[item.Field].ToString())) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } if (item.FormatValiFunc == "phone")//email检查 { if (!MyRegex.PhoneNumLogicJudge(jtCurUser[item.Field].ToString())) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } if (item.FormatValiFunc == "email")//email检查 { if (!MyRegex.EmailLogicJudge(jtCurUser[item.Field].ToString())) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } if (item.FormatValiFunc == "url") //url检查 { System.Text.RegularExpressions.Regex regUrl = new System.Text.RegularExpressions.Regex(@"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"); //网址 System.Text.RegularExpressions.Match match = regUrl.Match(jtCurUser[item.Field].ToString()); if (!match.Success) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } #endregion } } CurrentUserInfo.IsPhoneVerify = 1; CompanyWebsite_Config nWebsiteConfig = bllWebSite.GetCompanyWebsiteConfig(); if (nWebsiteConfig.MemberStandard == 2) { if (CurrentUserInfo.AccessLevel < 1) { CurrentUserInfo.AccessLevel = 1; CurrentUserInfo.MemberStartTime = DateTime.Now; } //CurrentUserInfo.MemberApplyStatus = 9; } else if (nWebsiteConfig.MemberStandard == 3) { CurrentUserInfo.MemberApplyStatus = 1; CurrentUserInfo.MemberApplyTime = DateTime.Now; } if (bllUser.Add(CurrentUserInfo)) { apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "提交完成"; context.Session[ZentCloud.Common.SessionKey.UserID] = CurrentUserInfo.UserID; context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态 } else { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "提交失败"; } bllUser.ContextResponse(context, apiResp); }
/// <summary> /// 注册 /// </summary> /// <param name="context"></param> /// <returns></returns> private string Reg(HttpContext context) { string phone = context.Request["phone"]; string pwd = context.Request["pwd"]; string verCode = context.Request["vercode"]; if (string.IsNullOrEmpty(phone)) { resp.errcode = 1; resp.errmsg = "请输入手机号"; goto outoff; } if ((!phone.StartsWith("1")) || (!phone.Length.Equals(11))) { resp.errcode = 2; resp.errmsg = "手机号格式不正确"; goto outoff; } if (string.IsNullOrEmpty(pwd)) { resp.errcode = 3; resp.errmsg = "请输入密码"; goto outoff; } if (string.IsNullOrEmpty(verCode)) { resp.errcode = 4; resp.errmsg = "请输入验证码"; goto outoff; } if (bllUser.GetUserInfo(phone, webSiteOwner) != null) { resp.errcode = 5; resp.errmsg = "此手机号已经被注册"; goto outoff; } ////验证码检查 var lastSmsVerificationCode = bllSms.GetLastSmsVerificationCode(phone); if (lastSmsVerificationCode == null) { resp.errcode = 6; resp.errmsg = "请先获取手机验证码"; goto outoff; } if (!lastSmsVerificationCode.VerificationCode.Equals(verCode)) { resp.errcode = 7; resp.errmsg = "验证码不正确"; goto outoff; } //// UserInfo regUser = new UserInfo(); regUser.WXHeadimgurl = basePath + "/img/persion.png"; regUser.UserID = phone; regUser.Password = pwd; regUser.WebsiteOwner = webSiteOwner; regUser.UserType = 2; regUser.Regtime = DateTime.Now; regUser.LastLoginDate = DateTime.Now; if (bllUser.Add(regUser)) { resp.errcode = 0; resp.errmsg = "注册成功"; context.Session[SessionKey.LoginStatu] = 1; context.Session[SessionKey.UserID] = regUser.UserID; //绑定微信 BindWXUser(context, regUser.UserID); goto outoff; } else { resp.errcode = 6; resp.errmsg = "注册失败"; goto outoff; } outoff: return(Common.JSONHelper.ObjectToJson(resp)); }
public void ProcessRequest(HttpContext context) { string code = context.Request["code"]; string Phone = context.Request["Phone"]; string wxOpenId; UserInfo CurrentUserInfo = bllUser.GetCurrentUserInfo(); #region 判断手机格式 if (!MyRegex.PhoneNumLogicJudge(Phone)) { apiResp.code = (int)APIErrCode.PhoneFormatError; apiResp.msg = "手机格式错误"; bllTableFieldMap.ContextResponse(context, apiResp); return; } #endregion #region 判断验证码是否正确 SmsVerificationCode sms = bllSms.GetLastSmsVerificationCode(Phone); if (sms == null || sms.VerificationCode != code) { apiResp.code = (int)APIErrCode.CheckCodeErr; apiResp.msg = "验证码错误"; bllSms.ContextResponse(context, apiResp); return; } #endregion #region 账号检查 未登录时检查已有账号 if (CurrentUserInfo == null) { if (context.Session["currWXOpenId"] == null) { apiResp.code = (int)APIErrCode.UserIsNotLogin; apiResp.msg = "请先登录"; bllSms.ContextResponse(context, apiResp); return; } wxOpenId = context.Session["currWXOpenId"].ToString(); UserInfo curUser = bllUser.GetUserInfoByOpenId(wxOpenId); if (curUser != null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "微信已绑定有账号"; bllSms.ContextResponse(context, apiResp); return; } curUser = bllUser.GetUserInfoByAllPhone(Phone); if (curUser != null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "微信已绑定有账号"; bllSms.ContextResponse(context, apiResp); return; } } #endregion #region 判断手机是否已被使用 UserInfo model = bllUser.GetUserInfoByPhone(Phone); if (model != null) { if (model.UserID != CurrentUserInfo.UserID) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "手机号码已被其他账号使用,请联系管理员"; bllSms.ContextResponse(context, apiResp); return; } } #endregion //string oldPhone = CurrentUserInfo.Phone; CurrentUserInfo = bllTableFieldMap.ConvertRequestToModel <UserInfo>(CurrentUserInfo); //if(CurrentUserInfo.IsPhoneVerify == 1) CurrentUserInfo.Phone = oldPhone; List <TableFieldMapping> listFieldList = bllTableFieldMap.GetTableFieldMapByTableName(bllTableFieldMap.WebsiteOwner, "ZCJ_UserInfo"); List <string> DefFields = new List <string>() { "AutoID", "UserID", "Password", "UserType", "TrueName", "Phone" }; #region 默认信息检查 姓名 TableFieldMapping TrueNameField = listFieldList.FirstOrDefault(p => p.Field.Equals("TrueName")); if ((TrueNameField == null || TrueNameField.FieldIsNull == 1) && string.IsNullOrWhiteSpace(CurrentUserInfo.TrueName)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "请完善姓名"; bllTableFieldMap.ContextResponse(context, apiResp); return; } #endregion JObject jtCurUser = JObject.FromObject(CurrentUserInfo); List <JProperty> listPropertys = jtCurUser.Properties().ToList(); foreach (var item in listFieldList.Where(p => p.FieldIsNull == 1 && !DefFields.Contains(p.Field)).OrderBy(p => p.Sort)) { if (!listPropertys.Exists(p => p.Name.Equals(item.Field))) { continue; } if (string.IsNullOrWhiteSpace(jtCurUser[item.Field].ToString())) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "请完善" + item.MappingName; bllTableFieldMap.ContextResponse(context, apiResp); return; } if (!string.IsNullOrWhiteSpace(item.FormatValiFunc)) { #region 检查数据格式 //检查数据格式 if (item.FormatValiFunc == "number") { if (!MyRegex.IsNumber(jtCurUser[item.Field].ToString())) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } if (item.FormatValiFunc == "phone")//email检查 { if (!MyRegex.PhoneNumLogicJudge(jtCurUser[item.Field].ToString())) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } if (item.FormatValiFunc == "email")//email检查 { if (!MyRegex.EmailLogicJudge(jtCurUser[item.Field].ToString())) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } if (item.FormatValiFunc == "url") //url检查 { System.Text.RegularExpressions.Regex regUrl = new System.Text.RegularExpressions.Regex(@"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"); //网址 System.Text.RegularExpressions.Match match = regUrl.Match(jtCurUser[item.Field].ToString()); if (!match.Success) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } #endregion } } CurrentUserInfo.IsPhoneVerify = 1; CompanyWebsite_Config nWebsiteConfig = bllWebSite.GetCompanyWebsiteConfig(); if (nWebsiteConfig.MemberStandard == 2) { if (CurrentUserInfo.AccessLevel < 1) { CurrentUserInfo.AccessLevel = 1; CurrentUserInfo.MemberStartTime = DateTime.Now; } //CurrentUserInfo.MemberApplyStatus = 9; } else if (nWebsiteConfig.MemberStandard == 3) { CurrentUserInfo.MemberApplyStatus = 1; CurrentUserInfo.MemberApplyTime = DateTime.Now; } if (bllUser.Update(CurrentUserInfo)) { apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "提交完成"; } else { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "提交失败"; } bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { context.Response.Expires = 0; string result = "false"; string nickName = context.Request["nickname"]; string phone = context.Request["username"];//手机号作为用户名 string smsVerCode = context.Request["smsvercode"]; string passWord = context.Request["password"]; string passwordConfirm = context.Request["passwordconfirm"]; string viewType = context.Request["view_type"]; //0普通 1加密 string isRepeat = context.Request["is_repeat_nickname"]; //是否能注册相同的昵称 string email = context.Request["email"]; if (string.IsNullOrEmpty(nickName)) { resp.errcode = 1; resp.errmsg = "请输入昵称"; goto outoff; } if (string.IsNullOrEmpty(phone)) { resp.errcode = 1; resp.errmsg = "请输入手机号码"; goto outoff; } if (string.IsNullOrEmpty(smsVerCode)) { resp.errcode = 1; resp.errmsg = "请输入验证码"; goto outoff; } if (!string.IsNullOrEmpty(isRepeat) && isRepeat == "1") { if (bllUser.GetUserInfoByNickName(nickName) != null) { resp.errcode = 1; resp.errmsg = "昵称重复"; goto outoff; } } if (!ZentCloud.Common.MyRegex.PhoneNumLogicJudge(phone)) { resp.errcode = (int)APIErrCode.PhoneFormatError; resp.errmsg = "手机格式不正确"; goto outoff; } var lastSms = bllSms.GetLastSmsVerificationCode(phone); if (lastSms == null) { resp.errcode = 1; resp.errmsg = "请先获取手机验证码"; goto outoff; } if (smsVerCode != lastSms.VerificationCode) { resp.errcode = 1; resp.errmsg = "手机验证码不正确"; goto outoff; } string msg = ""; string currWXOpenId = ""; if (!bllUser.IsLogin && context.Session["currWXOpenId"] != null) { currWXOpenId = context.Session["currWXOpenId"].ToString();//更新用户openid } if (bllUser.RegByPhone(phone, passWord, passwordConfirm, out msg, nickName, currWXOpenId, viewType)) { resp.errcode = 0; resp.errmsg = "注册成功"; resp.isSuccess = true; UserInfo curUser = bllUser.GetUserInfoByPhone(phone); bllUser.AddUserScoreDetail(curUser.UserID, CommonPlatform.Helper.EnumStringHelper.ToString(ScoreDefineType.Register), bllUser.WebsiteOwner, null, null); context.Session[SessionKey.UserID] = curUser.UserID; context.Session[SessionKey.LoginStatu] = 1; context.Response.Cookies.Add(bllUser.CreateLoginCookie(curUser.UserID, curUser.WXOpenId, curUser.WXNickname)); } else { resp.errcode = 1; resp.errmsg = msg; } outoff: bllUser.ContextResponse(context, resp); }
public void ProcessRequest(HttpContext context) { string phone = context.Request["phone"]; string code = context.Request["code"]; string newPwd = context.Request["new_pwd"]; string configPwd = context.Request["confirm_pwd"]; string auto_login = context.Request["auto_login"]; string pwdLength = context.Request["pwd_length"]; if (string.IsNullOrEmpty(phone)) { resp.errmsg = "phone 为必填项,请检查"; resp.errcode = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } if (string.IsNullOrEmpty(code)) { resp.errmsg = "code 为必填项,请检查"; resp.errcode = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } if (string.IsNullOrEmpty(newPwd)) { resp.errmsg = "newPwd 为必填项,请检查"; resp.errcode = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } if (string.IsNullOrEmpty(configPwd)) { resp.errmsg = "confirm 为必填项,请检查"; resp.errcode = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } #region 手机格式验证 if (!ZentCloud.Common.MyRegex.PhoneNumLogicJudge(phone)) { resp.errcode = (int)BLLJIMP.Enums.APIErrCode.PhoneFormatError; resp.errmsg = "手机号码出错"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } #endregion #region 密码检查 //输入是否一致 if (configPwd != newPwd) { resp.errmsg = "两次的密码输入不一致"; resp.errcode = (int)BLLJIMP.Enums.APIErrCode.OperateFail; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } if (!string.IsNullOrEmpty(pwdLength)) { if (newPwd.Length < int.Parse(pwdLength)) { resp.errmsg = "长度不够"; resp.errcode = (int)BLLJIMP.Enums.APIErrCode.OperateFail; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } } else { //密码长度 if (newPwd.Length < 8) { resp.errmsg = "长度不够"; resp.errcode = (int)BLLJIMP.Enums.APIErrCode.OperateFail; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } } #endregion UserInfo model = bllUser.GetUserInfoByPhone(phone); if (model == null) { resp.errmsg = "账号未找到"; resp.errcode = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } #region 判断验证码是否正确 SmsVerificationCode sms = bllSms.GetLastSmsVerificationCode(phone); if (sms.VerificationCode != code) { resp.errmsg = "验证码错误"; resp.errcode = (int)BLLJIMP.Enums.APIErrCode.CheckCodeErr; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } #endregion if (bllUser.Update(model, string.Format(" Password='******'", newPwd), string.Format(" Phone='{0}'", phone)) > 0) { resp.isSuccess = true; resp.errmsg = "修改密码成功"; if (auto_login == "1") { context.Session[SessionKey.UserID] = model.UserID; context.Session[SessionKey.LoginStatu] = 1; context.Response.Cookies.Add(bllUser.CreateLoginCookie(model.UserID, model.WXOpenId, model.WXNickname)); } } else { resp.errmsg = "修改密码出错"; resp.errcode = (int)BLLJIMP.Enums.APIErrCode.OperateFail; } context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); }
public void ProcessRequest(HttpContext context) { BLLUser userBll = new BLLUser(); BLLSMS smsBll = new BLLSMS(""); BLLDistribution bllDist = new BLLDistribution(); try { var phone = context.Request["phone"]; var code = context.Request["code"]; var password = context.Request["password"]; string openId = ""; if (context.Session["currWXOpenId"] != null) { openId = context.Session["currWXOpenId"].ToString(); } //if (string.IsNullOrWhiteSpace(openId)) //{ // apiResp.status = false; // apiResp.code = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete; // apiResp.msg = "找不到微信OpenId"; // userBll.ContextResponse(context, apiResp); // return; //} phone = phone.Trim(); code = code.Trim(); password = password.Trim(); if (string.IsNullOrWhiteSpace(phone) || string.IsNullOrWhiteSpace(code)) { apiResp.status = false; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "手机以及验证码必传"; userBll.ContextResponse(context, apiResp); return; } if (!ZentCloud.Common.MyRegex.PhoneNumLogicJudge(phone)) { apiResp.status = false; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "手机号码格式不正确"; userBll.ContextResponse(context, apiResp); return; } var vCode = smsBll.GetLastSmsVerificationCode(phone); if (vCode == null) { apiResp.status = false; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "无效验证码"; userBll.ContextResponse(context, apiResp); return; } if (vCode.VerificationCode != code) { apiResp.status = false; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "无效验证码"; userBll.ContextResponse(context, apiResp); return; } UserInfo phoneUser = userBll.GetUserInfoByPhone(phone); UserInfo openIdUser = null; if (!string.IsNullOrWhiteSpace(openId)) { openIdUser = userBll.GetUserInfoByOpenId(openId); } #region phoneUser != null if (phoneUser != null) { if (openIdUser == null && string.IsNullOrWhiteSpace(phoneUser.WXOpenId) && !string.IsNullOrWhiteSpace(openId)) { StringBuilder sbSQL = new StringBuilder(); sbSQL.AppendFormat(" WXOpenId = '{0}' ", openId); if (!string.IsNullOrWhiteSpace(password)) { sbSQL.AppendFormat(",Password = '******' ", password); } //绑定openid到手机号账户上 if (userBll.Update(phoneUser, sbSQL.ToString(), string.Format(" AutoID = {0} ", phoneUser.AutoID)) > 0) { //设置登陆状态成功 //设置用户会话ID context.Session[ZentCloud.Common.SessionKey.UserID] = phoneUser.UserID; context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态 apiResp.status = true; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsSuccess; apiResp.msg = "绑定成功"; userBll.ContextResponse(context, apiResp); bllDist.SetUserDistributionOwnerByTemp(phoneUser.UserID, phoneUser.WebsiteOwner); return; } else { apiResp.status = false; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "绑定失败"; userBll.ContextResponse(context, apiResp); return; } } else if (!string.IsNullOrWhiteSpace(password)) { if (userBll.Update(phoneUser, string.Format(" Password = {0} ", password), string.Format(" AutoID = {0} ", phoneUser.AutoID)) > 0) { //设置登陆状态成功 //设置用户会话ID context.Session[ZentCloud.Common.SessionKey.UserID] = phoneUser.UserID; context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态 apiResp.status = true; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsSuccess; apiResp.msg = "登录成功"; userBll.ContextResponse(context, apiResp); return; } else { apiResp.status = false; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "注册失败"; userBll.ContextResponse(context, apiResp); return; } } else { //设置登陆状态成功 //设置用户会话ID context.Session[ZentCloud.Common.SessionKey.UserID] = phoneUser.UserID; context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态 apiResp.status = true; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsSuccess; apiResp.msg = "登录成功"; userBll.ContextResponse(context, apiResp); return; } } #endregion if (openIdUser == null) { //构造新用户 var currentUserInfo = new ZentCloud.BLLJIMP.Model.UserInfo(); currentUserInfo.UserID = string.Format("WXUser{0}", Guid.NewGuid().ToString());//Guid if (!string.IsNullOrWhiteSpace(password)) { currentUserInfo.Password = password; } else { currentUserInfo.Password = ZentCloud.Common.Rand.Str_char(6); } currentUserInfo.UserType = 2; currentUserInfo.WebsiteOwner = userBll.WebsiteOwner; currentUserInfo.Regtime = DateTime.Now; if (!string.IsNullOrWhiteSpace(openId)) { currentUserInfo.WXOpenId = openId; } currentUserInfo.RegIP = ZentCloud.Common.MySpider.GetClientIP(); currentUserInfo.LastLoginIP = ZentCloud.Common.MySpider.GetClientIP(); currentUserInfo.LastLoginDate = DateTime.Now; currentUserInfo.LoginTotalCount = 1; currentUserInfo.Phone = phone; if (userBll.Add(currentUserInfo)) { //设置登陆状态成功 //设置用户会话ID context.Session[ZentCloud.Common.SessionKey.UserID] = currentUserInfo.UserID; context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态 apiResp.status = true; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsSuccess; apiResp.msg = "注册成功"; userBll.ContextResponse(context, apiResp); bllDist.SetUserDistributionOwnerByTemp(currentUserInfo.UserID, currentUserInfo.WebsiteOwner); return; } else { apiResp.status = false; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "注册失败"; userBll.ContextResponse(context, apiResp); return; } } else { apiResp.status = false; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "该微信已绑定其他账号"; userBll.ContextResponse(context, apiResp); return; StringBuilder sbSQL1 = new StringBuilder(); sbSQL1.AppendFormat(" Phone = '{0}' ", phone); if (!string.IsNullOrWhiteSpace(password)) { sbSQL1.AppendFormat(",Password = '******' ", password); } openIdUser.Phone = phone; if (userBll.Update(openIdUser, sbSQL1.ToString(), string.Format(" AutoID = {0} ", openIdUser.AutoID)) > 0) { //设置登陆状态成功 //设置用户会话ID context.Session[ZentCloud.Common.SessionKey.UserID] = openIdUser.UserID; context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态 apiResp.status = true; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsSuccess; apiResp.msg = "绑定成功"; userBll.ContextResponse(context, apiResp); bllDist.SetUserDistributionOwnerByTemp(openIdUser.UserID, openIdUser.WebsiteOwner); return; } else { apiResp.status = false; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "绑定失败"; userBll.ContextResponse(context, apiResp); return; } } } catch (Exception ex) { apiResp.status = false; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "绑定失败:" + ex.Message; userBll.ContextResponse(context, apiResp); return; } }
public void ProcessRequest(HttpContext context) { string phone = context.Request["phone"]; string code = context.Request["code"]; #region 判断手机格式 if (!MyRegex.PhoneNumLogicJudge(phone)) { apiResp.code = (int)APIErrCode.PhoneFormatError; apiResp.msg = "手机格式错误"; bllSms.ContextResponse(context, apiResp); return; } #endregion #region 判断手机是否已被使用,且是否是当前账号 UserInfo model = bllUser.GetUserInfoByPhone(phone); if (model != null) { if (model.UserID != CurrentUserInfo.UserID) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "手机号码已被其他账号使用,请联系管理员"; bllSms.ContextResponse(context, apiResp); return; } //if (model.IsPhoneVerify == 1) //{ // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "手机号码已验证"; // bllSms.ContextResponse(context, apiResp); // return; //} } #endregion #region 判断验证码是否正确 SmsVerificationCode sms = bllSms.GetLastSmsVerificationCode(phone); if (sms.VerificationCode != code) { apiResp.code = (int)APIErrCode.CheckCodeErr; apiResp.msg = "验证码错误"; bllSms.ContextResponse(context, apiResp); return; } #endregion CurrentUserInfo.Phone = phone; CurrentUserInfo.IsPhoneVerify = 1; CompanyWebsite_Config nWebsiteConfig = bllWebSite.GetCompanyWebsiteConfig(); if (nWebsiteConfig.MemberStandard == 1) { if (CurrentUserInfo.AccessLevel < 1) { CurrentUserInfo.AccessLevel = 1; CurrentUserInfo.MemberStartTime = DateTime.Now; } //CurrentUserInfo.MemberApplyStatus = 9; } if (bllUser.Update(CurrentUserInfo)) { apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "手机验证完成"; } else { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "验证失败"; } bllSms.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; context.Response.Expires = 0; string result = "false"; string phone = context.Request["phone"]; string smsContent = context.Request["smscontent"]; string is_register = context.Request["is_register"]; string is_reset = context.Request["is_reset"]; string is_member = context.Request["is_member"]; string content = context.Request["content"]; List <string> blackIpList = new List <string>(); blackIpList.Add("139.196.16.189"); if (blackIpList.Contains(context.Request.UserHostAddress)) { resp.errcode = 1; resp.errmsg = "Ip Invai"; goto outoff; } if (string.IsNullOrEmpty(phone)) { resp.errcode = 1; resp.errmsg = "请输入手机号"; goto outoff; } if ((!phone.StartsWith("1")) || (!phone.Length.Equals(11))) { resp.errcode = 2; resp.errmsg = "手机号格式不正确"; goto outoff; } if (!ZentCloud.Common.MyRegex.PhoneNumLogicJudge(phone)) { resp.errcode = 2; resp.errmsg = "手机格式不正确"; goto outoff; } if (string.IsNullOrEmpty(smsContent)) { resp.errcode = 1; resp.errmsg = "短信内容不能为空"; goto outoff; } if (!smsContent.Contains("{{SMSVERCODE}}"))//验证码标签 { resp.errcode = 1; resp.errmsg = "缺少标签{{SMSVERCODE}}"; goto outoff; } if (is_register == "1") { BLLUser bllUser = new BLLUser(); BLLJIMP.Model.UserInfo ouser = bllUser.GetUserInfoByPhone(phone, bllUser.WebsiteOwner); if (ouser != null) { resp.errcode = 1; resp.errmsg = "手机号码已存在账号,请尝试找回密码"; goto outoff; } } if (is_reset == "1") { BLLUser bllUser = new BLLUser(); BLLJIMP.Model.UserInfo ouser = bllUser.GetUserInfoByPhone(phone, bllUser.WebsiteOwner); if (ouser == null) { resp.errcode = 1; resp.errmsg = "手机号未注册"; goto outoff; } if (ouser.IsDisable == 1) { resp.errcode = 1; resp.errmsg = "账号已被禁用"; goto outoff; } if (is_member == "1" && ouser.MemberLevel == 0) { resp.errcode = 1; resp.errmsg = "您不是会员"; goto outoff; } } var lastSmsVerificationCode = bllSms.GetLastSmsVerificationCode(phone); if (lastSmsVerificationCode != null) { if ((DateTime.Now - lastSmsVerificationCode.InsertDate).TotalSeconds < 60) { resp.errcode = 3; resp.errmsg = "验证码限制每60秒发送一次"; goto outoff; } } bool isSuccess = false; string verCode = new Random().Next(111111, 999999).ToString(); string msg = ""; smsContent = smsContent.Replace("{{SMSVERCODE}}", verCode);//替换验证码标签 if (content == "1") { smsContent = "金融玩家欢迎你,验证码" + verCode; } string smsSignature = string.Format("{0}", bllSms.GetWebsiteInfoModelFromDataBase().SmsSignature);//短信签名 bllSms.SendSmsVerificationCode(phone, smsContent, smsSignature, verCode, out isSuccess, out msg); if (isSuccess) { resp.errcode = 0; resp.errmsg = "ok"; //resp.sms_vercode = verCode; } else { resp.errcode = 4; resp.errmsg = string.Format("发送验证码失败{0}", msg); } outoff: result = ZentCloud.Common.JSONHelper.ObjectToJson(resp); if (!string.IsNullOrEmpty(context.Request["callback"])) { //返回 jsonp数据 context.Response.Write(string.Format("{0}({1})", context.Request["callback"], result)); } else { //返回json数据 context.Response.Write(result); } }
public void ProcessRequest(HttpContext context) { string phone = context.Request["phone"]; string smsContent = context.Request["smscontent"]; string check_user = context.Request["check_user"]; string limit_user = context.Request["limit_user"]; #region 判断手机格式 if (!MyRegex.PhoneNumLogicJudge(phone)) { apiResp.code = (int)APIErrCode.PhoneFormatError; apiResp.msg = "手机格式错误"; bllSms.ContextResponse(context, apiResp); return; } #endregion #region 判断手机是否已被使用,且是否是当前账号 if (check_user == "1") { UserInfo model = bllUser.GetUserInfoByPhone(phone); if (limit_user == "1" && model == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "该手机号没有账号"; bllSms.ContextResponse(context, apiResp); return; } if (limit_user == "2" && model != null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "该手机号已有账号"; bllSms.ContextResponse(context, apiResp); return; } if (model != null) { UserInfo CurrentUserInfo = bllUser.GetCurrentUserInfo(); if (CurrentUserInfo != null && model.UserID != CurrentUserInfo.UserID) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "手机号码已被其他账号使用,请联系管理员"; bllSms.ContextResponse(context, apiResp); return; } //if (model.IsPhoneVerify == 1) //{ // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "手机号码已验证"; // bllSms.ContextResponse(context, apiResp); // return; //} } } #endregion var lastSmsVerificationCode = bllSms.GetLastSmsVerificationCode(phone); if (lastSmsVerificationCode != null) { if ((DateTime.Now - lastSmsVerificationCode.InsertDate).TotalSeconds < 60) { apiResp.code = (int)APIErrCode.IsRepeat; apiResp.msg = "验证码限制每60秒发送一次"; bllSms.ContextResponse(context, apiResp); return; } } string verCode = new Random().Next(111111, 999999).ToString(); string smsSignature = string.Format("{0}", bllSms.GetWebsiteInfoModelFromDataBase().SmsSignature);//短信签名 if (string.IsNullOrWhiteSpace(smsContent) || !smsContent.Contains("{{SMSVERCODE}}")) { smsContent = "手机验证码:{{SMSVERCODE}}"; } smsContent = smsContent.Replace("{{SMSVERCODE}}", verCode);//替换验证码标签 string msg = ""; bool isSuccess = false; bllSms.SendSmsVerificationCode(phone, smsContent, smsSignature, verCode, out isSuccess, out msg); if (!isSuccess) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "手机验证码发送失败"; bllSms.ContextResponse(context, apiResp); return; } apiResp.status = isSuccess; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "手机验证码已发送"; bllSms.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { string data = context.Request["data"]; RequestModel requestModel; try { requestModel = ZentCloud.Common.JSONHelper.JsonToModel <RequestModel>(context.Request["data"]); } catch (Exception) { resp.errcode = -1; resp.errmsg = "json格式错误,请检查"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } if (!string.IsNullOrEmpty(requestModel.ver_code)) { if (requestModel.ver_code != context.Session["CheckCode"].ToString().ToLower()) { resp.errcode = -1; resp.errmsg = "验证码错误"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } } UserInfo userInfo = bll.GetCurrentUserInfo(); StringBuilder sbPar = new StringBuilder(); StringBuilder sbRemark = new StringBuilder("修改会员信息:"); if (string.IsNullOrWhiteSpace(requestModel.action)) { //默认信息处理方式 if (!string.IsNullOrEmpty(requestModel.truename)) { sbPar.AppendFormat(" TrueName='{0}',", requestModel.truename); sbRemark.AppendFormat(" 姓名[{0}-{1}]", userInfo.TrueName, requestModel.truename); } if (!string.IsNullOrEmpty(requestModel.company)) { sbPar.AppendFormat(" Company='{0}',", requestModel.company); sbRemark.AppendFormat(" 公司[{0}-{1}]", userInfo.Company, requestModel.company); } if (!string.IsNullOrEmpty(requestModel.postion)) { sbPar.AppendFormat(" Postion='{0}',", requestModel.postion); sbRemark.AppendFormat(" 职位[{0}-{1}]", userInfo.Postion, requestModel.postion); } if (!string.IsNullOrEmpty(requestModel.phone) && requestModel.phone != userInfo.Phone) { #region 手机变更进行检查 if (!ZentCloud.Common.MyRegex.PhoneNumLogicJudge(requestModel.phone)) { resp.errcode = (int)BLLJIMP.Enums.APIErrCode.PhoneFormatError; resp.errmsg = "手机号码格式出错"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } if (requestModel.check_code == 1) { #region 判断验证码是否正确 if (bll.GetUserInfoByPhone(requestModel.phone) != null) { resp.errcode = (int)BLLJIMP.Enums.APIErrCode.IsRepeat; resp.errmsg = "手机已存在"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } if (string.IsNullOrEmpty(requestModel.code)) { resp.errmsg = "请填写验证码"; resp.errcode = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } BLLSMS bllSms = new BLLSMS(""); SmsVerificationCode sms = bllSms.GetLastSmsVerificationCode(requestModel.phone); if (sms.VerificationCode != requestModel.code) { resp.errmsg = "验证码错误"; resp.errcode = (int)BLLJIMP.Enums.APIErrCode.CheckCodeErr; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } #endregion } #endregion sbPar.AppendFormat(" Phone='{0}',", requestModel.phone); sbRemark.AppendFormat(" 手机号[{0}-{1}]", userInfo.Phone, requestModel.phone); } if (!string.IsNullOrEmpty(requestModel.email)) { sbPar.AppendFormat(" Email='{0}',", requestModel.email); sbRemark.AppendFormat(" 邮箱[{0}-{1}]", userInfo.Email, requestModel.email); } if (!string.IsNullOrEmpty(requestModel.ex1)) { sbPar.AppendFormat(" Ex1='{0}',", requestModel.ex1); } if (!string.IsNullOrEmpty(requestModel.ex2)) { sbPar.AppendFormat(" Ex2='{0}',", requestModel.ex2); } if (!string.IsNullOrEmpty(requestModel.district)) { sbPar.AppendFormat(" District='{0}',", requestModel.district); } if (!string.IsNullOrEmpty(requestModel.nickname)) { sbPar.AppendFormat(" WXNickname='{0}',", requestModel.nickname); sbRemark.AppendFormat(" 昵称[{0}-{1}]", userInfo.WXNickname, requestModel.nickname); } if (!string.IsNullOrEmpty(requestModel.gender)) { sbPar.AppendFormat(" Gender='{0}',", requestModel.gender); string oG = ""; if (userInfo.Gender == "1") { oG = "男"; } else if (userInfo.Gender == "0") { oG = "女"; } string nG = ""; if (requestModel.gender == "1") { nG = "男"; } else if (requestModel.gender == "0") { nG = "女"; } sbRemark.AppendFormat(" 性别[{0}-{1}]", oG, nG); } if (!string.IsNullOrEmpty(requestModel.birthday.ToString())) { sbPar.AppendFormat(" BirthDay='{0}',", bll.GetTime(requestModel.birthday).ToString()); } if (!string.IsNullOrEmpty(requestModel.identification)) { sbPar.AppendFormat(" Ex5='{0}',", requestModel.identification); } if (requestModel.describe != null) { sbPar.AppendFormat(" Description='{0}',", ZentCloud.Common.StringHelper.GetReplaceStr(requestModel.describe)); } if (!string.IsNullOrEmpty(requestModel.province)) { sbPar.AppendFormat(" Province='{0}',", requestModel.province); } if (!string.IsNullOrEmpty(requestModel.city)) { sbPar.AppendFormat(" City='{0}',", requestModel.city); } if (requestModel.salary >= 0) { sbPar.AppendFormat(" Salary={0},", requestModel.salary); } if (!string.IsNullOrEmpty(requestModel.ex3)) { sbPar.AppendFormat(" Ex3='{0}',", requestModel.ex3); } if (!string.IsNullOrEmpty(requestModel.ex4)) { sbPar.AppendFormat(" Ex4='{0}',", requestModel.ex4); } if (!string.IsNullOrEmpty(requestModel.avatar)) { sbPar.AppendFormat(" Avatar='{0}',", requestModel.avatar); sbRemark.AppendFormat(" 头像[{0}-{1}]", userInfo.Avatar, requestModel.avatar); } if (!string.IsNullOrEmpty(requestModel.identity_card_photo_front)) { sbPar.AppendFormat(" IdentityCardPhotoFront='{0}',", requestModel.identity_card_photo_front); sbRemark.AppendFormat(" 身份证正面[{0}-{1}]", userInfo.IdentityCardPhotoFront, requestModel.identity_card_photo_front); } if (!string.IsNullOrEmpty(requestModel.identity_card_photo_behind)) { sbPar.AppendFormat(" IdentityCardPhotoBehind='{0}',", requestModel.identity_card_photo_behind); sbRemark.AppendFormat(" 身份证反面[{0}-{1}]", userInfo.IdentityCardPhotoBehind, requestModel.identity_card_photo_behind); } if (!string.IsNullOrEmpty(requestModel.identity_card_photo_handheld)) { sbPar.AppendFormat(" IdentityCardPhotoHandheld='{0}',", requestModel.identity_card_photo_handheld); sbRemark.AppendFormat(" 身份证手持照[{0}-{1}]", userInfo.IdentityCardPhotoHandheld, requestModel.identity_card_photo_handheld); } if (!string.IsNullOrEmpty(requestModel.intelligence_certificate_business)) { sbPar.AppendFormat(" IntelligenceCertificateBusiness='{0}',", requestModel.intelligence_certificate_business); } if (!string.IsNullOrEmpty(requestModel.business_intelligence_certificate_photo1)) { sbPar.AppendFormat(" BusinessIntelligenceCertificatePhoto1='{0}',", requestModel.business_intelligence_certificate_photo1); sbRemark.AppendFormat(" 公司资质三证合一[{0}-{1}]", userInfo.BusinessIntelligenceCertificatePhoto1, requestModel.business_intelligence_certificate_photo1); } if (!string.IsNullOrEmpty(requestModel.business_intelligence_certificate_photo2)) { sbPar.AppendFormat(" BusinessIntelligenceCertificatePhoto2='{0}',", requestModel.business_intelligence_certificate_photo2); sbRemark.AppendFormat(" 公司资质补充一[{0}-{1}]", userInfo.BusinessIntelligenceCertificatePhoto2, requestModel.business_intelligence_certificate_photo2); } if (!string.IsNullOrEmpty(requestModel.business_intelligence_certificate_photo3)) { sbPar.AppendFormat(" BusinessIntelligenceCertificatePhoto3='{0}',", requestModel.business_intelligence_certificate_photo3); sbRemark.AppendFormat(" 公司资质补充二[{0}-{1}]", userInfo.BusinessIntelligenceCertificatePhoto3, requestModel.business_intelligence_certificate_photo3); } if (!string.IsNullOrEmpty(requestModel.business_intelligence_certificate_photo4)) { sbPar.AppendFormat(" BusinessIntelligenceCertificatePhoto4='{0}',", requestModel.business_intelligence_certificate_photo4); } if (!string.IsNullOrEmpty(requestModel.business_intelligence_certificate_photo5)) { sbPar.AppendFormat(" BusinessIntelligenceCertificatePhoto5='{0}',", requestModel.business_intelligence_certificate_photo5); } if (requestModel.imgs != null) { sbPar.AppendFormat(" Images='{0}',", requestModel.imgs); } sbPar.AppendFormat(" ViewType='{0}',", requestModel.view_type); } else if (requestModel.action == "memberattribution") { //归属地设置 //Province ProvinceCode City CityCode District DistrictCode ,Town TownCode 暂时设置的的时候就设置为空 sbPar.AppendFormat(" Province='{0}', ProvinceCode='{1}', City='{2}', CityCode='{3}', District='{4}', DistrictCode='{5}' ", requestModel.province, requestModel.province_code, requestModel.city, requestModel.city_code, requestModel.district, requestModel.district_code ); } if (requestModel.company_is_repeat == "1") { if (userInfo.Company != requestModel.company) { if (bll.GetUserInfoByCompany(requestModel.company) != null) { resp.errcode = (int)BLLJIMP.Enums.APIErrCode.IsRepeat; resp.errmsg = "公司名称重复"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } } } //if (requestModel.phone_is_repeat=="1") //{ // if (userInfo.Phone != requestModel.phone) // { // if (bll.GetUserInfoByPhone(requestModel.phone) != null) // { // resp.errcode = (int)BLLJIMP.Enums.APIErrCode.IsRepeat; // resp.errmsg = "手机已存在"; // context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); // return; // } // } //} if (requestModel.user_is_repeat == "1") { if (userInfo.WXNickname != requestModel.nickname) { if (bll.GetUserInfoByNickName(requestModel.nickname) != null) { resp.errcode = (int)BLLJIMP.Enums.APIErrCode.IsRepeat; resp.errmsg = "昵称重复"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } } } if (bll.Update(userInfo, sbPar.ToString().TrimEnd(','), string.Format(" AutoID={0}", userInfo.AutoID)) > 0) { resp.isSuccess = true; resp.errmsg = "ok"; resp.returnObj = sbPar.ToString(); try { string remark = sbRemark.ToString(); if (remark != "修改会员信息:" && CurrentUserInfo.MemberLevel >= 10) { bllLog.Add(EnumLogType.ShMember, EnumLogTypeAction.Update, CurrentUserInfo.UserID, remark, targetID: userInfo.UserID); } bll.AddUserScoreDetail(CurrentUserInfo.UserID, CommonPlatform.Helper.EnumStringHelper.ToString(ZentCloud.BLLJIMP.Enums.ScoreDefineType.UpdateMyInfo), bll.WebsiteOwner, null, null); } catch (Exception) { } } else { resp.errcode = (int)BLLJIMP.Enums.APIErrCode.OperateFail; resp.errmsg = "修改会员数据出错"; } context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); }