public void ProcessRequest(HttpContext context) { JuActivityInfo ninfo = new JuActivityInfo(); ninfo.WebsiteOwner = bll.WebsiteOwner; ninfo.UserID = currentUserInfo.UserID; ninfo.ArticleType = context.Request["ArticleType"]; #region 字段检查 ArticleCategoryTypeConfig typeConfig = bllArticleCategory.GetArticleCategoryTypeConfig(bllArticleCategory.WebsiteOwner, ninfo.ArticleType); if (typeConfig.TimeSetMethod == 1 || typeConfig.TimeSetMethod == 2) { ninfo.UserLongitude = context.Request["UserLongitude"]; ninfo.UserLatitude = context.Request["UserLatitude"]; } List <TableFieldMapping> listFieldList = bllTableFieldMap.GetTableFieldMapByWebsite(bllTableFieldMap.WebsiteOwner, "ZCJ_JuActivityInfo", ninfo.ArticleType, null, "0", null); List <string> DefFields = new List <string>() { "JuActivityID" }; JObject jtCurUser = JObject.FromObject(ninfo); List <string> listPropertys = jtCurUser.Properties().Select(p => p.Name).ToList(); foreach (var item in listFieldList.Where(p => !DefFields.Contains(p.Field) && listPropertys.Contains(p.Field)).OrderBy(p => p.Sort)) { string nValue = context.Request[item.Field]; if (item.FieldIsNull == 1 && string.IsNullOrWhiteSpace(nValue)) { 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(nValue)) { 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(nValue)) { 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(nValue)) { 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(nValue); if (!match.Success) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } #endregion } ninfo = bll.ConvertToModel <JuActivityInfo>(ninfo, item.Field, nValue); } #endregion ninfo.JuActivityID = int.Parse(bll.GetGUID(BLLJIMP.TransacType.AddOutlets)); if (bll.Add(ninfo)) { apiResp.status = true; apiResp.msg = "提交成功"; apiResp.code = (int)APIErrCode.IsSuccess; } else { apiResp.msg = "提交失败"; apiResp.code = (int)APIErrCode.OperateFail; } bll.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { string id = context.Request["id"]; 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 = "手机号码已被其他账号使用,请联系管理员"; bllUser.ContextResponse(context, apiResp); return; } #endregion CurrentUserInfo = bllUser.GetUserInfoByAutoID(Convert.ToInt32(id), bllUser.WebsiteOwner); if (CurrentUserInfo == null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "绑定账号未找到"; bllUser.ContextResponse(context, apiResp); return; } if (!string.IsNullOrWhiteSpace(CurrentUserInfo.WXOpenId) && CurrentUserInfo.WXOpenId != wxOpenId) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "账号已有其他微信绑定"; bllUser.ContextResponse(context, apiResp); return; } List <string> pmsString = new List <string>(); pmsString.Add(string.Format("Phone='{0}'", Phone)); pmsString.Add(string.Format("WXOpenId='{0}'", wxOpenId)); pmsString.Add(string.Format("IsPhoneVerify='{0}'", 1)); CompanyWebsite_Config nWebsiteConfig = bllWebSite.GetCompanyWebsiteConfig(); if (nWebsiteConfig.MemberStandard == 3) { pmsString.Add(string.Format("MemberApplyStatus='{0}'", 1)); pmsString.Add(string.Format("MemberApplyTime='{0}'", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); } else { if (CurrentUserInfo.AccessLevel < 1) { CurrentUserInfo.AccessLevel = 1; CurrentUserInfo.MemberStartTime = DateTime.Now; } pmsString.Add(string.Format("AccessLevel='{0}'", CurrentUserInfo.AccessLevel)); pmsString.Add(string.Format("MemberStartTime='{0}'", CurrentUserInfo.MemberStartTime.ToString("yyyy-MM-dd HH:mm:ss"))); //CurrentUserInfo.MemberApplyStatus = 9; } if (bllUser.Update(new UserInfo(), ZentCloud.Common.MyStringHelper.ListToStr(pmsString, "", ","), string.Format("AutoID={0}", CurrentUserInfo.AutoID.ToString())) > 0) { 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"]; 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"]; #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) { UserInfo nUser = new UserInfo(); nUser = bllTableFieldMap.ConvertRequestToModel <UserInfo>(nUser); nUser.UserID = string.Format("PCUser{0}", Guid.NewGuid().ToString());//Guid nUser.Password = ZentCloud.Common.Rand.Str_char(12); nUser.UserType = 2; nUser.WebsiteOwner = bllTableFieldMap.WebsiteOwner; nUser.LastLoginDate = DateTime.Now; List <TableFieldMapping> formField = bllTableFieldMap.GetTableFieldMapByWebsite(bllTableFieldMap.WebsiteOwner, "ZCJ_UserInfo", null, null, context.Request["mapping_type"]); formField = formField.Where(p => p.IsReadOnly == 0 && p.IsDelete == 0 && p.Field != "AutoID" && p.Field != "UserID").ToList(); List <string> defFields = new List <string>() { "AutoID", "UserID", "Password", "UserType", "TrueName", "Phone", "WebsiteOwner" }; JObject jtCurUser = JObject.FromObject(nUser); List <JProperty> listPropertys = jtCurUser.Properties().ToList(); foreach (var item in formField.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 } } if (bllTableFieldMap.Add(nUser)) { if (!string.IsNullOrEmpty(nUser.TagName)) { foreach (var tag in nUser.TagName.Split(',')) { if (bllUser.GetCount <ZentCloud.BLLJIMP.Model.MemberTag>(string.Format(" WebsiteOwner='{0}' And TagName='{1}' And TagType='Member'", bllUser.WebsiteOwner, tag)) == 0) { ZentCloud.BLLJIMP.Model.MemberTag model = new BLLJIMP.Model.MemberTag(); model.CreateTime = DateTime.Now; model.WebsiteOwner = bllUser.WebsiteOwner; model.TagType = "Member"; model.TagName = tag; model.Creator = currentUserInfo.UserID; if (!bllUser.Add(model)) { apiResp.msg = "新增标签失败"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); } } } } apiResp.status = true; apiResp.msg = "新增完成"; apiResp.code = (int)APIErrCode.IsSuccess; } else { apiResp.msg = "新增失败"; apiResp.code = (int)APIErrCode.OperateFail; } bllTableFieldMap.ContextResponse(context, apiResp); }
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) { List <TableFieldMapping> formField = bllTableFieldMap.GetTableFieldMapByWebsite(bllTableFieldMap.WebsiteOwner, "ZCJ_UserInfo", null, null, context.Request["mapping_type"]); formField = formField.Where(p => p.IsReadOnly == 0 && p.IsDelete == 0 && p.Field != "AutoID").ToList(); if (formField.Count == 0) { apiResp.msg = "没有可编辑字段"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); return; } List <string> limitFields = new List <string>() { "UserID", "Phone", "WXOpenId" }; #region 默认信息检查 姓名 string autoID = context.Request["AutoID"]; if (string.IsNullOrWhiteSpace(autoID) || autoID == "0") { apiResp.msg = "用户未找到"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); return; } UserInfo curUser = bllTableFieldMap.GetByKey <UserInfo>("AutoID", autoID); if (curUser == null) { apiResp.msg = "用户未找到"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); return; } #endregion List <string> pms = new List <string>(); #region 构造修改字段 TableFieldMapping userIDField = formField.FirstOrDefault(p => p.Field.Equals("UserID")); if (userIDField != null) { string val = context.Request[userIDField.Field]; if (!string.IsNullOrWhiteSpace(val)) { List <UserInfo> oUserList = bllTableFieldMap.GetColList <UserInfo>(int.MaxValue, 1, string.Format("UserID='{0}' And AutoID != {1} ", val, autoID), "AutoID,UserID"); if (oUserList.Count > 0) { apiResp.msg = "账号已被使用"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); return; } pms.Add(string.Format("{0}='{1}'", userIDField.Field, val)); } } TableFieldMapping phoneField = formField.FirstOrDefault(p => p.Field.Equals("Phone")); if (phoneField != null) { string val = context.Request[phoneField.Field]; if (!string.IsNullOrWhiteSpace(val)) { List <UserInfo> oUserList = bllTableFieldMap.GetColList <UserInfo>(int.MaxValue, 1, string.Format("Phone='{0}' And WebsiteOwner='{2}' And AutoID != {1} And IsSubAccount!='1'", val, autoID, bllTableFieldMap.WebsiteOwner), "AutoID,Phone"); if (oUserList.Count > 0) { apiResp.msg = "手机号已被使用"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); return; } pms.Add(string.Format("{0}='{1}'", phoneField.Field, val)); } } TableFieldMapping wXOpenIdField = formField.FirstOrDefault(p => p.Field.Equals("WXOpenId")); if (wXOpenIdField != null) { string val = context.Request[wXOpenIdField.Field]; if (!string.IsNullOrWhiteSpace(val)) { List <UserInfo> oUserList = bllTableFieldMap.GetColList <UserInfo>(int.MaxValue, 1, string.Format("WXOpenId='{0}' And WebsiteOwner='{2}' And AutoID != {1} ", val, autoID, bllTableFieldMap.WebsiteOwner), "AutoID,Phone"); if (oUserList.Count > 0) { apiResp.msg = "WXOpenId已被使用"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); return; } pms.Add(string.Format("{0}='{1}'", wXOpenIdField.Field, val)); } } foreach (TableFieldMapping item in formField.Where(p => !limitFields.Contains(p.Field))) { string val = context.Request[item.Field]; if (string.IsNullOrWhiteSpace(val) && item.FieldIsNull == 1) { apiResp.msg = item.MappingName + "不能为空"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); return; } if (string.IsNullOrWhiteSpace(val)) { pms.Add(string.Format("{0}=Null", item.Field)); } else { if (!string.IsNullOrWhiteSpace(item.FormatValiFunc)) { #region 检查数据格式 //检查数据格式 if (item.FormatValiFunc == "number") { if (!MyRegex.IsNumber(val)) { 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(val)) { 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(val)) { 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(val); if (!match.Success) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("{0}格式不正确", item.MappingName); bllTableFieldMap.ContextResponse(context, apiResp); return; } } #endregion } pms.Add(string.Format("{0}='{1}'", item.Field, val)); } } #endregion if (bllTableFieldMap.Update(new UserInfo(), ZentCloud.Common.MyStringHelper.ListToStr(pms, "", ","), string.Format("AutoID={0}", autoID)) > 0) { apiResp.status = true; apiResp.msg = "编辑完成"; apiResp.code = (int)APIErrCode.IsSuccess; bllUser.AddUserScoreDetail(curUser.UserID, CommonPlatform.Helper.EnumStringHelper.ToString(ZentCloud.BLLJIMP.Enums.ScoreDefineType.UpdateMyInfo), bllUser.WebsiteOwner, null, null); // TableFieldMapping tagNameField = formField.FirstOrDefault(p => p.Field.Equals("TagName")); if (tagNameField != null && context.Request["TagName"] != null) { foreach (var tag in context.Request["TagName"].Split(',')) { if (bllUser.GetCount <ZentCloud.BLLJIMP.Model.MemberTag>(string.Format(" WebsiteOwner='{0}' And TagName='{1}' And TagType='Member'", bllUser.WebsiteOwner, tag)) == 0) { ZentCloud.BLLJIMP.Model.MemberTag model = new BLLJIMP.Model.MemberTag(); model.CreateTime = DateTime.Now; model.WebsiteOwner = bllUser.WebsiteOwner; model.TagType = "Member"; model.TagName = tag; model.Creator = currentUserInfo.UserID; if (!bllUser.Add(model)) { apiResp.msg = "新增标签失败"; apiResp.code = (int)APIErrCode.OperateFail; bllTableFieldMap.ContextResponse(context, apiResp); } } } } // } else { apiResp.msg = "编辑失败"; apiResp.code = (int)APIErrCode.OperateFail; } bllTableFieldMap.ContextResponse(context, apiResp); }