Example #1
0
        public ActionResult Header()
        {
            List <ProductBrowsedHistoryModel> productBrowsedHistoryModels;
            bool currentUser = base.CurrentUser != null;

            base.ViewBag.isLogin        = (currentUser ? "true" : "false");
            base.ViewBag.MemberIntegral = (currentUser ? ServiceHelper.Create <IMemberIntegralService>().GetMemberIntegral(base.CurrentUser.Id).AvailableIntegrals : 0);
            List <FavoriteInfo> favoriteInfos = (currentUser ? ServiceHelper.Create <IProductService>().GetUserAllConcern(base.CurrentUser.Id) : new List <FavoriteInfo>());

            ViewBag.Concern = favoriteInfos.Take(10).ToList();
            List <UserCouponInfo> userCouponInfos = (currentUser ? ServiceHelper.Create <ICouponService>().GetAllUserCoupon(base.CurrentUser.Id).ToList() : new List <UserCouponInfo>());

            userCouponInfos = (userCouponInfos == null ? new List <UserCouponInfo>() : userCouponInfos);
            ViewBag.Coupons = userCouponInfos;
            List <ShopBonusReceiveInfo> shopBonusReceiveInfos = (currentUser ? ServiceHelper.Create <IShopBonusService>().GetCanUseDetailByUserId(base.CurrentUser.Id) : new List <ShopBonusReceiveInfo>());

            shopBonusReceiveInfos       = (shopBonusReceiveInfos == null ? new List <ShopBonusReceiveInfo>() : shopBonusReceiveInfos);
            ViewBag.ShopBonus           = shopBonusReceiveInfos;
            productBrowsedHistoryModels = (currentUser ? BrowseHistrory.GetBrowsingProducts(10, (base.CurrentUser == null ? 0 : base.CurrentUser.Id)) : new List <ProductBrowsedHistoryModel>());
            ViewBag.BrowsingProducts    = productBrowsedHistoryModels;
            ChemCloud.Service.SiteSettingService a = new ChemCloud.Service.SiteSettingService();
            ViewBag.MaterialsMallURL          = a.GetSiteValue("MaterialMallURL");
            ViewBag.DiscuzURL                 = a.GetSiteValue("BBSURL");
            ViewBag.isShowHaoCai              = a.GetSiteValue("isShowHaoCai");
            ViewBag.isShowHuiYiZhongXin       = a.GetSiteValue("isShowHuiYiZhongXin");
            ViewBag.isShowDaShujuZhongXin     = a.GetSiteValue("isShowDaShujuZhongXin");
            ViewBag.isShowJiShuJiaoYiZhongXin = a.GetSiteValue("isShowJiShuJiaoYiZhongXin");
            ViewBag.isShowRenCaiShiChang      = a.GetSiteValue("isShowRenCaiShiChang");
            ViewBag.isShowLunTan              = a.GetSiteValue("isShowLunTan");
            ViewBag.isShowFaLvFaGui           = a.GetSiteValue("isShowFaLvFaGui");
            InitHeaderData();
            ViewBag.HotKey = base.CurrentSiteSetting.Keyword;
            ViewBag.Keys   = base.CurrentSiteSetting.Hotkeywords.Split(',');
            return(base.PartialView("~/Areas/Web/Views/Shared/Header.cshtml"));
        }
        /// <summary>
        /// 侧边我的资产
        /// </summary>
        /// <returns></returns>
        public ActionResult MyAsset()
        {
            MyAssetViewModel result = new Models.MyAssetViewModel();

            result.MyCouponCount = 0;
            result.isLogin       = CurrentUser != null;
            ViewBag.isLogin      = result.isLogin ? "true" : "false";
            //用户积分
            result.MyMemberIntegral = result.isLogin ? _iMemberIntegralService.GetMemberIntegral(CurrentUser.Id).AvailableIntegrals : 0;
            //关注商品
            var concern = result.isLogin ? _iProductService.GetUserAllConcern(CurrentUser.Id) : new List <FavoriteInfo>();

            result.MyConcernsProducts = concern.Take(10).ToList();
            //优惠卷
            var coupons = result.isLogin ?_iCouponService.GetAllUserCoupon(CurrentUser.Id).ToList() : new List <UserCouponInfo>();

            coupons               = coupons == null ? new List <UserCouponInfo>() : coupons;
            result.MyCoupons      = coupons;
            result.MyCouponCount += result.MyCoupons.Count();

            //红包
            var shopBonus = result.isLogin ? _iShopBonusService.GetCanUseDetailByUserId(CurrentUser.Id) : new List <ShopBonusReceiveInfo>();

            shopBonus             = shopBonus == null ? new List <ShopBonusReceiveInfo>() : shopBonus;
            result.MyShopBonus    = shopBonus;
            result.MyCouponCount += result.MyShopBonus.Count();

            //浏览的商品
            var browsingPro = result.isLogin ? BrowseHistrory.GetBrowsingProducts(10, CurrentUser == null ? 0 : CurrentUser.Id) : new List <ProductBrowsedHistoryModel>();

            result.MyBrowsingProducts = browsingPro;
            return(View(result));
        }
Example #3
0
        /// <summary>
        /// 侧边我的资产
        /// </summary>
        /// <returns></returns>
        public ActionResult MyAsset()
        {
            MyAssetViewModel result = new Models.MyAssetViewModel();

            result.MyCouponCount = 0;
            result.isLogin       = CurrentUser != null;
            ViewBag.isLogin      = result.isLogin ? "true" : "false";
            //用户积分
            result.MyMemberIntegral = result.isLogin ? MemberIntegralApplication.GetAvailableIntegral(CurrentUser.Id) : 0;
            //关注商品
            result.MyConcernsProducts = result.isLogin ? _iProductService.GetUserAllConcern(CurrentUser.Id, 10) : new List <Entities.FavoriteInfo>();
            //优惠卷
            var coupons = result.isLogin ? _iCouponService.GetAllUserCoupon(CurrentUser.Id).ToList() : new List <UserCouponInfo>();

            coupons               = coupons == null ? new List <UserCouponInfo>() : coupons;
            result.MyCoupons      = coupons;
            result.MyCouponCount += result.MyCoupons.Count();

            //红包
            result.MyShopBonus    = ShopBonusApplication.GetShopBounsByUser(CurrentUser.Id);
            result.MyCouponCount += result.MyShopBonus.Count();

            //浏览的商品
            var browsingPro = result.isLogin ? BrowseHistrory.GetBrowsingProducts(10, CurrentUser == null ? 0 : CurrentUser.Id) : new List <ProductBrowsedHistoryModel>();

            result.MyBrowsingProducts = browsingPro;
            ViewBag.Keyword           = SiteSettings.Keyword;
            return(View(result));
        }
Example #4
0
        public ActionResult MyAsset()
        {
            MyAssetViewModel myAssetViewModel = new MyAssetViewModel()
            {
                MyCouponCount = 0,
                isLogin       = base.CurrentUser != null
            };

            base.ViewBag.isLogin = (myAssetViewModel.isLogin ? "true" : "false");
            myAssetViewModel.MyMemberIntegral = (myAssetViewModel.isLogin ? ServiceHelper.Create <IMemberIntegralService>().GetMemberIntegral(base.CurrentUser.Id).AvailableIntegrals : 0);
            List <FavoriteInfo> favoriteInfos = (myAssetViewModel.isLogin ? ServiceHelper.Create <IProductService>().GetUserAllConcern(base.CurrentUser.Id) : new List <FavoriteInfo>());

            myAssetViewModel.MyConcernsProducts = favoriteInfos.Take(10).ToList();
            List <UserCouponInfo> userCouponInfos = (myAssetViewModel.isLogin ? ServiceHelper.Create <ICouponService>().GetAllUserCoupon(base.CurrentUser.Id).ToList() : new List <UserCouponInfo>());

            userCouponInfos            = (userCouponInfos == null ? new List <UserCouponInfo>() : userCouponInfos);
            myAssetViewModel.MyCoupons = userCouponInfos;
            MyAssetViewModel myCouponCount = myAssetViewModel;

            myCouponCount.MyCouponCount = myCouponCount.MyCouponCount + myAssetViewModel.MyCoupons.Count();
            List <ShopBonusReceiveInfo> shopBonusReceiveInfos = (myAssetViewModel.isLogin ? ServiceHelper.Create <IShopBonusService>().GetCanUseDetailByUserId(base.CurrentUser.Id) : new List <ShopBonusReceiveInfo>());

            shopBonusReceiveInfos        = (shopBonusReceiveInfos == null ? new List <ShopBonusReceiveInfo>() : shopBonusReceiveInfos);
            myAssetViewModel.MyShopBonus = shopBonusReceiveInfos;
            MyAssetViewModel myCouponCount1 = myAssetViewModel;

            myCouponCount1.MyCouponCount        = myCouponCount1.MyCouponCount + myAssetViewModel.MyShopBonus.Count();
            myAssetViewModel.MyBrowsingProducts = (myAssetViewModel.isLogin ? BrowseHistrory.GetBrowsingProducts(10, (base.CurrentUser == null ? 0 : base.CurrentUser.Id)) : new List <ProductBrowsedHistoryModel>());
            return(View(myAssetViewModel));
        }
        public object GetHistoryVisite()
        {
            var products = BrowseHistrory.GetBrowsingProducts(10, CurrentUserId);

            foreach (var product in products)
            {
                //product.ImagePath = "http://" + Url.Request.RequestUri.Host + product.ImagePath;
                product.ImagePath = Core.HimallIO.GetRomoteImagePath(product.ImagePath);
            }
            return(Json(new { Success = "true", Product = products }));
        }
Example #6
0
 internal void LogProduct(long pid)
 {
     if (CurrentUser != null)
     {
         BrowseHistrory.AddBrowsingProduct(pid, CurrentUser.Id);
     }
     else
     {
         BrowseHistrory.AddBrowsingProduct(pid);
     }
     //ServiceProvider.Instance<IProductService>.Create.LogProductVisti( pid );
 }
Example #7
0
 public JsonResult LogProduct(long pid)
 {
     if (base.CurrentUser == null)
     {
         BrowseHistrory.AddBrowsingProduct(pid, 0);
     }
     else
     {
         BrowseHistrory.AddBrowsingProduct(pid, base.CurrentUser.Id);
     }
     ServiceHelper.Create <IProductService>().LogProductVisti(pid);
     return(Json(null));
 }
        public ActionResult Header()
        {
            List <ProductBrowsedHistoryModel> productBrowsedHistoryModels;
            bool currentUser = base.CurrentUser != null;

            base.ViewBag.isLogin        = (currentUser ? "true" : "false");
            base.ViewBag.MemberIntegral = (currentUser ? ServiceHelper.Create <IMemberIntegralService>().GetMemberIntegral(base.CurrentUser.Id).AvailableIntegrals : 0);
            List <FavoriteInfo> favoriteInfos = (currentUser ? ServiceHelper.Create <IProductService>().GetUserAllConcern(base.CurrentUser.Id) : new List <FavoriteInfo>());

            ViewBag.Concern = favoriteInfos.Take(10).ToList();
            List <UserCouponInfo> userCouponInfos = (currentUser ? ServiceHelper.Create <ICouponService>().GetAllUserCoupon(base.CurrentUser.Id).ToList() : new List <UserCouponInfo>());

            userCouponInfos = (userCouponInfos == null ? new List <UserCouponInfo>() : userCouponInfos);
            ViewBag.Coupons = userCouponInfos;
            List <ShopBonusReceiveInfo> shopBonusReceiveInfos = (currentUser ? ServiceHelper.Create <IShopBonusService>().GetCanUseDetailByUserId(base.CurrentUser.Id) : new List <ShopBonusReceiveInfo>());

            shopBonusReceiveInfos       = (shopBonusReceiveInfos == null ? new List <ShopBonusReceiveInfo>() : shopBonusReceiveInfos);
            ViewBag.ShopBonus           = shopBonusReceiveInfos;
            productBrowsedHistoryModels = (currentUser ? BrowseHistrory.GetBrowsingProducts(10, (base.CurrentUser == null ? 0 : base.CurrentUser.Id)) : new List <ProductBrowsedHistoryModel>());
            ViewBag.BrowsingProducts    = productBrowsedHistoryModels;
            InitHeaderData();
            return(base.PartialView("~/Areas/Web/Views/Shared/Header.cshtml"));
        }
        // GET: Web/Search/SearchAd
        /// <summary>
        ///  商品搜索页面
        /// </summary>
        /// <param name="keywords">搜索关键字</param>
        /// <param name="cid">分类ID</param>
        /// <param name="b_id">品牌ID</param>
        /// <param name="a_id">属性ID, 表现形式:attrId_attrValueId</param>
        /// <param name="orderKey">序项(1:默认,2:销量,3:价格,4:评论数,5:上架时间)</param>
        /// <param name="orderType">排序方式(1:升序,2:降序)</param>
        /// <param name="pageNo">页码</param>
        /// <param name="pageSize">每页显示数据量</param>
        /// <returns></returns>
        public ActionResult SearchAd(
            string keywords = "", /* 搜索关键字 */
            long cid        = 0,  /* 分类ID */
            long b_id       = 0,  /* 品牌ID */
            string a_id     = "", /* 属性值ID, 表现形式:valueid,valueid */
            int orderKey    = 1,  /* 排序项(1:默认,2:销量,3:价格,4:评论数,5:上架时间) */
            int orderType   = 1,  /* 排序方式(1:升序,2:降序) */
            int pageNo      = 1,  /*页码*/
            int pageSize    = 60  /*每页显示数据量*/
            )
        {
            try
            {
                if (string.IsNullOrEmpty(keywords) && cid <= 0 && b_id <= 0 && a_id == "")
                {
                    keywords = Application.SiteSettingApplication.GetSiteSettings().Keyword;
                }

                #region 初始化查询Model
                SearchProductQuery model = new SearchProductQuery();
                model.ShopId  = 0;
                model.BrandId = b_id;
                if (cid != 0)
                {
                    var catelist = _iCategoryService.GetCategories();
                    var cate     = catelist.FirstOrDefault(r => r.Id == cid);
                    if (cate.Depth == 1)
                    {
                        model.FirstCateId = cid;
                    }
                    else if (cate.Depth == 2)
                    {
                        model.SecondCateId = cid;
                    }
                    else if (cate.Depth == 3)
                    {
                        model.ThirdCateId = cid;
                    }
                }
                model.AttrValIds = a_id.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                model.Keyword    = keywords;
                model.OrderKey   = orderKey;
                model.OrderType  = orderType == 1;
                model.PageNumber = pageNo;
                model.PageSize   = pageSize;
                #endregion
                SearchProductResult result = _iSearchProductService.SearchProduct(model);
                int total = result.Total;

                //当查询的结果少于一页时用like进行补偿
                if (result.Total < pageSize)
                {
                    model.IsLikeSearch = true;
                    SearchProductResult result2 = _iSearchProductService.SearchProduct(model);
                    var idList1 = result.Data.Select(a => a.ProductId).ToList();
                    var nresult = result2.Data.Where(a => !idList1.Contains(a.ProductId)).ToList();
                    if (nresult.Count > 0)
                    {
                        result.Total += nresult.Count;
                        result.Data.AddRange(nresult);
                    }
                }
                if (result.Total == 0)
                {
                    ViewBag.BrowsedHistory = BrowseHistrory.GetBrowsingProducts(13, CurrentUser == null ? 0 : CurrentUser.Id);
                    var    category     = _iCategoryService.GetCategory(model.ThirdCateId);
                    string categoryName = category == null ? string.Empty : category.Name;
                    var    brand        = _iBrandService.GetBrand(b_id) ?? new BrandInfo();
                    string bname        = brand == null ? "" : brand.Name;
                    ViewBag.categoryName = categoryName;
                    ViewBag.bName        = bname;
                }
                total = result.Total;

                if (Core.HimallIO.GetHimallIO().GetType().FullName.Equals("Himall.Strategy.OSS"))
                {
                    ViewBag.IsOss = true;
                }
                else
                {
                    ViewBag.IsOss = false;
                }

                ViewBag.keywords  = model.Keyword;
                ViewBag.cid       = cid;
                ViewBag.b_id      = b_id;
                ViewBag.a_id      = a_id;
                ViewBag.orderKey  = orderKey;
                ViewBag.orderType = orderType;

                #region 分页控制
                PagingInfo info = new PagingInfo
                {
                    CurrentPage  = model.PageNumber,
                    ItemsPerPage = pageSize,
                    TotalItems   = total
                };
                ViewBag.pageInfo = info;
                #endregion


                return(View(result.Data));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #10
0
        // GET: Web/Search/SearchAd
        /// <summary>
        ///  商品搜索页面
        /// </summary>
        /// <param name="keywords">搜索关键字</param>
        /// <param name="cid">分类ID</param>
        /// <param name="b_id">品牌ID</param>
        /// <param name="a_id">属性ID, 表现形式:attrId_attrValueId</param>
        /// <param name="orderKey">序项(1:默认,2:销量,3:价格,4:评论数,5:上架时间)</param>
        /// <param name="orderType">排序方式(1:升序,2:降序)</param>
        /// <param name="pageNo">页码</param>
        /// <param name="pageSize">每页显示数据量</param>
        /// <returns></returns>
        public ActionResult SearchAd(
            string keywords = "", /* 搜索关键字 */
            long cid        = 0,  /* 分类ID */
            long b_id       = 0,  /* 品牌ID */
            string a_id     = "", /* 属性值ID, 表现形式:valueid,valueid */
            int orderKey    = 1,  /* 排序项(1:默认,2:销量,3:价格,4:评论数,5:上架时间) */
            int orderType   = 1,  /* 排序方式(1:升序,2:降序) */
            int pageNo      = 1,  /*页码*/
            int pageSize    = 60  /*每页显示数据量*/
            )
        {
            try
            {
                var  siteSetingInfo = SiteSettingApplication.SiteSettings;
                bool isShow         = siteSetingInfo.ProductSaleCountOnOff == 1;
                if (string.IsNullOrEmpty(keywords) && cid <= 0 && b_id <= 0 && a_id == "")
                {
                    keywords = siteSetingInfo.Keyword;
                }

                #region 初始化查询Model
                SearchProductQuery model = new SearchProductQuery();
                model.ShopId  = 0;
                model.BrandId = b_id;
                if (cid != 0)
                {
                    var catelist = _iCategoryService.GetCategories();
                    var cate     = catelist.FirstOrDefault(r => r.Id == cid);
                    if (cate != null)
                    {
                        if (cate.Depth == 1)
                        {
                            model.FirstCateId = cid;
                        }
                        else if (cate.Depth == 2)
                        {
                            model.SecondCateId = cid;
                        }
                        else if (cate.Depth == 3)
                        {
                            model.ThirdCateId = cid;
                        }
                        ViewBag.pageTitle = cate.Name;
                    }
                }
                model.AttrValIds = a_id.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                model.Keyword    = keywords;
                model.OrderKey   = orderKey;
                model.OrderType  = orderType == 1;
                model.PageNumber = pageNo;
                model.PageSize   = pageSize;
                #endregion
                SearchProductResult result = _iSearchProductService.SearchProduct(model);
                int total = result.Total;

                //当查询的结果少于一页时用like进行补偿
                if (result.Total < pageSize)
                {
                    model.IsLikeSearch = true;
                    SearchProductResult result2 = _iSearchProductService.SearchProduct(model);
                    var idList1 = result.Data.Select(a => a.ProductId).ToList();
                    var nresult = result2.Data.Where(a => !idList1.Contains(a.ProductId)).ToList();
                    if (nresult.Count > 0)
                    {
                        result.Total += nresult.Count;
                        result.Data.AddRange(nresult);
                    }
                    //补充数据后,重新排序
                    Func <IEnumerable <ProductView>, IOrderedEnumerable <ProductView> > orderby     = null;
                    Func <IEnumerable <ProductView>, IOrderedEnumerable <ProductView> > orderByDesc = null;
                    switch (model.OrderKey)
                    {
                    case 2:
                        //order.Append(" ORDER BY SaleCount ");
                        orderby     = e => e.OrderBy(p => p.SaleCount + TypeHelper.ObjectToInt(p.VirtualSaleCounts));
                        orderByDesc = e => e.OrderByDescending(p => p.SaleCount + TypeHelper.ObjectToInt(p.VirtualSaleCounts));
                        break;

                    case 3:
                        //order.Append(" ORDER BY SalePrice ");
                        orderby     = e => e.OrderBy(p => p.SalePrice);
                        orderByDesc = e => e.OrderByDescending(p => p.SalePrice);
                        break;

                    case 4:
                        //order.Append(" ORDER BY Comments ");
                        orderby     = e => e.OrderBy(p => p.Comments);
                        orderByDesc = e => e.OrderByDescending(p => p.Comments);
                        break;

                    default:
                        //order.Append(" ORDER BY Id ");
                        //按最新的排序规则作为默认排序【序号越大,在前台展示的商品越靠前,序号一致时,优先销量排前,销量一致时,优先上架时间排前】
                        //orderby = e => e.OrderBy(p => p.ProductId);
                        if (isShow)
                        {    //底层已经将虚拟销量累加到销量中
                            orderByDesc = e => e.OrderByDescending(p => p.DisplaySequence).ThenByDescending(p => p.SaleCount).ThenByDescending(p => p.ProductId);
                        }
                        else
                        {
                            orderByDesc = e => e.OrderByDescending(p => p.DisplaySequence).ThenByDescending(p => p.ProductId);
                        }
                        break;
                    }
                    if (model.OrderKey > 1)
                    {
                        if (model.OrderType)
                        {
                            result.Data = orderby(result.Data).ToList();
                        }
                        else
                        {
                            result.Data = orderByDesc(result.Data).ToList();
                        }
                    }
                    else
                    {
                        result.Data = orderByDesc(result.Data).ToList();
                    }
                }
                if (result.Total == 0)
                {
                    ViewBag.BrowsedHistory = BrowseHistrory.GetBrowsingProducts(13, CurrentUser == null ? 0 : CurrentUser.Id);
                    var    category     = _iCategoryService.GetCategory(model.ThirdCateId);
                    string categoryName = category == null ? string.Empty : category.Name;
                    var    brand        = _iBrandService.GetBrand(b_id) ?? new Entities.BrandInfo();
                    string bname        = brand == null ? "" : brand.Name;
                    ViewBag.categoryName = categoryName;
                    ViewBag.bName        = bname;
                }
                total = result.Total;

                //补商品状态
                foreach (var item in result.Data)
                {
                    var _pro = _iProductService.GetProduct(item.ProductId);
                    var skus = ProductManagerApplication.GetSKUs(item.ProductId);
                    if (_pro == null || skus == null)
                    {
                        continue;
                    }
                    if (_pro.SaleStatus == Entities.ProductInfo.ProductSaleStatus.OnSale && _pro.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited)
                    {
                        item.ShowStatus = 0;
                        if (skus.Sum(d => d.Stock) < 1)
                        {
                            item.ShowStatus = 2;
                        }
                    }
                    else
                    {
                        if (_pro.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited && _pro.SaleStatus == Entities.ProductInfo.ProductSaleStatus.InStock)
                        {
                            item.ShowStatus = 3;
                        }
                        else
                        {
                            item.ShowStatus = 1;
                        }
                    }
                }

                if (Core.HimallIO.GetHimallIO().GetType().FullName.Equals("Himall.Strategy.OSS"))
                {
                    ViewBag.IsOss = true;
                }
                else
                {
                    ViewBag.IsOss = false;
                }

                ViewBag.keywords  = model.Keyword;
                ViewBag.cid       = cid;
                ViewBag.b_id      = b_id;
                ViewBag.a_id      = a_id;
                ViewBag.orderKey  = orderKey;
                ViewBag.orderType = orderType;

                #region 分页控制
                PagingInfo info = new PagingInfo
                {
                    CurrentPage  = model.PageNumber,
                    ItemsPerPage = pageSize,
                    TotalItems   = total
                };
                ViewBag.pageInfo = info;
                #endregion
                ViewBag.isSaleCountOnOff = isShow;

                return(View(result.Data));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        // GET: Web/UserCenter
        public ActionResult Home()
        {
            UserCenterHomeModel viewModel = new UserCenterHomeModel();
            var model = _iMemberService.GetUserCenterModel(CurrentUser.Id);

            viewModel.userCenterModel = model;
            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 = _iProductService.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, Himall.Model.MemberContactsInfo.UserTypes.General))
            });

            viewModel.BindContactInfo = data;
            var orders = _iOrderService.GetOrders <OrderInfo>(new OrderQuery
            {
                PageNo   = 1,
                PageSize = int.MaxValue,
                UserId   = CurrentUser.Id
            });

            viewModel.OrderCount = orders.Total;
            //交易预约单 待结算
            viewModel.OrderWaitReceiving = orders.Models.Where(c => c.OrderStatus == OrderInfo.OrderOperateStatus.WaitReceiving).Count();
            //交易预约单 待付款
            viewModel.OrderWaitPay = orders.Models.Where(c => c.OrderStatus == OrderInfo.OrderOperateStatus.WaitPay).Count();
            //交易预约单 待评价
            var productEvaluations = _iCommentService.GetProductEvaluation(new CommentQuery
            {
                UserID   = CurrentUser.Id,
                PageSize = int.MaxValue,
                PageNo   = 1,
                Sort     = "PComment"
            });
            var orderEvaluations = productEvaluations.Models.Where(item => item.EvaluationStatus == false).Select(item => item.OrderId).Distinct();

            viewModel.OrderEvaluationStatus = orderEvaluations.Count();
            //TODO:[LLY]增加我的资产
            var capitalInfo = _iMemberCapitalService.GetCapitalInfo(CurrentUser.Id);
            var balance     = 0M;

            if (capitalInfo != null && capitalInfo.Balance.HasValue)
            {
                balance = capitalInfo.Balance.Value;
            }
            viewModel.Balance = balance;
            //TODO:[YZG]增加账户安全等级
            MemberAccountSafety memberAccountSafety = new MemberAccountSafety();

            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;
            return(View(viewModel));
        }
        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));
        }
        public ActionResult GetBrowedProductList()
        {
            var list = BrowseHistrory.GetBrowsingProducts(5, CurrentUser == null ? 0 : CurrentUser.Id);

            return(PartialView("_ProductBrowsedHistory", list));
        }
        public ActionResult Detail(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            string price = "";

            #region 定义Model和变量

            LimitTimeProductDetailModel model = new LimitTimeProductDetailModel
            {
                MainId = long.Parse(id),
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Product      = new Model.ProductInfo(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Color        = new CollectionSKU(),
                Size         = new CollectionSKU(),
                Version      = new CollectionSKU()
            };

            FlashSaleModel market = null;
            ShopInfo       shop   = null;

            long gid = 0, mid = 0;

            #endregion


            #region 诊疗项目Id不合法
            if (long.TryParse(id, out mid))
            {
            }
            if (mid == 0)
            {
                //跳转到出错页面
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            #endregion


            #region 初始化诊疗项目和诊所

            market = _iLimitTimeBuyService.Get(mid);

            switch (market.Status)
            {
            case FlashSaleInfo.FlashSaleStatus.Ended:
                return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));

                break;

            case FlashSaleInfo.FlashSaleStatus.Cancelled:
                return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));

                break;
            }
            if (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                return(RedirectToAction("Home"));
            }
            model.FlashSale = market;
            if (market == null || market.Id == 0 || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                //可能参数是诊疗项目ID
                market = market == null?_iLimitTimeBuyService.GetFlaseSaleByProductId(mid) : market;

                if (market == null)
                {
                    //跳转到404页面
                    return(RedirectToAction("Error404", "Error", new { area = "Mobile" }));
                }
                if (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
                {
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
                }
            }

            model.MaxSaleCount = market.LimitCountOfThePeople;
            model.Title        = market.Title;

            shop            = _iShopService.GetShop(market.ShopId);
            model.Shop.Name = shop.ShopName;
            #endregion

            #region 诊疗项目描述
            var product = _iProductService.GetProduct(market.ProductId);
            gid = market.ProductId;
            //product.MarketPrice = market.MinPrice;
            //product.SaleCounts = market.SaleCount;

            var brandModel = ServiceHelper.Create <IBrandService>().GetBrand(product.BrandId);
            product.BrandName = brandModel == null ? "" : brandModel.Name;

            model.Product            = product;
            model.ProductDescription = product.ProductDescriptionInfo.Description;
            if (product.ProductDescriptionInfo.DescriptionPrefixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(product.ProductDescriptionInfo.DescriptionPrefixId, product.ShopId);
                model.DescriptionPrefix = desc == null ? "" : desc.Content;
            }

            if (product.ProductDescriptionInfo.DescriptiondSuffixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(product.ProductDescriptionInfo.DescriptiondSuffixId, product.ShopId);
                model.DescriptiondSuffix = desc == null ? "" : desc.Content;
            }

            #endregion

            #region 诊所

            var categories = _iShopCategoryService.GetShopCategory(product.ShopId);
            List <ShopCategoryInfo> allcate = categories.ToList();
            foreach (var main in allcate.Where(s => s.ParentCategoryId == 0))
            {
                var topC = new CategoryJsonModel()
                {
                    Name        = main.Name,
                    Id          = main.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                foreach (var secondItem in allcate.Where(s => s.ParentCategoryId == main.Id))
                {
                    var secondC = new SecondLevelCategory()
                    {
                        Name = secondItem.Name,
                        Id   = secondItem.Id.ToString(),
                    };

                    topC.SubCategory.Add(secondC);
                }
                model.ShopCategory.Add(topC);
            }
            model.CashDeposits = _iCashDepositsService.GetCashDepositsObligation(product.Id);

            #endregion

            #region 热门使用

            var sale = _iProductService.GetHotSaleProduct(shop.Id, 5);
            if (sale != null)
            {
                foreach (var item in sale.ToArray())
                {
                    model.HotSaleProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.SaleCounts
                    });
                }
            }

            #endregion

            #region 热门关注

            var hot = _iProductService.GetHotConcernedProduct(shop.Id, 5);
            if (hot != null)
            {
                foreach (var item in hot.ToArray())
                {
                    model.HotAttentionProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.ConcernedCount
                    });
                }
            }
            #endregion

            #region 诊疗项目规格

            ProductTypeInfo typeInfo     = _iTypeService.GetType(product.TypeId);
            string          colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
            string          sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
            string          versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
            model.ColorAlias   = colorAlias;
            model.SizeAlias    = sizeAlias;
            model.VersionAlias = versionAlias;
            if (product.SKUInfo != null && product.SKUInfo.Count() > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                foreach (var sku in product.SKUInfo)
                {
                    var specs = sku.Id.Split('_');
                    if (specs.Count() > 0)
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value.Equals(sku.Color)))
                            {
                                var c = product.SKUInfo.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1)
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = product.SKUInfo.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name         = "选择" + sizeAlias,
                                    EnabledClass = ss != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2)
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = product.SKUInfo.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择版本",
                                    Name         = "选择" + versionAlias,
                                    EnabledClass = v != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
                decimal min = 0, max = 0;
                if (product.SKUInfo.FirstOrDefault(s => s.Stock >= 0) != null)
                {
                    min = product.SKUInfo.Where(s => s.Stock >= 0).Min(s => s.SalePrice);
                }
                if (product.SKUInfo.FirstOrDefault(s => s.Stock >= 0) != null)
                {
                    max = product.SKUInfo.Where(s => s.Stock >= 0).Max(s => s.SalePrice);
                }
                if (min == 0 && max == 0)
                {
                    price = product.MinSalePrice.ToString("f2");
                }
                else if (max > min)
                {
                    price = string.Format("{0}-{1}", min.ToString("f2"), max.ToString("f2"));
                }
                else
                {
                    price = string.Format("{0}", min.ToString("f2"));
                }
            }
            model.Price = string.IsNullOrWhiteSpace(price) ? product.MinSalePrice.ToString("f2") : price;
            #endregion

            #region 诊疗项目属性
            List <TypeAttributesModel> ProductAttrs = new List <TypeAttributesModel>();
            var prodAttrs = _iProductService.GetProductAttribute(product.Id).ToList();
            foreach (var attr in prodAttrs)
            {
                if (!ProductAttrs.Any(p => p.AttrId == attr.AttributeId))
                {
                    TypeAttributesModel attrModel = new TypeAttributesModel()
                    {
                        AttrId     = attr.AttributeId,
                        AttrValues = new List <TypeAttrValue>(),
                        Name       = attr.AttributesInfo.Name
                    };
                    foreach (var attrV in attr.AttributesInfo.AttributeValueInfo)
                    {
                        if (prodAttrs.Any(p => p.ValueId == attrV.Id))
                        {
                            attrModel.AttrValues.Add(new TypeAttrValue
                            {
                                Id   = attrV.Id.ToString(),
                                Name = attrV.Value
                            });
                        }
                    }
                    ProductAttrs.Add(attrModel);
                }
                else
                {
                    var attrTemp = ProductAttrs.FirstOrDefault(p => p.AttrId == attr.AttributeId);

                    if (!attrTemp.AttrValues.Any(p => p.Id == attr.ValueId.ToString()))
                    {
                        attrTemp.AttrValues.Add(new TypeAttrValue
                        {
                            Id   = attr.ValueId.ToString(),
                            Name = attr.AttributesInfo.AttributeValueInfo.FirstOrDefault(a => a.Id == attr.ValueId).Value
                        });
                    }
                }
            }
            model.ProductAttrs = ProductAttrs;
            #endregion

            #region 获取评论、咨询数量
            //var comments = _iCommentService.GetComments( new CommentQuery
            //{
            //    ProductID = product.Id ,
            //    PageNo = 1 ,
            //    PageSize = 10000
            //} );
            //model.CommentCount = comments.Total;

            var com      = product.Himall_ProductComments.Where(item => !item.IsHidden.HasValue || item.IsHidden.Value == false);
            var comCount = com.Count();
            model.CommentCount = comCount;

            var consultations = _iConsultationService.GetConsultations(gid);
            model.Consultations = consultations.Count();

            #endregion

            #region 累加浏览次数、 加入历史记录
            if (CurrentUser != null)
            {
                BrowseHistrory.AddBrowsingProduct(product.Id, CurrentUser.Id);
            }
            else
            {
                BrowseHistrory.AddBrowsingProduct(product.Id);
            }

            //_iProductService.LogProductVisti(gid);
            //统计诊疗项目浏览量、诊所浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);
            #endregion

            #region 红包
            var bonus = ServiceHelper.Create <IShopBonusService>().GetByShopId(product.ShopId);
            if (bonus != null)
            {
                model.GrantPrice = bonus.GrantPrice;
            }
            else
            {
                model.GrantPrice = 0;
            }
            #endregion

            #region 获取诊所的评价统计

            var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(shop.Id);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault();
            var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault();

            var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault();
            var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault();

            var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault();
            var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault();

            decimal defaultValue = 5;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                ViewBag.ProductAndDescription     = productAndDescription.CommentValue;
                ViewBag.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                ViewBag.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                ViewBag.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                ViewBag.ProductAndDescription     = defaultValue;
                ViewBag.ProductAndDescriptionPeer = defaultValue;
                ViewBag.ProductAndDescriptionMin  = defaultValue;
                ViewBag.ProductAndDescriptionMax  = defaultValue;
            }
            //诊所服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                ViewBag.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                ViewBag.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                ViewBag.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                ViewBag.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                ViewBag.SellerServiceAttitude     = defaultValue;
                ViewBag.SellerServiceAttitudePeer = defaultValue;
                ViewBag.SellerServiceAttitudeMax  = defaultValue;
                ViewBag.SellerServiceAttitudeMin  = defaultValue;
            }
            //诊所发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                ViewBag.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                ViewBag.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                ViewBag.SellerDeliverySpeedMax  = sellerDeliverySpeedMax.CommentValue;
                ViewBag.sellerDeliverySpeedMin  = sellerDeliverySpeedMin.CommentValue;
            }
            else
            {
                ViewBag.SellerDeliverySpeed     = defaultValue;
                ViewBag.SellerDeliverySpeedPeer = defaultValue;
                ViewBag.SellerDeliverySpeedMax  = defaultValue;
                ViewBag.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            #region 客服
            model.Service = ServiceHelper.Create <ICustomerService>().GetCustomerService(shop.Id).Where(c => c.Type == CustomerServiceInfo.ServiceType.PreSale && c.TerminalType == CustomerServiceInfo.ServiceTerminalType.PC).OrderBy(m => m.Tool);
            #endregion

            #region 开团提醒场景二维码
            var siteSetting = _iSiteSettingService.GetSiteSettings();
            if (DateTime.Parse(model.FlashSale.BeginDate) > DateTime.Now && WXIsConfig(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret))
            {
                var                     token   = AccessTokenContainer.TryGetToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret);
                SceneHelper             helper  = new SceneHelper();
                Himall.Model.SceneModel scene   = new SceneModel(QR_SCENE_Type.FlashSaleRemind, model.FlashSale.Id);
                int                     sceneId = helper.SetModel(scene);
                var                     ticket  = Senparc.Weixin.MP.AdvancedAPIs.QrCode.QrCodeApi.Create(token, 86400, sceneId).ticket;
                ViewBag.ticket = ticket;
            }
            #endregion

            model.Logined    = (null != CurrentUser) ? 1 : 0;
            model.EnabledBuy = product.AuditStatus == ProductInfo.ProductAuditStatus.Audited && DateTime.Parse(market.BeginDate) <= DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now && product.SaleStatus == ProductInfo.ProductSaleStatus.OnSale;
            if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) < DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.EndDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                model.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
            }
            else if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.BeginDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                model.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
            }

            //补充当前诊所红包功能
            ViewBag.isShopPage     = true;
            ViewBag.CurShopId      = product.ShopId;
            TempData["isShopPage"] = true;
            TempData["CurShopId"]  = product.ShopId;

            return(View(model));
        }
Example #15
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));
        }
 public ActionResult GetBrowedProductList()
 {
     return(PartialView("_ProductBrowsedHistory", BrowseHistrory.GetBrowsingProducts(5, (base.CurrentUser == null ? 0 : base.CurrentUser.Id))));
 }
 public JsonResult GetBrowedProduct()
 {
     return(Json(BrowseHistrory.GetBrowsingProducts(5, (base.CurrentUser == null ? 0 : base.CurrentUser.Id)), JsonRequestBehavior.AllowGet));
 }
Example #18
0
        public ActionResult SearchAd(string sid, long cid = 0, string keywords = "", int pageNo = 1, decimal startPrice = 0, decimal endPrice = decimal.MaxValue)
        {
            int      pageSize = 40;
            long     shopId   = 0;
            ShopInfo shopObj  = null;

            endPrice   = endPrice <= 0 || endPrice < startPrice ? decimal.MaxValue : endPrice;
            startPrice = startPrice < 0 ? 0 : startPrice;

            //shopId 不是数字
            if (!long.TryParse(sid, out shopId))
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
                //404 页面
            }

            //店铺Id不存在
            shopObj = _iShopService.GetShop(shopId);
            if (null == shopObj)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
                //404 页面
            }
            #region 初始化Model

            ShopHomeModel model = new ShopHomeModel
            {
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Floors       = new List <ShopHomeFloor>(),
                Navignations = new List <BannerInfo>(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Slides       = new List <SlideAdInfo>(),
                Logo         = ""
            };

            #endregion

            #region 导航和3个推荐商品

            //导航
            model.Navignations = _iNavigationService.GetSellerNavigations(shopObj.Id).ToList();

            //banner和3个推荐商品
            model.ImageAds = _iSlideAdsService.GetImageAds(shopObj.Id).OrderBy(item => item.Id).ToList();

            model.Slides = _iSlideAdsService.GetSlidAds(shopObj.Id, SlideAdInfo.SlideAdType.ShopHome).ToList();

            #endregion

            #region 店铺分类

            var categories = _iShopCategoryService.GetShopCategory(shopObj.Id).ToArray();
            foreach (var main in categories.Where(s => s.ParentCategoryId == 0))
            {
                var topC = new CategoryJsonModel()
                {
                    Name        = main.Name,
                    Id          = main.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                foreach (var secondItem in categories.Where(s => s.ParentCategoryId == main.Id))
                {
                    var secondC = new SecondLevelCategory()
                    {
                        Name = secondItem.Name,
                        Id   = secondItem.Id.ToString(),
                    };

                    topC.SubCategory.Add(secondC);
                }
                model.ShopCategory.Add(topC);
            }

            #endregion

            #region 店铺信息

            var mark = ShopServiceMark.GetShopComprehensiveMark(shopObj.Id);
            model.Shop.Name              = shopObj.ShopName;
            model.Shop.CompanyName       = shopObj.CompanyName;
            model.Shop.Id                = shopObj.Id;
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            model.Shop.Phone             = shopObj.CompanyPhone;
            model.Shop.Address           = _iRegionService.GetFullName(shopObj.CompanyRegionId);
            model.Logo = shopObj.Logo;
            #endregion

            SearchProductQuery query = new SearchProductQuery()
            {
                ShopId         = long.Parse(sid),
                ShopCategoryId = cid,
                Keyword        = keywords,
                StartPrice     = startPrice,
                EndPrice       = endPrice,
                PageNumber     = pageNo,
                PageSize       = pageSize
            };

            SearchProductResult result = _iSearchProductService.SearchProduct(query);

            model.Products = result.Data;

            //#endregion

            #region 热门销售

            var sale = _iProductService.GetHotSaleProduct(shopObj.Id, 5);
            if (sale != null)
            {
                foreach (var item in sale)
                {
                    model.HotSaleProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.SaleCounts
                    });
                }
            }

            #endregion


            #region 热门关注

            var hot = _iProductService.GetHotConcernedProduct(shopObj.Id, 5).ToList();
            if (hot != null)
            {
                foreach (var item in hot)
                {
                    model.HotAttentionProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.ConcernedCount
                    });
                }
            }
            #endregion

            #region 获取店铺的评价统计
            var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(shopId);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault();
            var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault();

            var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault();
            var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault();

            var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault();
            var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault();

            decimal defaultValue = 5;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                ViewBag.ProductAndDescription     = productAndDescription.CommentValue;
                ViewBag.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                ViewBag.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                ViewBag.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                ViewBag.ProductAndDescription     = defaultValue;
                ViewBag.ProductAndDescriptionPeer = defaultValue;
                ViewBag.ProductAndDescriptionMin  = defaultValue;
                ViewBag.ProductAndDescriptionMax  = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                ViewBag.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                ViewBag.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                ViewBag.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                ViewBag.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                ViewBag.SellerServiceAttitude     = defaultValue;
                ViewBag.SellerServiceAttitudePeer = defaultValue;
                ViewBag.SellerServiceAttitudeMax  = defaultValue;
                ViewBag.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                ViewBag.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                ViewBag.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                ViewBag.SellerDeliverySpeedMax  = sellerDeliverySpeedMax.CommentValue;
                ViewBag.sellerDeliverySpeedMin  = sellerDeliverySpeedMin.CommentValue;
            }
            else
            {
                ViewBag.SellerDeliverySpeed     = defaultValue;
                ViewBag.SellerDeliverySpeedPeer = defaultValue;
                ViewBag.SellerDeliverySpeedMax  = defaultValue;
                ViewBag.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            #region 分页控制
            PagingInfo info = new PagingInfo
            {
                CurrentPage  = pageNo,
                ItemsPerPage = pageSize,
                TotalItems   = result.Total
            };
            ViewBag.pageInfo = info;
            #endregion
            var categoryName = string.Empty;
            if (keywords == string.Empty)
            {
                if (cid != 0)
                {
                    var category = _iShopCategoryService.GetCategory(cid) ?? new ShopCategoryInfo()
                    {
                    };
                    categoryName = category.Name;
                }
            }
            ViewBag.CategoryName   = categoryName;
            ViewBag.Keyword        = keywords;
            ViewBag.cid            = cid;
            ViewBag.BrowsedHistory = BrowseHistrory.GetBrowsingProducts(13, CurrentUser == null ? 0 : CurrentUser.Id);

            //补充当前店铺红包功能
            ViewBag.isShopPage     = true;
            ViewBag.CurShopId      = shopId;
            TempData["isShopPage"] = true;
            TempData["CurShopId"]  = shopId;
            //统计店铺访问人数
            StatisticApplication.StatisticShopVisitUserCount(shopId);
            return(View(model));
        }
Example #19
0
 public ActionResult HistoryVisite(long userId)
 {
     return(View(BrowseHistrory.GetBrowsingProducts(10, userId)));
 }
Example #20
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));
        }
        public ActionResult Detail(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            string price = "";

            #region 定义Model和变量

            LimitTimeProductDetailModel model = new LimitTimeProductDetailModel
            {
                MainId = long.Parse(id),
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Product      = new Entities.ProductInfo(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Color        = new CollectionSKU(),
                Size         = new CollectionSKU(),
                Version      = new CollectionSKU()
            };

            FlashSaleModel    market = null;
            Entities.ShopInfo shop   = null;

            long gid = 0, mid = 0;

            #endregion


            #region 商品Id不合法
            if (long.TryParse(id, out mid))
            {
            }
            if (mid == 0)
            {
                //跳转到出错页面
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            #endregion


            #region 初始化商品和店铺

            market = _iLimitTimeBuyService.Get(mid);

            switch (market.Status)
            {
            case Entities.FlashSaleInfo.FlashSaleStatus.Ended:
                return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));

            case Entities.FlashSaleInfo.FlashSaleStatus.Cancelled:
                return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
            }
            if (market.Status != Entities.FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                return(RedirectToAction("Home"));
            }
            model.FlashSale = market;
            if (market == null || market.Id == 0 || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                //可能参数是商品ID
                market = market == null?_iLimitTimeBuyService.GetFlaseSaleByProductId(mid) : market;

                if (market == null)
                {
                    //跳转到404页面
                    return(RedirectToAction("Error404", "Error", new { area = "Mobile" }));
                }
                if (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
                {
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
                }
            }

            model.MaxSaleCount = market.LimitCountOfThePeople;
            model.Title        = market.Title;

            shop            = _iShopService.GetShop(market.ShopId);
            model.Shop.Name = shop.ShopName;
            #endregion

            #region 商品描述
            var product = _iProductService.GetProduct(market.ProductId);
            gid = market.ProductId;


            var brandModel = ServiceApplication.Create <IBrandService>().GetBrand(product.BrandId);
            product.BrandName = brandModel == null ? "" : brandModel.Name;
            if (CurrentUser != null && CurrentUser.Id > 0)
            {
                product.IsFavorite = ProductManagerApplication.IsFavorite(product.Id, CurrentUser.Id);
            }
            model.Product = product;
            model.Skus    = ProductManagerApplication.GetSKUsByProduct(new List <long> {
                product.Id
            });
            var description = ProductManagerApplication.GetProductDescription(product.Id);
            model.ProductDescription = description.Description;
            if (description.DescriptionPrefixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(description.DescriptionPrefixId, product.ShopId);
                model.DescriptionPrefix = desc == null ? "" : desc.Content;
            }

            if (description.DescriptiondSuffixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(description.DescriptiondSuffixId, product.ShopId);
                model.DescriptiondSuffix = desc == null ? "" : desc.Content;
            }

            #endregion

            #region 店铺

            var categories = _iShopCategoryService.GetShopCategory(product.ShopId);
            List <Entities.ShopCategoryInfo> allcate = categories.ToList();
            foreach (var main in allcate.Where(s => s.ParentCategoryId == 0))
            {
                var topC = new CategoryJsonModel()
                {
                    Name        = main.Name,
                    Id          = main.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                foreach (var secondItem in allcate.Where(s => s.ParentCategoryId == main.Id))
                {
                    var secondC = new SecondLevelCategory()
                    {
                        Name = secondItem.Name,
                        Id   = secondItem.Id.ToString(),
                    };

                    topC.SubCategory.Add(secondC);
                }
                model.ShopCategory.Add(topC);
            }
            model.CashDeposits = _iCashDepositsService.GetCashDepositsObligation(product.Id);

            #endregion

            #region 热门销售

            //会员折扣
            decimal discount   = 1M;
            long    SelfShopId = 0;
            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;
                var shopInfo = ShopApplication.GetSelfShop();
                SelfShopId = shopInfo.Id;
            }
            var sale = _iProductService.GetHotSaleProduct(shop.Id, 5);
            if (sale != null)
            {
                foreach (var item in sale.ToArray())
                {
                    var salePrice = item.MinSalePrice;
                    if (item.ShopId == SelfShopId)
                    {
                        salePrice = item.MinSalePrice * discount;
                    }
                    var limitBuy = LimitTimeApplication.GetLimitTimeMarketItemByProductId(item.Id);
                    if (limitBuy != null)
                    {
                        salePrice = limitBuy.MinPrice;
                    }
                    model.HotSaleProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = Math.Round(salePrice, 2),
                        Id        = item.Id,
                        SaleCount = (int)item.SaleCounts + Mall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts)
                    });
                }
            }

            #endregion

            #region 热门关注

            var hot = _iProductService.GetHotConcernedProduct(shop.Id, 5);
            if (hot != null)
            {
                foreach (var item in hot.ToArray())
                {
                    model.HotAttentionProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.ConcernedCount
                    });
                }
            }
            #endregion

            #region 商品规格

            Entities.TypeInfo typeInfo     = _iTypeService.GetType(product.TypeId);
            string            colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
            string            sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
            string            versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
            if (product != null)
            {
                colorAlias   = !string.IsNullOrWhiteSpace(product.ColorAlias) ? product.ColorAlias : colorAlias;
                sizeAlias    = !string.IsNullOrWhiteSpace(product.SizeAlias) ? product.SizeAlias : sizeAlias;
                versionAlias = !string.IsNullOrWhiteSpace(product.VersionAlias) ? product.VersionAlias : versionAlias;
            }
            model.ColorAlias   = colorAlias;
            model.SizeAlias    = sizeAlias;
            model.VersionAlias = versionAlias;
            var skus = _iProductService.GetSKUs(product.Id);
            if (skus.Count > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                foreach (var sku in skus)
                {
                    var specs = sku.Id.Split('_');
                    if (specs.Count() > 0 && !string.IsNullOrEmpty(sku.Color))
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value.Equals(sku.Color)))
                            {
                                var c = skus.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = Mall.Core.MallIO.GetImagePath(sku.ShowPic)
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1 && !string.IsNullOrEmpty(sku.Size))
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = skus.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name         = "选择" + sizeAlias,
                                    EnabledClass = ss != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2 && !string.IsNullOrEmpty(sku.Version))
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = skus.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择版本",
                                    Name         = "选择" + versionAlias,
                                    EnabledClass = v != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }

                price = ProductWebApplication.GetProductPriceStr(product, skus, discount);//最小价或区间价文本
            }
            model.Price = string.IsNullOrWhiteSpace(price) ? product.MinSalePrice.ToString("f2") : price;
            #endregion

            #region 商品属性
            List <TypeAttributesModel> ProductAttrs = new List <TypeAttributesModel>();
            var prodAttrs = ProductManagerApplication.GetProductAttributes(product.Id);
            foreach (var attr in prodAttrs)
            {
                if (!ProductAttrs.Any(p => p.AttrId == attr.AttributeId))
                {
                    var attribute = _iTypeService.GetAttribute(attr.AttributeId);
                    var values    = _iTypeService.GetAttributeValues(attr.AttributeId);
                    var attrModel = new TypeAttributesModel()
                    {
                        AttrId     = attr.AttributeId,
                        AttrValues = new List <TypeAttrValue>(),
                        Name       = attribute.Name
                    };
                    foreach (var attrV in values)
                    {
                        if (prodAttrs.Any(p => p.ValueId == attrV.Id))
                        {
                            attrModel.AttrValues.Add(new TypeAttrValue
                            {
                                Id   = attrV.Id.ToString(),
                                Name = attrV.Value
                            });
                        }
                    }
                    ProductAttrs.Add(attrModel);
                }
                else
                {
                    var attrTemp = ProductAttrs.FirstOrDefault(p => p.AttrId == attr.AttributeId);
                    var values   = _iTypeService.GetAttributeValues(attr.AttributeId);
                    if (!attrTemp.AttrValues.Any(p => p.Id == attr.ValueId.ToString()))
                    {
                        attrTemp.AttrValues.Add(new TypeAttrValue
                        {
                            Id   = attr.ValueId.ToString(),
                            Name = values.FirstOrDefault(a => a.Id == attr.ValueId).Value
                        });
                    }
                }
            }
            model.ProductAttrs = ProductAttrs;
            #endregion

            #region 获取评论、咨询数量

            model.CommentCount = CommentApplication.GetCommentCountByProduct(product.Id);

            var consultations = _iConsultationService.GetConsultations(gid);
            model.Consultations = consultations.Count();

            #endregion

            #region 累加浏览次数、 加入历史记录
            if (CurrentUser != null)
            {
                BrowseHistrory.AddBrowsingProduct(product.Id, CurrentUser.Id);
            }
            else
            {
                BrowseHistrory.AddBrowsingProduct(product.Id);
            }

            //_iProductService.LogProductVisti(gid);
            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);
            #endregion

            #region 红包
            var bonus = ServiceApplication.Create <IShopBonusService>().GetByShopId(product.ShopId);
            if (bonus != null)
            {
                model.GrantPrice = bonus.GrantPrice;
            }
            else
            {
                model.GrantPrice = 0;
            }
            #endregion

            #region 获取店铺的评价统计

            var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(shop.Id);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault();
            var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault();

            var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault();
            var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault();

            var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault();
            var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault();

            decimal defaultValue = 5;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                ViewBag.ProductAndDescription     = productAndDescription.CommentValue;
                ViewBag.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                ViewBag.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                ViewBag.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                ViewBag.ProductAndDescription     = defaultValue;
                ViewBag.ProductAndDescriptionPeer = defaultValue;
                ViewBag.ProductAndDescriptionMin  = defaultValue;
                ViewBag.ProductAndDescriptionMax  = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                ViewBag.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                ViewBag.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                ViewBag.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                ViewBag.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                ViewBag.SellerServiceAttitude     = defaultValue;
                ViewBag.SellerServiceAttitudePeer = defaultValue;
                ViewBag.SellerServiceAttitudeMax  = defaultValue;
                ViewBag.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                ViewBag.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                ViewBag.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                ViewBag.SellerDeliverySpeedMax  = sellerDeliverySpeedMax.CommentValue;
                ViewBag.sellerDeliverySpeedMin  = sellerDeliverySpeedMin.CommentValue;
            }
            else
            {
                ViewBag.SellerDeliverySpeed     = defaultValue;
                ViewBag.SellerDeliverySpeedPeer = defaultValue;
                ViewBag.SellerDeliverySpeedMax  = defaultValue;
                ViewBag.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            #region 客服
            model.Service = ServiceApplication.Create <ICustomerService>().GetCustomerService(shop.Id).Where(c => c.Type == Entities.CustomerServiceInfo.ServiceType.PreSale && c.TerminalType == Entities.CustomerServiceInfo.ServiceTerminalType.PC).OrderBy(m => m.Tool);
            #endregion

            #region 开团提醒场景二维码
            var siteSetting = SiteSettingApplication.SiteSettings;
            if (DateTime.Parse(model.FlashSale.BeginDate) > DateTime.Now && WXIsConfig(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret))
            {
                try
                {
                    var         token   = AccessTokenContainer.TryGetAccessToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret);
                    SceneHelper helper  = new SceneHelper();
                    SceneModel  scene   = new SceneModel(QR_SCENE_Type.FlashSaleRemind, model.FlashSale.Id);
                    int         sceneId = helper.SetModel(scene);
                    var         ticket  = QrCodeApi.Create(token, 86400, sceneId, Senparc.Weixin.MP.QrCode_ActionName.QR_LIMIT_SCENE, null).ticket;
                    ViewBag.ticket = ticket;
                }
                catch { }
            }
            #endregion

            model.Logined    = (null != CurrentUser) ? 1 : 0;
            model.EnabledBuy = product.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited && DateTime.Parse(market.BeginDate) <= DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now && product.SaleStatus == Entities.ProductInfo.ProductSaleStatus.OnSale;
            if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) < DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.EndDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                model.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
            }
            else if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.BeginDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                model.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
            }

            //补充当前店铺红包功能
            ViewBag.isShopPage     = true;
            ViewBag.CurShopId      = product.ShopId;
            TempData["isShopPage"] = true;
            TempData["CurShopId"]  = product.ShopId;

            ViewBag.Keyword          = SiteSettings.Keyword;
            ViewBag.Quantity         = market.Quantity;//总活动库存
            model.VirtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(product.Id);
            model.FreightTemplate    = FreightTemplateApplication.GetFreightTemplate(product.FreightTemplateId);
            return(View(model));
        }
        public ActionResult Detail(string id)
        {
            long valueId;

            ProductInfo[]            array;
            int                      i;
            double                   num;
            string                   str = "";
            ProductDetailModelForWeb productDetailModelForWeb = new ProductDetailModelForWeb()
            {
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Product      = new ProductInfo(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Color        = new CollectionSKU(),
                Size         = new CollectionSKU(),
                Version      = new CollectionSKU()
            };
            ProductDetailModelForWeb maxSaleCount        = productDetailModelForWeb;
            LimitTimeMarketInfo      limitTimeMarketItem = null;
            ShopInfo shop      = null;
            long     productId = 0;
            long     num1      = 0;

            long.TryParse(id, out num1);
            if (num1 == 0)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            limitTimeMarketItem = ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItem(num1);
            if (limitTimeMarketItem == null || limitTimeMarketItem.AuditStatus != LimitTimeMarketInfo.LimitTimeMarketAuditStatus.Ongoing)
            {
                limitTimeMarketItem = (limitTimeMarketItem == null ? ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItemByProductId(num1) : limitTimeMarketItem);
                if (limitTimeMarketItem == null || limitTimeMarketItem.AuditStatus != LimitTimeMarketInfo.LimitTimeMarketAuditStatus.Ongoing)
                {
                    return(RedirectToAction("Error404", "Error", new { area = "Web" }));
                }
            }
            maxSaleCount.MaxSaleCount = limitTimeMarketItem.MaxSaleCount;
            maxSaleCount.Title        = limitTimeMarketItem.Title;
            shop = ServiceHelper.Create <IShopService>().GetShop(limitTimeMarketItem.ShopId, false);
            if (limitTimeMarketItem == null || limitTimeMarketItem.Id == 0)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            ProductInfo product = ServiceHelper.Create <IProductService>().GetProduct(limitTimeMarketItem.ProductId);

            productId                       = limitTimeMarketItem.ProductId;
            product.MarketPrice             = limitTimeMarketItem.Price;
            product.SaleCounts              = limitTimeMarketItem.SaleCount;
            maxSaleCount.Product            = product;
            maxSaleCount.ProductDescription = product.ProductDescriptionInfo.Description;
            if (product.ProductDescriptionInfo.DescriptionPrefixId != 0)
            {
                ProductDescriptionTemplateInfo template = ServiceHelper.Create <IProductDescriptionTemplateService>().GetTemplate(product.ProductDescriptionInfo.DescriptionPrefixId, product.ShopId);
                maxSaleCount.DescriptionPrefix = (template == null ? "" : template.Content);
            }
            if (product.ProductDescriptionInfo.DescriptiondSuffixId != 0)
            {
                ProductDescriptionTemplateInfo productDescriptionTemplateInfo = ServiceHelper.Create <IProductDescriptionTemplateService>().GetTemplate(product.ProductDescriptionInfo.DescriptiondSuffixId, product.ShopId);
                maxSaleCount.DescriptiondSuffix = (productDescriptionTemplateInfo == null ? "" : productDescriptionTemplateInfo.Content);
            }
            IQueryable <ShopCategoryInfo> shopCategory = ServiceHelper.Create <IShopCategoryService>().GetShopCategory(product.ShopId);
            List <ShopCategoryInfo>       list         = shopCategory.ToList();

            foreach (ShopCategoryInfo shopCategoryInfo in
                     from s in list
                     where s.ParentCategoryId == 0
                     select s)
            {
                CategoryJsonModel categoryJsonModel = new CategoryJsonModel()
                {
                    Name = shopCategoryInfo.Name
                };
                valueId = shopCategoryInfo.Id;
                categoryJsonModel.Id          = valueId.ToString();
                categoryJsonModel.SubCategory = new List <SecondLevelCategory>();
                CategoryJsonModel categoryJsonModel1 = categoryJsonModel;
                foreach (ShopCategoryInfo shopCategoryInfo1 in
                         from s in list
                         where s.ParentCategoryId == shopCategoryInfo.Id
                         select s)
                {
                    SecondLevelCategory secondLevelCategory = new SecondLevelCategory()
                    {
                        Name = shopCategoryInfo1.Name,
                        Id   = shopCategoryInfo1.Id.ToString()
                    };
                    categoryJsonModel1.SubCategory.Add(secondLevelCategory);
                }
                maxSaleCount.ShopCategory.Add(categoryJsonModel1);
            }
            IQueryable <ProductInfo> hotSaleProduct = ServiceHelper.Create <IProductService>().GetHotSaleProduct(shop.Id, 5);

            if (hotSaleProduct != null)
            {
                array = hotSaleProduct.ToArray();
                for (i = 0; i < array.Length; i++)
                {
                    ProductInfo           productInfo     = array[i];
                    List <HotProductInfo> hotSaleProducts = maxSaleCount.HotSaleProducts;
                    HotProductInfo        hotProductInfo  = new HotProductInfo()
                    {
                        ImgPath   = productInfo.ImagePath,
                        Name      = productInfo.ProductName,
                        Price     = productInfo.MinSalePrice,
                        Id        = productInfo.Id,
                        SaleCount = (int)productInfo.SaleCounts
                    };
                    hotSaleProducts.Add(hotProductInfo);
                }
            }
            IQueryable <ProductInfo> hotConcernedProduct = ServiceHelper.Create <IProductService>().GetHotConcernedProduct(shop.Id, 5);

            if (hotConcernedProduct != null)
            {
                array = hotConcernedProduct.ToArray();
                for (i = 0; i < array.Length; i++)
                {
                    ProductInfo           productInfo1         = array[i];
                    List <HotProductInfo> hotAttentionProducts = maxSaleCount.HotAttentionProducts;
                    HotProductInfo        hotProductInfo1      = new HotProductInfo()
                    {
                        ImgPath   = productInfo1.ImagePath,
                        Name      = productInfo1.ProductName,
                        Price     = productInfo1.MinSalePrice,
                        Id        = productInfo1.Id,
                        SaleCount = productInfo1.ConcernedCount
                    };
                    hotAttentionProducts.Add(hotProductInfo1);
                }
            }
            if (product.SKUInfo != null && product.SKUInfo.Count() > 0)
            {
                long num2 = 0;
                long num3 = 0;
                long num4 = 0;
                foreach (SKUInfo sKUInfo in product.SKUInfo)
                {
                    string[] strArrays = sKUInfo.Id.Split(new char[] { '\u005F' });
                    if (strArrays.Count() > 0)
                    {
                        long.TryParse(strArrays[1], out num2);
                        if (num2 != 0)
                        {
                            if (!maxSaleCount.Color.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Color)))
                            {
                                long num5 = (
                                    from s in product.SKUInfo
                                    where s.Color.Equals(sKUInfo.Color)
                                    select s).Sum <SKUInfo>((SKUInfo s) => s.Stock);
                                CollectionSKU color      = maxSaleCount.Color;
                                ProductSKU    productSKU = new ProductSKU()
                                {
                                    Name          = "选择颜色",
                                    EnabledClass  = (num5 != 0 ? "enabled" : "disabled"),
                                    SelectedClass = "",
                                    SKUId         = num2,
                                    Value         = sKUInfo.Color
                                };
                                color.Add(productSKU);
                            }
                        }
                    }
                    if (strArrays.Count() > 1)
                    {
                        long.TryParse(strArrays[2], out num3);
                        if (num3 != 0)
                        {
                            if (!maxSaleCount.Size.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Size)))
                            {
                                long num6 = (
                                    from s in product.SKUInfo
                                    where s.Size.Equals(sKUInfo.Size)
                                    select s).Sum <SKUInfo>((SKUInfo s1) => s1.Stock);
                                CollectionSKU size        = maxSaleCount.Size;
                                ProductSKU    productSKU1 = new ProductSKU()
                                {
                                    Name          = "选择尺码",
                                    EnabledClass  = (num6 != 0 ? "enabled" : "disabled"),
                                    SelectedClass = "",
                                    SKUId         = num3,
                                    Value         = sKUInfo.Size
                                };
                                size.Add(productSKU1);
                            }
                        }
                    }
                    if (strArrays.Count() <= 2)
                    {
                        continue;
                    }
                    long.TryParse(strArrays[3], out num4);
                    if (num4 == 0)
                    {
                        continue;
                    }
                    if (maxSaleCount.Version.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Version)))
                    {
                        continue;
                    }
                    long num7 = (
                        from s in product.SKUInfo
                        where s.Version.Equals(sKUInfo.Version)
                        select s).Sum <SKUInfo>((SKUInfo s) => s.Stock);
                    CollectionSKU version     = maxSaleCount.Version;
                    ProductSKU    productSKU2 = new ProductSKU()
                    {
                        Name          = "选择版本",
                        EnabledClass  = (num7 != 0 ? "enabled" : "disabled"),
                        SelectedClass = "",
                        SKUId         = num4,
                        Value         = sKUInfo.Version
                    };
                    version.Add(productSKU2);
                }
                decimal num8 = new decimal(0);
                decimal num9 = new decimal(0);
                num8 = (
                    from s in product.SKUInfo
                    where s.Stock >= 0
                    select s).Min <SKUInfo>((SKUInfo s) => s.SalePrice);
                num9 = (
                    from s in product.SKUInfo
                    where s.Stock >= 0
                    select s).Max <SKUInfo>((SKUInfo s) => s.SalePrice);
                if (!(num8 == new decimal(0)) || !(num9 == new decimal(0)))
                {
                    str = (num9 <= num8 ? string.Format("{0}", num8.ToString("f2")) : string.Format("{0}-{1}", num8.ToString("f2"), num9.ToString("f2")));
                }
                else
                {
                    str = product.MinSalePrice.ToString("f2");
                }
            }
            base.ViewBag.Price = (string.IsNullOrWhiteSpace(str) ? product.MinSalePrice.ToString("f2") : str);
            List <TypeAttributesModel>  typeAttributesModels  = new List <TypeAttributesModel>();
            List <ProductAttributeInfo> productAttributeInfos = ServiceHelper.Create <IProductService>().GetProductAttribute(product.Id).ToList();

            foreach (ProductAttributeInfo productAttributeInfo in productAttributeInfos)
            {
                if (typeAttributesModels.Any((TypeAttributesModel p) => p.AttrId == productAttributeInfo.AttributeId))
                {
                    TypeAttributesModel typeAttributesModel = typeAttributesModels.FirstOrDefault((TypeAttributesModel p) => p.AttrId == productAttributeInfo.AttributeId);
                    if (typeAttributesModel.AttrValues.Any((TypeAttrValue p) => p.Id == productAttributeInfo.ValueId.ToString()))
                    {
                        continue;
                    }
                    List <TypeAttrValue> attrValues    = typeAttributesModel.AttrValues;
                    TypeAttrValue        typeAttrValue = new TypeAttrValue();
                    valueId            = productAttributeInfo.ValueId;
                    typeAttrValue.Id   = valueId.ToString();
                    typeAttrValue.Name = productAttributeInfo.AttributesInfo.AttributeValueInfo.FirstOrDefault((AttributeValueInfo a) => a.Id == productAttributeInfo.ValueId).Value;
                    attrValues.Add(typeAttrValue);
                }
                else
                {
                    TypeAttributesModel typeAttributesModel1 = new TypeAttributesModel()
                    {
                        AttrId     = productAttributeInfo.AttributeId,
                        AttrValues = new List <TypeAttrValue>(),
                        Name       = productAttributeInfo.AttributesInfo.Name
                    };
                    TypeAttributesModel typeAttributesModel2 = typeAttributesModel1;
                    foreach (AttributeValueInfo attributeValueInfo in productAttributeInfo.AttributesInfo.AttributeValueInfo)
                    {
                        if (!productAttributeInfos.Any((ProductAttributeInfo p) => p.ValueId == attributeValueInfo.Id))
                        {
                            continue;
                        }
                        List <TypeAttrValue> typeAttrValues = typeAttributesModel2.AttrValues;
                        TypeAttrValue        value          = new TypeAttrValue();
                        valueId    = attributeValueInfo.Id;
                        value.Id   = valueId.ToString();
                        value.Name = attributeValueInfo.Value;
                        typeAttrValues.Add(value);
                    }
                    typeAttributesModels.Add(typeAttributesModel2);
                }
            }
            ViewBag.ProductAttrs = typeAttributesModels;
            ICommentService commentService = ServiceHelper.Create <ICommentService>();
            CommentQuery    commentQuery   = new CommentQuery()
            {
                ProductID = product.Id,
                PageNo    = 1,
                PageSize  = 10000
            };
            PageModel <ProductCommentInfo> comments = commentService.GetComments(commentQuery);

            ViewBag.CommentCount = comments.Total;
            IQueryable <ProductConsultationInfo> consultations = ServiceHelper.Create <IConsultationService>().GetConsultations(productId);

            ViewBag.Consultations = consultations.Count();
            if (base.CurrentUser == null)
            {
                BrowseHistrory.AddBrowsingProduct(product.Id, 0);
            }
            else
            {
                BrowseHistrory.AddBrowsingProduct(product.Id, base.CurrentUser.Id);
            }
            ServiceHelper.Create <IProductService>().LogProductVisti(productId);
            base.ViewBag.Logined    = (base.CurrentUser != null ? 1 : 0);
            base.ViewBag.EnabledBuy = (product.AuditStatus != ProductInfo.ProductAuditStatus.Audited || !(limitTimeMarketItem.StartTime <= DateTime.Now) || !(limitTimeMarketItem.EndTime > DateTime.Now) ? false : product.SaleStatus == ProductInfo.ProductSaleStatus.OnSale);
            DateTime endTime  = limitTimeMarketItem.EndTime;
            TimeSpan timeSpan = new TimeSpan(endTime.Ticks);

            endTime = DateTime.Now;
            TimeSpan timeSpan1 = timeSpan.Subtract(new TimeSpan(endTime.Ticks));
            dynamic  viewBag   = base.ViewBag;

            num            = (timeSpan1.TotalSeconds < 0 ? 0 : timeSpan1.TotalSeconds);
            viewBag.Second = num;
            return(View(maxSaleCount));
        }
        public ActionResult Search(string keywords = "", string exp_keywords = "", long cid = 0L, long b_id = 0L, string a_id = "", int orderKey = 1, int orderType = 1, int pageNo = 1, int pageSize = 60)
        {
            int           i;
            long          valueId;
            long          num;
            string        str;
            ProductSearch productSearch = new ProductSearch()
            {
                shopId     = 0,
                BrandId    = b_id,
                CategoryId = cid,
                Ex_Keyword = exp_keywords,
                Keyword    = keywords,
                OrderKey   = orderKey,
                OrderType  = orderType == 1,
                AttrIds    = new List <string>(),
                PageNumber = pageNo,
                PageSize   = pageSize
            };
            ProductSearch productSearch1 = productSearch;
            string        str1           = a_id.Replace("%40", "@");

            char[]   chrArray  = new char[] { '@' };
            string[] strArrays = str1.Split(chrArray);
            for (i = 0; i < strArrays.Length; i++)
            {
                string str2 = strArrays[i];
                if (!string.IsNullOrWhiteSpace(str2))
                {
                    productSearch1.AttrIds.Add(str2);
                }
            }
            IProductService         productService = ServiceHelper.Create <IProductService>();
            PageModel <ProductInfo> pageModel      = productService.SearchProduct(productSearch1);
            int total = pageModel.Total;

            ViewBag.Total = total;
            ProductInfo[] array   = pageModel.Models.ToArray();
            dynamic       viewBag = base.ViewBag;

            num = (base.CurrentUser == null ? 0 : base.CurrentUser.Id);
            viewBag.BrowsedHistory = BrowseHistrory.GetBrowsingProducts(13, num);
            CategoryInfo category = ServiceHelper.Create <ICategoryService>().GetCategory(productSearch1.CategoryId);
            string       str3     = (category == null ? string.Empty : category.Name);
            BrandInfo    brand    = ServiceHelper.Create <IBrandService>().GetBrand(b_id) ?? new BrandInfo();
            string       str4     = (brand == null ? "" : brand.Name);
            string       str5     = (string.IsNullOrEmpty(keywords) ? str3 : keywords);

            base.ViewBag.keywords = (string.IsNullOrEmpty(str5) ? str4 : str5);
            ViewBag.exp_keywords  = exp_keywords;
            if (pageModel.Total == 0)
            {
                return(View());
            }
            var categoryId =
                from prod in array
                orderby prod.CategoryId
                group prod by prod.CategoryId into G
                select new { Key = G.Key, Path = G.FirstOrDefault().CategoryPath };
            List <CategoryJsonModel> categoryJsonModels = new List <CategoryJsonModel>();

            foreach (var variable in categoryId)
            {
                string path      = variable.Path;
                char[] chrArray1 = new char[] { '|' };
                if (path.Split(chrArray1).Length != 2)
                {
                    string path1 = variable.Path;
                    chrArray = new char[] { '|' };
                    if (path1.Split(chrArray).Length != 3)
                    {
                        continue;
                    }
                    string path2 = variable.Path;
                    chrArray = new char[] { '|' };
                    long   num1  = long.Parse(path2.Split(chrArray)[1]);
                    string path3 = variable.Path;
                    chrArray = new char[] { '|' };
                    InitialCategory(categoryJsonModels, num1, long.Parse(path3.Split(chrArray)[2]));
                }
                else
                {
                    string path4 = variable.Path;
                    chrArray = new char[] { '|' };
                    long   num2  = long.Parse(path4.Split(chrArray)[0]);
                    string path5 = variable.Path;
                    chrArray = new char[] { '|' };
                    InitialCategory(categoryJsonModels, num2, long.Parse(path5.Split(chrArray)[1]));
                }
            }
            List <BrandInfo>   brandInfos = new List <BrandInfo>();
            IEnumerable <long> nums       = (
                from a in array
                where a.BrandId != 0
                select a.BrandId).Distinct <long>();
            IQueryable <BrandInfo> brands =
                from a in ServiceHelper.Create <IBrandService>().GetBrands("")
                where nums.Contains(a.Id)
                select a;

            brandInfos = brands.ToList();
            List <TypeAttributesModel> typeAttributesModels = new List <TypeAttributesModel>();
            var collection =
                from p in array
                group p by p.CategoryId into G
                select new { Key = G.Key, Count = G.Count() } into pp
            orderby pp.Count descending
            select pp;
            long   key = collection.ToList()[0].Key;

            array = (
                from p in array
                orderby p.CategoryId.Equals(key) descending
                select p).ToArray();
            if (collection.Count() <= 20)
            {
                IEnumerable <ProductInfo> productInfos =
                    from p in array
                    where p.CategoryId.Equals(key)
                    select p;
                foreach (ProductInfo productInfo in productInfos)
                {
                    if (System.IO.File.Exists(Server.MapPath(productInfo.ImagePath + string.Format("/{0}.png", 1))))
                    {
                        if (!System.IO.File.Exists(Server.MapPath(productInfo.ImagePath + string.Format("/{0}_{1}.png", 1, base.CurrentSiteSetting.CategoryProductPictureSize))))
                        {
                            string str8 = Server.MapPath(productInfo.ImagePath + string.Format("/{0}_{1}.png", 1, base.CurrentSiteSetting.CategoryProductPictureSize));
                            ImageHelper.CreateThumbnail(Server.MapPath(productInfo.ImagePath + string.Format("/{0}.png", 1)), str8, int.Parse(base.CurrentSiteSetting.CategoryProductPictureSize), int.Parse(base.CurrentSiteSetting.CategoryProductPictureSize));
                        }
                    }
                    ProductAttributeInfo[] productAttributeInfoArray  = productService.GetProductAttribute(productInfo.Id).ToArray();
                    ProductAttributeInfo[] productAttributeInfoArray1 = productAttributeInfoArray;
                    for (i = 0; i < productAttributeInfoArray1.Length; i++)
                    {
                        ProductAttributeInfo productAttributeInfo = productAttributeInfoArray1[i];
                        if (typeAttributesModels.Any((TypeAttributesModel p) => p.AttrId == productAttributeInfo.AttributeId))
                        {
                            TypeAttributesModel typeAttributesModel = typeAttributesModels.FirstOrDefault((TypeAttributesModel p) => p.AttrId == productAttributeInfo.AttributeId);
                            if (!typeAttributesModel.AttrValues.Any((TypeAttrValue p) => p.Id == productAttributeInfo.ValueId.ToString()))
                            {
                                if (productAttributeInfo.AttributesInfo.AttributeValueInfo.FirstOrDefault((AttributeValueInfo a) => a.Id == productAttributeInfo.ValueId) != null)
                                {
                                    List <TypeAttrValue> attrValues    = typeAttributesModel.AttrValues;
                                    TypeAttrValue        typeAttrValue = new TypeAttrValue();
                                    valueId            = productAttributeInfo.ValueId;
                                    typeAttrValue.Id   = valueId.ToString();
                                    typeAttrValue.Name = productAttributeInfo.AttributesInfo.AttributeValueInfo.FirstOrDefault((AttributeValueInfo a) => a.Id == productAttributeInfo.ValueId).Value;
                                    attrValues.Add(typeAttrValue);
                                }
                            }
                        }
                        else
                        {
                            TypeAttributesModel typeAttributesModel1 = new TypeAttributesModel()
                            {
                                AttrId     = productAttributeInfo.AttributeId,
                                AttrValues = new List <TypeAttrValue>(),
                                Name       = productAttributeInfo.AttributesInfo.Name
                            };
                            TypeAttributesModel typeAttributesModel2 = typeAttributesModel1;
                            foreach (AttributeValueInfo attributeValueInfo in productAttributeInfo.AttributesInfo.AttributeValueInfo)
                            {
                                if (!((IEnumerable <ProductAttributeInfo>)productAttributeInfoArray).Any((ProductAttributeInfo p) => p.ValueId == attributeValueInfo.Id))
                                {
                                    continue;
                                }
                                List <TypeAttrValue> typeAttrValues = typeAttributesModel2.AttrValues;
                                TypeAttrValue        value          = new TypeAttrValue();
                                valueId    = attributeValueInfo.Id;
                                value.Id   = valueId.ToString();
                                value.Name = attributeValueInfo.Value;
                                typeAttrValues.Add(value);
                            }
                            typeAttributesModels.Add(typeAttributesModel2);
                        }
                    }
                }
            }
            Dictionary <string, string> strs = new Dictionary <string, string>();

            foreach (string attrId in productSearch1.AttrIds)
            {
                long num3 = 0;
                chrArray = new char[] { '\u005F' };
                long.TryParse(attrId.Split(chrArray)[0], out num3);
                long num4 = 0;
                chrArray = new char[] { '\u005F' };
                long.TryParse(attrId.Split(chrArray)[1], out num4);
                AttributeInfo      attributeInfo       = ServiceHelper.Create <IProductService>().GetAttributeInfo(num3);
                AttributeValueInfo attributeValueInfo1 = attributeInfo.AttributeValueInfo.FirstOrDefault((AttributeValueInfo v) => v.Id == num4);
                string             str6 = string.Concat(attributeInfo.Name, ':', attributeValueInfo1.Value);
                string             str7 = "";
                foreach (string attrId1 in productSearch1.AttrIds)
                {
                    if (attrId1.Equals(attrId))
                    {
                        if (productSearch1.AttrIds.Count() != 1)
                        {
                            continue;
                        }
                        str7 = attrId1;
                    }
                    else
                    {
                        str7 = string.Concat(str7, attrId1, '@');
                    }
                }
                chrArray = new char[] { '@' };
                strs.Add(str6, str7.TrimEnd(chrArray));
            }
            ViewBag.Attrs     = typeAttributesModels;
            ViewBag.Brands    = brandInfos;
            ViewBag.Category  = categoryJsonModels;
            ViewBag.cid       = cid;
            ViewBag.b_id      = b_id;
            ViewBag.a_id      = a_id;
            ViewBag.orderKey  = orderKey;
            ViewBag.orderType = orderType;
            dynamic obj = base.ViewBag;

            str                  = (b_id == 0 ? "" : brandInfos.FirstOrDefault((BrandInfo b) => b.Id.Equals(b_id)).Name);
            obj.BrandName        = str;
            ViewBag.AttrDic      = strs;
            base.ViewBag.Logined = (base.CurrentUser != null ? 1 : 0);
            switch (orderKey)
            {
            case 2:
            {
                ProductInfo[] productInfoArray = array;
                for (i = 0; i < productInfoArray.Length; i++)
                {
                    ProductInfo      productInfo1     = productInfoArray[i];
                    ProductVistiInfo productVistiInfo = productInfo1.Himall_ProductVistis.FirstOrDefault();
                    productInfo1.OrderCounts = (productVistiInfo == null || !productVistiInfo.OrderCounts.HasValue ? 0 : productVistiInfo.OrderCounts.Value);
                }
                array = (
                    from p in array
                    orderby p.OrderCounts descending
                    select p).ToArray();
                break;
            }

            case 3:
            {
                if (orderType != 2)
                {
                    array = (
                        from p in array
                        orderby p.MinSalePrice
                        select p).ToArray();
                    break;
                }
                else
                {
                    array = (
                        from p in array
                        orderby p.MinSalePrice descending
                        select p).ToArray();
                    break;
                }
            }

            case 4:
            {
                array = (
                    from p in array
                    orderby p.ProductConsultationInfo.Count() descending
                    select p).ToArray();
                break;
            }

            case 5:
            {
                array = (
                    from p in array
                    orderby p.AddedDate descending
                    select p).ToArray();
                break;
            }
            }
            PagingInfo pagingInfo = new PagingInfo()
            {
                CurrentPage  = productSearch1.PageNumber,
                ItemsPerPage = pageSize,
                TotalItems   = total
            };

            ViewBag.pageInfo = pagingInfo;
            CategoryInfo categoryInfo = ServiceHelper.Create <ICategoryService>().GetCategory(cid);

            if (categoryInfo != null && categoryInfo.Depth == 3)
            {
                array = (
                    from p in array
                    where p.CategoryId == cid
                    select p).ToArray();
            }
            return(View(array ?? new ProductInfo[0]));
        }
Example #24
0
        public ActionResult Search(string sid, long cid = 0L, string keywords = "", int pageNo = 1, [DecimalConstant(0, 0, 0, 0, 0)] decimal startPrice = default(decimal), decimal endPrice = 0)
        {
            long     num;
            int      num1 = 40;
            long     num2 = 0;
            ShopInfo shop = null;

            endPrice   = (endPrice <= new decimal(0) || endPrice < startPrice ? new decimal(-1, -1, -1, false, 0) : endPrice);
            startPrice = (startPrice < new decimal(0) ? new decimal(0) : startPrice);
            if (!long.TryParse(sid, out num2))
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            shop = ServiceHelper.Create <IShopService>().GetShop(num2, false);
            if (shop == null)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            ShopHomeModel shopHomeModel = new ShopHomeModel()
            {
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Floors       = new List <ShopHomeFloor>(),
                Navignations = new List <BannerInfo>(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Slides       = new List <SlideAdInfo>(),
                Logo         = ""
            };
            ShopHomeModel list = shopHomeModel;

            list.Navignations = ServiceHelper.Create <INavigationService>().GetSellerNavigations(shop.Id, PlatformType.PC).ToList();
            list.ImageAds     = (
                from item in ServiceHelper.Create <ISlideAdsService>().GetImageAds(shop.Id)
                orderby item.Id
                select item).ToList();
            list.Slides = ServiceHelper.Create <ISlideAdsService>().GetSlidAds(shop.Id, SlideAdInfo.SlideAdType.ShopHome).ToList();
            ShopCategoryInfo[] array = ServiceHelper.Create <IShopCategoryService>().GetShopCategory(shop.Id).ToArray();
            foreach (ShopCategoryInfo shopCategoryInfo in
                     from s in array
                     where s.ParentCategoryId == 0
                     select s)
            {
                CategoryJsonModel categoryJsonModel = new CategoryJsonModel()
                {
                    Name        = shopCategoryInfo.Name,
                    Id          = shopCategoryInfo.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                CategoryJsonModel categoryJsonModel1 = categoryJsonModel;
                foreach (ShopCategoryInfo shopCategoryInfo1 in
                         from s in array
                         where s.ParentCategoryId == shopCategoryInfo.Id
                         select s)
                {
                    SecondLevelCategory secondLevelCategory = new SecondLevelCategory()
                    {
                        Name = shopCategoryInfo1.Name,
                        Id   = shopCategoryInfo1.Id.ToString()
                    };
                    categoryJsonModel1.SubCategory.Add(secondLevelCategory);
                }
                list.ShopCategory.Add(categoryJsonModel1);
            }
            ShopServiceMarkModel shopComprehensiveMark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);

            list.Shop.Name              = shop.ShopName;
            list.Shop.CompanyName       = shop.CompanyName;
            list.Shop.Id                = shop.Id;
            list.Shop.PackMark          = shopComprehensiveMark.PackMark;
            list.Shop.ServiceMark       = shopComprehensiveMark.ServiceMark;
            list.Shop.ComprehensiveMark = shopComprehensiveMark.ComprehensiveMark;
            list.Shop.Phone             = shop.CompanyPhone;
            list.Shop.Address           = ServiceHelper.Create <IRegionService>().GetRegionFullName(shop.CompanyRegionId, " ");
            list.Logo = shop.Logo;
            ProductSearch productSearch = new ProductSearch()
            {
                startPrice     = startPrice,
                EndPrice       = endPrice,
                shopId         = num2,
                BrandId        = 0,
                ShopCategoryId = new long?(cid),
                Ex_Keyword     = "",
                Keyword        = keywords,
                OrderKey       = 0,
                OrderType      = true,
                AttrIds        = new List <string>(),
                PageSize       = num1,
                PageNumber     = pageNo
            };
            PageModel <ProductInfo> pageModel = ServiceHelper.Create <IProductService>().SearchProduct(productSearch);
            int total = pageModel.Total;

            ProductInfo[] productInfoArray  = pageModel.Models.ToArray();
            ProductInfo[] productInfoArray1 = productInfoArray;
            for (int i = 0; i < productInfoArray1.Length; i++)
            {
                ProductInfo saleCounts = productInfoArray1[i];
                saleCounts.SaleCounts = ServiceHelper.Create <IProductService>().GetProductVistInfo(saleCounts.Id, null).SaleCounts;
            }
            list.Products = ((IEnumerable <ProductInfo>)(productInfoArray ?? new ProductInfo[0])).ToList();
            IQueryable <ProductInfo> hotSaleProduct = ServiceHelper.Create <IProductService>().GetHotSaleProduct(shop.Id, 5);

            if (hotSaleProduct != null)
            {
                foreach (ProductInfo productInfo in hotSaleProduct)
                {
                    List <HotProductInfo> hotSaleProducts = list.HotSaleProducts;
                    HotProductInfo        hotProductInfo  = new HotProductInfo()
                    {
                        ImgPath   = productInfo.ImagePath,
                        Name      = productInfo.ProductName,
                        Price     = productInfo.MinSalePrice,
                        Id        = productInfo.Id,
                        SaleCount = (int)productInfo.SaleCounts
                    };
                    hotSaleProducts.Add(hotProductInfo);
                }
            }
            List <ProductInfo> productInfos = ServiceHelper.Create <IProductService>().GetHotConcernedProduct(shop.Id, 5).ToList();

            if (productInfos != null)
            {
                foreach (ProductInfo productInfo1 in productInfos)
                {
                    List <HotProductInfo> hotAttentionProducts = list.HotAttentionProducts;
                    HotProductInfo        hotProductInfo1      = new HotProductInfo()
                    {
                        ImgPath   = productInfo1.ImagePath,
                        Name      = productInfo1.ProductName,
                        Price     = productInfo1.MinSalePrice,
                        Id        = productInfo1.Id,
                        SaleCount = productInfo1.ConcernedCount
                    };
                    hotAttentionProducts.Add(hotProductInfo1);
                }
            }
            IQueryable <StatisticOrderCommentsInfo> shopStatisticOrderComments = ServiceHelper.Create <IShopService>().GetShopStatisticOrderComments(num2);
            StatisticOrderCommentsInfo statisticOrderCommentsInfo = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 1
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo1 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 9
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo2 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 5
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo3 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 2
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo4 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 10
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo5 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 6
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo6 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 3
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo7 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 4
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo8 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 11
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo9 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 12
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo10 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 7
                select c).FirstOrDefault();
            StatisticOrderCommentsInfo statisticOrderCommentsInfo11 = (
                from c in shopStatisticOrderComments
                where (int)c.CommentKey == 8
                select c).FirstOrDefault();
            int num3 = 5;

            if (statisticOrderCommentsInfo == null || statisticOrderCommentsInfo3 == null)
            {
                ViewBag.ProductAndDescription     = num3;
                ViewBag.ProductAndDescriptionPeer = num3;
                ViewBag.ProductAndDescriptionMin  = num3;
                ViewBag.ProductAndDescriptionMax  = num3;
            }
            else
            {
                ViewBag.ProductAndDescription     = statisticOrderCommentsInfo.CommentValue;
                ViewBag.ProductAndDescriptionPeer = statisticOrderCommentsInfo3.CommentValue;
                ViewBag.ProductAndDescriptionMin  = statisticOrderCommentsInfo7.CommentValue;
                ViewBag.ProductAndDescriptionMax  = statisticOrderCommentsInfo6.CommentValue;
            }
            if (statisticOrderCommentsInfo1 == null || statisticOrderCommentsInfo4 == null)
            {
                ViewBag.SellerServiceAttitude     = num3;
                ViewBag.SellerServiceAttitudePeer = num3;
                ViewBag.SellerServiceAttitudeMax  = num3;
                ViewBag.SellerServiceAttitudeMin  = num3;
            }
            else
            {
                ViewBag.SellerServiceAttitude     = statisticOrderCommentsInfo1.CommentValue;
                ViewBag.SellerServiceAttitudePeer = statisticOrderCommentsInfo4.CommentValue;
                ViewBag.SellerServiceAttitudeMax  = statisticOrderCommentsInfo8.CommentValue;
                ViewBag.SellerServiceAttitudeMin  = statisticOrderCommentsInfo9.CommentValue;
            }
            if (statisticOrderCommentsInfo5 == null || statisticOrderCommentsInfo2 == null)
            {
                ViewBag.SellerDeliverySpeed     = num3;
                ViewBag.SellerDeliverySpeedPeer = num3;
                ViewBag.SellerDeliverySpeedMax  = num3;
                ViewBag.sellerDeliverySpeedMin  = num3;
            }
            else
            {
                ViewBag.SellerDeliverySpeed     = statisticOrderCommentsInfo2.CommentValue;
                ViewBag.SellerDeliverySpeedPeer = statisticOrderCommentsInfo5.CommentValue;
                ViewBag.SellerDeliverySpeedMax  = statisticOrderCommentsInfo10.CommentValue;
                ViewBag.sellerDeliverySpeedMin  = statisticOrderCommentsInfo11.CommentValue;
            }
            PagingInfo pagingInfo = new PagingInfo()
            {
                CurrentPage  = pageNo,
                ItemsPerPage = num1,
                TotalItems   = total
            };

            ViewBag.pageInfo = pagingInfo;
            string empty = string.Empty;

            if (keywords == string.Empty && cid != 0)
            {
                empty = (ServiceHelper.Create <IShopCategoryService>().GetCategory(cid) ?? new ShopCategoryInfo()).Name;
            }
            ViewBag.CategoryName = empty;
            ViewBag.Keyword      = keywords;
            ViewBag.cid          = cid;
            dynamic viewBag = base.ViewBag;

            num = (base.CurrentUser == null ? 0 : base.CurrentUser.Id);
            viewBag.BrowsedHistory = BrowseHistrory.GetBrowsingProducts(13, num);
            return(View(list));
        }
        public JsonResult GetBrowedProduct()
        {
            var p = BrowseHistrory.GetBrowsingProducts(5, CurrentUser == null ? 0 : CurrentUser.Id);

            return(Json(p, JsonRequestBehavior.AllowGet));
        }
Example #26
0
        public JsonResult GetBrowedProduct()
        {
            var p = BrowseHistrory.GetBrowsingProducts(5, CurrentUser == null ? 0 : CurrentUser.Id);

            return(Json(p));
        }