/// <summary> /// 发送验证码 /// </summary> /// <param name="phone"></param> /// <param name="verificationCode"></param> /// <param name="isSuccess"></param> /// <param name="msg"></param> public void SendSmsVerificationCode(string phone, string msgContent, string smsSignature, string verificationCode, out bool isSuccess, out string msg) { isSuccess = false; msg = ""; if (string.IsNullOrEmpty(smsSignature)) { smsSignature = "至云"; } string sendContent = string.Format("{0}【{1}】", msgContent, smsSignature); ZentCloud.ZCBLLEngine.BLLTransaction tran = new BLLTransaction(); SmsVerificationCode model = new SmsVerificationCode(); model.Phone = phone; model.InsertDate = DateTime.Now; model.VerificationCode = verificationCode; model.WebsiteOwner = WebsiteOwner; if (Add(model, tran)) { if (SendSms(WebsiteOwner, phone, sendContent)) { isSuccess = true; tran.Commit(); } else { msg = "短信发送失败"; tran.Rollback(); } } else { tran.Rollback(); } }
public async Task <IActionResult> GetSmsPriorityCode(SmsConfirmationRequest model) { var result = await _confirmationCodesService.GetPriorityCode(model.PartnerId, model.Phone); if (result == null) { return(BadRequest("Code not found.")); } var responseModel = new SmsVerificationCode(result.Code, result.CreationDateTime, result.ExpirationDate); return(Ok(responseModel)); }
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); }
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) { 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) { 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) { 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)); }