Пример #1
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 }));
        }
Пример #2
0
        public ActionResult Center()
        {
            var userId = CurrentUser.Id;
            MemberCenterModel model = new MemberCenterModel();

            var statistic = StatisticApplication.GetMemberOrderStatistic(userId, true);

            var member = _iMemberService.GetMember(userId);

            model.Member               = member;
            model.AllOrders            = statistic.OrderCount;
            model.WaitingForRecieve    = statistic.WaitingForRecieve + OrderApplication.GetWaitConsumptionOrderNumByUserId(UserId);
            model.WaitingForPay        = statistic.WaitingForPay;
            model.WaitingForDelivery   = statistic.WaitingForDelivery;
            model.WaitingForComments   = statistic.WaitingForComments;
            model.RefundOrders         = statistic.RefundCount;
            model.FavoriteProductCount = FavoriteApplication.GetFavoriteCountByUser(userId);

            //拼团
            model.CanFightGroup         = FightGroupApplication.IsOpenMarketService();
            model.BulidFightGroupNumber = FightGroupApplication.CountJoiningOrder(userId);

            model.Capital      = MemberCapitalApplication.GetBalanceByUserId(userId);
            model.CouponsCount = MemberApplication.GetAvailableCouponCount(userId);
            var integral = MemberIntegralApplication.GetMemberIntegral(userId);

            model.GradeName = MemberGradeApplication.GetMemberGradeByUserIntegral(integral.HistoryIntegrals).GradeName;
            model.MemberAvailableIntegrals = MemberIntegralApplication.GetAvailableIntegral(userId);

            model.CollectionShop = ShopApplication.GetUserConcernShopsCount(userId);

            model.CanSignIn             = _iMemberSignInService.CanSignInByToday(userId);
            model.SignInIsEnable        = _iMemberSignInService.GetConfig().IsEnable;
            model.userMemberInfo        = CurrentUser;
            model.IsOpenRechargePresent = SiteSettings.IsOpenRechargePresent;

            model.DistributionOpenMyShopShow = SiteSettings.DistributorRenameOpenMyShop;
            model.DistributionMyShopShow     = SiteSettings.DistributorRenameMyShop;

            if (PlatformType == PlatformType.WeiXin)
            {
                //分销
                model.IsShowDistributionOpenMyShop = SiteSettings.DistributionIsEnable;
                var duser = DistributionApplication.GetDistributor(CurrentUser.Id);
                if (duser != null && duser.DistributionStatus != (int)DistributorStatus.UnApply)
                {
                    model.IsShowDistributionOpenMyShop = false;
                    //拒绝的分销员显示“我要开店”
                    if (duser.DistributionStatus == (int)DistributorStatus.Refused || duser.DistributionStatus == (int)DistributorStatus.UnAudit)
                    {
                        model.IsShowDistributionOpenMyShop = true && SiteSettings.DistributionIsEnable;
                    }

                    model.IsShowDistributionMyShop = true && SiteSettings.DistributionIsEnable;
                    if (duser.DistributionStatus == (int)DistributorStatus.NotAvailable || duser.DistributionStatus == (int)DistributorStatus.Refused || duser.DistributionStatus == (int)DistributorStatus.UnAudit)
                    {
                        model.IsShowDistributionMyShop = false;
                    }
                }
            }
            _iMemberService.AddIntegel(member); //给用户加积分//执行登录后初始化相关操作
            return(View(model));
        }