Exemplo n.º 1
0
        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var user   = CookieHelper.GetCurrentWxUser();
            var person = CookieHelper.GetCurrentPeople();

            if (user == null || person == null)
            {
                return(OAuthExpired());
            }
            UserCenterModel model = new UserCenterModel();

            model.User = new Model.User()
            {
                HeadImgUrl = user.headimgurl,
                NickName   = user.nickname
            };
            model.Score = IUserService.Find_PersonUserScore(person.UNID, user.openid);
            var signModel = IUserSignService.Get_LastSign(user.openid, person.UNID);

            if (signModel != null && signModel.SignDate == DateTime.Now.Date)
            {
                model.TodayHadSign = true;
            }
            model.SignNum = signModel == null ? 0 : (model.TodayHadSign?signModel.SignNum:0);
            model.SignDic = IUserSignService.Get_LastelyTenDaySign(user.openid, person.UNID);
            return(View(model));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var user   = CookieHelper.GetCurrentWxUser();
            var person = CookieHelper.GetCurrentPeople();

            if (user == null || person == null)
            {
                return(OAuthExpired());
            }
            UserCenterModel model = new UserCenterModel();

            return(View(model));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        public ActionResult Index(string info, string comId)
        {
            //接收微信用户数据
            var userInfoCache = CookieHelper.GetCurrentWxUser();
            var person        = CookieHelper.GetCurrentPeople();

            if (person == null && !string.IsNullOrEmpty(comId))
            {
                person = IPersonService.Get_ByComId(comId.GetInt());
                CookieHelper.CreatePeople(person);
            }
            UserCenterModel model = new UserCenterModel();

            if (!string.IsNullOrEmpty(info) && userInfoCache == null)
            {
                WXUser entity = info.DeserializeJson <WXUser>();
                if (entity != null)
                {
                    model.User = new Model.User()
                    {
                        NickName   = entity.nickname,
                        HeadImgUrl = entity.headimgurl
                    };
                    userInfoCache = entity;
                    //更新数据
                    IUserService.Update_User(entity);
                    CookieHelper.CreateWxUser(entity);
                }
            }

            model.User = new Model.User()
            {
                HeadImgUrl = userInfoCache.headimgurl,
                NickName   = userInfoCache.nickname
            };
            model.Score = IUserService.Find_PersonUserScore(person.UNID, userInfoCache.openid);
            var signModel = IUserSignService.Get_LastSign(userInfoCache.openid, person.UNID);

            model.SignNum = signModel == null ? 0 : (signModel.SignDate == DateTime.Now.Date || signModel.SignDate == DateTime.Now.AddDays(-1).Date ? signModel.SignNum : 0);

            return(View(model));
        }
Exemplo n.º 4
0
        public UserCenterModel GetUserCenterModel(long id)
        {
            List <OrderInfo> list = (
                from a in context.OrderInfo
                where a.UserId == id
                select a).ToList();
            UserCenterModel userCenterModel = new UserCenterModel();
            int             num             = (
                from a in context.MemberIntegral
                where a.MemberId == id
                select a.HistoryIntegrals).FirstOrDefault();

            userCenterModel.GradeName = GetMemberGrade(num);
            userCenterModel.Intergral = (
                from a in context.MemberIntegral
                where a.MemberId == id
                select a.AvailableIntegrals).FirstOrDefault();
            userCenterModel.UserCoupon = context.CouponRecordInfo.Count((CouponRecordInfo a) => a.UserId == id && a.CounponStatus == 0 && (a.ChemCloud_Coupon.EndTime > DateTime.Now));
            UserCenterModel userCoupon = userCenterModel;

            userCoupon.UserCoupon         = userCoupon.UserCoupon + context.ShopBonusReceiveInfo.Count((ShopBonusReceiveInfo p) => p.UserId == id && (int)p.State == 1 && (p.ChemCloud_ShopBonusGrant.ChemCloud_ShopBonus.BonusDateEnd > DateTime.Now));
            userCenterModel.RefundCount   = context.OrderRefundInfo.Count((OrderRefundInfo a) => a.UserId == id && (int)a.SellerAuditStatus != 4 && (int)a.ManagerConfirmStatus != 7);
            userCenterModel.WaitPayOrders = (
                from a in list
                where a.OrderStatus == OrderInfo.OrderOperateStatus.WaitPay
                select a).Count();
            userCenterModel.WaitReceivingOrders = (
                from a in list
                where a.OrderStatus == OrderInfo.OrderOperateStatus.WaitReceiving
                select a).Count();
            userCenterModel.WaitEvaluationOrders = list.Where((OrderInfo a) =>
            {
                if (a.OrderStatus != OrderInfo.OrderOperateStatus.Finish)
                {
                    return(false);
                }
                return(a.OrderCommentInfo.Count == 0);
            }).Count();
            userCenterModel.FollowProductCount = context.FavoriteInfo.Count((FavoriteInfo a) => a.UserId == id);
            if (userCenterModel.FollowProductCount > 0)
            {
                userCenterModel.FollwProducts = (
                    from a in
                    (
                        from a in context.FavoriteInfo
                        where a.UserId == id
                        orderby a.Id descending
                        select a).ToArray()
                    select new FollowProduct()
                {
                    ProductId = a.ProductId,
                    ProductName = a.ProductInfo.ProductName,
                    Price = a.ProductInfo.MinSalePrice,
                    ImagePath = a.ProductInfo.ImagePath
                }).Take(4).ToList();
            }
            FavoriteShopInfo[] array = (
                from a in context.FavoriteShopInfo.Include("ChemCloud_Shops")
                where a.UserId == id
                orderby a.Id descending
                select a).ToArray();
            userCenterModel.FollowShopsCount = array.Length;
            if (array.Length > 0)
            {
                List <FollowShop> followShops = (
                    from a in array
                    select new FollowShop()
                {
                    ShopName = a.ChemCloud_Shops.ShopName,
                    Logo = a.ChemCloud_Shops.Logo,
                    ShopID = a.ShopId
                }).ToList();
                if (followShops.Count > 8)
                {
                    userCenterModel.FollowShops = followShops.Take(8).ToList <FollowShop>();
                }
                userCenterModel.FollowShops = followShops;
            }
            userCenterModel.Orders = Instance <IOrderService> .Create.GetTopOrders(3, id);

            userCenterModel.FollowShopCartsCount = context.ShoppingCartItemInfo_.Count((ShoppingCartItemInfo a) => a.UserId == id);
            if (userCenterModel.FollowShopCartsCount > 0)
            {
                //List<ProductInfo> productInfos = (
                //    from p in context.ShoppingCartItemInfo_
                //    join o in context.ProductInfo on p.ProductId equals o.Id
                //    join x in context.ShopInfo on o.ShopId equals x.Id
                //    where p.UserId == id && (int)o.SaleStatus != 4
                //    select o).Distinct<ProductInfo>().Take(4).ToList();

                //List<ProductInfo> productInfos = (
                //   from p in context.ShoppingCartItemInfo_
                //   join o in context.ProductInfo on p.ProductId equals o.Id
                //   join x in context.ShopInfo on o.ShopId equals x.Id
                //   where p.UserId == id && (int)o.SaleStatus != 4
                //   select o).Take(4).ToList();

                userCenterModel.FollowShopCarts = (
                    from p in context.ShoppingCartItemInfo_
                    join o in context.ProductInfo on p.ProductId equals o.Id
                    join x in context.ShopInfo on o.ShopId equals x.Id
                    where p.UserId == id && (int)o.SaleStatus != 4
                    select new FollowShopCart()
                {
                    ImagePath = o.ImagePath,
                    ProductName = o.ProductName,
                    ProductId = o.Id,
                    Quantity = p.Quantity
                }).ToList();
            }
            return(userCenterModel);
        }
Exemplo n.º 5
0
        public ActionResult Home()
        {
            string          str;
            long            num;
            UserCenterModel userCenterModel = ServiceHelper.Create <IMemberService>().GetUserCenterModel(base.CurrentUser.Id);
            dynamic         viewBag         = base.ViewBag;

            str = (base.CurrentUser.Nick == "" ? base.CurrentUser.UserName : base.CurrentUser.Nick);
            viewBag.UserName = str;
            ViewBag.Logo     = base.CurrentUser.Photo;
            long[] array = (
                from a in ServiceHelper.Create <ICartService>().GetCart(base.CurrentUser.Id).Items
                orderby a.AddTime descending
                select a into p
                select p.ProductId).Take(3).ToArray();
            ViewBag.ShoppingCartItems = ServiceHelper.Create <IProductService>().GetProductByIds(array).ToArray();
            OrderItemInfo[] orderItemInfoArray = ServiceHelper.Create <ICommentService>().GetUnEvaluatProducts(base.CurrentUser.Id).ToArray();
            ViewBag.UnEvaluatProductsNum  = orderItemInfoArray.Count();
            ViewBag.Top3UnEvaluatProducts = orderItemInfoArray.Take(3).ToArray();
            ViewBag.Top3RecommendProducts = ServiceHelper.Create <IProductService>().GetPlatHotSaleProductByNearShop(8, base.CurrentUser.Id).ToArray();
            dynamic browsingProducts = base.ViewBag;

            num = (base.CurrentUser == null ? 0 : base.CurrentUser.Id);
            browsingProducts.BrowsingProducts = BrowseHistrory.GetBrowsingProducts(4, num);
            IEnumerable <Plugin <IMessagePlugin> > plugins = PluginsManagement.GetPlugins <IMessagePlugin>();
            IEnumerable <PluginsInfo> pluginsInfo          =
                from item in plugins
                select new PluginsInfo()
            {
                ShortName       = item.Biz.ShortName,
                PluginId        = item.PluginInfo.PluginId,
                Enable          = item.PluginInfo.Enable,
                IsSettingsValid = item.Biz.IsSettingsValid,
                IsBind          = !string.IsNullOrEmpty(ServiceHelper.Create <IMessageService>().GetDestination(base.CurrentUser.Id, item.PluginInfo.PluginId, MemberContactsInfo.UserTypes.General))
            };

            ViewBag.BindContactInfo = pluginsInfo;
            IOrderService orderService = ServiceHelper.Create <IOrderService>();
            OrderQuery    orderQuery   = new OrderQuery()
            {
                PageNo   = 1,
                PageSize = 2147483647,
                UserId   = new long?(base.CurrentUser.Id)
            };
            PageModel <OrderInfo> orders = orderService.GetOrders <OrderInfo>(orderQuery, null);

            ViewBag.OrderCount = orders.Total;
            dynamic obj = base.ViewBag;
            IQueryable <OrderInfo> models = orders.Models;

            obj.OrderWaitReceiving = (
                from c in models
                where (int)c.OrderStatus == 3
                select c).Count();
            dynamic viewBag1 = base.ViewBag;
            IQueryable <OrderInfo> orderInfos = orders.Models;

            viewBag1.OrderWaitPay = (
                from c in orderInfos
                where (int)c.OrderStatus == 1
                select c).Count();
            ICommentService commentService = ServiceHelper.Create <ICommentService>();
            CommentQuery    commentQuery   = new CommentQuery()
            {
                UserID   = base.CurrentUser.Id,
                PageSize = 2147483647,
                PageNo   = 1,
                Sort     = "PComment"
            };
            IQueryable <long> nums = (
                from item in commentService.GetProductEvaluation(commentQuery).Models
                where !item.EvaluationStatus
                select item.OrderId).Distinct <long>();

            ViewBag.OrderEvaluationStatus = nums.Count();
            CapitalInfo capitalInfo = ServiceHelper.Create <IMemberCapitalService>().GetCapitalInfo(base.CurrentUser.Id);
            decimal     value       = new decimal(0);

            if (capitalInfo != null && capitalInfo.Balance.HasValue)
            {
                value = capitalInfo.Balance.Value;
            }
            ViewBag.Balance = value;
            MemberAccountSafety memberAccountSafety = new MemberAccountSafety()
            {
                AccountSafetyLevel = 1
            };

            if (base.CurrentUser.PayPwd != null)
            {
                memberAccountSafety.PayPassword = true;
                MemberAccountSafety accountSafetyLevel = memberAccountSafety;
                accountSafetyLevel.AccountSafetyLevel = accountSafetyLevel.AccountSafetyLevel + 1;
            }
            IMessageService create = Instance <IMessageService> .Create;

            foreach (PluginsInfo pluginsInfo1 in pluginsInfo)
            {
                if (pluginsInfo1.PluginId.IndexOf("SMS") <= 0)
                {
                    if (!pluginsInfo1.IsBind)
                    {
                        continue;
                    }
                    memberAccountSafety.BindEmail = true;
                    MemberAccountSafety accountSafetyLevel1 = memberAccountSafety;
                    accountSafetyLevel1.AccountSafetyLevel = accountSafetyLevel1.AccountSafetyLevel + 1;
                }
                else
                {
                    if (!pluginsInfo1.IsBind)
                    {
                        continue;
                    }
                    memberAccountSafety.BindPhone = true;
                    MemberAccountSafety memberAccountSafety1 = memberAccountSafety;
                    memberAccountSafety1.AccountSafetyLevel = memberAccountSafety1.AccountSafetyLevel + 1;
                }
            }
            userCenterModel.memberAccountSafety = memberAccountSafety;
            return(View(userCenterModel));
        }
Exemplo n.º 6
0
        public ActionResult Home()
        {
            RedirectToAction("Bargain");
            //string str;
            long            num;
            UserCenterModel userCenterModel = ServiceHelper.Create <IMemberService>().GetUserCenterModel(base.CurrentUser.Id);

            dynamic viewBag = base.ViewBag;

            //str = base.CurrentUser.UserName;
            viewBag.UserName = base.CurrentUser.UserName;
            // UserMemberInfo uminfo = ServiceHelper.Create<IMemberDetailService>().GetMemberInfoById(base.CurrentUser.Id);
            MemberDetail md = ServiceHelper.Create <IMemberDetailService>().GetMemberDetailByUid(base.CurrentUser.Id);

            if (md != null)
            {
                ViewBag.Logo = md.CompanySign;//old: base.CurrentUser.Photo;
            }
            else
            {
                ViewBag.Logo = "";
            }

            long[] array = (
                from a in ServiceHelper.Create <ICartService>().GetCart(base.CurrentUser.Id).Items
                orderby a.AddTime descending
                select a into p
                select p.ProductId).Take(3).ToArray();
            ViewBag.ShoppingCartItems = ServiceHelper.Create <IProductService>().GetProductByIds(array).ToArray();
            OrderItemInfo[] orderItemInfoArray = ServiceHelper.Create <ICommentService>().GetUnEvaluatProducts(base.CurrentUser.Id).ToArray();
            ViewBag.UnEvaluatProductsNum  = orderItemInfoArray.Count();
            ViewBag.Top3UnEvaluatProducts = orderItemInfoArray.Take(3).ToArray();
            ViewBag.Top3RecommendProducts = ServiceHelper.Create <IProductService>().GetPlatHotSaleProductByNearShop(8, base.CurrentUser.Id).ToArray();
            dynamic browsingProducts = base.ViewBag;

            num = (base.CurrentUser == null ? 0 : base.CurrentUser.Id);
            browsingProducts.BrowsingProducts = BrowseHistrory.GetBrowsingProducts(4, num);
            IEnumerable <Plugin <IMessagePlugin> > plugins = PluginsManagement.GetPlugins <IMessagePlugin>();
            IEnumerable <PluginsInfo> pluginsInfo          =
                from item in plugins
                select new PluginsInfo()
            {
                ShortName       = item.Biz.ShortName,
                PluginId        = item.PluginInfo.PluginId,
                Enable          = item.PluginInfo.Enable,
                IsSettingsValid = item.Biz.IsSettingsValid,
                IsBind          = !string.IsNullOrEmpty(ServiceHelper.Create <IMessageService>().GetDestination(base.CurrentUser.Id, item.PluginInfo.PluginId, MemberContactsInfo.UserTypes.General))
            };

            ViewBag.BindContactInfo = pluginsInfo;
            IOrderService orderService = ServiceHelper.Create <IOrderService>();
            OrderQuery    orderQuery   = new OrderQuery()
            {
                PageNo   = 1,
                PageSize = 2147483647,
                UserId   = new long?(base.CurrentUser.Id)
            };
            PageModel <OrderInfo> orders = orderService.GetOrders <OrderInfo>(orderQuery, null);

            ViewBag.OrderCount = orders.Total;

            dynamic obj = base.ViewBag;
            IQueryable <OrderInfo> models = orders.Models;

            obj.WaitEvaluationOrders = (
                from c in models
                where (int)c.OrderStatus == 6   //已签收=未评价
                select c).Count();
            obj.OrderWaitReceiving = (
                from c in models
                where (int)c.OrderStatus == 3
                select c).Count();
            dynamic viewBag1 = base.ViewBag;
            IQueryable <OrderInfo> orderInfos = orders.Models;

            viewBag1.OrderWaitPay = (
                from c in orderInfos
                where (int)c.OrderStatus == 1
                select c).Count();
            ICommentService commentService = ServiceHelper.Create <ICommentService>();
            CommentQuery    commentQuery   = new CommentQuery()
            {
                UserID   = base.CurrentUser.Id,
                PageSize = 2147483647,
                PageNo   = 1,
                Sort     = "PComment"
            };
            IQueryable <long> nums = (
                from item in commentService.GetProductEvaluation(commentQuery).Models
                where !item.EvaluationStatus
                select item.OrderId).Distinct <long>();

            ViewBag.OrderEvaluationStatus = nums.Count();
            //CapitalInfo capitalInfo = ServiceHelper.Create<IMemberCapitalService>().GetCapitalInfo(base.CurrentUser.Id);
            string         value  = "0.00";
            Finance_Wallet fw     = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString()));
            string         m_type = ConfigurationManager.AppSettings["CoinType"].ToString();

            if (m_type == "1")
            {
                ViewBag.MoneyType = "CNY";
            }
            else if (m_type == "2")
            {
                ViewBag.MoneyType = "USD";
            }
            else
            {
                ViewBag.MoneyType = "";
            }
            if (fw != null)
            {
                value = fw.Wallet_UserLeftMoney.ToString("F2");
            }
            ViewBag.Balance = value;
            MemberAccountSafety memberAccountSafety = new MemberAccountSafety()
            {
                AccountSafetyLevel = 1
            };
            string         cointype   = System.Configuration.ConfigurationManager.AppSettings["CoinType"] == null ? "" : System.Configuration.ConfigurationManager.AppSettings["CoinType"].ToString();
            Finance_Wallet walletInfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(cointype));

            if (walletInfo != null && walletInfo.Wallet_PayPassword != null)
            {
                memberAccountSafety.PayPassword = true;
                MemberAccountSafety accountSafetyLevel = memberAccountSafety;
                accountSafetyLevel.AccountSafetyLevel = accountSafetyLevel.AccountSafetyLevel + 1;
            }


            IMessageService create = Instance <IMessageService> .Create;

            foreach (PluginsInfo pluginsInfo1 in pluginsInfo)
            {
                if (pluginsInfo1.PluginId.IndexOf("SMS") <= 0)
                {
                    if (!pluginsInfo1.IsBind)
                    {
                        continue;
                    }
                    memberAccountSafety.BindEmail = true;
                    MemberAccountSafety accountSafetyLevel1 = memberAccountSafety;
                    accountSafetyLevel1.AccountSafetyLevel = accountSafetyLevel1.AccountSafetyLevel + 1;
                }
                else
                {
                    if (!pluginsInfo1.IsBind)
                    {
                        continue;
                    }
                    memberAccountSafety.BindPhone = true;
                    MemberAccountSafety memberAccountSafety1 = memberAccountSafety;
                    memberAccountSafety1.AccountSafetyLevel = memberAccountSafety1.AccountSafetyLevel + 1;
                }
            }
            userCenterModel.memberAccountSafety = memberAccountSafety;


            foreach (var p in userCenterModel.FollowShopCarts)
            {
                int pub_cid = ServiceHelper.Create <IProductService>().GetProduct(p.ProductId) == null ? 0 :
                              (ServiceHelper.Create <IProductService>().GetProduct(p.ProductId).Pub_CID == null ? 0 : ServiceHelper.Create <IProductService>().GetProduct(p.ProductId).Pub_CID);

                p.ImagePath = pub_cid.ToString();
            }

            return(View(userCenterModel));
        }