예제 #1
0
        public object GetUser(string UserKey)
        {
            CheckUserLogin();
            dynamic data   = SuccessResult();
            long    userId = CurrentUser.Id;

            var member = MemberApplication.GetMember(userId);

            data.UserId    = member.Id;
            data.UserName  = member.UserName;
            data.Photo     = string.IsNullOrEmpty(member.Photo) ? "" : HimallIO.GetRomoteImagePath(member.Photo);
            data.CellPhone = member.CellPhone;

            data.QQ       = member.QQ;
            data.BirthDay = member.BirthDay;
            data.Nick     = member.Nick;
            data.RealName = member.RealName;
            data.Sex      = (int)member.Sex;


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

            //用户所有订单
            data.AllOrders = orderStatic.OrderCount;
            //待付款订单
            data.WaitingForPay = orderStatic.WaitingForPay;
            //待发货订单
            data.WaitingForDelivery = orderStatic.WaitingForDelivery;//获取待发货订单数
            //未评论订单
            data.WaitingForComments = orderStatic.WaitingForComments;
            //待收货订单/待消费
            data.WaitingForRecieve = orderStatic.WaitingForRecieve + OrderApplication.GetWaitConsumptionOrderNumByUserId(userId);
            //待处理的售后
            data.RefundOrders    = orderStatic.RefundCount;
            data.FavoriteShop    = ShopApplication.GetUserConcernShopsCount(userId);
            data.FavoriteProduct = FavoriteApplication.GetFavoriteCountByUser(userId);
            data.Coupon          = MemberApplication.GetAvailableCouponCount(userId);
            data.Integral        = MemberIntegralApplication.GetAvailableIntegral(userId);
            data.Balance         = MemberCapitalApplication.GetBalanceByUserId(userId);


            //用户参与的团数量
            var seastatus = new List <FightGroupOrderJoinStatus>
            {
                FightGroupOrderJoinStatus.Ongoing,
                FightGroupOrderJoinStatus.JoinSuccess,
                FightGroupOrderJoinStatus.BuildFailed,
                FightGroupOrderJoinStatus.BuildSuccess
            };

            //TODO:FG 查询待优化
            data.GroupTotal = ServiceProvider.Instance <IFightGroupService> .Create.GetJoinGroups(userId, seastatus, 1, 1).Total;

            data.MyGroup = ServiceProvider.Instance <IFightGroupService> .Create.CountJoiningOrder(userId);

            data.IsOpenRechargePresent = SiteSettingApplication.SiteSettings.IsOpenRechargePresent;

            MemberApplication.AddIntegel(member);//给用户加积分//执行登录后初始化相关操作
            return(data);
        }
예제 #2
0
        /// <summary>
        /// 根据OpenId判断是否有账号,根据OpenId进行登录
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetLoginByOpenId(string openId = "")
        {
            //string oauthType = "Himall.Plugin.OAuth.WeiXin";//默认小程序微信端登录
            string unionid    = "";
            var    wxuserinfo = ApiHelper.GetAppletUserInfo(Request);

            if (wxuserinfo != null)
            {
                unionid = wxuserinfo.unionId;
            }
            if (!string.IsNullOrEmpty(openId))
            {
                MemberInfo member = new MemberInfo();
                if (!string.IsNullOrWhiteSpace(unionid))
                {
                    member = MemberApplication.GetMemberByUnionIdAndProvider(SmallProgServiceProvider, unionid) ?? new MemberInfo();
                }

                if (member.Id == 0)
                {
                    member = MemberApplication.GetMemberByOpenId(SmallProgServiceProvider, openId) ?? new MemberInfo();
                }
                if (member.Id > 0)
                {
                    //信任登录并且已绑定
                    string memberId = UserCookieEncryptHelper.Encrypt(member.Id, CookieKeysCollection.USERROLE_USER);
                    MemberApplication.AddIntegel(member);//给用户加积分//执行登录后初始化相关操作
                    return(GetMember(member, openId));
                }
                else
                {
                    //信任登录未绑定
                    return(Json(ErrorResult <dynamic>("未绑定商城帐号")));
                }
            }
            return(Json(ErrorResult <dynamic>(string.Empty)));
        }
예제 #3
0
        public object PostRegisterUser(RegisterUserModel user)
        {
            dynamic result = new Result();

            try
            {
                var email = "";
                //普通注册
                if (user.userName != null && user.password != null && user.userName != "" && user.password != "")
                {
                    string userName = user.userName;
                    string password = user.password;
                    email = user.email;
                    string code = user.code;

                    var pluginId = "";

                    if (!string.IsNullOrEmpty(email) && Core.Helper.ValidateHelper.IsEmail(email))
                    {
                        pluginId = "Himall.Plugin.Message.Email";

                        var cache     = CacheKeyCollection.MemberPluginCheck(email, pluginId);
                        var cacheCode = Core.Cache.Get <string>(cache);
                        if (cacheCode == null || cacheCode != code)
                        {
                            return(new { success = false, ErrorMsg = "验证码输入错误或者已经超时" });
                        }
                    }


                    Regex reg = new Regex("^[a-zA-Z0-9_\u4e00-\u9fa5]+$");
                    if (!reg.IsMatch(userName) || userName.Length < 4 || userName.Length > 20)
                    {
                        throw new HimallException("用户名由4-20个中文英文数字字母下划线组成");
                    }

                    var member = ServiceProvider.Instance <IMemberService> .Create.Register(userName, password, (int)PlatformType.Android, string.Empty, email, 0);

                    if (member == null)
                    {
                        result = ErrorResult("注册失败", 104);
                    }
                    else
                    {
                        //手机注册直接绑定手机
                        if (Core.Helper.ValidateHelper.IsMobile(userName))
                        {
                            pluginId         = "Himall.Plugin.Message.SMS";
                            member.CellPhone = userName;
                            ServiceProvider.Instance <IMemberService> .Create.UpdateMember(member);

                            ServiceProvider.Instance <IMessageService> .Create.UpdateMemberContacts(new Entities.MemberContactInfo()
                            {
                                Contact         = userName,
                                ServiceProvider = pluginId,
                                UserId          = member.Id,
                                UserType        = Entities.MemberContactInfo.UserTypes.General
                            });
                        }

                        //注册赠送优惠券
                        int num = this.RegisterSendCoupon(member.Id, member.UserName);

                        //注册送积分
                        MemberApplication.AddIntegel(member); //给用户加积分//执行登录后初始化相关操作

                        result.success   = true;
                        result.UserId    = member.Id.ToString();
                        result.CouponNum = num;
                        string memberId = UserCookieEncryptHelper.Encrypt(member.Id, "Mobile");
                        //WebHelper.SetCookie(CookieKeysCollection.HIMALL_USER_KEY(platformType), memberId, DateTime.MaxValue);
                    }
                }
                //信任登录并且不绑定,后台给一个快速注册
                else
                {
                    string username = DateTime.Now.ToString("yyMMddHHmmssffffff");
                    var    member   = ServiceProvider.Instance <IMemberService> .Create.QuickRegister(username, string.Empty, user.oauthNickName, user.oauthType, user.oauthOpenId, (int)PlatformType.Android, user.unionid, user.sex, user.headimgurl, Entities.MemberOpenIdInfo.AppIdTypeEnum.Normal);

                    //注册赠送优惠券
                    int num = 0;
                    if (member.IsNewAccount)
                    {
                        num = this.RegisterSendCoupon(member.Id, member.UserName);
                    }

                    //注册送积分
                    MemberApplication.AddIntegel(member); //给用户加积分//执行登录后初始化相关操作

                    string memberId = UserCookieEncryptHelper.Encrypt(member.Id, "Mobile");
                    //WebHelper.SetCookie(CookieKeysCollection.HIMALL_USER_KEY(platformType), memberId);
                    result.success   = true;
                    result.UserId    = member.Id.ToString();
                    result.CouponNum = num;
                }
            }
            catch (Exception ex)
            {
                result = ErrorResult(ex.Message, 104);
            }
            return(result);
        }