private bool CheckAddUserParameters(UserParam parameter, out string result)
        {
            if (!OpenApiHelper.CheckSystemParameters(parameter.app_key, parameter.timestamp, parameter.sign, out result))
            {
                return(false);
            }
            parameter.user_name = DataHelper.CleanSearchString(parameter.user_name);
            if (string.IsNullOrWhiteSpace(parameter.user_name))
            {
                result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Parameters_Format_Error, "user_name");
                return(false);
            }
            if (MemberProcessor.FindMemberByUsername(parameter.user_name) != null)
            {
                result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Parameters_Format_Error, "user_name");
                return(false);
            }
            Regex regex  = new Regex("^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$", RegexOptions.Compiled);
            Regex regex2 = new Regex("^0?(13|15|18|14|17)[0-9]{9}$", RegexOptions.Compiled);

            if (!string.IsNullOrWhiteSpace(parameter.email))
            {
                if (!regex.IsMatch(parameter.email))
                {
                    result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Parameters_Format_Error, "email");
                    return(false);
                }
                if (MemberProcessor.FindMemberByEmail(parameter.email) != null)
                {
                    result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Parameters_Format_Error, "email");
                    return(false);
                }
            }
            if (!string.IsNullOrWhiteSpace(parameter.mobile))
            {
                if (!regex2.IsMatch(parameter.mobile))
                {
                    result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Parameters_Format_Error, "mobile");
                    return(false);
                }
                if (MemberProcessor.FindMemberByCellphone(parameter.mobile) != null)
                {
                    result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Parameters_Format_Error, "mobile");
                    return(false);
                }
            }
            return(true);
        }
Example #2
0
        private void btnReferral_Click(object sender, EventArgs e)
        {
            SiteSettings masterSettings   = SettingsManager.GetMasterSettings();
            string       text             = DataHelper.CleanSearchString(this.txtRealName.Text.Trim());
            string       text2            = DataHelper.CleanSearchString(this.txtEmail.Text.Trim());
            string       text3            = DataHelper.CleanSearchString(this.txtPhone.Text.Trim());
            string       text4            = DataHelper.CleanSearchString(this.txtAddress.Text.Trim());
            string       promoterNeedInfo = masterSettings.PromoterNeedInfo;
            string       text5            = DataHelper.CleanSearchString(this.txtShopName.Text.Trim());
            string       bannerUrl        = "";
            MemberInfo   user             = Users.GetUser(HiContext.Current.UserId);

            if (HiContext.Current.SiteSettings.ApplyReferralCondition == 1 && HiContext.Current.User.Expenditure < HiContext.Current.SiteSettings.ApplyReferralNeedAmount)
            {
                this.ShowMessage("您的消费金额还没达到系统设置的金额(" + HiContext.Current.SiteSettings.ApplyReferralNeedAmount.F2ToString("f2") + ")元", false, "", 1);
            }
            else if (string.IsNullOrEmpty(text5) || text5.Length > 100)
            {
                this.ShowMessage("请输入店铺名称,长度在1-10个之间", false, "", 1);
            }
            else if (string.IsNullOrEmpty(text) && promoterNeedInfo.Contains("1"))
            {
                this.ShowMessage("请填写真实姓名,长度在1-10个之间", false, "", 1);
            }
            else if (string.IsNullOrEmpty(text4) && promoterNeedInfo.Contains("4"))
            {
                this.ShowMessage("请填写详细地址", false, "", 1);
            }
            else
            {
                if (promoterNeedInfo.Contains("3"))
                {
                    if (text2 != null && text2.Length > 0 && !DataHelper.IsEmail(text2))
                    {
                        this.ShowMessage("请输入正确的邮箱地址", false, "", 1);
                        return;
                    }
                    if (text2 != null && text2.Length > 0)
                    {
                        MemberInfo memberInfo = MemberProcessor.FindMemberByEmail(text2);
                        if (memberInfo != null && memberInfo.UserId != user.UserId)
                        {
                            this.ShowMessage("该邮箱地址已被其他用户使用", false, "", 1);
                            return;
                        }
                    }
                }
                if (promoterNeedInfo.Contains("2"))
                {
                    if (text3 != null && text3.Length > 0 && !DataHelper.IsMobile(text3))
                    {
                        this.ShowMessage("请输入正确的手机号码", false, "", 1);
                        return;
                    }
                    if (text3 != null && text3.Length > 0)
                    {
                        MemberInfo memberInfo2 = MemberProcessor.FindMemberByCellphone(text3);
                        if (memberInfo2 != null && memberInfo2.UserId != user.UserId)
                        {
                            this.ShowMessage("该手机号码已被其他用户使用", false, "", 1);
                            return;
                        }
                        if (SettingsManager.GetMasterSettings().IsPromoterValidatePhone)
                        {
                            string msg = "";
                            if (!HiContext.Current.CheckVerifyCode(this.txtNumber.Text.Trim(), ""))
                            {
                                this.ShowMessage("图形验证码错误", false, "", 1);
                                return;
                            }
                            if (!HiContext.Current.CheckPhoneVerifyCode(this.txtPhoneCode.Text.Trim(), text3, out msg))
                            {
                                this.ShowMessage(msg, false, "", 1);
                                return;
                            }
                        }
                    }
                }
                int num         = 0;
                int topRegionId = 0;
                if (this.hidValidateAddress.Value == "1" && this.dropRegionsSelect.GetSelectedRegionId().HasValue)
                {
                    num         = this.dropRegionsSelect.GetSelectedRegionId().Value;
                    topRegionId = RegionHelper.GetTopRegionId(num, true);
                }
                if (MemberProcessor.ReferralRequest(HiContext.Current.UserId, text, text3, topRegionId, num, text4, text2, text5, bannerUrl))
                {
                    Users.ClearUserCache(HiContext.Current.UserId, "");
                    this.Page.Response.Redirect("/user/ReferralRegisterresults.aspx");
                }
                else
                {
                    this.ShowMessage("申请失败,请重试", false, "", 1);
                }
            }
        }