Example #1
0
        /// <summary>
        /// 获取客服电话
        /// </summary>
        /// <param name="context"></param>
        //public JsonResult<Result<dynamic>> GetServicePhone()
        //{
        //    var siteSettings = SiteSettingApplication.SiteSettings;
        //    return JsonResult<dynamic>(new
        //    {
        //        ServicePhone = siteSettings.SitePhone
        //    });
        //}
        /// <summary>
        /// 获取首页数据
        /// </summary>
        /// <param name="openId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        //public JsonResult<Result<dynamic>> GetIndexData(string openId = "", int pageIndex = 10, int pageSize = 1)
        //{
        //    //CheckUserLogin();
        //    MemberInfo member = CurrentUser;
        //    var sitesetting = SiteSettingApplication.SiteSettings;
        //    string homejson = Request.RequestUri.Scheme + "://" + Request.RequestUri.Authority + "/AppletHome/data/default.json";

        //    long vidnumber = sitesetting.XcxHomeVersionCode;
        //    return JsonResult<dynamic>(new
        //    {
        //        HomeTopicPath = homejson,
        //        Vid = vidnumber,
        //        QQMapKey = CommonConst.QQMapKey
        //    });
        //}
        /// <summary>
        /// 检查版本号
        /// </summary>
        /// <param name="context"></param>
        //public JsonResult<Result<int>> GetInitVeCode(string vid)
        //{
        //    if (string.IsNullOrEmpty(vid))
        //    {
        //        return Json(ErrorResult<int>("版本号不允许为空", 100, 100));
        //    }

        //    var sitesetting = SiteSettingApplication.SiteSettings;
        //    long xcxvid = sitesetting.XcxHomeVersionCode;

        //    if (xcxvid > long.Parse(vid))
        //    {
        //        return Json(ErrorResult("版本需要更新", 101, 101));
        //    }
        //    else
        //    {
        //        return JsonResult(100, "版本不需要更新", 100);
        //    }
        //}

        //public JsonResult<Result<List<dynamic>>> GetIndexProductData(string openId = "", int pageIndex = 1, int pageSize = 10)
        //{
        //    var homeProducts = ServiceProvider.Instance<IWXSmallProgramService>.Create.GetWXSmallHomeProducts(pageIndex,pageSize);
        //    decimal discount = 1M;
        //    long SelfShopId = 0;
        //    var CartInfo = new ShoppingCartInfo();
        //    var ids = homeProducts.Models.Select(p => p.Id).ToList();
        //    var productList = new List<dynamic>();
        //    var cartitems = new List<Himall.Entities.ShoppingCartItem>();
        //    long userId = 0;
        //    if (CurrentUser != null)
        //    {
        //        userId = CurrentUser.Id;
        //        discount = CurrentUser.MemberDiscount;
        //        var shopInfo = ShopApplication.GetSelfShop();
        //        SelfShopId = shopInfo.Id;
        //        CartInfo = ServiceProvider.Instance<ICartService>.Create.GetCart(CurrentUser.Id);
        //        cartitems = CartApplication.GetCartQuantityByIds(CurrentUser.Id, ids);
        //    }

        //    foreach (var item in homeProducts.Models)
        //    {
        //        long activeId = 0;
        //        int activetype = 0;
        //        item.ImagePath = HimallIO.GetRomoteProductSizeImage(Core.HimallIO.GetImagePath(item.ImagePath), 1, (int)Himall.CommonModel.ImageSize.Size_350);
        //        if (item.ShopId == SelfShopId)
        //            item.MinSalePrice = item.MinSalePrice * discount;
        //        var limitBuy = ServiceProvider.Instance<ILimitTimeBuyService>.Create.GetLimitTimeMarketItemByProductId(item.Id);
        //        if (limitBuy != null)
        //        {
        //            item.MinSalePrice = limitBuy.MinPrice;
        //            activeId = limitBuy.Id;
        //            activetype = 1;
        //        }
        //        int quantity = 0;
        //        quantity = cartitems.Where(d => d.ProductId == item.Id).Sum(d => d.Quantity);

        //        long stock = 0;

        //        var productInfo = ServiceProvider.Instance<IProductService>.Create.GetProduct(item.Id);
        //        if (productInfo != null)
        //        {
        //            var skus = ProductManagerApplication.GetSKUs(productInfo.Id);
        //            stock = skus.Sum(x => x.Stock);
        //            if (productInfo.MaxBuyCount > 0)
        //            {
        //                stock = productInfo.MaxBuyCount;
        //            }
        //        }
        //        if (productInfo.AuditStatus == ProductInfo.ProductAuditStatus.Audited)
        //        {
        //            var ChoiceProducts = new
        //            {
        //                ProductId = item.Id,
        //                ProductName = item.ProductName,
        //                SalePrice = item.MinSalePrice.ToString("0.##"),
        //                ThumbnailUrl160 = item.ImagePath,
        //                MarketPrice = item.MarketPrice.ToString("0.##"),
        //                CartQuantity = quantity,
        //                HasSKU = item.HasSKU,
        //                SkuId = GetSkuIdByProductId(item.Id),
        //                ActiveId = activeId,
        //                ActiveType = activetype,//获取该商品是否参与活动
        //                Stock = stock
        //            };
        //            productList.Add(ChoiceProducts);
        //        }
        //    }
        //    return JsonResult(productList);
        //}

        private JsonResult <Result <dynamic> > GetMember(Entities.MemberInfo member, string openId)
        {
            var model = MemberApplication.GetUserCenterModel(member.Id, false);
            //获取会员未使用的优惠券数目
            int couponsCount = model.UserCoupon;

            return(JsonResult <dynamic>(new
            {
                couponsCount = couponsCount,
                picture = HimallIO.GetRomoteImagePath(member.Photo),
                points = model.Intergral,
                waitPayCount = model.WaitPayOrders,
                waitSendCount = model.WaitDeliveryOrders,
                waitFinishCount = model.WaitReceivingOrders,
                waitReviewCount = model.WaitEvaluationOrders,
                afterSalesCount = model.RefundCount,
                realName = string.IsNullOrEmpty(member.ShowNick) ? (string.IsNullOrEmpty(member.RealName) ? member.UserName : member.RealName) : member.ShowNick,
                gradeId = model.GradeId,
                gradeName = model.GradeName,
                UserName = member.UserName,
                UserId = member.Id,
                OpenId = openId,
                ServicePhone = SiteSettingApplication.SiteSettings.SitePhone
            }));
        }
Example #2
0
        public ActionResult Home()
        {
            UserCenterHomeModel viewModel = new UserCenterHomeModel();

            viewModel.userCenterModel = MemberApplication.GetUserCenterModel(CurrentUser.Id);
            viewModel.UserName        = CurrentUser.Nick == "" ? CurrentUser.UserName : CurrentUser.Nick;
            viewModel.Logo            = CurrentUser.Photo;
            var items = _iCartService.GetCart(CurrentUser.Id).Items.OrderByDescending(a => a.AddTime).Select(p => p.ProductId).Take(3).ToArray();

            viewModel.ShoppingCartItems = ProductManagerApplication.GetProductByIds(items).ToArray();
            var UnEvaluatProducts = _iCommentService.GetUnEvaluatProducts(CurrentUser.Id).ToArray();

            viewModel.UnEvaluatProductsNum  = UnEvaluatProducts.Count();
            viewModel.Top3UnEvaluatProducts = UnEvaluatProducts.Take(3).ToArray();
            viewModel.Top3RecommendProducts = _iProductService.GetPlatHotSaleProductByNearShop(8, CurrentUser.Id).ToArray();
            viewModel.BrowsingProducts      = BrowseHistrory.GetBrowsingProducts(4, CurrentUser == null ? 0 : CurrentUser.Id);

            var messagePlugins = PluginsManagement.GetPlugins <IMessagePlugin>();
            var data           = messagePlugins.Select(item => new PluginsInfo
            {
                ShortName       = item.Biz.ShortName,
                PluginId        = item.PluginInfo.PluginId,
                Enable          = item.PluginInfo.Enable,
                IsSettingsValid = item.Biz.IsSettingsValid,
                IsBind          = !string.IsNullOrEmpty(_iMessageService.GetDestination(CurrentUser.Id, item.PluginInfo.PluginId, Entities.MemberContactInfo.UserTypes.General))
            });

            viewModel.BindContactInfo = data;

            var statistic = StatisticApplication.GetMemberOrderStatistic(CurrentUser.Id);

            viewModel.OrderCount            = statistic.OrderCount;
            viewModel.OrderWaitReceiving    = statistic.WaitingForRecieve;
            viewModel.OrderWaitPay          = statistic.WaitingForPay;
            viewModel.OrderEvaluationStatus = statistic.WaitingForComments;
            viewModel.Balance = MemberCapitalApplication.GetBalanceByUserId(CurrentUser.Id);
            //TODO:[YZG]增加账户安全等级
            MemberAccountSafety memberAccountSafety = new MemberAccountSafety
            {
                AccountSafetyLevel = 1
            };

            if (CurrentUser.PayPwd != null)
            {
                memberAccountSafety.PayPassword         = true;
                memberAccountSafety.AccountSafetyLevel += 1;
            }
            var ImessageService = _iMessageService;

            foreach (var messagePlugin in data)
            {
                if (messagePlugin.PluginId.IndexOf("SMS") > 0)
                {
                    if (messagePlugin.IsBind)
                    {
                        memberAccountSafety.BindPhone           = true;
                        memberAccountSafety.AccountSafetyLevel += 1;
                    }
                }
                else
                {
                    if (messagePlugin.IsBind)
                    {
                        memberAccountSafety.BindEmail           = true;
                        memberAccountSafety.AccountSafetyLevel += 1;
                    }
                }
            }
            viewModel.memberAccountSafety = memberAccountSafety;
            ViewBag.Keyword  = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords = SiteSettings.HotKeyWords;
            return(View(viewModel));
        }