public JsonResult Skip(string serviceProvider, string openId, string nickName, string realName, string headimgurl, MemberOpenIdInfo.AppIdTypeEnum appidtype = MemberOpenIdInfo.AppIdTypeEnum.Normal, string unionid = null, string sex = null, string city = null, string province = null)
        {
            int    num      = 0;
            string username = DateTime.Now.ToString("yyMMddHHmmssffffff");   //TODO:DZY[150916]未使用,在方法内会重新生成

            nickName   = System.Web.HttpUtility.UrlDecode(nickName);
            realName   = System.Web.HttpUtility.UrlDecode(realName);
            headimgurl = System.Web.HttpUtility.UrlDecode(headimgurl);
            province   = System.Web.HttpUtility.UrlDecode(province);
            city       = System.Web.HttpUtility.UrlDecode(city);
            UserMemberInfo memberInfo = _iMemberService.GetMemberByUnionId(openId);

            if (memberInfo == null)
            {
                memberInfo = _iMemberService.QuickRegister(username, realName, nickName, serviceProvider, openId, unionid, sex, headimgurl, appidtype, null, city, province);
                //TODO:ZJT  在用户注册的时候,检查此用户是否存在OpenId是否存在红包,存在则添加到用户预存款里
                _iBonusService.DepositToRegister(memberInfo.Id);
                //用户注册的时候,检查是否开启注册领取优惠券活动,存在自动添加到用户预存款里
                num = CouponApplication.RegisterSendCoupon(memberInfo.Id, memberInfo.UserName);
            }

            base.SetUserLoginCookie(memberInfo.Id);
            Application.MemberApplication.UpdateLastLoginDate(memberInfo.Id);
            WebHelper.SetCookie(CookieKeysCollection.HIMALL_ACTIVELOGOUT, "0", DateTime.MaxValue);
            return(Json(new { success = true, num = num }));
        }
Exemple #2
0
        public JsonResult InviteRegist(string serviceProvider, string openId, string username, string password, string nickName, string headimgurl, long introducer, string sex, string city = null, string province = null, string unionid = null, string mobile = null)
        {
            headimgurl = System.Web.HttpUtility.UrlDecode(headimgurl);
            nickName   = System.Web.HttpUtility.UrlDecode(nickName);
            username   = System.Web.HttpUtility.UrlDecode(username);
            province   = System.Web.HttpUtility.UrlDecode(province);
            city       = System.Web.HttpUtility.UrlDecode(city);
            var platform = PlatformType.GetHashCode();//注册终端来源

            Entities.MemberInfo member;
            if (string.IsNullOrWhiteSpace(username))
            {
                username = mobile;
            }
            if (!string.IsNullOrWhiteSpace(serviceProvider) && !string.IsNullOrWhiteSpace(openId))
            {
                member = _iMemberService.Register(username, password, serviceProvider, openId, platform, sex, headimgurl, introducer, nickName
                                                  , city, province, unionid, spreadId: CurrentSpreadId);
            }
            else
            {
                member = _iMemberService.Register(username, password, platform, mobile, "", introducer, spreadId: CurrentSpreadId);
            }

            //TODO:ZJT  在用户注册的时候,检查此用户是否存在OpenId是否存在红包,存在则添加到用户预存款里
            _iBonusService.DepositToRegister(member.Id);
            //用户注册的时候,检查是否开启注册领取优惠券活动,存在自动添加到用户预存款里
            int num = CouponApplication.RegisterSendCoupon(member.Id, member.UserName);

            ClearDistributionSpreadCookie();
            base.SetUserLoginCookie(member.Id);
            Application.MemberApplication.UpdateLastLoginDate(member.Id);
            _iMemberService.AddIntegel(member); //给用户加积分//执行登录后初始化相关操作
            return(Json <dynamic>(success: true, data: new { memberId = member.Id, num = num }));
        }
        public JsonResult InviteRegist(string serviceProvider, string openId, string username, string password, string nickName, string headimgurl, long introducer, string sex, string city = null, string province = null, string unionid = null, string mobile = null)
        {
            headimgurl = System.Web.HttpUtility.UrlDecode(headimgurl);
            nickName   = System.Web.HttpUtility.UrlDecode(nickName);
            username   = System.Web.HttpUtility.UrlDecode(username);
            province   = System.Web.HttpUtility.UrlDecode(province);
            city       = System.Web.HttpUtility.UrlDecode(city);
            UserMemberInfo member;

            if (string.IsNullOrWhiteSpace(username))
            {
                username = mobile;
            }
            if (!string.IsNullOrWhiteSpace(serviceProvider) && !string.IsNullOrWhiteSpace(openId))
            {
                member = _iMemberService.Register(username, password, serviceProvider, openId, sex, headimgurl, introducer, nickName, city, province, unionid);
            }
            else
            {
                member = _iMemberService.Register(username, password, mobile, "", introducer);
            }

            //TODO:ZJT  在用户注册的时候,检查此用户是否存在OpenId是否存在红包,存在则添加到用户预存款里
            _iBonusService.DepositToRegister(member.Id);
            //用户注册的时候,检查是否开启注册领取优惠券活动,存在自动添加到用户预存款里
            int num = CouponApplication.RegisterSendCoupon(member.Id, member.UserName);

            base.SetUserLoginCookie(member.Id);
            Application.MemberApplication.UpdateLastLoginDate(member.Id);
            return(Json(new { success = true, memberId = member.Id, num = num }));
        }
        /// <summary>
        ///一键登录
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetQuickLogin(string openId = "", string nickName = "", string headImage = "", long?spreadId = null)
        {
            var    wxuserinfo = ApiHelper.GetAppletUserInfo(Request);
            string unionid    = string.Empty;

            if (wxuserinfo != null)
            {
                unionid = wxuserinfo.unionId;
            }
            string unionopenid = "";

            if (!string.IsNullOrEmpty(openId))
            {
                headImage = System.Web.HttpUtility.UrlDecode(headImage);
                nickName  = System.Web.HttpUtility.UrlDecode(nickName);
                string username = DateTime.Now.ToString("yyMMddHHmmssffffff");
                var    member   = ServiceProvider.Instance <IMemberService> .Create.QuickRegister(username, string.Empty, nickName, SmallProgServiceProvider, openId, (int)PlatformType.WeiXinSmallProg, unionid, unionopenid : unionopenid, headImage : headImage, spreadId : spreadId);

                if (member != null)
                {
                    //TODO:ZJT  在用户注册的时候,检查此用户是否存在OpenId是否存在红包,存在则添加到用户预存款里
                    BonusApplication.DepositToRegister(member.Id);
                    //用户注册的时候,检查是否开启注册领取优惠券活动,存在自动添加到用户预存款里
                    if (member.IsNewAccount)
                    {
                        CouponApplication.RegisterSendCoupon(member.Id, member.UserName);
                    }
                }
                return(GetMember(member, openId));
            }
            return(Json(ErrorResult <dynamic>(string.Empty)));
        }
Exemple #5
0
        /// <summary>
        /// 注册赠送优惠券
        /// </summary>
        /// <returns></returns>
        private int RegisterSendCoupon(long Id, string UserName)
        {
            Log.Info("注册赠送优惠券方法进入");
            var iCouponSendByRegisterService = ServiceProvider.Instance <ICouponSendByRegisterService> .Create;
            var iCouponService = ServiceProvider.Instance <ICouponService> .Create;

            return(CouponApplication.RegisterSendCoupon(Id, UserName));
        }
        public JsonResult RegisterUser(string username, string password, string mobile, string email, string checkCode, long introducer = 0)
        {
            var siteset = SiteSettings;

            if (siteset.RegisterEmailRequired)
            {
                if (string.IsNullOrWhiteSpace(email))
                {
                    return(Json(new { success = false, msg = "错误的电子邮箱地址" }));
                }
            }
            if (siteset.MobileVerifOpen)
            {
                if (string.IsNullOrWhiteSpace(mobile))
                {
                    return(Json(new { success = false, msg = "错误的手机号码" }));
                }
            }

            if (StringHelper.GetStringLength(username) > CommonModel.CommonConst.MEMBERNAME_LENGTH)
            {
                var unicodeChar = CommonModel.CommonConst.MEMBERNAME_LENGTH / 2;

                return(Json(new { success = false, msg = "用户名最大长度为" + CommonModel.CommonConst.MEMBERNAME_LENGTH + "位," + unicodeChar + "个中文字符" }));
            }

            var cacheCheckCode = Session[CHECK_CODE_KEY] as string;

            if (cacheCheckCode == null || string.IsNullOrEmpty(checkCode) || checkCode.ToLower() != cacheCheckCode.ToLower())
            {
                return(Json(new { success = false, msg = "验证码错误" }));
            }

            var member = _iMemberService.Register(username, password, (int)PlatformType.PC, mobile, email, introducer);

            if (member != null)
            {
                //自动登录
                _iMemberService.Login(username, password);

                base.SetUserLoginCookie(member.Id);

                Session.Remove(CHECK_CODE_KEY);
                if (!string.IsNullOrEmpty(mobile))
                {
                    Core.Cache.Remove(CacheKeyCollection.MemberPluginCheck(mobile, "Himall.Plugin.Message.SMS"));
                }
            }
            //TODO:ZJT  在用户注册的时候,检查此用户是否存在OpenId是否存在红包,存在则添加到用户预存款里
            _iBonusService.DepositToRegister(member.Id);
            //用户注册的时候,检查是否开启注册领取优惠券活动,存在自动添加到用户预存款里
            int num = CouponApplication.RegisterSendCoupon(member.Id, member.UserName);

            return(Json(new { success = true, memberId = member.Id, num = num }));
        }
Exemple #7
0
        public JsonResult Skip(string oauthId, string openId, string nickName, string unionid = null, string unionopenid = null)
        {
            string username   = DateTime.Now.ToString("yyMMddHHmmssffffff");
            var    memberInfo = _iMemberService.QuickRegister(username, string.Empty, nickName, oauthId, openId, (int)PlatformType.PC, unionid, unionopenid: unionopenid);

            if (memberInfo != null)
            {
                //TODO:ZJT  在用户注册的时候,检查此用户是否存在OpenId是否存在红包,存在则添加到用户预存款里
                BonusApplication.DepositToRegister(memberInfo.Id);
                //用户注册的时候,检查是否开启注册领取优惠券活动,存在自动添加到用户预存款里
                if (memberInfo.IsNewAccount)
                {
                    CouponApplication.RegisterSendCoupon(memberInfo.Id, memberInfo.UserName);
                }
            }
            base.SetUserLoginCookie(memberInfo.Id);
            Application.MemberApplication.UpdateLastLoginDate(memberInfo.Id);

            return(Json(new { success = true }));
        }
Exemple #8
0
        public JsonResult Skip(string serviceProvider, string openId, string nickName, string realName, string headimgurl, Entities.MemberOpenIdInfo.AppIdTypeEnum appidtype = Entities.MemberOpenIdInfo.AppIdTypeEnum.Normal, string unionid = null, string sex = null, string city = null, string province = null)
        {
            int    num      = 0;
            string username = DateTime.Now.ToString("yyMMddHHmmssffffff");   //TODO:DZY[150916]未使用,在方法内会重新生成

            nickName   = System.Web.HttpUtility.UrlDecode(nickName);
            realName   = System.Web.HttpUtility.UrlDecode(realName);
            headimgurl = System.Web.HttpUtility.UrlDecode(headimgurl);
            province   = System.Web.HttpUtility.UrlDecode(province);
            city       = System.Web.HttpUtility.UrlDecode(city);
            Entities.MemberInfo memberInfo = _iMemberService.GetMemberByUnionIdOpenId(unionid, openId);
            if (memberInfo == null)
            {
                memberInfo = _iMemberService.QuickRegister(username, realName, nickName, serviceProvider, openId, PlatformType.GetHashCode(),
                                                           unionid, sex, headimgurl, appidtype, null, city, province, spreadId: CurrentSpreadId);
                //TODO:ZJT  在用户注册的时候,检查此用户是否存在OpenId是否存在红包,存在则添加到用户预存款里
                _iBonusService.DepositToRegister(memberInfo.Id);
                //用户注册的时候,检查是否开启注册领取优惠券活动,存在自动添加到用户预存款里
                if (memberInfo.IsNewAccount)
                {
                    num = CouponApplication.RegisterSendCoupon(memberInfo.Id, memberInfo.UserName);
                }
                ClearDistributionSpreadCookie();
                _iMemberService.AddIntegel(memberInfo); //给用户加积分//执行登录后初始化相关操作
            }

            base.SetUserLoginCookie(memberInfo.Id);
            Application.MemberApplication.UpdateLastLoginDate(memberInfo.Id);
            WebHelper.SetCookie(CookieKeysCollection.HIMALL_ACTIVELOGOUT, "0", DateTime.MaxValue);

            #region 判断是否强制绑定手机号
            MemberApplication.UpdateLastLoginDate(memberInfo.Id);
            var isBind = MessageApplication.IsOpenBindSms(memberInfo.Id);
            if (!isBind)
            {
                return(Json <dynamic>(success: false, data: new { num = num }, code: 99));
            }
            #endregion

            return(Json <dynamic>(success: true, data: new { num = num }));
        }
Exemple #9
0
        public JsonResult Index(string serviceProvider, string openId, string username, string password, string checkCode, string mobilecheckCode,
                                string headimgurl, long introducer = 0, string unionid = null, string sex = null,
                                string city = null, string province = null, string country = null, string nickName = null, string email = "", string emailcheckCode = "")
        {
            var    mobilepluginId  = "Himall.Plugin.Message.SMS";
            var    emailpluginId   = "Himall.Plugin.Message.Email";
            string systemCheckCode = Session[CHECK_CODE_KEY] as string;

            if (systemCheckCode.ToLower() != checkCode.ToLower())
            {
                throw new Core.HimallException("验证码错误");
            }

            if (Core.Helper.ValidateHelper.IsMobile(username))
            {
                var cache     = CacheKeyCollection.MemberPluginCheck(username, mobilepluginId);
                var cacheCode = Core.Cache.Get <string>(cache);

                if (string.IsNullOrEmpty(mobilecheckCode) || mobilecheckCode.ToLower() != cacheCode.ToLower())
                {
                    throw new Core.HimallException("手机验证码错误");
                }
            }

            if (!string.IsNullOrEmpty(email) && Core.Helper.ValidateHelper.IsMobile(email))
            {
                var cache     = CacheKeyCollection.MemberPluginCheck(username, emailpluginId);
                var cacheCode = Core.Cache.Get <string>(cache);

                if (string.IsNullOrEmpty(emailcheckCode) || emailcheckCode.ToLower() != cacheCode.ToLower())
                {
                    throw new Core.HimallException("手机验证码错误");
                }
            }

            headimgurl = System.Web.HttpUtility.UrlDecode(headimgurl);
            nickName   = System.Web.HttpUtility.UrlDecode(nickName);
            province   = System.Web.HttpUtility.UrlDecode(province);
            city       = System.Web.HttpUtility.UrlDecode(city);
            Entities.MemberInfo member;
            var mobile = "";

            if (Core.Helper.ValidateHelper.IsMobile(username))
            {
                mobile = username;
            }
            var platform = PlatformType.GetHashCode();//注册终端来源

            if (!string.IsNullOrWhiteSpace(serviceProvider) && !string.IsNullOrWhiteSpace(openId))
            {
                OAuthUserModel userModel = new OAuthUserModel
                {
                    UserName      = username,
                    Password      = password,
                    LoginProvider = serviceProvider,
                    OpenId        = openId,
                    Headimgurl    = headimgurl,
                    Sex           = sex,
                    NickName      = nickName,
                    Email         = email,
                    UnionId       = unionid,
                    introducer    = introducer,
                    Province      = province,
                    City          = city,
                    Platform      = platform,
                    SpreadId      = CurrentSpreadId
                };
                member = _iMemberService.Register(userModel);
            }
            else
            {
                member = _iMemberService.Register(username, password, platform, mobile, email, introducer, spreadId: CurrentSpreadId);
            }
            if (member != null)
            {
                Session.Remove(CHECK_CODE_KEY);
                MessageHelper helper = new MessageHelper();
                helper.ClearErrorTimes(member.UserName);
                if (!string.IsNullOrEmpty(email))
                {
                    helper.ClearErrorTimes(member.Email);
                }
                ClearDistributionSpreadCookie();
            }
            //TODO:ZJT  在用户注册的时候,检查此用户是否存在OpenId是否存在红包,存在则添加到用户预存款里
            _iBonusService.DepositToRegister(member.Id);
            //用户注册的时候,检查是否开启注册领取优惠券活动,存在自动添加到用户预存款里
            int num = CouponApplication.RegisterSendCoupon(member.Id, member.UserName);

            base.SetUserLoginCookie(member.Id);
            Application.MemberApplication.UpdateLastLoginDate(member.Id);
            _iMemberService.AddIntegel(member); //给用户加积分//执行登录后初始化相关操作
            return(Json <dynamic>(success: true, data: new { memberId = member.Id, num = num }));
        }
Exemple #10
0
        /// <summary>
        /// 添加会员
        /// </summary>
        /// <param name="user_name"></param>
        /// <param name="password"></param>
        /// <param name="created"></param>
        /// <param name="real_name"></param>
        /// <param name="mobile"></param>
        /// <param name="email"></param>
        /// <param name="sex"></param>
        /// <param name="birthday"></param>
        /// <param name="state"></param>
        /// <param name="city"></param>
        /// <param name="district"></param>
        /// <param name="town"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        public long AddUser(string user_name, string password, DateTime created, string real_name, string mobile, string email, string sex, DateTime?birthday, string state, string city, string district, string town, string address)
        {
            long result = 0;
            var  user   = _iMemberService.Register(user_name, password, (int)PlatformType.PC, mobile, email, 0);

            user.Sex = SexType.Male;
            if (sex == "女")
            {
                user.Sex = SexType.Female;
            }
            user.RealName   = real_name;
            user.CreateDate = created;
            user.BirthDay   = birthday;
            user.Address    = address;
            if (!string.IsNullOrWhiteSpace(district))
            {
                var dreg = _iRegionService.GetRegionByName(district);
                if (dreg != null)
                {
                    user.RegionId    = dreg.Id;
                    user.TopRegionId = dreg.Parent.Parent.Id;
                    if (!string.IsNullOrWhiteSpace(town))
                    {
                        var treg = dreg.Sub.FirstOrDefault(p => p.Name.Contains(town) || town.Contains(p.Name));
                        if (treg != null)
                        {
                            user.RegionId = treg.Id;
                        }
                    }
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(city))
                {
                    var creg = _iRegionService.GetRegionByName(city);
                    if (creg != null)
                    {
                        user.RegionId    = creg.Id;
                        user.TopRegionId = creg.Parent.Id;
                    }
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(state))
                    {
                        var sreg = _iRegionService.GetRegionByName(state);
                        if (sreg != null)
                        {
                            user.RegionId    = sreg.Id;
                            user.TopRegionId = sreg.Id;
                        }
                    }
                }
                if (!string.IsNullOrWhiteSpace(town))
                {
                    user.Address = town + " " + address;
                }
            }
            _iMemberService.UpdateMemberInfo(user);
            int num = CouponApplication.RegisterSendCoupon(user.Id, user.UserName);

            result = user.Id;
            return(result);
        }