Beispiel #1
0
 protected VActivityidTemplatedWebControl()
 {
     if (MemberProcessor.GetCurrentMember() == null)
     {
         SiteSettings masterSettings = SettingsManager.GetMasterSettings(true, wid);
         if (masterSettings.IsValidationService)
         {
             string str = this.Page.Request.QueryString["code"];
             if (!string.IsNullOrEmpty(str))
             {
                 string responseResult = this.GetResponseResult("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + masterSettings.WeixinAppId + "&secret=" + masterSettings.WeixinAppSecret + "&code=" + str + "&grant_type=authorization_code");
                 if (responseResult.Contains("access_token"))
                 {
                     JObject obj2 = JsonConvert.DeserializeObject(responseResult) as JObject;
                     string  str3 = this.GetResponseResult("https://api.weixin.qq.com/sns/userinfo?access_token=" + obj2["access_token"].ToString() + "&openid=" + obj2["openid"].ToString() + "&lang=zh_CN");
                     if (str3.Contains("nickname"))
                     {
                         JObject    obj3       = JsonConvert.DeserializeObject(str3) as JObject;
                         string     generateId = Globals.GetGenerateId();
                         MemberInfo member     = new MemberInfo {
                             GradeId        = MemberProcessor.GetDefaultMemberGrade(this.wid),
                             UserName       = Globals.UrlDecode(obj3["nickname"].ToString()),
                             OpenId         = obj3["openid"].ToString(),
                             CreateDate     = DateTime.Now,
                             SessionId      = generateId,
                             SessionEndTime = DateTime.Now.AddDays(10),
                             wid            = this.wid
                         };
                         MemberProcessor.CreateMember(member);
                         MemberInfo info2  = MemberProcessor.GetMember(generateId);
                         HttpCookie cookie = new HttpCookie("Vshop-Member")
                         {
                             Value   = info2.UserId.ToString(),
                             Expires = DateTime.Now.AddYears(10)
                         };
                         HttpContext.Current.Response.Cookies.Add(cookie);
                         this.Page.Response.Redirect(HttpContext.Current.Request.Url.ToString());
                     }
                     else
                     {
                         this.Page.Response.Redirect(Globals.ApplicationPath + "Default.aspx");
                     }
                 }
                 else
                 {
                     this.Page.Response.Redirect(Globals.ApplicationPath + "Default.aspx");
                 }
             }
             else if (!string.IsNullOrEmpty(this.Page.Request.QueryString["state"]))
             {
                 this.Page.Response.Redirect(Globals.ApplicationPath + "Default.aspx");
             }
             else
             {
                 string url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + masterSettings.WeixinAppId + "&redirect_uri=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()) + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
                 this.Page.Response.Redirect(url);
             }
         }
     }
 }
Beispiel #2
0
        private void ProcessRegiester(System.Web.HttpContext context)
        {
            string text  = context.Request["userName"];
            string text2 = context.Request["password"];
            string text3 = context.Request["email"];

            if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text2) || string.IsNullOrEmpty(text3))
            {
                context.Response.Write(this.GetErrorJosn(101, "缺少必填参数"));
                return;
            }
            if (string.IsNullOrEmpty(text3.Trim()))
            {
                context.Response.Write(this.GetErrorJosn(203, "邮箱帐号不能为空"));
                return;
            }
            if (text3.Length > 256 || !System.Text.RegularExpressions.Regex.IsMatch(text3, "([a-zA-Z\\.0-9_-])+@([a-zA-Z0-9_-])+((\\.[a-zA-Z0-9_-]{2,4}){1,2})"))
            {
                context.Response.Write(this.GetErrorJosn(204, "错误的邮箱帐号"));
                return;
            }
            Member member = new Member(UserRole.Member);

            member.GradeId             = MemberProcessor.GetDefaultMemberGrade();
            member.SessionId           = Globals.GetGenerateId();
            member.Username            = text;
            member.Email               = text3;
            member.Password            = text2;
            member.PasswordFormat      = System.Web.Security.MembershipPasswordFormat.Hashed;
            member.TradePasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;
            member.TradePassword       = text2;
            member.IsApproved          = true;
            member.RealName            = string.Empty;
            member.Address             = string.Empty;
            CreateUserStatus createUserStatus = MemberProcessor.CreateMember(member);

            if (createUserStatus == CreateUserStatus.DuplicateUsername || createUserStatus == CreateUserStatus.DisallowedUsername)
            {
                context.Response.Write(this.GetErrorJosn(201, "用户名重复"));
                return;
            }
            if (createUserStatus == CreateUserStatus.DuplicateEmailAddress)
            {
                context.Response.Write(this.GetErrorJosn(202, "邮件名重复"));
                return;
            }
            if (createUserStatus == CreateUserStatus.Created)
            {
                Messenger.UserRegister(member, text2);
                member.OnRegister(new UserEventArgs(member.Username, text2, null));
                System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                stringBuilder.Append("{\"result\":{");
                stringBuilder.AppendFormat("\"uid\":{0},", member.UserId);
                stringBuilder.AppendFormat("\"sessionid\":\"{0}\"", member.SessionId);
                stringBuilder.Append("}}");
                context.Response.Write(stringBuilder.ToString());
                return;
            }
            context.Response.Write(this.GetErrorJosn(121, "注册用户失败"));
        }
        private void SkipWinxinOpenId(string userName, string openId)
        {
            string     generateId = Globals.GetGenerateId();
            MemberInfo memberInfo = new MemberInfo();

            memberInfo.GradeId   = MemberProcessor.GetDefaultMemberGrade();
            memberInfo.UserName  = userName;
            memberInfo.SessionId = generateId;
            memberInfo.Password  = generateId;
            string text2 = memberInfo.PasswordSalt = "Open";

            memberInfo.RealName = string.Empty;
            memberInfo.Address  = string.Empty;
            int num = MemberProcessor.CreateMember(memberInfo);

            if (num == 0)
            {
                memberInfo.UserName = "******" + generateId;
                memberInfo.Password = generateId;
                MemberProcessor.CreateMember(memberInfo);
            }
            MemberOpenIdInfo memberOpenIdInfo = new MemberOpenIdInfo();

            memberOpenIdInfo.UserId     = num;
            memberOpenIdInfo.OpenIdType = "hishop.plugins.openid.weixin";
            memberOpenIdInfo.OpenId     = openId;
            if (MemberProcessor.GetMemberByOpenId(memberOpenIdInfo.OpenIdType, memberOpenIdInfo.OpenId) == null)
            {
                MemberProcessor.AddMemberOpenId(memberOpenIdInfo);
            }
            Users.SetCurrentUser(num, 30, true, false);
            HiContext.Current.User = memberInfo;
        }
Beispiel #4
0
        private bool CreatMember(string OpenId, int ReferralUserId)
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);
            string       tOKEN          = TokenApi.GetToken_Message(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret);
            string       nickName       = "";
            string       headImageUrl   = "";
            string       retInfo        = "";

            BarCodeApi.GetHeadImageUrlByOpenID(tOKEN, OpenId, out retInfo, out nickName, out headImageUrl);
            string     generateId = Globals.GetGenerateId();
            MemberInfo info       = new MemberInfo
            {
                GradeId        = MemberProcessor.GetDefaultMemberGrade(),
                UserName       = Globals.UrlDecode(nickName),
                OpenId         = OpenId,
                CreateDate     = DateTime.Now,
                SessionId      = generateId,
                SessionEndTime = DateTime.Now.AddYears(10),
                UserHead       = headImageUrl,
                ReferralUserId = ReferralUserId,
                Password       = HiCryptographer.Md5Encrypt("888888")
            };

            Globals.Debuglog(JsonConvert.SerializeObject(info), "_Debuglog.txt");
            return(MemberProcessor.CreateMember(info));
        }
Beispiel #5
0
        private bool CreatMember(string OpenId, int ReferralUserId, string AceessTokenDefault = "")
        {
            if (string.IsNullOrEmpty(AceessTokenDefault))
            {
                SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);
                AceessTokenDefault = TokenApi.GetToken_Message(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret);
            }
            string urlToDecode = "";
            string userHead    = "";
            string text        = "";

            BarCodeApi.GetHeadImageUrlByOpenID(AceessTokenDefault, OpenId, out text, out urlToDecode, out userHead);
            string     generateId = Globals.GetGenerateId();
            MemberInfo memberInfo = new MemberInfo();

            memberInfo.GradeId        = MemberProcessor.GetDefaultMemberGrade();
            memberInfo.UserName       = Globals.UrlDecode(urlToDecode);
            memberInfo.OpenId         = OpenId;
            memberInfo.CreateDate     = System.DateTime.Now;
            memberInfo.SessionId      = generateId;
            memberInfo.SessionEndTime = System.DateTime.Now.AddYears(10);
            memberInfo.UserHead       = userHead;
            memberInfo.ReferralUserId = ReferralUserId;
            memberInfo.Password       = HiCryptographer.Md5Encrypt("888888");
            Globals.Debuglog(JsonConvert.SerializeObject(memberInfo), "_DebuglogScanRegisterUserInfo.txt");
            return(MemberProcessor.CreateMember(memberInfo));
        }
Beispiel #6
0
        protected override void AttachChildControls()
        {
            if (!int.TryParse(this.Page.Request.QueryString["activityid"], out this.activityid))
            {
                base.GotoResourceNotFound("");
            }
            this.bgimg           = (HtmlImage)this.FindControl("bgimg");
            this.litActivityDesc = (Literal)this.FindControl("litActivityDesc");
            this.litStartDate    = (Literal)this.FindControl("litStartDate");
            this.litEndDate      = (Literal)this.FindControl("litEndDate");
            this.litPrizeNames   = (Common_PrizeNames)this.FindControl("litPrizeNames");
            this.litPrizeUsers   = (Common_PrizeUsers)this.FindControl("litPrizeUsers");
            PageTitle.AddSiteNameTitle("幸运大转盘");
            LotteryActivityInfo lotteryActivity = VshopBrowser.GetLotteryActivity(this.activityid);

            if (lotteryActivity == null)
            {
                base.GotoResourceNotFound("");
            }
            if (MemberProcessor.GetCurrentMember() == null)
            {
                MemberInfo member     = new MemberInfo();
                string     generateId = Globals.GetGenerateId();
                member.GradeId        = MemberProcessor.GetDefaultMemberGrade(this.wid);
                member.UserName       = "";
                member.OpenId         = "";
                member.CreateDate     = DateTime.Now;
                member.SessionId      = generateId;
                member.SessionEndTime = DateTime.Now;
                member.wid            = this.wid;
                MemberProcessor.CreateMember(member);
                member = MemberProcessor.GetMember(generateId);
                HttpCookie cookie = new HttpCookie("Vshop-Member")
                {
                    Value   = member.UserId.ToString(),
                    Expires = DateTime.Now.AddDays(10)
                };
                HttpContext.Current.Response.Cookies.Add(cookie);
            }
            this.litStartDate.Text = lotteryActivity.StartTime.ToString("yyyy年MM月dd日 HH:mm:ss");
            this.litEndDate.Text   = lotteryActivity.EndTime.ToString("yyyy年MM月dd日 HH:mm:ss");
            if (lotteryActivity.PrizeSettingList.Count > 3)
            {
                this.bgimg.Src = Globals.GetVshopSkinPath(null) + "/images/process/panpic2.png";
            }
            if ((lotteryActivity.StartTime < DateTime.Now) && (DateTime.Now < lotteryActivity.EndTime))
            {
                this.litActivityDesc.Text   = lotteryActivity.ActivityDesc;
                this.litPrizeNames.Activity = lotteryActivity;
                this.litPrizeUsers.Activity = lotteryActivity;
                int userPrizeCount = VshopBrowser.GetUserPrizeCount(this.activityid);
                this.litActivityDesc.Text = this.litActivityDesc.Text + string.Format("您一共有{0}次参与机会,目前还剩{1}次。", lotteryActivity.MaxNum, lotteryActivity.MaxNum - userPrizeCount);
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(base.GetType(), "myscript", "<script>$(function(){alert_h(\"活动还未开始或者已经结束!\",function(){window.location.href=\"Default.aspx\";});});</script>");
            }
        }
Beispiel #7
0
        protected override void AttachChildControls()
        {
            if (!long.TryParse(this.Page.Request.QueryString["voteId"], out this.voteId))
            {
                base.GotoResourceNotFound("");
            }
            VoteInfo voteById = StoreHelper.GetVoteById(this.voteId);

            if (voteById != null && voteById.VoteId > 0)
            {
                PageTitle.AddSiteNameTitle(voteById.VoteName);
            }

            this.panelHomePage = (Panel)this.FindControl("panelHomePage");
            if (MemberProcessor.GetCurrentMember() == null)
            {
                MemberInfo member     = new MemberInfo();
                string     generateId = Globals.GetGenerateId();
                member.GradeId        = MemberProcessor.GetDefaultMemberGrade();
                member.UserName       = "";
                member.OpenId         = "";
                member.CreateDate     = DateTime.Now;
                member.SessionId      = generateId;
                member.SessionEndTime = DateTime.Now;
                MemberProcessor.CreateMember(member);
                member = MemberProcessor.GetMember(generateId);
                HttpCookie cookie = new HttpCookie("Vshop-Member")
                {
                    Value   = member.UserId.ToString(),
                    Expires = DateTime.Now.AddYears(10)
                };
                HttpContext.Current.Response.Cookies.Add(cookie);
            }

            //加载配置模块
            panelHomePage.Controls.Clear();
            string  selectSql = string.Format("Select * From Yihui_Votes_Model Where VoteId={0} order by ModelSN", voteId);
            DataSet ds        = DataBaseHelper.GetDataSet(selectSql);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                BaseModel baseModel = (BaseModel)this.Page.LoadControl("/admin/HomePage/ModelTag/" + dr["ModelCode"] + ".ascx");
                baseModel.PKID   = new Guid(dr["VMID"].ToString());//模块的内容ID
                baseModel.PageSN = dr["ModelSN"] + "";
                panelHomePage.Controls.Add(baseModel);
            }
        }
        private string lastAddUser(UserParam parameter)
        {
            string     format     = "{{\"user_add_response\":{{\"user\":{{ \"uid\":\"{0}\",\"password\":\"{1}\",\"created\":\"{2}\" }} }} }}";
            MemberInfo memberInfo = new MemberInfo();

            memberInfo.GradeId   = MemberProcessor.GetDefaultMemberGrade();
            memberInfo.UserName  = parameter.user_name;
            memberInfo.RealName  = parameter.real_name;
            memberInfo.Email     = parameter.email;
            memberInfo.CellPhone = parameter.mobile;
            string text = Globals.RndStr(128, true);

            if (string.IsNullOrWhiteSpace(parameter.password))
            {
                parameter.password = Globals.RndStr(6, true);
            }
            string password = parameter.password;

            password = (memberInfo.Password = Users.EncodePassword(password, text));
            memberInfo.PasswordSalt = text;
            if (parameter.sex.IndexOf("男") >= 0)
            {
                memberInfo.Gender = Gender.Female;
            }
            else if (parameter.sex.IndexOf("女") >= 0)
            {
                memberInfo.Gender = Gender.Female;
            }
            else
            {
                memberInfo.Gender = Gender.NotSet;
            }
            memberInfo.BirthDate  = parameter.birthday;
            memberInfo.RegionId   = RegionHelper.GetRegionId(parameter.town, parameter.district, parameter.city, parameter.state);
            memberInfo.Address    = parameter.address;
            memberInfo.CreateDate = DateTime.Now;
            int num = MemberProcessor.CreateMember(memberInfo);

            if (num > 0)
            {
                return(string.Format(format, num, parameter.password, memberInfo.CreateDate.ToString("yyyy-MM-dd HH:mm:ss")));
            }
            return(OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.System_Error, "create user"));
        }
        private void SkipWinxinOpenId(string userName, string openId)
        {
            string generateId = Globals.GetGenerateId();
            Member member     = new Member(UserRole.Member);

            member.GradeId             = MemberProcessor.GetDefaultMemberGrade();
            member.Username            = userName;
            member.OpenId              = openId;
            member.Email               = generateId + "@localhost.com";
            member.SessionId           = generateId;
            member.Password            = generateId;
            member.PasswordFormat      = MembershipPasswordFormat.Hashed;
            member.TradePasswordFormat = MembershipPasswordFormat.Hashed;
            member.TradePassword       = generateId;
            member.IsApproved          = true;
            member.RealName            = string.Empty;
            member.Address             = string.Empty;
            CreateUserStatus createUserStatus = MemberProcessor.CreateMember(member);

            if (createUserStatus != CreateUserStatus.Created)
            {
                member.Username = "******" + generateId;
                member.Email    = generateId + "@localhost.com";
                member.Password = (member.TradePassword = generateId);
                MemberProcessor.CreateMember(member);
            }
            string     name       = "Vshop-Member";
            HttpCookie httpCookie = new HttpCookie("Vshop-Member");

            httpCookie.Value   = Globals.UrlEncode(member.Username);
            httpCookie.Expires = System.DateTime.Now.AddDays(7);
            httpCookie.Domain  = HttpContext.Current.Request.Url.Host;
            if (HttpContext.Current.Response.Cookies[name] != null)
            {
                HttpContext.Current.Response.Cookies.Remove(name);
            }
            HttpContext.Current.Response.Cookies.Add(httpCookie);

            HiContext.Current.User = member;
            member.OnLogin();
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            ViewBag.Name = new SelectList(context.Roles.Where(u => !u.Name.Contains("Admin"))
                                          .ToList(), "Name", "Name");
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.UserName, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    //Assign Role to user Here
                    await this.UserManager.AddToRoleAsync(user.Id, model.UserRoles);

                    //Ends Here
                    int record  = UserProcessor.CreateUser(user.UserName, user.Email);
                    int record2 = MemberProcessor.CreateMember(model.UserName, model.FirstName, model.LastName, model.Phone);

                    int id     = UserProcessor.get_id(model.UserName);
                    int mem_id = MemberProcessor.get_id(id);

                    return(RedirectToAction("Index", "Users", new
                    {
                        id,
                        mem_id
                    }));
                }

                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Beispiel #11
0
        protected VMemberTemplatedWebControl()
        {
            string userAgent = this.Page.Request.UserAgent;

            MemberInfo currentMember = MemberProcessor.GetCurrentMember();

            if ((currentMember != null) && (currentMember.Status != Convert.ToInt32(UserStatus.Normal)))
            {
                wid = currentMember.wid;
                this.Page.Response.Redirect(Globals.ApplicationPath + "/logout.aspx");
            }
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(true, wid);

            if (((currentMember == null) || (this.Page.Session["userid"] == null)) || (this.Page.Session["userid"].ToString() != currentMember.UserId.ToString()))
            {
                if (userAgent.ToLower().Contains("micromessenger"))
                {
                    if (!masterSettings.IsValidationService)
                    {
                        this.Page.Response.Redirect(Globals.ApplicationPath + "/UserLogin.aspx?returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()));
                    }
                    else
                    {
                        string msg = this.Page.Request.QueryString["code"];
                        this.WriteError(msg, "code值");
                        if (string.IsNullOrEmpty(msg))
                        {
                            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["state"]))
                            {
                                this.Page.Response.Redirect(Globals.ApplicationPath + "/Default.aspx");
                            }
                            else
                            {
                                string str6 = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + masterSettings.WeixinAppId + "&redirect_uri=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()) + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
                                this.WriteError(str6, "用户授权的路径");
                                this.Page.Response.Redirect(str6);
                            }
                        }
                        else
                        {
                            string responseResult = this.GetResponseResult("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + masterSettings.WeixinAppId + "&secret=" + masterSettings.WeixinAppSecret + "&code=" + msg + "&grant_type=authorization_code");
                            if (!responseResult.Contains("access_token"))
                            {
                                this.Page.Response.Redirect(Globals.ApplicationPath + "/Default.aspx");
                            }
                            else
                            {
                                this.WriteError(responseResult, "access_token");
                                JObject obj2 = JsonConvert.DeserializeObject(responseResult) as JObject;
                                if (this.HasLogin(obj2["openid"].ToString()))
                                {
                                    MemberInfo openIdMember = MemberProcessor.GetOpenIdMember(obj2["openid"].ToString());
                                    HttpCookie cookie4      = new HttpCookie("Vshop-Member")
                                    {
                                        Value   = openIdMember.UserId.ToString(),
                                        Expires = DateTime.Now.AddDays(10)
                                    };
                                    HttpContext.Current.Response.Cookies.Add(cookie4);
                                    this.Page.Session["userid"] = openIdMember.UserId.ToString();
                                    DistributorsInfo userIdDistributors = new DistributorsInfo();
                                    userIdDistributors = DistributorsBrower.GetUserIdDistributors(openIdMember.UserId);
                                    if ((userIdDistributors != null) && (userIdDistributors.UserId > 0))
                                    {
                                        HttpCookie cookie5 = new HttpCookie("Vshop-ReferralId")
                                        {
                                            Value   = userIdDistributors.UserId.ToString(),
                                            Expires = DateTime.Now.AddDays(1)
                                        };
                                        HttpContext.Current.Response.Cookies.Add(cookie5);
                                    }
                                    this.WriteError("会员OpenId已绑定过会员帐号已自动登陆!", obj2["openid"].ToString());
                                    if (string.IsNullOrEmpty(openIdMember.UserBindName))
                                    {
                                        //this.Page.Response.Redirect("/BindUserMessage.aspx?status=1&returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()));
                                    }
                                }
                                else
                                {
                                    string str4 = this.GetResponseResult("https://api.weixin.qq.com/sns/userinfo?access_token=" + obj2["access_token"].ToString() + "&openid=" + obj2["openid"].ToString() + "&lang=zh_CN");
                                    if (!str4.Contains("nickname"))
                                    {
                                        this.Page.Response.Redirect(Globals.ApplicationPath + "/Default.aspx");
                                    }
                                    else
                                    {
                                        JObject    obj3       = JsonConvert.DeserializeObject(str4) as JObject;
                                        string     generateId = Globals.GetGenerateId();
                                        MemberInfo member     = new MemberInfo {
                                            GradeId        = MemberProcessor.GetDefaultMemberGrade(this.wid),
                                            UserName       = Globals.UrlDecode(obj3["nickname"].ToString()),
                                            OpenId         = obj3["openid"].ToString(),
                                            CreateDate     = DateTime.Now,
                                            SessionId      = generateId,
                                            SessionEndTime = DateTime.Now.AddDays(10),
                                            UserHead       = obj3["headimgurl"].ToString(),
                                            wid            = this.wid
                                        };
                                        HttpCookie cookie = HttpContext.Current.Request.Cookies["Vshop-ReferralId"];
                                        if (cookie != null)
                                        {
                                            member.ReferralUserId = Convert.ToInt32(cookie.Value);
                                        }
                                        else
                                        {
                                            member.ReferralUserId = 0;
                                        }
                                        member.Password = HiCryptographer.Md5Encrypt("888888");
                                        MemberProcessor.CreateMember(member);
                                        MemberInfo info3   = MemberProcessor.GetMember(generateId);
                                        HttpCookie cookie2 = new HttpCookie("Vshop-Member")
                                        {
                                            Value   = info3.UserId.ToString(),
                                            Expires = DateTime.Now.AddDays(10)
                                        };
                                        HttpContext.Current.Response.Cookies.Add(cookie2);
                                        this.Page.Session["userid"] = info3.UserId.ToString();
                                        DistributorsInfo info4 = new DistributorsInfo();
                                        info4 = DistributorsBrower.GetUserIdDistributors(info3.UserId);
                                        if ((info4 != null) && (info4.UserId > 0))
                                        {
                                            HttpCookie cookie3 = new HttpCookie("Vshop-ReferralId")
                                            {
                                                Value   = info4.UserId.ToString(),
                                                Expires = DateTime.Now.AddDays(1)
                                            };
                                            HttpContext.Current.Response.Cookies.Add(cookie3);
                                        }
                                        if (string.IsNullOrEmpty(info3.UserBindName))
                                        {
                                            //this.Page.Response.Redirect("/BindUserMessage.aspx?status=1&returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else if (this.Page.Request.Cookies["Vshop-Member"] == null)
                {
                    string url = Globals.ApplicationPath + "/UserLogin.aspx?returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString());
                    this.Page.Response.Redirect(url);
                }
            }
        }
Beispiel #12
0
        protected void SkipTaoBaoOpenId()
        {
            Member member = null;

            if (HiContext.Current.SiteSettings.IsDistributorSettings)
            {
                member = new Member(UserRole.Underling);
                member.ParentUserId = HiContext.Current.SiteSettings.UserId;
            }
            else
            {
                member = new Member(UserRole.Member);
            }
            if (HiContext.Current.ReferralUserId > 0)
            {
                member.ReferralUserId = new int?(HiContext.Current.ReferralUserId);
            }
            member.GradeId = MemberProcessor.GetDefaultMemberGrade();
            string str = this.parameters["CurrentOpenId"];

            if (!string.IsNullOrEmpty(str))
            {
                member.Username = HttpUtility.UrlDecode(str);
            }
            if (string.IsNullOrEmpty(member.Username))
            {
                member.Username = "******" + this.GenerateUsername(8);
            }
            member.Email = this.GenerateUsername() + "@localhost.com";
            if (string.IsNullOrEmpty(member.Email))
            {
                member.Email = this.GenerateUsername() + "@localhost.com";
            }
            string str2 = this.GeneratePassword();

            member.Password            = str2;
            member.PasswordFormat      = MembershipPasswordFormat.Hashed;
            member.TradePasswordFormat = MembershipPasswordFormat.Hashed;
            member.TradePassword       = str2;
            member.IsApproved          = true;
            member.RealName            = string.Empty;
            member.Address             = string.Empty;
            if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
            {
                member.Username = "******" + this.GenerateUsername(8);
                member.Password = member.TradePassword = str2;
                if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
                {
                    member.Username = this.GenerateUsername();
                    member.Email    = this.GenerateUsername() + "@localhost.com";
                    member.Password = member.TradePassword = str2;
                    if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
                    {
                        base.Response.Write("为您创建随机账户时失败,请重试。");
                        return;
                    }
                }
            }
            UserHelper.BindOpenId(member.Username, this.parameters["CurrentOpenId"], this.parameters["HIGW"]);
            HttpCookie authCookie = FormsAuthentication.GetAuthCookie(member.Username, false);

            member.GetUserCookie().WriteCookie(authCookie, 30, false);
            ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart();

            CookieShoppingProvider.Instance().ClearShoppingCart();
            HiContext.Current.User = member;
            if (shoppingCart != null)
            {
                ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart);
            }
            if (!string.IsNullOrEmpty(this.parameters["token"]))
            {
                HttpCookie cookie = new HttpCookie("Token_" + HiContext.Current.User.UserId.ToString());
                cookie.Expires = DateTime.Now.AddMinutes(30.0);
                cookie.Value   = this.parameters["token"];
                HttpContext.Current.Response.Cookies.Add(cookie);
            }
            if (!string.IsNullOrEmpty(this.parameters["target_url"]))
            {
                this.Page.Response.Redirect(this.parameters["target_url"]);
            }
            this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
        }
Beispiel #13
0
        protected void SkipQQOpenId()
        {
            Hidistro.Membership.Context.Member member;
            if (Hidistro.Membership.Context.HiContext.Current.SiteSettings.IsDistributorSettings)
            {
                member = new Hidistro.Membership.Context.Member(Hidistro.Membership.Core.Enums.UserRole.Underling);
                member.ParentUserId = Hidistro.Membership.Context.HiContext.Current.SiteSettings.UserId;
            }
            else
            {
                member = new Hidistro.Membership.Context.Member(Hidistro.Membership.Core.Enums.UserRole.Member);
            }
            if (Hidistro.Membership.Context.HiContext.Current.ReferralUserId > 0)
            {
                member.ReferralUserId = new int?(Hidistro.Membership.Context.HiContext.Current.ReferralUserId);
            }
            member.GradeId = MemberProcessor.GetDefaultMemberGrade();
            System.Web.HttpCookie httpCookie = System.Web.HttpContext.Current.Request.Cookies["NickName"];
            if (httpCookie != null)
            {
                member.Username = System.Web.HttpUtility.UrlDecode(httpCookie.Value);
            }
            if (string.IsNullOrEmpty(member.Username))
            {
                member.Username = "******" + this.GenerateUsername(8);
            }
            member.Email = this.GenerateUsername() + "@localhost.com";
            string text = this.GeneratePassword();

            member.Password            = text;
            member.PasswordFormat      = System.Web.Security.MembershipPasswordFormat.Hashed;
            member.TradePasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;
            member.TradePassword       = text;
            member.IsApproved          = true;
            member.RealName            = string.Empty;
            member.Address             = string.Empty;
            if (MemberProcessor.CreateMember(member) != Hidistro.Membership.Core.Enums.CreateUserStatus.Created)
            {
                member.Username = "******" + this.GenerateUsername(8);
                member.Password = (member.TradePassword = text);
                if (MemberProcessor.CreateMember(member) != Hidistro.Membership.Core.Enums.CreateUserStatus.Created)
                {
                    member.Username = this.GenerateUsername();
                    member.Email    = this.GenerateUsername() + "@localhost.com";
                    member.Password = (member.TradePassword = text);
                    if (MemberProcessor.CreateMember(member) != Hidistro.Membership.Core.Enums.CreateUserStatus.Created)
                    {
                        base.Response.Write("为您创建随机账户时失败,请重试。");
                        return;
                    }
                }
            }
            Hidistro.Membership.Core.UserHelper.BindOpenId(member.Username, this.parameters["CurrentOpenId"], this.parameters["HIGW"]);
            System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
            Hidistro.Membership.Core.IUserCookie userCookie = member.GetUserCookie();
            userCookie.WriteCookie(authCookie, 30, false);
            ShoppingCartInfo       shoppingCart           = ShoppingCartProcessor.GetShoppingCart();
            CookieShoppingProvider cookieShoppingProvider = CookieShoppingProvider.Instance();

            cookieShoppingProvider.ClearShoppingCart();
            Hidistro.Membership.Context.HiContext.Current.User = member;
            if (shoppingCart != null)
            {
                ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart);
            }
            if (!string.IsNullOrEmpty(this.parameters["token"]))
            {
                System.Web.HttpCookie httpCookie2 = new System.Web.HttpCookie("Token_" + Hidistro.Membership.Context.HiContext.Current.User.UserId.ToString());
                httpCookie2.Expires = System.DateTime.Now.AddMinutes(30.0);
                httpCookie2.Value   = this.parameters["token"];
                System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie2);
            }
            if (!string.IsNullOrEmpty(this.parameters["target_url"]))
            {
                this.Page.Response.Redirect(this.parameters["target_url"]);
            }
            this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
        }
        public void AlipayLoginAction(SiteSettings site)
        {
            if (string.IsNullOrEmpty(AlipayFuwuConfig.appId) && !AlipayFuwuConfig.CommSetConfig(site.AlipayAppid, this.Page.Server.MapPath("~/"), "GBK"))
            {
                this.WriteFuwuError(this.Page.Request.QueryString.ToString(), "服务窗口参数配置不准确!");
                this.Page.Response.Redirect(Globals.ApplicationPath + "/UserLogin.aspx");
            }
            string str  = this.Page.Request.QueryString["auth_code"];
            string str2 = this.Page.Request.QueryString["scope"];

            if (!string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str))
            {
                this.WriteFuwuError(this.Page.Request.QueryString.ToString(), "已授权");
                AlipaySystemOauthTokenResponse oauthTokenResponse = AliOHHelper.GetOauthTokenResponse(str);
                this.WriteFuwuError(AliOHHelper.SerializeObject(oauthTokenResponse, true), "获取AccessToken");
                if (((oauthTokenResponse != null) && !oauthTokenResponse.IsError) && (oauthTokenResponse.AccessToken != null))
                {
                    string  alipayUserId = oauthTokenResponse.AlipayUserId;
                    string  openId       = "";
                    JObject obj2         = JsonConvert.DeserializeObject(oauthTokenResponse.Body) as JObject;
                    if (obj2["alipay_system_oauth_token_response"]["user_id"] != null)
                    {
                        openId = obj2["alipay_system_oauth_token_response"]["user_id"].ToString();
                    }
                    if (this.HasLogin(openId, "fuwu") || this.HasLogin(alipayUserId, "fuwu"))
                    {
                        MemberInfo openIdMember = MemberProcessor.GetOpenIdMember(openId, "fuwu");
                        if ((openIdMember == null) || (openIdMember.Status == Convert.ToInt32(UserStatus.DEL)))
                        {
                            this.Page.Response.Redirect(Globals.ApplicationPath + "/logout.aspx");
                        }
                        string alipayOpenid = openIdMember.AlipayOpenid;
                        if (((alipayUserId != "") && (alipayUserId != alipayOpenid)) || string.IsNullOrEmpty(alipayOpenid))
                        {
                            openIdMember.AlipayOpenid = alipayUserId;
                            MemberProcessor.SetAlipayInfos(openIdMember);
                        }
                        this.setLogin(openIdMember.UserId);
                        this.WriteFuwuError("已存在用户登入!", openId);
                    }
                    else
                    {
                        AlipayUserUserinfoShareResponse alipayUserUserinfo = AliOHHelper.GetAlipayUserUserinfo(oauthTokenResponse.AccessToken);
                        this.WriteFuwuError(AliOHHelper.SerializeObject(alipayUserUserinfo, true), "获取用户信息");
                        string str7     = "";
                        string realName = "";
                        string avatar   = "";
                        if ((alipayUserUserinfo != null) && !alipayUserUserinfo.IsError)
                        {
                            avatar = alipayUserUserinfo.Avatar;
                            if (alipayUserUserinfo.RealName != null)
                            {
                                realName = alipayUserUserinfo.RealName;
                            }
                            if (string.IsNullOrEmpty(alipayUserId))
                            {
                                alipayUserId = alipayUserUserinfo.UserId;
                            }
                            if (string.IsNullOrEmpty(openId))
                            {
                                JObject obj3 = JsonConvert.DeserializeObject(alipayUserUserinfo.Body) as JObject;
                                if (obj3["alipay_user_id"] != null)
                                {
                                    openId = obj3["alipay_user_id"].ToString();
                                }
                            }
                        }
                        str7 = "FW*" + openId.Substring(10);
                        string     generateId = Globals.GetGenerateId();
                        MemberInfo member     = new MemberInfo {
                            GradeId        = MemberProcessor.GetDefaultMemberGrade(),
                            UserName       = str7,
                            CreateDate     = DateTime.Now,
                            SessionId      = generateId,
                            SessionEndTime = DateTime.Now.AddYears(10),
                            UserHead       = avatar,
                            AlipayAvatar   = avatar,
                            AlipayLoginId  = str7,
                            AlipayOpenid   = alipayUserId,
                            AlipayUserId   = openId,
                            AlipayUsername = realName
                        };
                        HttpCookie cookie = HttpContext.Current.Request.Cookies["Vshop-ReferralId"];
                        if (cookie != null)
                        {
                            member.ReferralUserId = Convert.ToInt32(cookie.Value);
                        }
                        else
                        {
                            member.ReferralUserId = 0;
                        }
                        member.Password = HiCryptographer.Md5Encrypt("888888");
                        MemberProcessor.CreateMember(member);
                        MemberInfo info3 = MemberProcessor.GetMember(generateId);
                        this.setLogin(info3.UserId);
                    }
                }
                else
                {
                    this.Page.Response.Redirect(Globals.ApplicationPath + "/UserLogin.aspx?returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.AbsoluteUri.ToString()));
                }
            }
            else if (!string.IsNullOrEmpty(str2))
            {
                this.WriteFuwuError(this.Page.Request.QueryString.ToString(), "拒绝授权");
                this.Page.Response.Redirect(Globals.ApplicationPath + "/UserLogin.aspx");
            }
            else
            {
                string msg = AliOHHelper.AlipayAuthUrl(HttpContext.Current.Request.Url.ToString().Replace(":" + HttpContext.Current.Request.Url.Port, ""), site.AlipayAppid, "auth_userinfo");
                this.WriteFuwuError(msg, "用户登入授权的路径");
                this.Page.Response.Redirect(msg);
            }
        }
Beispiel #15
0
        protected override void AttachChildControls()
        {
            if (!int.TryParse(this.Page.Request.QueryString["activityid"], out this.activityid))
            {
                base.GotoResourceNotFound("");
            }
            //this.bgimg = (HtmlImage) this.FindControl("bgimg");
            this.litActivityDesc = (Literal)this.FindControl("litActivityDesc");
            //this.litStartDate = (Literal) this.FindControl("litStartDate");
            //this.litEndDate = (Literal) this.FindControl("litEndDate");
            this.litPrizeNames = (Common_PrizeNames)this.FindControl("litPrizeNames");
            this.litPrizeUsers = (Common_PrizeUsers)this.FindControl("litPrizeUsers");
            this.litSurplusNum = (Literal)this.FindControl("litSurplusNum");
            this.litNum        = (Literal)this.FindControl("litNum");
            this.litimage      = (Literal)this.FindControl("litimage");
            LotteryActivityInfo lotteryActivity = VshopBrowser.GetLotteryActivity(this.activityid);

            if (lotteryActivity == null)
            {
                base.GotoResourceNotFound("");
            }
            if (MemberProcessor.GetCurrentMember() == null)
            {
                MemberInfo member     = new MemberInfo();
                string     generateId = Globals.GetGenerateId();
                member.GradeId        = MemberProcessor.GetDefaultMemberGrade();
                member.UserName       = "";
                member.OpenId         = "";
                member.CreateDate     = DateTime.Now;
                member.SessionId      = generateId;
                member.SessionEndTime = DateTime.Now;
                MemberProcessor.CreateMember(member);
                member = MemberProcessor.GetMember(generateId);
                HttpCookie cookie = new HttpCookie("Vshop-Member")
                {
                    Value   = member.UserId.ToString(),
                    Expires = DateTime.Now.AddYears(10)
                };
                HttpContext.Current.Response.Cookies.Add(cookie);
            }
            PageTitle.AddSiteNameTitle(lotteryActivity.ActivityName);
            litimage.Text = Globals.HostPath(HttpContext.Current.Request.Url) + lotteryActivity.ActivityPic;
            //this.litStartDate.Text = lotteryActivity.StartTime.ToString("yyyy年MM月dd日 HH:mm:ss");
            //this.litEndDate.Text = lotteryActivity.EndTime.ToString("yyyy年MM月dd日 HH:mm:ss");
            //if (lotteryActivity.PrizeSettingList.Count > 3)
            //{
            //    this.bgimg.Src = Globals.GetVshopSkinPath(null) + "/images/process/panpic2.png";
            //}
            if ((lotteryActivity.StartTime < DateTime.Now) && (DateTime.Now < lotteryActivity.EndTime))
            {
                this.litActivityDesc.Text   = lotteryActivity.ActivityDesc;
                this.litPrizeNames.Activity = lotteryActivity;
                this.litPrizeUsers.Activity = lotteryActivity;
                int userPrizeCount = VshopBrowser.GetUserPrizeCount(this.activityid);
                this.litActivityDesc.Text = this.litActivityDesc.Text;
                //剩余次数提示
                this.litSurplusNum.Text = string.Format("您一共有{0}次参与机会,目前还剩<b class=\"sign\">{1}</b>次。", lotteryActivity.MaxNum, lotteryActivity.MaxNum - userPrizeCount);

                PrizeQuery page = new PrizeQuery
                {
                    ActivityId = this.activityid
                };
                System.Collections.Generic.List <PrizeRecordInfo> prizeList = VShopHelper.GetPrizeListEx(page);
                if (prizeList != null && prizeList.Count > 0)
                {
                    this.litNum.Text = prizeList.Count.ToString();
                }
                else
                {
                    this.litNum.Text = "0";
                }

                //前台JS刷的营销数据
                if (!string.IsNullOrEmpty(lotteryActivity.GradeIds))
                {
                    this.litNum.Text = lotteryActivity.GradeIds;
                }
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(base.GetType(), "myscript", "<script>$(function(){alert_h(\"活动还未开始或者已经结束!\");});</script>");
            }
        }
Beispiel #16
0
        public IHttpActionResult Register(JObject request)
        {
            Logger.WriterLogger("Account.Register, Params: " + request.ToString(), LoggerType.Info);

            ParamRegister param = new ParamRegister();

            try
            {
                param = request.ToObject <ParamRegister>();
            }
            catch
            {
                //throw new CommonException(40100);
                return(base.JsonFaultResult(new CommonException(40100).GetMessage(), request.ToString()));
            }

            string accessToken   = param.accessToken;
            string sessionKey    = "";
            string sessionSecret = "";

            // 验证令牌
            int accessTookenCode = VerifyAccessToken(accessToken, out sessionKey, out sessionSecret);

            if (accessTookenCode > 0)
            {
                return(base.JsonFaultResult(new CommonException(accessTookenCode).GetMessage(), request.ToString()));
            }

            string username = param.username;
            string code     = param.code;

            string password    = param.password;
            int    accountType = param.accountType;

            int    channel  = param.channel;
            int    platform = param.platform;
            string ver      = param.ver;

            // 保存访问信息
            base.SaveVisitInfo("", channel, platform, ver);

            string decryptUsername = username;
            string decryptPassword = password;
            string decryptCode     = code;

            if ((platform == 3 && base.AndroidIsEncryption) || (platform == 2 && base.IOSIsEncryption) || (platform == 1 && base.PCIsEncryption))
            {
                decryptUsername = base.Decrypt(username, sessionKey, sessionSecret);      //TODO 解密
                decryptPassword = base.Decrypt(password, sessionKey, sessionSecret);

                //decryptCode = base.Decrypt(code, sessionKey, sessionSecret);
            }

            string email  = "";
            string mobile = "";

            switch (accountType)
            {
            case 1:
                break;

            case 2:
                mobile = decryptUsername;
                //email = decryptUsername + "@mail.haimylife.com";

                if (string.IsNullOrEmpty(decryptUsername))
                {
                    return(base.JsonFaultResult(new FaultInfo(40100, "手机号码为空"), request.ToString()));
                }
                if (!System.Text.RegularExpressions.Regex.IsMatch(decryptUsername, "^(13|14|15|17|18)\\d{9}$"))
                {
                    return(base.JsonFaultResult(new FaultInfo(40100, "请输入正确的手机号码"), request.ToString()));
                }
                if (UserHelper.IsExistCellPhoneAndUserName(decryptUsername) > 0)
                {
                    return(base.JsonFaultResult(new FaultInfo(40100, "已经存在相同的手机号码"), request.ToString()));
                }

                Verify verifyto = new TelVerifyDao().GetVerify(decryptUsername, 1);
                if (!(verifyto != null && verifyto.VerifyCode == decryptCode))
                {
                    return(base.JsonFaultResult(new CommonException(40205).GetMessage(), request.ToString()));
                }
                break;

            case 3:
                email = decryptUsername;
                break;
            }

            string msg = "";

            int provinceId = 0;
            int userId     = 0;

            string sessionId = Guid.NewGuid().ToString();

            if (string.IsNullOrEmpty(decryptUsername) || string.IsNullOrEmpty(decryptPassword))
            {
                return(base.JsonFaultResult(new FaultInfo(40200, "缺少必填参数"), request.ToString()));
            }

            //注册类型为3时检测邮箱
            if (accountType == 3)
            {
                if (string.IsNullOrEmpty(email.Trim()))
                {
                    return(base.JsonFaultResult(new FaultInfo(40200, "邮箱帐号不能为空"), request.ToString()));
                }
                if (email.Length > 256 || !System.Text.RegularExpressions.Regex.IsMatch(email, "([a-zA-Z\\.0-9_-])+@([a-zA-Z0-9_-])+((\\.[a-zA-Z0-9_-]{2,4}){1,2})"))
                {
                    return(base.JsonFaultResult(new FaultInfo(40200, "错误的邮箱帐号"), request.ToString()));
                }
            }

            //判断邀请码是否存在
            if (!string.IsNullOrWhiteSpace(param.recemmendCode))
            {
                if (!MemberHelper.IsExsitRecommendCode(param.recemmendCode.Trim(), 0))
                {
                    return(base.JsonFaultResult(new FaultInfo(40100, "邀请码错误,请填写正确的邀请码或者选择不填"), request.ToString()));
                }
            }

            Member member = new Member(UserRole.Member);

            member.GradeId   = MemberProcessor.GetDefaultMemberGrade();
            member.SessionId = Globals.GetGenerateId();
            member.Username  = decryptUsername;

            member.Password                 = decryptPassword;
            member.PasswordFormat           = System.Web.Security.MembershipPasswordFormat.Hashed;
            member.TradePasswordFormat      = System.Web.Security.MembershipPasswordFormat.Hashed;
            member.TradePassword            = decryptPassword;
            member.IsApproved               = true;
            member.RealName                 = string.Empty;
            member.Address                  = string.Empty;
            member.MembershipUser.SessionId = sessionId;
            member.CellPhone                = mobile;
            member.CreateDate               = DateTime.Now;

            //member.MembershipUser.MobilePIN = mobile;
            // 手机注册默认验证手机号码
            if (accountType == 2)
            {
                member.CellPhoneVerification = true;
            }

            if (accountType == 3)
            {
                member.Email = email;
            }

            member.UserType = this.CovertToUserType(param.platform);

            CreateUserStatus createUserStatus = MemberProcessor.CreateMember(member);

            if (createUserStatus == CreateUserStatus.DuplicateUsername || createUserStatus == CreateUserStatus.DisallowedUsername)
            {
                msg = "已经存在该用户名";
            }
            if (createUserStatus == CreateUserStatus.DuplicateEmailAddress)
            {
                msg = "已经存在相同的邮箱";
            }
            if (createUserStatus == CreateUserStatus.DuplicateCellphone)
            {
                msg = "已经存在相同的手机号码";
            }

            if (createUserStatus == CreateUserStatus.Created)
            {
                Messenger.UserRegister(member, decryptPassword);
                member.OnRegister(new UserEventArgs(member.Username, decryptPassword, null));

                long timestamp = long.Parse(DateTime.Now.AddSeconds(USER_CACHE_KEEP_TIME).ToString("yyyyMMddHHmmss"));

                string authenTicket = SecurityUtil.MD5Encrypt(sessionId + timestamp.ToString() + sessionSecret).ToLower();
                string authenUserId = sessionId.ToLowerGuid();

                CacheUserSet(authenUserId, authenTicket, timestamp, member.UserId);

                #region ==判断是否有优惠卷
                if (!MemberHelper.NewUserSendRegisterCoupon(member))
                {
                    msg = "注册优惠卷赠送失败";
                    return(base.JsonFaultResult(new FaultInfo(40200, msg), request.ToString()));
                }
                #endregion
                #region == 判断是否有邀请码
                string sourcechars    = ConfigurationManager.AppSettings["sourcechars"];
                string newsourcechars = ConfigurationManager.AppSettings["newsourcechars"];
                string rcode          = param.recemmendCode;
                if (!string.IsNullOrWhiteSpace(rcode))
                {
                    string currcode = BaseConvertHelper.BaseConvert(rcode, newsourcechars, sourcechars);
                    string useredId = MemberHelper.GetUserIdByRecommendCode(currcode);
                    if (!string.IsNullOrWhiteSpace(useredId) && !string.IsNullOrWhiteSpace(currcode))
                    {
                        // 插入到邀请码记录表
                        MemberHelper.AddRecommendCodeRecord(member.UserId, Convert.ToInt32(useredId), currcode, rcode);
                    }
                }
                #endregion
                StandardResult <RegisterOrLoginResult> okResult = new StandardResult <RegisterOrLoginResult>();
                okResult.code = 0;
                okResult.msg  = "注册成功,恭喜您,50元现金券已经打到您的海美账户了,现在就去购物吧!";
                okResult.data = new RegisterOrLoginResult()
                {
                    DisplayName  = decryptUsername,
                    AuthenTicket = authenTicket,
                    AuthenUserId = authenUserId,
                    Timestamp    = timestamp
                };

                return(base.JsonActionResult(okResult));
            }
            else
            {
                msg = "注册用户失败," + msg;
            }

            return(base.JsonFaultResult(new FaultInfo(40200, msg), request.ToString()));
        }
Beispiel #17
0
        protected int SkipWeixinOpenId(string openId, string weixinNickName, string unionId, string headimgurl, string ReferralUserId, bool isSubscribe)
        {
            int        num        = 1;
            MemberInfo memberInfo = MemberProcessor.GetMemberByOpenId("hishop.plugins.openid.weixin", openId);
            bool       flag       = false;

            if (memberInfo == null)
            {
                memberInfo = MemberProcessor.GetMemberByUnionId(unionId);
                flag       = true;
            }
            SiteSettings     masterSettings     = SettingsManager.GetMasterSettings();
            ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
            bool             flag2 = false;

            if (memberInfo != null)
            {
                num = 2;
                if (memberInfo.IsSubscribe != isSubscribe)
                {
                    memberInfo.IsSubscribe = isSubscribe;
                    flag2 = true;
                }
                bool flag3 = MemberProcessor.IsBindedWeixin(memberInfo.UserId, "hishop.plugins.openid.weixin");
                memberInfo.Picture = headimgurl;
                if (!string.IsNullOrEmpty(unionId) && memberInfo.UnionId != unionId && !flag)
                {
                    memberInfo.UnionId = unionId;
                    flag2 = true;
                }
                if (flag)
                {
                    if (!flag3)
                    {
                        MemberOpenIdInfo memberOpenIdInfo = new MemberOpenIdInfo();
                        memberOpenIdInfo.UserId     = memberInfo.UserId;
                        memberOpenIdInfo.OpenIdType = "hishop.plugins.openid.weixin";
                        memberOpenIdInfo.OpenId     = openId;
                        MemberProcessor.AddMemberOpenId(memberOpenIdInfo);
                        memberInfo.IsQuickLogin = true;
                        flag2 = true;
                    }
                    else
                    {
                        MemberOpenIdInfo memberOpenIdInfo2 = new MemberOpenIdInfo();
                        memberOpenIdInfo2.UserId     = memberInfo.UserId;
                        memberOpenIdInfo2.OpenIdType = "hishop.plugins.openid.weixin";
                        memberOpenIdInfo2.OpenId     = openId;
                        MemberProcessor.UpdateMemberOpenId(memberOpenIdInfo2);
                    }
                }
                if (flag2)
                {
                    MemberProcessor.UpdateMember(memberInfo);
                }
                Users.SetCurrentUser(memberInfo.UserId, 30, true, false);
                HiContext.Current.User = memberInfo;
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
                if (!string.IsNullOrEmpty(openId))
                {
                    HttpCookie httpCookie = new HttpCookie("openId");
                    httpCookie.HttpOnly = true;
                    httpCookie.Value    = openId;
                    httpCookie.Expires  = DateTime.MaxValue;
                    HttpContext.Current.Response.Cookies.Add(httpCookie);
                }
                lock (this.lockCopyRedEnvelope)
                {
                    this.CopyRedEnvelope(openId, memberInfo);
                }
                return(num);
            }
            memberInfo             = new MemberInfo();
            memberInfo.Picture     = headimgurl;
            memberInfo.IsSubscribe = isSubscribe;
            int num2 = 0;

            if (ReferralUserId.ToInt(0) > 0)
            {
                memberInfo.ReferralUserId = ReferralUserId.ToInt(0);
            }
            MemberWXReferralInfo wXReferral = VShopHelper.GetWXReferral(openId.Trim());

            if (wXReferral != null)
            {
                VShopHelper.DeleteWXReferral(openId.Trim());
            }
            memberInfo.GradeId = MemberProcessor.GetDefaultMemberGrade();
            if (!string.IsNullOrEmpty(weixinNickName))
            {
                MemberInfo memberInfo2 = memberInfo;
                MemberInfo memberInfo3 = memberInfo;
                string     text3       = memberInfo2.UserName = (memberInfo3.NickName = HttpUtility.UrlDecode(weixinNickName));
            }
            if (string.IsNullOrEmpty(memberInfo.UserName))
            {
                memberInfo.UserName = "******" + this.GenerateUsername(8);
            }
            if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
            {
                memberInfo.UserName = "******" + this.GenerateUsername(9);
                if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
                {
                    memberInfo.UserName = this.GenerateUsername();
                    if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
                    {
                        num = -1;
                    }
                }
            }
            if (num == 1)
            {
                string text4 = this.GeneratePassword();
                string text5 = "Open";
                string text6 = text4;
                text4 = (memberInfo.Password = Users.EncodePassword(text4, text5));
                memberInfo.PasswordSalt     = text5;
                memberInfo.RegisteredSource = 3;
                memberInfo.CreateDate       = DateTime.Now;
                memberInfo.IsQuickLogin     = true;
                memberInfo.IsLogined        = true;
                memberInfo.UnionId          = unionId;
                num2 = MemberProcessor.CreateMember(memberInfo);
                if (num2 <= 0)
                {
                    num = -1;
                }
            }
            if (num == 1)
            {
                memberInfo.UserId   = num2;
                memberInfo.UserName = MemberHelper.GetUserName(memberInfo.UserId);
                MemberHelper.Update(memberInfo, true);
                Users.SetCurrentUser(memberInfo.UserId, 30, false, false);
                HiContext.Current.User = memberInfo;
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
                if (!string.IsNullOrEmpty(openId))
                {
                    MemberOpenIdInfo memberOpenIdInfo3 = new MemberOpenIdInfo();
                    memberOpenIdInfo3.UserId     = memberInfo.UserId;
                    memberOpenIdInfo3.OpenIdType = "hishop.plugins.openid.weixin";
                    memberOpenIdInfo3.OpenId     = openId;
                    if (MemberProcessor.GetMemberByOpenId(memberOpenIdInfo3.OpenIdType, openId) == null)
                    {
                        MemberProcessor.AddMemberOpenId(memberOpenIdInfo3);
                    }
                    if (!string.IsNullOrEmpty(openId))
                    {
                        HttpCookie httpCookie2 = new HttpCookie("openId");
                        httpCookie2.HttpOnly = true;
                        httpCookie2.Value    = openId;
                        httpCookie2.Expires  = DateTime.MaxValue;
                        HttpContext.Current.Response.Cookies.Add(httpCookie2);
                    }
                    lock (this.lockCopyRedEnvelope)
                    {
                        this.CopyRedEnvelope(openId, memberInfo);
                    }
                }
            }
            return(num);
        }
Beispiel #18
0
        private void btnRegister_Click(object sender, System.EventArgs e)
        {
            if (!this.chkAgree.Checked)
            {
                this.ShowMessage("您必须先阅读并同意注册协议", false);
            }
            else
            {
                if (string.Compare(this.txtUserName.Text.Trim().ToLower(System.Globalization.CultureInfo.InvariantCulture), "anonymous", false, System.Globalization.CultureInfo.InvariantCulture) == 0)
                {
                    this.ShowMessage("已经存在相同的用户名", false);
                }
                else
                {
                    if (this.txtUserName.Text.Trim().Length < 2 || this.txtUserName.Text.Trim().Length > 20)
                    {
                        this.ShowMessage("用户名不能为空,且在2-20个字符之间", false);
                    }
                    else
                    {
                        if (string.Compare(this.txtPassword.Text, this.txtPassword2.Text) != 0)
                        {
                            this.ShowMessage("两次输入的密码不相同", false);
                        }
                        else
                        {
                            if (this.txtPassword.Text.Length == 0)
                            {
                                this.ShowMessage("密码不能为空", false);
                            }
                            else
                            {
                                if (this.txtPassword.Text.Length < System.Web.Security.Membership.Provider.MinRequiredPasswordLength || this.txtPassword.Text.Length > HiConfiguration.GetConfig().PasswordMaxLength)
                                {
                                    this.ShowMessage(string.Format("密码的长度只能在{0}和{1}个字符之间", System.Web.Security.Membership.Provider.MinRequiredPasswordLength, HiConfiguration.GetConfig().PasswordMaxLength), false);
                                }
                                else
                                {
                                    Hidistro.Membership.Context.Member member;
                                    if (Hidistro.Membership.Context.HiContext.Current.SiteSettings.IsDistributorSettings)
                                    {
                                        member = new Hidistro.Membership.Context.Member(Hidistro.Membership.Core.Enums.UserRole.Underling);
                                        member.ParentUserId = Hidistro.Membership.Context.HiContext.Current.SiteSettings.UserId;
                                    }
                                    else
                                    {
                                        member = new Hidistro.Membership.Context.Member(Hidistro.Membership.Core.Enums.UserRole.Member);
                                    }
                                    if (Hidistro.Membership.Context.HiContext.Current.ReferralUserId > 0)
                                    {
                                        member.ReferralUserId = new int?(Hidistro.Membership.Context.HiContext.Current.ReferralUserId);
                                    }
                                    member.GradeId             = MemberProcessor.GetDefaultMemberGrade();
                                    member.Username            = Globals.HtmlEncode(this.txtUserName.Text.Trim());
                                    member.Email               = this.txtEmail.Text;
                                    member.Password            = this.txtPassword.Text;
                                    member.PasswordFormat      = System.Web.Security.MembershipPasswordFormat.Hashed;
                                    member.TradePasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;
                                    member.TradePassword       = this.txtPassword.Text;
                                    if (this.txtCellPhone != null)
                                    {
                                        member.CellPhone = this.txtCellPhone.Text;
                                    }
                                    member.IsApproved = true;
                                    member.RealName   = string.Empty;
                                    member.Address    = string.Empty;
                                    if (this.ValidationMember(member))
                                    {
                                        if (!Hidistro.Membership.Context.HiContext.Current.CheckVerifyCode(this.txtNumber.Text))
                                        {
                                            this.ShowMessage("验证码输入错误", false);
                                        }
                                        else
                                        {
                                            switch (MemberProcessor.CreateMember(member))
                                            {
                                            case Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure:
                                                this.ShowMessage("未知错误", false);
                                                break;

                                            case Hidistro.Membership.Core.Enums.CreateUserStatus.Created:
                                            {
                                                Messenger.UserRegister(member, this.txtPassword.Text);
                                                member.OnRegister(new Hidistro.Membership.Context.UserEventArgs(member.Username, this.txtPassword.Text, null));
                                                Hidistro.Membership.Core.IUser user           = Hidistro.Membership.Context.Users.GetUser(0, member.Username, false, true);
                                                ShoppingCartInfo       shoppingCart           = ShoppingCartProcessor.GetShoppingCart();
                                                CookieShoppingProvider cookieShoppingProvider = CookieShoppingProvider.Instance();
                                                cookieShoppingProvider.ClearShoppingCart();
                                                Hidistro.Membership.Context.HiContext.Current.User = user;
                                                if (shoppingCart != null)
                                                {
                                                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart);
                                                }
                                                System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
                                                Hidistro.Membership.Core.IUserCookie userCookie = user.GetUserCookie();
                                                userCookie.WriteCookie(authCookie, 30, false);
                                                this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("registerUserSave") + "?UserId=" + user.UserId);
                                                break;
                                            }

                                            case Hidistro.Membership.Core.Enums.CreateUserStatus.DuplicateUsername:
                                                this.ShowMessage("已经存在相同的用户名", false);
                                                break;

                                            case Hidistro.Membership.Core.Enums.CreateUserStatus.DuplicateEmailAddress:
                                                this.ShowMessage("电子邮件地址已经存在", false);
                                                break;

                                            case Hidistro.Membership.Core.Enums.CreateUserStatus.DisallowedUsername:
                                                this.ShowMessage("用户名禁止注册", false);
                                                break;

                                            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidPassword:
                                                this.ShowMessage("无效的密码", false);
                                                break;

                                            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidEmail:
                                                this.ShowMessage("无效的电子邮件地址", false);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #19
0
        //扫描二维码事件
        public override AbstractResponse OnEvent_ScanRequest(ScanEventRequest scanEventRequest)
        {
            Utils.LogWriter.SaveLog("产生扫码事件:" + scanEventRequest.EventKey);
            if (!string.IsNullOrEmpty(scanEventRequest.EventKey))
            {
                /*
                 * 打开分享图片
                 * 获取用户信息
                 *
                 * */

                string open_id        = scanEventRequest.FromUserName;
                int    ReferralUserId = int.Parse(scanEventRequest.EventKey);

                //判断是否会员
                if (MemberProcessor.IsExitOpenId(open_id))
                {
                    //Utils.LogWriter.SaveLog("已存在会员:" + open_id);
                    Hidistro.Entities.Members.MemberInfo m = MemberProcessor.GetMembers(open_id);
                    if (m.ReferralUserId == 0 && m.OpenId != open_id)
                    {
                        m.ReferralUserId = ReferralUserId;
                        MemberProcessor.UpdateMember(m);
                        Utils.LogWriter.SaveLog("扫码填补上级ID:" + ReferralUserId);
                        return(null);
                    }

                    //Utils.LogWriter.SaveLog("返回提示:" + open_id);
                    TextResponse response = new TextResponse
                    {
                        CreateTime   = DateTime.Now,
                        Content      = "您已经有上级了哦",
                        ToUserName   = scanEventRequest.FromUserName,
                        FromUserName = scanEventRequest.ToUserName
                    };
                    return(response);
                }

                SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);

                JObject wx_user_info = TokenApi.GetUserInfo(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, open_id);
                Utils.LogWriter.SaveLog("wx_user_info:" + wx_user_info["nickname"].ToString());

                string generateId = Globals.GetGenerateId();
                Hidistro.Entities.Members.MemberInfo member = new Hidistro.Entities.Members.MemberInfo
                {
                    GradeId        = MemberProcessor.GetDefaultMemberGrade(),
                    UserName       = Globals.UrlDecode(wx_user_info["nickname"].ToString()),
                    OpenId         = open_id,
                    CreateDate     = DateTime.Now,
                    SessionId      = generateId,
                    SessionEndTime = DateTime.Now.AddYears(10),
                    ReferralUserId = ReferralUserId
                };

                //Utils.LogWriter.SaveLog("创建客户资料");
                MemberProcessor.CreateMember(member);
            }

            return(null);
        }
Beispiel #20
0
        protected void SkipWeiXinOpenId()
        {
            MemberInfo memberInfo = new MemberInfo();

            if (HiContext.Current.ReferralUserId > 0)
            {
                memberInfo.ReferralUserId = HiContext.Current.ReferralUserId;
            }
            memberInfo.UnionId = this.Parameters["CurrentOpenId"].ToNullString();
            memberInfo.GradeId = MemberProcessor.GetDefaultMemberGrade();
            HttpCookie httpCookie = HttpContext.Current.Request.Cookies["NickName"];

            if (httpCookie != null)
            {
                memberInfo.UserName = Globals.StripAllTags(HttpUtility.UrlDecode(httpCookie.Value).Trim());
            }
            memberInfo.NickName = this.hidNickName.Value;
            if (string.IsNullOrEmpty(memberInfo.UserName))
            {
                memberInfo.UserName = "******" + this.GenerateUsername(8);
            }
            if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
            {
                memberInfo.UserName = "******" + this.GenerateUsername(8);
                if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
                {
                    memberInfo.UserName = this.GenerateUsername();
                    if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
                    {
                        this.ShowMessage("为您创建随机账户时失败,请重试。", false, "", 1);
                        return;
                    }
                }
            }
            string pass = this.GeneratePassword();
            string text = "Open";

            pass = (memberInfo.Password = Users.EncodePassword(pass, text));
            memberInfo.PasswordSalt     = text;
            memberInfo.RegisteredSource = 1;
            memberInfo.CreateDate       = DateTime.Now;
            memberInfo.IsLogined        = false;
            memberInfo.IsQuickLogin     = false;
            int num = MemberProcessor.CreateMember(memberInfo);

            if (num <= 0)
            {
                this.ShowMessage("为您创建账户时失败,请重试。", false, "", 1);
            }
            else
            {
                int num2 = 0;
                memberInfo.UserId = num;
                SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                if (masterSettings.IsOpenGiftCoupons)
                {
                    string[] array = masterSettings.GiftCouponList.Split(',');
                    foreach (string obj in array)
                    {
                        if (obj.ToInt(0) > 0 && CouponHelper.AddCouponItemInfo(memberInfo, obj.ToInt(0)) == CouponActionStatus.Success)
                        {
                            num2++;
                        }
                    }
                }
                memberInfo.UserName = MemberHelper.GetUserName(memberInfo.UserId);
                MemberHelper.Update(memberInfo, true);
                HiContext.Current.User = memberInfo;
                this.SetLoginState(memberInfo, num2);
            }
        }
Beispiel #21
0
        //关注事件
        public override AbstractResponse OnEvent_SubscribeRequest(SubscribeEventRequest subscribeEventRequest)
        {
            Utils.LogWriter.SaveLog("产生关注事件:" + subscribeEventRequest.EventKey);
            string event_key = subscribeEventRequest.EventKey;

            if (!string.IsNullOrEmpty(event_key) && event_key.IndexOf("qrscene_") != -1)
            {
                //关联上级

                /*
                 * 打开分享图片
                 * 获取用户信息
                 *
                 * */

                string open_id = subscribeEventRequest.FromUserName;
                Utils.LogWriter.SaveLog("产生关注事件step1:" + open_id);
                int ReferralUserId = int.Parse(subscribeEventRequest.EventKey.Replace("qrscene_", ""));
                Utils.LogWriter.SaveLog("产生关注事件step2:" + ReferralUserId);

                //判断是否会员
                if (MemberProcessor.IsExitOpenId(open_id))
                {
                    Utils.LogWriter.SaveLog("产生关注事件step3:已存在会员信息");
                    Hidistro.Entities.Members.MemberInfo m = MemberProcessor.GetMembers(open_id);
                    if (m.ReferralUserId == 0 && m.OpenId != open_id)
                    {
                        m.ReferralUserId = ReferralUserId;
                        MemberProcessor.UpdateMember(m);
                        //Utils.LogWriter.SaveLog("扫码填补上级ID:" + ReferralUserId);
                        return(null);
                    }
                }
                else
                {
                    Utils.LogWriter.SaveLog("产生关注事件step3:不存在会员信息");
                    //关联上级并增加客户资料
                    SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);

                    JObject wx_user_info = TokenApi.GetUserInfo(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, open_id);
                    Utils.LogWriter.SaveLog("产生关注事件step4:" + wx_user_info["nickname"].ToString());

                    string generateId = Globals.GetGenerateId();
                    Hidistro.Entities.Members.MemberInfo member = new Hidistro.Entities.Members.MemberInfo
                    {
                        GradeId        = MemberProcessor.GetDefaultMemberGrade(),
                        UserName       = Globals.UrlDecode(wx_user_info["nickname"].ToString()),
                        OpenId         = open_id,
                        CreateDate     = DateTime.Now,
                        SessionId      = generateId,
                        SessionEndTime = DateTime.Now.AddYears(10),
                        ReferralUserId = ReferralUserId
                    };

                    Utils.LogWriter.SaveLog("创建客户资料");
                    MemberProcessor.CreateMember(member);

                    //获取上级
                    Hidistro.Entities.Members.MemberInfo parentInfo = MemberProcessor.GetMember(ReferralUserId);

                    //获取第多少个会员
                    int count = MemberProcessor.GetMemberCount();

                    TextResponse r = new TextResponse
                    {
                        CreateTime = DateTime.Now,
                        Content    = "恭喜您!您已通过【" + parentInfo.UserName + "】的推荐成为本站会员,您是本站第" + (10000 + count)
                                     + "个会员,点击右下方【创业良机】~【组建团队】进入财富倍增快通道。",
                        ToUserName   = subscribeEventRequest.FromUserName,
                        FromUserName = subscribeEventRequest.ToUserName
                    };
                    return(r);
                }
            }

            ReplyInfo subscribeReply = ReplyHelper.GetSubscribeReply();

            if (subscribeReply == null)
            {
                return(null);
            }
            subscribeReply.Keys = "登录";
            AbstractResponse response = this.GetResponse(subscribeReply, subscribeEventRequest.FromUserName);

            if (response == null)
            {
                this.GotoManyCustomerService(subscribeEventRequest);
            }
            response.ToUserName   = subscribeEventRequest.FromUserName;
            response.FromUserName = subscribeEventRequest.ToUserName;
            return(response);
        }
Beispiel #22
0
        public string GetOpenID(SiteSettings site, int isMustLogin)
        {
            string text = this.Page.Request.QueryString["code"];
            int    num  = Globals.RequestQueryNum("ReferralId");

            try
            {
                string getCurrentWXOpenId = Globals.GetCurrentWXOpenId;
                if (string.IsNullOrEmpty(getCurrentWXOpenId) && site != null)
                {
                    string result;
                    if (!string.IsNullOrEmpty(text))
                    {
                        string responseResult = this.GetResponseResult(string.Concat(new string[]
                        {
                            "https://api.weixin.qq.com/sns/oauth2/access_token?appid=",
                            site.WeixinAppId,
                            "&secret=",
                            site.WeixinAppSecret,
                            "&code=",
                            text,
                            "&grant_type=authorization_code"
                        }));
                        if (string.IsNullOrEmpty(responseResult) || !responseResult.Contains("access_token"))
                        {
                            goto IL_569;
                        }
                        JObject jObject = JsonConvert.DeserializeObject(responseResult) as JObject;
                        string  text2   = jObject["openid"].ToString();
                        Globals.GetCurrentWXOpenId = text2;
                        try
                        {
                            if (!this.HasReg(text2, "wx"))
                            {
                                string     generateId = Globals.GetGenerateId();
                                MemberInfo memberInfo = new MemberInfo();
                                memberInfo.GradeId        = MemberProcessor.GetDefaultMemberGrade();
                                memberInfo.UserName       = Globals.UrlDecode("新用户");
                                memberInfo.OpenId         = text2;
                                memberInfo.CreateDate     = DateTime.Now;
                                memberInfo.SessionId      = generateId;
                                memberInfo.SessionEndTime = DateTime.Now.AddYears(10);
                                memberInfo.UserHead       = Globals.GetWebUrlStart() + "/templates/common/images/user.png";
                                memberInfo.ReferralUserId = Globals.GetCurrentDistributorId();
                                memberInfo.Password       = HiCryptographer.Md5Encrypt("888888");
                                string responseResult2 = this.GetResponseResult(string.Concat(new string[]
                                {
                                    "https://api.weixin.qq.com/sns/userinfo?access_token=",
                                    jObject["access_token"].ToString(),
                                    "&openid=",
                                    jObject["openid"].ToString(),
                                    "&lang=zh_CN"
                                }));
                                JObject jObject2 = JsonConvert.DeserializeObject(responseResult2) as JObject;
                                if (responseResult2.Contains("nickname"))
                                {
                                    memberInfo.UserName = Globals.UrlDecode(jObject2["nickname"].ToString());
                                    memberInfo.UserHead = jObject2["headimgurl"].ToString();
                                    MemberProcessor.CreateMember(memberInfo);
                                    MemberInfo openIdMember = MemberProcessor.GetOpenIdMember(text2, "wx");
                                    if (openIdMember == null)
                                    {
                                        Globals.ClearUserCookie();
                                        result = "/Default.aspx?ReferralId=" + num;
                                        return(result);
                                    }
                                    MemberHelper.SetUserHeadAndUserName(text2, "", "", 2);
                                    this.setLogin(openIdMember.UserId);
                                }
                                else
                                {
                                    if (isMustLogin != 0)
                                    {
                                        string text3 = HttpContext.Current.Request.Url.ToString().Replace(":" + HttpContext.Current.Request.Url.Port, "");
                                        text3 = Regex.Replace(text3, "&code=(.*)&state=STATE", "");
                                        string text4 = "snsapi_userinfo";
                                        string text5 = string.Concat(new string[]
                                        {
                                            "https://open.weixin.qq.com/connect/oauth2/authorize?appid=",
                                            site.WeixinAppId,
                                            "&redirect_uri=",
                                            Globals.UrlEncode(text3),
                                            "&response_type=code&scope=",
                                            text4,
                                            "&state=STATE#wechat_redirect"
                                        });
                                        result = text5;
                                        return(result);
                                    }
                                    memberInfo.Status = Convert.ToInt32(UserStatus.Visitor);
                                    MemberProcessor.CreateMember(memberInfo);
                                }
                            }
                            else
                            {
                                string responseResult3 = this.GetResponseResult(string.Concat(new string[]
                                {
                                    "https://api.weixin.qq.com/sns/userinfo?access_token=",
                                    jObject["access_token"].ToString(),
                                    "&openid=",
                                    jObject["openid"].ToString(),
                                    "&lang=zh_CN"
                                }));
                                JObject jObject3 = JsonConvert.DeserializeObject(responseResult3) as JObject;
                                if (responseResult3.Contains("nickname"))
                                {
                                    MemberInfo openIdMember2 = MemberProcessor.GetOpenIdMember(text2, "wx");
                                    if (openIdMember2 == null)
                                    {
                                        Globals.ClearUserCookie();
                                        result = "/Default.aspx?ReferralId=" + num;
                                        return(result);
                                    }
                                    if (openIdMember2.UserName == "新用户" || string.IsNullOrEmpty(openIdMember2.UserHead) || openIdMember2.UserHead.ToLower().Contains("/templates/common/images/user.png"))
                                    {
                                        MemberHelper.SetUserHeadAndUserName(text2, jObject3["headimgurl"].ToString(), Globals.UrlDecode(jObject3["nickname"].ToString()), 1);
                                    }
                                    else if (openIdMember2.IsAuthorizeWeiXin == 0)
                                    {
                                        MemberHelper.SetUserHeadAndUserName(text2, "", "", 2);
                                    }
                                    this.setLogin(openIdMember2.UserId);
                                }
                            }
                            goto IL_569;
                        }
                        catch (ThreadAbortException ex)
                        {
                            Globals.Debuglog(ex.ToString(), "_DebuglogWX_021.txt");
                            goto IL_569;
                        }
                        catch (Exception ex2)
                        {
                            Globals.Debuglog(ex2.ToString() + "||" + responseResult, "_DebuglogWX_01.txt");
                            goto IL_569;
                        }
                    }
                    string text6 = string.Concat(new string[]
                    {
                        "https://open.weixin.qq.com/connect/oauth2/authorize?appid=",
                        site.WeixinAppId,
                        "&redirect_uri=",
                        Globals.UrlEncode(HttpContext.Current.Request.Url.ToString().Replace(":" + HttpContext.Current.Request.Url.Port, "")),
                        "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
                    });
                    result = text6;
                    return(result);
                }
                IL_569 :;
            }
            catch (ThreadAbortException ex3)
            {
                Globals.Debuglog(ex3.ToString(), "_DebuglogWX_02.txt");
            }
            catch (Exception ex4)
            {
                Globals.Debuglog(ex4.ToString(), "_DebuglogWX_03.txt");
            }
            return("");
        }
Beispiel #23
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            #region 获取商品规格信息,构造购物车信息
            //实例化购物车
            ShoppingCartInfo shoppingCartInfo = new ShoppingCartInfo();

            //实例化SKU信息
            SkuItemInfo skuItemInfo = new SkuItemInfo();

            List <SkuInfo> skuInfoList           = new List <SkuInfo>();
            List <ShoppingCartItemInfo> itemInfo = new List <ShoppingCartItemInfo>();

            //区县Id
            int regionId = 0;
            int.TryParse(txtRegionId.Text, out regionId);
            if (regionId == 0 && dropRegions.GetSelectedRegionId() != null && this.dropRegions.GetSelectedRegionId().Value > 0)
            {
                regionId = this.dropRegions.GetSelectedRegionId().Value;
            }

            string skuList = !string.IsNullOrWhiteSpace(hiddenSkus.Value) ? hiddenSkus.Value : "";

            if (!string.IsNullOrEmpty(skuList))
            {
                skuItemInfo.skuInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <SkuInfo[]>(skuList);
            }

            if (skuItemInfo != null && skuItemInfo.skuInfo != null && skuItemInfo.skuInfo.Count() > 0)
            {
                skuInfoList = skuItemInfo.skuInfo.OrderByDescending(a => a.SkuId).ToList();
            }
            string skuIdStr = "";

            if (skuInfoList.Count > 0)
            {
                skuInfoList.ForEach(a => { skuIdStr += "'" + a.SkuId + "'" + ","; });
            }

            if (!string.IsNullOrEmpty(skuIdStr) && skuIdStr.Length > 0)
            {
                skuIdStr = skuIdStr.Substring(0, skuIdStr.Length - 1);
                skuIdStr = "(" + skuIdStr + ")";

                itemInfo = ShoppingProcessor.GetSkuList(skuIdStr).ToList();
            }

            if (itemInfo.Count > 0)
            {
                //循环处理
                itemInfo.ForEach(a =>
                {
                    skuInfoList.ForEach(b =>
                    {
                        if (b.SkuId == a.SkuId)
                        {
                            a.Quantity      = b.BuyQty;
                            a.ShippQuantity = b.BuyQty;
                        }
                    });
                });
            }
            #endregion

            //收货地址ID
            int shippingId = 0;
            int.TryParse(txtShippingId.Text, out shippingId);
            //身份证号码
            string identityCard = txtIdentityCard.Text.Trim();
            //用户ID
            int userId = 0;
            int.TryParse(txtUserId.Text, out userId);
            //手机号码
            string cellPhone = txtCellPhone.Text.Trim();
            //收货人姓名
            string shipTo = txtShipTo.Text.Trim();
            //地址
            string address     = txtDetailsAddress.Text.Trim();
            string addressproc = "";
            if (!string.IsNullOrEmpty(dropRegions.SelectedRegions))
            {
                addressproc = (dropRegions.SelectedRegions).Replace(",", "") + address;
            }
            //邮政编码
            string zipcode = txtZipcode.Text.Trim();
            //电话号码
            string telPhone = txtTelPhone.Text.Trim();
            //用户名
            string username = txtUserName.Text.Trim();

            #region 新增或修改收货地址信息
            ShippingAddressInfo shippingAddress = new ShippingAddressInfo()
            {
                ShipTo       = shipTo,
                Address      = addressproc,
                Zipcode      = zipcode,
                TelPhone     = telPhone,
                CellPhone    = cellPhone,
                IdentityCard = identityCard,
                IsDefault    = true,
                RegionId     = regionId,
                UserId       = userId,
                ShippingId   = shippingId
            };

            //如果没有选择收获地址,那么新增一个用户,手机号作为用户名,密码为手机号
            int newUserId = 0;
            if (userId == 0)
            {
                Member member = new Member(UserRole.Member);
                member.GradeId             = MemberProcessor.GetDefaultMemberGrade();
                member.SessionId           = Globals.GetGenerateId();
                member.Username            = cellPhone;
                member.Email               = "";// cellPhone + "@mail.haimylife.com";
                member.Password            = cellPhone;
                member.PasswordFormat      = MembershipPasswordFormat.Hashed;
                member.TradePasswordFormat = MembershipPasswordFormat.Hashed;
                member.TradePassword       = cellPhone;
                member.IsApproved          = true;
                member.RealName            = string.Empty;
                member.Address             = string.Empty;
                CreateUserStatus createUserStatus = MemberProcessor.CreateMember(member);
                if (createUserStatus == CreateUserStatus.DuplicateUsername || createUserStatus == CreateUserStatus.DisallowedUsername)
                {
                    ErrorLog.Write("用户名重复,用户名为:" + member.Username);
                }
                if (createUserStatus == CreateUserStatus.DuplicateEmailAddress)
                {
                    ErrorLog.Write("邮件名重复,邮箱为:" + member.Email);
                }
                if (createUserStatus == CreateUserStatus.Created)
                {
                    newUserId = member.UserId;
                    userId    = member.UserId;
                }
            }

            int newShippingId = 0;

            //新增或修改收货地址信息
            int addressResult = MemberProcessor.AddOrUpdateShippingAddress(shippingAddress, newUserId, out newShippingId);
            if (addressResult > 0)
            {
                ErrorLog.Write("新增或修改收货地址信息成功,收获地址Id[newShippingId]" + newShippingId);
            }

            #endregion


            itemInfo.ForEach(a =>
            {
                //门店Id为当前登录用户的Id
                a.StoreId = HiContext.Current.User.UserId;
                a.UserId  = userId;
                shoppingCartInfo.LineItems.Add(a);
            });

            //获取订单信息
            OrderInfo orderInfo = ShoppingProcessor.ConvertShoppingCartToOrder(shoppingCartInfo, false, false, false, userId);
            if (orderInfo != null)
            {
                orderInfo.OrderId   = this.GenerateOrderId();
                orderInfo.OrderDate = System.DateTime.Now;
                orderInfo.UserId    = userId;

                if (!string.IsNullOrEmpty(username))
                {
                    orderInfo.Username = username;
                }
                else
                {
                    orderInfo.Username = cellPhone;
                }
                orderInfo.EmailAddress = "";
                orderInfo.RealName     = "";
                orderInfo.QQ           = "";
                orderInfo.Remark       = txtBak.Text.Trim();
                //站点默认为深圳
                orderInfo.SiteId       = 0;
                orderInfo.IdentityCard = identityCard;
                orderInfo.OrderStatus  = OrderStatus.WaitBuyerPay;
                orderInfo.RefundStatus = RefundStatus.None;
                orderInfo.ShipToDate   = DateTime.Now.ToString();
                //门店Id
                int userStoreId = ManagerHelper.GetStoreIdByUserId(HiContext.Current.User.UserId);
                orderInfo.StoreId = userStoreId;

                if (!string.IsNullOrEmpty(txtDeductible.Text.Trim()))
                {
                    orderInfo.Deductible = Decimal.Parse(txtDeductible.Text.Trim());
                }


                if (shippingAddress != null)
                {
                    #region 验证每人每日最多消费1000元,1000元以上为单件商品
                    int mayCount = 0;
                    foreach (ShoppingCartItemInfo item in shoppingCartInfo.LineItems)
                    {
                        mayCount += item.Quantity;
                        //#region 验证库存
                        int stock = ShoppingProcessor.GetProductStock(item.SkuId);
                        if (stock <= 0 || stock < item.Quantity)
                        {
                            this.ShowMsg("商品库存不足!商品名称为:" + item.Name, false);
                            return;
                        }
                    }
                    #endregion

                    #region 验证是否符合清关条件
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < shoppingCartInfo.LineItems.Count; i++)
                    {
                        if (i == (shoppingCartInfo.LineItems.Count - 1))
                        {
                            sb.Append(shoppingCartInfo.LineItems[i].ProductId);
                        }
                        else
                        {
                            sb.AppendFormat("{0},", shoppingCartInfo.LineItems[i].ProductId);
                        }
                    }
                    bool b = ShoppingProcessor.CheckIsCustomsClearance(sb.ToString());
                    if (b)
                    {
                        orderInfo.IsCustomsClearance = 1;
                        if (string.IsNullOrEmpty(identityCard))
                        {
                            Member memberNew = Users.GetUser(HiContext.Current.User.UserId, false) as Member;
                            identityCard = memberNew.IdentityCard;
                        }
                        if (string.IsNullOrEmpty(identityCard))
                        {
                            this.ShowMsg("有需要清关的商品,身份证号码不能为空,请到个人资料里面填写身份信息!", false);
                            return;
                        }
                    }
                    else
                    {
                        orderInfo.IsCustomsClearance = 0;
                    }
                    #endregion

                    orderInfo.ShippingRegion = RegionHelper.GetFullRegion(regionId, ",");
                    orderInfo.RegionId       = regionId;
                    orderInfo.Address        = address;
                    orderInfo.ZipCode        = zipcode;
                    orderInfo.ShipTo         = shipTo;
                    orderInfo.TelPhone       = telPhone;
                    orderInfo.CellPhone      = cellPhone;

                    orderInfo.ShippingId = shippingId <= 0 ? newShippingId : shippingId;
                }

                //配送方式
                orderInfo.ShippingModeId = ddlshippingMode.SelectedValue > 0 ? (int)ddlshippingMode.SelectedValue : 0;
                orderInfo.ModeName       = !string.IsNullOrEmpty(ddlshippingMode.SelectedItem.Text) ? ddlshippingMode.SelectedItem.Text : "";
                decimal tax     = 0m;
                decimal freight = 0m;

                Dictionary <int, decimal> dictShippingMode = new Dictionary <int, decimal>();
                if (shoppingCartInfo.LineItems.Count != shoppingCartInfo.LineItems.Count((ShoppingCartItemInfo a) => a.IsfreeShipping) && !shoppingCartInfo.IsFreightFree)
                {
                    foreach (ShoppingCartItemInfo item in shoppingCartInfo.LineItems)
                    {
                        tax += item.AdjustedPrice * item.TaxRate * item.Quantity;
                        if ((!item.IsfreeShipping))
                        {
                            if (item.TemplateId > 0)
                            {
                                if (dictShippingMode.ContainsKey(item.TemplateId))
                                {
                                    dictShippingMode[item.TemplateId] += item.Weight * item.Quantity;
                                }
                                else
                                {
                                    dictShippingMode.Add(item.TemplateId, item.Weight * item.Quantity);
                                }
                            }
                        }
                    }
                    foreach (var item in dictShippingMode)
                    {
                        ShippingModeInfo shippingMode = ShoppingProcessor.GetShippingMode(item.Key);
                        freight += ShoppingProcessor.CalcFreight(shippingAddress.RegionId, item.Value, shippingMode);
                    }
                    //运费需要减去优惠
                    orderInfo.Freight     = freight;
                    orderInfo.Tax         = tax <= 50 ? 0 : tax;
                    orderInfo.OriginalTax = tax;
                }
                else
                {
                    orderInfo.Freight = 0m;
                }
                orderInfo.AdjustedFreight = orderInfo.Freight;

                int num = ddlpayment.SelectedValue > 0 ? (int)ddlpayment.SelectedValue:0;
                orderInfo.PaymentTypeId = num;
                if (num == 16)
                {
                    orderInfo.PaymentType = "线下支付";
                    orderInfo.Gateway     = "Ecdev.plugins.payment.bankrequest";
                }
                else
                {
                    PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode(num);
                    if (paymentMode != null)
                    {
                        orderInfo.PaymentTypeId = paymentMode.ModeId;
                        orderInfo.PaymentType   = paymentMode.Name;
                        orderInfo.Gateway       = paymentMode.Gateway;
                    }
                }

                orderInfo.OrderSource = OrderSource.storeAdd;

                try
                {
                    orderInfo.OrderType = (int)OrderType.Normal;

                    if (ShoppingProcessor.CreateOrder(orderInfo, true, true))
                    {
                        Reset();
                        //this.ShowMsg("添加门店订单成功", true);
                        string url = Globals.GetAdminAbsolutePath("/sales/StoreManageOrder.aspx");
                        //清除前端的cookie
                        ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>ClearsCookie();alert('添加门店订单成功');window.location.href='" + url + "';</script>");
                        //base.Response.Redirect(Globals.GetAdminAbsolutePath("'/sales/StoreManageOrder.aspx'"), true);
                    }
                    else
                    {
                        this.ShowMsg("添加门店订单失败!", false);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ErrorLog.Write("后台成功添加门店订单错误:", Newtonsoft.Json.JsonConvert.SerializeObject(orderInfo), ex);
                }
            }
        }
Beispiel #24
0
        void btnRegister_Click(object sender, EventArgs e)
        {
            if (!this.chkAgree.Checked)
            {
                this.ShowMessage("您必须先阅读并同意注册协议", false);
            }
            else if (string.Compare(this.txtUserName.Text.Trim().ToLower(CultureInfo.InvariantCulture), "anonymous", false, CultureInfo.InvariantCulture) == 0)
            {
                this.ShowMessage("已经存在相同的用户名", false);
            }
            else
            {
                string pattern = @"[\u4e00-\u9fa5a-zA-Z]+[\u4e00-\u9fa5_a-zA-Z0-9]*";
                Regex  regex   = new Regex(pattern);
                if ((!regex.IsMatch(this.txtUserName.Text.Trim()) || (this.txtUserName.Text.Trim().Length < 2)) || (this.txtUserName.Text.Trim().Length > 20))
                {
                    this.ShowMessage("用户名不能为空,必须以汉字或是字母开头,且在2-20个字符之间", false);
                }
                else if (string.Compare(this.txtPassword.Text, this.txtPassword2.Text) != 0)
                {
                    this.ShowMessage("两次输入的密码不相同", false);
                }
                else if (this.txtPassword.Text.Length == 0)
                {
                    this.ShowMessage("密码不能为空", false);
                }
                else if ((this.txtPassword.Text.Length < Membership.Provider.MinRequiredPasswordLength) || (this.txtPassword.Text.Length > HiConfiguration.GetConfig().PasswordMaxLength))
                {
                    this.ShowMessage(string.Format("密码的长度只能在{0}和{1}个字符之间", Membership.Provider.MinRequiredPasswordLength, HiConfiguration.GetConfig().PasswordMaxLength), false);
                }
                else
                {
                    Member member = null;
                    if (HiContext.Current.SiteSettings.IsDistributorSettings)
                    {
                        member = new Member(UserRole.Underling);
                        member.ParentUserId = HiContext.Current.SiteSettings.UserId;
                    }
                    else
                    {
                        member = new Member(UserRole.Member);
                    }
                    if (HiContext.Current.ReferralUserId > 0)
                    {
                        member.ReferralUserId = new int?(HiContext.Current.ReferralUserId);
                    }
                    member.GradeId             = MemberProcessor.GetDefaultMemberGrade();
                    member.Username            = Globals.HtmlEncode(this.txtUserName.Text.Trim());
                    member.Email               = this.txtEmail.Text;
                    member.Password            = this.txtPassword.Text;
                    member.PasswordFormat      = MembershipPasswordFormat.Hashed;
                    member.TradePasswordFormat = MembershipPasswordFormat.Hashed;
                    member.TradePassword       = this.txtPassword.Text;
                    member.IsApproved          = true;
                    member.RealName            = string.Empty;
                    member.Address             = string.Empty;
                    if (this.ValidationMember(member))
                    {
                        if (!HiContext.Current.CheckVerifyCode(this.txtNumber.Text))
                        {
                            this.ShowMessage("验证码输入错误", false);
                        }
                        else
                        {
                            switch (MemberProcessor.CreateMember(member))
                            {
                            case CreateUserStatus.UnknownFailure:
                                this.ShowMessage("未知错误", false);
                                return;

                            case CreateUserStatus.Created:
                            {
                                Messenger.UserRegister(member, this.txtPassword.Text);
                                member.OnRegister(new UserEventArgs(member.Username, this.txtPassword.Text, null));
                                IUser            user         = Users.GetUser(0, member.Username, false, true);
                                ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart();
                                CookieShoppingProvider.Instance().ClearShoppingCart();
                                HiContext.Current.User = user;
                                if (shoppingCart != null)
                                {
                                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart);
                                }
                                HttpCookie authCookie = FormsAuthentication.GetAuthCookie(member.Username, false);
                                user.GetUserCookie().WriteCookie(authCookie, 30, false);
                                this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("registerUserSave") + "?UserId=" + user.UserId);
                                return;
                            }

                            case CreateUserStatus.DuplicateUsername:
                                this.ShowMessage("已经存在相同的用户名", false);
                                return;

                            case CreateUserStatus.DuplicateEmailAddress:
                                this.ShowMessage("电子邮件地址已经存在", false);
                                return;

                            case CreateUserStatus.InvalidFirstCharacter:
                            case CreateUserStatus.Updated:
                            case CreateUserStatus.Deleted:
                            case CreateUserStatus.InvalidQuestionAnswer:
                                return;

                            case CreateUserStatus.DisallowedUsername:
                                this.ShowMessage("用户名禁止注册", false);
                                return;

                            case CreateUserStatus.InvalidPassword:
                                this.ShowMessage("无效的密码", false);
                                return;

                            case CreateUserStatus.InvalidEmail:
                                this.ShowMessage("无效的电子邮件地址", false);
                                return;
                            }
                        }
                    }
                }
            }
        }
Beispiel #25
0
        protected void SkipSinaOpenId()
        {
            Member member = new Member(UserRole.Member);

            if (HiContext.Current.ReferralUserId > 0)
            {
                member.ReferralUserId = new int?(HiContext.Current.ReferralUserId);
            }
            member.GradeId  = MemberProcessor.GetDefaultMemberGrade();
            member.Username = this.parameters["CurrentOpenId"];
            if (string.IsNullOrEmpty(member.Username))
            {
                member.Username = "******" + this.GenerateUsername(8);
            }
            member.Email = this.GenerateUsername() + "@localhost.com";
            string text = this.GeneratePassword();

            member.Password            = text;
            member.PasswordFormat      = System.Web.Security.MembershipPasswordFormat.Hashed;
            member.TradePasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;
            member.TradePassword       = text;
            member.IsApproved          = true;
            member.RealName            = string.Empty;
            member.Address             = string.Empty;
            if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
            {
                member.Username = "******" + this.GenerateUsername(9);
                member.Password = (member.TradePassword = text);
                if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
                {
                    member.Username = this.GenerateUsername();
                    member.Email    = this.GenerateUsername() + "@localhost.com";
                    member.Password = (member.TradePassword = text);
                    if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
                    {
                        base.Response.Write("为您创建随机账户时失败,请重试。");
                        return;
                    }
                }
            }
            UserHelper.BindOpenId(member.Username, this.parameters["CurrentOpenId"], this.parameters["HIGW"]);
            System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
            IUserCookie           userCookie = member.GetUserCookie();

            userCookie.WriteCookie(authCookie, 30, false);
            ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();

            HiContext.Current.User = member;
            if (cookieShoppingCart != null)
            {
                ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                ShoppingCartProcessor.ClearCookieShoppingCart();
            }
            if (!string.IsNullOrEmpty(this.parameters["token"]))
            {
                System.Web.HttpCookie httpCookie = new System.Web.HttpCookie("Token_" + HiContext.Current.User.UserId.ToString());
                httpCookie.Expires = System.DateTime.Now.AddMinutes(30.0);
                httpCookie.Value   = this.parameters["token"];
                System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
            }
            this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
        }
        protected void SkipSinaOpenId()
        {
            MemberInfo memberInfo = new MemberInfo();

            if (HiContext.Current.ReferralUserId > 0)
            {
                memberInfo.ReferralUserId = HiContext.Current.ReferralUserId;
            }
            memberInfo.GradeId = MemberProcessor.GetDefaultMemberGrade();
            HttpCookie httpCookie = HttpContext.Current.Request.Cookies["SinaNickName"];

            if (httpCookie != null)
            {
                memberInfo.UserName = HttpUtility.UrlDecode(httpCookie.Value);
            }
            if (string.IsNullOrEmpty(memberInfo.UserName))
            {
                memberInfo.UserName = "******" + this.GenerateUsername(8);
            }
            string pass = this.GeneratePassword();
            string text = "Open";

            pass = (memberInfo.Password = Users.EncodePassword(pass, text));
            memberInfo.PasswordSalt     = text;
            memberInfo.RegisteredSource = 2;
            memberInfo.CreateDate       = DateTime.Now;
            memberInfo.IsLogined        = true;
            int num = MemberProcessor.CreateMember(memberInfo);

            if (num <= 0)
            {
                memberInfo.UserName = "******" + this.GenerateUsername(9);
                num = MemberProcessor.CreateMember(memberInfo);
                if (num <= 0)
                {
                    memberInfo.UserName = this.GenerateUsername();
                    num = MemberProcessor.CreateMember(memberInfo);
                    if (num <= 0)
                    {
                        base.Response.Write("为您创建随机账户时失败,请重试。");
                        return;
                    }
                }
            }
            memberInfo.UserId = num;
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();

            if (masterSettings.IsOpenGiftCoupons)
            {
                int      num2  = 0;
                string[] array = masterSettings.GiftCouponList.Split(',');
                foreach (string obj in array)
                {
                    if (obj.ToInt(0) > 0 && CouponHelper.AddCouponItemInfo(memberInfo, obj.ToInt(0)) == CouponActionStatus.Success)
                    {
                        num2++;
                    }
                }
                if (num2 > 0)
                {
                    base.Response.Write("恭喜您注册成功," + num2 + " 张优惠券已经放入您的账户,可在会员中心我的优惠券中进行查看");
                }
            }
            this.SetLoginState(memberInfo);
        }
Beispiel #27
0
        protected void SkipAlipayOpenId()
        {
            MemberInfo memberInfo = new MemberInfo();

            if (HiContext.Current.ReferralUserId > 0)
            {
                memberInfo.ReferralUserId = HiContext.Current.ReferralUserId;
            }
            memberInfo.GradeId  = MemberProcessor.GetDefaultMemberGrade();
            memberInfo.UserName = (string.IsNullOrEmpty(Globals.StripAllTags(this.Parameters["real_name"])) ? string.Empty : Globals.StripAllTags(this.Parameters["real_name"]).Trim());
            memberInfo.NickName = this.hidNickName.Value;
            if (string.IsNullOrEmpty(memberInfo.UserName))
            {
                memberInfo.UserName = "******" + Globals.StripAllTags(this.Parameters["user_id"]);
            }
            if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
            {
                memberInfo.UserName = this.GenerateUsername(8);
                if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
                {
                    memberInfo.UserName = this.GenerateUsername();
                    if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
                    {
                        this.ShowMessage("为您创建随机账户时失败,请重试。", false, "", 1);
                        return;
                    }
                }
            }
            memberInfo.Email = Globals.StripAllTags(this.Parameters["email"]);
            string pass = this.GeneratePassword();
            string text = "Open";

            pass = (memberInfo.Password = Users.EncodePassword(pass, text));
            memberInfo.PasswordSalt     = text;
            memberInfo.RegisteredSource = 1;
            memberInfo.CreateDate       = DateTime.Now;
            int num = MemberProcessor.CreateMember(memberInfo);

            if (num <= 0)
            {
                this.ShowMessage("为您创建账户时失败,请重试。", false, "", 1);
            }
            else
            {
                int num2 = 0;
                memberInfo.UserId = num;
                SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                if (masterSettings.IsOpenGiftCoupons)
                {
                    string[] array = masterSettings.GiftCouponList.Split(',');
                    foreach (string obj in array)
                    {
                        if (obj.ToInt(0) > 0 && CouponHelper.AddCouponItemInfo(memberInfo, obj.ToInt(0)) == CouponActionStatus.Success)
                        {
                            num2++;
                        }
                    }
                }
                memberInfo.UserName = MemberHelper.GetUserName(memberInfo.UserId);
                MemberHelper.Update(memberInfo, true);
                HiContext.Current.User = memberInfo;
                this.SetLoginState(memberInfo, num2);
            }
        }
Beispiel #28
0
        public void AlipayLoginAction(SiteSettings site)
        {
            if (string.IsNullOrEmpty(AlipayFuwuConfig.appId) && !AlipayFuwuConfig.CommSetConfig(site.AlipayAppid, this.Page.Server.MapPath("~/"), "GBK"))
            {
                this.WriteFuwuError(this.Page.Request.QueryString.ToString(), "服务窗口参数配置不准确!");
                this.Page.Response.Redirect(Globals.ApplicationPath + "/UserLogin.aspx");
            }
            string text  = this.Page.Request.QueryString["auth_code"];
            string value = this.Page.Request.QueryString["scope"];

            if (!string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(text))
            {
                this.WriteFuwuError(this.Page.Request.QueryString.ToString(), "已授权");
                AlipaySystemOauthTokenResponse oauthTokenResponse = AliOHHelper.GetOauthTokenResponse(text);
                this.WriteFuwuError(AliOHHelper.SerializeObject(oauthTokenResponse, true), "获取AccessToken");
                if (oauthTokenResponse == null || oauthTokenResponse.IsError || oauthTokenResponse.AccessToken == null)
                {
                    this.Page.Response.Redirect(Globals.ApplicationPath + "/UserLogin.aspx?returnUrl=" + Globals.UrlEncode(HttpContext.Current.Request.Url.AbsoluteUri.ToString()));
                    return;
                }
                string  text2   = oauthTokenResponse.AlipayUserId;
                string  text3   = "";
                JObject jObject = JsonConvert.DeserializeObject(oauthTokenResponse.Body) as JObject;
                if (jObject["alipay_system_oauth_token_response"]["user_id"] != null)
                {
                    text3 = jObject["alipay_system_oauth_token_response"]["user_id"].ToString();
                }
                if (this.HasLogin(text3, "fuwu") || this.HasLogin(text2, "fuwu"))
                {
                    MemberInfo openIdMember = MemberProcessor.GetOpenIdMember(text3, "fuwu");
                    if (openIdMember == null || openIdMember.Status == Convert.ToInt32(UserStatus.DEL))
                    {
                        this.Page.Response.Redirect(Globals.ApplicationPath + "/logout.aspx");
                    }
                    string alipayOpenid = openIdMember.AlipayOpenid;
                    if ((text2 != "" && text2 != alipayOpenid) || string.IsNullOrEmpty(alipayOpenid))
                    {
                        openIdMember.AlipayOpenid = text2;
                        MemberProcessor.SetAlipayInfos(openIdMember);
                    }
                    this.setLogin(openIdMember.UserId);
                    this.WriteFuwuError("已存在用户登入!", text3);
                    return;
                }
                string accessToken = oauthTokenResponse.AccessToken;
                AlipayUserUserinfoShareResponse alipayUserUserinfo = AliOHHelper.GetAlipayUserUserinfo(accessToken);
                this.WriteFuwuError(AliOHHelper.SerializeObject(alipayUserUserinfo, true), "获取用户信息");
                string alipayUsername = "";
                string text4          = "";
                if (alipayUserUserinfo != null && !alipayUserUserinfo.IsError)
                {
                    text4 = alipayUserUserinfo.Avatar;
                    if (alipayUserUserinfo.RealName != null)
                    {
                        alipayUsername = alipayUserUserinfo.RealName;
                    }
                    if (string.IsNullOrEmpty(text2))
                    {
                        text2 = alipayUserUserinfo.UserId;
                    }
                    if (string.IsNullOrEmpty(text3))
                    {
                        JObject jObject2 = JsonConvert.DeserializeObject(alipayUserUserinfo.Body) as JObject;
                        if (jObject2["alipay_user_id"] != null)
                        {
                            text3 = jObject2["alipay_user_id"].ToString();
                        }
                    }
                }
                string     text5      = "FW*" + text3.Substring(10);
                string     generateId = Globals.GetGenerateId();
                MemberInfo memberInfo = new MemberInfo();
                memberInfo.GradeId        = MemberProcessor.GetDefaultMemberGrade();
                memberInfo.UserName       = text5;
                memberInfo.CreateDate     = DateTime.Now;
                memberInfo.SessionId      = generateId;
                memberInfo.SessionEndTime = DateTime.Now.AddYears(10);
                memberInfo.UserHead       = text4;
                memberInfo.AlipayAvatar   = text4;
                memberInfo.AlipayLoginId  = text5;
                memberInfo.AlipayOpenid   = text2;
                memberInfo.AlipayUserId   = text3;
                memberInfo.AlipayUsername = alipayUsername;
                HttpCookie httpCookie = HttpContext.Current.Request.Cookies["Vshop-ReferralId"];
                if (httpCookie != null)
                {
                    memberInfo.ReferralUserId = Convert.ToInt32(httpCookie.Value);
                }
                else
                {
                    memberInfo.ReferralUserId = 0;
                }
                memberInfo.Password = HiCryptographer.Md5Encrypt("888888");
                MemberProcessor.CreateMember(memberInfo);
                MemberInfo member = MemberProcessor.GetMember(generateId);
                this.setLogin(member.UserId);
                return;
            }
            else
            {
                if (!string.IsNullOrEmpty(value))
                {
                    this.WriteFuwuError(this.Page.Request.QueryString.ToString(), "拒绝授权");
                    this.Page.Response.Redirect(Globals.ApplicationPath + "/UserLogin.aspx");
                    return;
                }
                string text6 = AliOHHelper.AlipayAuthUrl(HttpContext.Current.Request.Url.ToString().Replace(":" + HttpContext.Current.Request.Url.Port, ""), site.AlipayAppid, "auth_userinfo");
                this.WriteFuwuError(text6, "用户登入授权的路径");
                this.Page.Response.Redirect(text6);
                return;
            }
        }
        bool SkipWinxinOpenId(string userName, string openId, string headimgurl, string state, int t)
        {
            WxLogger("      状态信息:** 进入 SkipWinxinOpenId 函数体 **");

            bool flag = false;

            try
            {
                string generateId = Globals.GetGenerateId();

                MemberInfo member = new MemberInfo();

                member.GradeId  = MemberProcessor.GetDefaultMemberGrade();
                member.UserName = userName;
                member.RealName = userName;
                if (t == 0)
                {
                    member.OpenId    = openId;
                    member.RegSource = 0;//微信注册
                }
                else if (t == 1)
                {
                    member.AliOpenId = openId;
                    member.RegSource = 1;//支付宝
                }
                member.CreateDate     = DateTime.Now;
                member.SessionId      = generateId;
                member.SessionEndTime = DateTime.Now.AddYears(10);
                member.Email          = generateId + "@localhost.com";
                member.SessionId      = generateId;
                member.Password       = generateId;
                member.RealName       = string.Empty;
                member.Address        = string.Empty;
                member.UserHead       = headimgurl;//用户头像
                #region 设置推荐人
                if (!string.IsNullOrWhiteSpace(state))
                {
                    int referralUserId = 0;
                    if (int.TryParse(state, out referralUserId))
                    {
                        member.ReferralUserId = referralUserId;
                    }
                }

                //System.IO.File.AppendAllText(HiContext.Current.Context.Request.MapPath("~/ReferralUserId.txt"), "用户名:" + userName + ";ReferralUserId=" + member.ReferralUserId + ";openid=" + openId + Environment.NewLine);

                #endregion

                WxLogger(" 调式A **" + member.OpenId);

                if (MemberProcessor.CreateMember(member))
                {
                    //MemberProcessor.GetusernameMember(Globals.UrlDecode(userName));
                    //MemberProcessor.GetusernameMember(Globals.UrlDecode(obj3["nickname"].ToString()));
                    //System.IO.File.AppendAllText(Page.Request.MapPath("~/wx.txt"), "***用户创建成功了***" + Environment.NewLine);//获取到openid
                    WxLogger(" 调式b**" + member.OpenId);
                    IList <MemberInfo> memberLst = Hidistro.ControlPanel.Members.MemberHelper.GetMemdersByOpenIds("'" + openId + "'", t);

                    HttpCookie cookie = new HttpCookie("Vshop-Member");

                    cookie.Value = memberLst[0].UserId.ToString();

                    cookie.Expires = DateTime.Now.AddYears(10);

                    HttpContext.Current.Response.Cookies.Add(cookie);
                    WxLogger(" 调式c**" + Globals.GetCurrentMemberUserId().ToString());

                    /*
                     * DistributorsInfo userIdDistributors = new DistributorsInfo();
                     *
                     * userIdDistributors = DistributorsBrower.GetUserIdDistributors(member.UserId);
                     *
                     * if ((userIdDistributors != null) && (userIdDistributors.UserId > 0))
                     * {
                     *  HttpCookie cookie2 = new HttpCookie("Vshop-ReferralId")
                     *  {
                     *      Value = userIdDistributors.UserId.ToString(),
                     *      Expires = DateTime.Now.AddYears(1)
                     *  };
                     *  HttpContext.Current.Response.Cookies.Add(cookie2);
                     * }*/

                    flag = true;
                }
            }
            catch (Exception ex)
            {
                WxLogger("      异常信息:** SkipWinxinOpenId()函数调用引发的异常:" + ex.Message + "**");
            }


            return(flag);
        }
Beispiel #30
0
        public void GetOpenID(SiteSettings site)
        {
            string text = this.Page.Request.QueryString["code"];
            string getCurrentWXOpenId = Globals.GetCurrentWXOpenId;

            Globals.Debuglog("进入9,获取OpenID的Cookie" + this.Page.Request.Url.ToString(), "_debugtest.txt");
            if (!string.IsNullOrEmpty(getCurrentWXOpenId))
            {
                return;
            }
            if (!string.IsNullOrEmpty(text))
            {
                Globals.Debuglog("无openid Cookie,并请求access_token" + this.Page.Request.Url.ToString(), "_debugtest.txt");
                string responseResult = this.GetResponseResult(string.Concat(new string[]
                {
                    "https://api.weixin.qq.com/sns/oauth2/access_token?appid=",
                    site.WeixinAppId,
                    "&secret=",
                    site.WeixinAppSecret,
                    "&code=",
                    text,
                    "&grant_type=authorization_code"
                }));
                if (responseResult.Contains("access_token"))
                {
                    Globals.Debuglog("获取到access_token" + this.Page.Request.Url.ToString(), "_debugtest.txt");
                    JObject jObject = JsonConvert.DeserializeObject(responseResult) as JObject;
                    string  text2   = jObject["openid"].ToString();
                    Globals.GetCurrentWXOpenId = text2;
                    if (!this.HasLogin(text2, "wx"))
                    {
                        Globals.Debuglog("开始注册匿名会员" + this.Page.Request.Url.ToString(), "_debugtest.txt");
                        string generateId = Globals.GetGenerateId();
                        MemberProcessor.CreateMember(new MemberInfo
                        {
                            GradeId        = MemberProcessor.GetDefaultMemberGrade(),
                            UserName       = Globals.UrlDecode("新用户"),
                            OpenId         = text2,
                            CreateDate     = DateTime.Now,
                            SessionId      = generateId,
                            SessionEndTime = DateTime.Now.AddYears(10),
                            UserHead       = Globals.GetWebUrlStart() + "/templates/common/images/user.png",
                            ReferralUserId = Globals.GetCurrentDistributorId(),
                            Password       = HiCryptographer.Md5Encrypt("888888")
                        });
                        Globals.Debuglog("进入5,准备获取到基本信息" + this.Page.Request.Url.ToString(), "_debugtest.txt");
                        string responseResult2 = this.GetResponseResult(string.Concat(new string[]
                        {
                            "https://api.weixin.qq.com/sns/userinfo?access_token=",
                            jObject["access_token"].ToString(),
                            "&openid=",
                            jObject["openid"].ToString(),
                            "&lang=zh_CN"
                        }));
                        JObject jObject2 = JsonConvert.DeserializeObject(responseResult2) as JObject;
                        if (responseResult2.Contains("nickname"))
                        {
                            Globals.Debuglog("进入116,获取到基本信息" + this.Page.Request.Url.ToString(), "_debugtest.txt");
                            MemberInfo openIdMember = MemberProcessor.GetOpenIdMember(text2, "wx");
                            if (openIdMember == null)
                            {
                                Globals.Debuglog("进入16,检测用户信息为空,清空Cookie并跳转到首页" + this.Page.Request.Url.ToString(), "_debugtest.txt");
                                Globals.ClearUserCookie();
                                this.Page.Response.Redirect("/Default.aspx");
                            }
                            MemberHelper.SetUserHeadAndUserName(text2, jObject2["headimgurl"].ToString(), Globals.UrlDecode(jObject2["nickname"].ToString()));
                            this.setLogin(openIdMember.UserId);
                            return;
                        }
                    }
                }
            }
            else
            {
                Globals.Debuglog("进入11,请求静默登录" + this.Page.Request.Url.ToString(), "_debugtest.txt");
                string url = string.Concat(new string[]
                {
                    "https://open.weixin.qq.com/connect/oauth2/authorize?appid=",
                    site.WeixinAppId,
                    "&redirect_uri=",
                    Globals.UrlEncode(HttpContext.Current.Request.Url.ToString().Replace(":" + HttpContext.Current.Request.Url.Port, "")),
                    "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
                });
                this.Page.Response.Redirect(url);
            }
        }