示例#1
0
        public void Execute(object eventInfo)
        {
            EventInfo e = (EventInfo)eventInfo;

            //清空过期浏览历史
            BrowseHistories.ClearExpiredBrowseHistory();

            EventLogs.CreateEventLog(e.Key, e.Title, Environment.MachineName, DateTime.Now);
        }
示例#2
0
        /// <summary>
        /// 浏览商品列表
        /// </summary>
        public ActionResult AjaxBrowseProductList()
        {
            int page = WebHelper.GetQueryInt("page");//当前页数

            PageModel pageModel = new PageModel(10, page, BrowseHistories.GetUserBrowseProductCount(WorkContext.Uid));
            AjaxBrowseProductListModel model = new AjaxBrowseProductListModel()
            {
                ProductList = BrowseHistories.GetUserBrowseProductList(pageModel.PageSize, pageModel.PageNumber, WorkContext.Uid),
                PageModel   = pageModel
            };

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        /// <summary>
        /// 浏览商品列表
        /// </summary>
        public ActionResult AjaxBrowseProductList()
        {
            int page = WebHelper.GetQueryInt("page");//当前页数

            PageModel pageModel = new PageModel(10, page, BrowseHistories.GetUserBrowseProductCount(WorkContext.Uid));
            AjaxBrowseProductListModel model = new AjaxBrowseProductListModel()
            {
                ProductList = BrowseHistories.GetUserBrowseProductList(pageModel.PageSize, pageModel.PageNumber, WorkContext.Uid),
                PageModel   = pageModel
            };

            return(Content(JsonConvert.SerializeObject(model)));
        }
示例#4
0
        /// <summary>
        /// 商品
        /// </summary>
        public ActionResult Product()
        {
            //商品id
            int pid = GetRouteInt("pid");

            if (pid == 0)
            {
                pid = WebHelper.GetQueryInt("pid");
            }

            //判断商品是否存在
            ProductInfo productInfo = Products.GetProductById(pid);

            if (productInfo == null)
            {
                return(PromptView("/", "你访问的商品不存在"));
            }

            //店铺信息
            StoreInfo storeInfo = Stores.GetStoreById(productInfo.StoreId);

            if (storeInfo.State != (int)StoreState.Open)
            {
                return(PromptView("/", "你访问的商品不存在"));
            }

            //商品存在时
            ProductModel model = new ProductModel();

            //商品id
            model.Pid = pid;
            //商品信息
            model.ProductInfo = productInfo;
            //商品分类
            model.CategoryInfo = Categories.GetCategoryById(productInfo.CateId);
            //商品品牌
            model.BrandInfo = Brands.GetBrandById(productInfo.BrandId);
            //店铺信息
            model.StoreInfo = storeInfo;
            //店长信息
            model.StoreKeeperInfo = Stores.GetStoreKeeperById(storeInfo.StoreId);
            //店铺区域
            model.StoreRegion = Regions.GetRegionById(storeInfo.RegionId);
            //店铺等级信息
            model.StoreRankInfo = StoreRanks.GetStoreRankById(storeInfo.StoreRid);
            //商品图片列表
            model.ProductImageList = Products.GetProductImageList(pid);
            //扩展商品属性列表
            model.ExtProductAttributeList = Products.GetExtProductAttributeList(pid);
            //商品SKU列表
            model.ProductSKUList = Products.GetProductSKUListBySKUGid(productInfo.SKUGid);
            //商品库存数量
            model.StockNumber = Products.GetProductStockNumberByPid(pid);


            //单品促销
            model.SinglePromotionInfo = Promotions.GetSinglePromotionByPidAndTime(pid, DateTime.Now);
            //买送促销活动列表
            model.BuySendPromotionList = Promotions.GetBuySendPromotionList(productInfo.StoreId, pid, DateTime.Now);
            //赠品促销活动
            model.GiftPromotionInfo = Promotions.GetGiftPromotionByPidAndTime(pid, DateTime.Now);
            //赠品列表
            if (model.GiftPromotionInfo != null)
            {
                model.ExtGiftList = Promotions.GetExtGiftList(model.GiftPromotionInfo.PmId);
            }
            //套装商品列表
            model.SuitProductList = Promotions.GetProductAllSuitPromotion(pid, DateTime.Now);
            //满赠促销活动
            model.FullSendPromotionInfo = Promotions.GetFullSendPromotionByStoreIdAndPidAndTime(productInfo.StoreId, pid, DateTime.Now);
            //满减促销活动
            model.FullCutPromotionInfo = Promotions.GetFullCutPromotionByStoreIdAndPidAndTime(productInfo.StoreId, pid, DateTime.Now);

            //广告语
            model.Slogan = model.SinglePromotionInfo == null ? "" : model.SinglePromotionInfo.Slogan;
            //商品促销信息
            model.PromotionMsg = Promotions.GeneratePromotionMsg(model.SinglePromotionInfo, model.BuySendPromotionList, model.FullSendPromotionInfo, model.FullCutPromotionInfo);
            //商品折扣价格
            model.DiscountPrice = Promotions.ComputeDiscountPrice(model.ProductInfo.ShopPrice, model.SinglePromotionInfo);

            //关联商品列表
            model.RelateProductList = Products.GetRelateProductList(pid);

            //用户浏览历史
            model.UserBrowseHistory = BrowseHistories.GetUserBrowseHistory(WorkContext.Uid, pid);

            //商品咨询类型列表
            model.ProductConsultTypeList = ProductConsults.GetProductConsultTypeList();

            //更新浏览历史
            if (WorkContext.Uid > 0)
            {
                Asyn.UpdateBrowseHistory(WorkContext.Uid, pid);
            }
            //更新商品统计
            Asyn.UpdateProductStat(pid, WorkContext.RegionId);

            return(View(model));
        }
示例#5
0
        /// <summary>
        /// 搜索
        /// </summary>
        public ActionResult Search()
        {
            //搜索词
            string word = WebHelper.GetQueryString("word");
            //分类id
            int cateId = WebHelper.GetQueryInt("cateId");
            //品牌id
            int brandId = WebHelper.GetQueryInt("brandId");
            //筛选价格
            int filterPrice = WebHelper.GetQueryInt("filterPrice");
            //筛选属性
            string filterAttr = WebHelper.GetQueryString("filterAttr");
            //是否只显示有货
            int onlyStock = WebHelper.GetQueryInt("onlyStock");
            //排序列
            int sortColumn = WebHelper.GetQueryInt("sortColumn");
            //排序方向
            int sortDirection = WebHelper.GetQueryInt("sortDirection");
            //当前页数
            int page = WebHelper.GetQueryInt("page");

            //搜索词处理
            WorkContext.SearchWord = word;
            if (word.Length == 0)
            {
                return(PromptView(WorkContext.UrlReferrer, "请输入搜索词"));
            }

            //检查当前页数
            if (page < 1)
            {
                page = 1;
            }

            //筛选属性处理
            List <int> attrValueIdList = new List <int>();

            string[] filterAttrValueIdList = StringHelper.SplitString(filterAttr, "-");
            foreach (string attrValueId in filterAttrValueIdList)
            {
                int temp = TypeHelper.StringToInt(attrValueId);
                if (temp > 0)
                {
                    attrValueIdList.Add(temp);
                }
            }

            //分类信息
            CategoryInfo categoryInfo = null;

            //分类价格范围列表
            string[] catePriceRangeList = null;
            //分类筛选属性及其值列表
            List <KeyValuePair <AttributeInfo, List <AttributeValueInfo> > > cateAAndVList = null;
            //分类列表
            List <CategoryInfo> categoryList = null;
            //品牌信息
            BrandInfo brandInfo = null;
            //品牌列表
            List <BrandInfo> brandList = null;
            //商品总数量
            int totalCount = 0;
            //商品列表
            List <StoreProductInfo> productList = null;

            //搜索
            Searches.SearchMallProducts(20, page, word, cateId, brandId, filterPrice, attrValueIdList, onlyStock, sortColumn, sortDirection, ref categoryInfo, ref catePriceRangeList, ref cateAAndVList, ref categoryList, ref brandInfo, ref brandList, ref totalCount, ref productList);

            if (productList == null)
            {
                return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在"));
            }

            //当筛选属性和分类的筛选属性数目不对应时,重置筛选属性
            if (cateAAndVList == null)
            {
                filterAttr = "0";
            }
            else
            {
                if (filterAttrValueIdList.Length != cateAAndVList.Count)
                {
                    if (cateAAndVList.Count == 0)
                    {
                        filterAttr = "0";
                    }
                    else
                    {
                        int           count = cateAAndVList.Count;
                        StringBuilder sb    = new StringBuilder();
                        for (int i = 0; i < count; i++)
                        {
                            sb.Append("0-");
                        }
                        filterAttr = sb.Remove(sb.Length - 1, 1).ToString();
                    }
                }
            }

            //用户浏览历史
            List <PartProductInfo> userBrowseHistory = BrowseHistories.GetUserBrowseHistory(WorkContext.Uid, 0);

            //分页对象
            PageModel pageModel = new PageModel(20, page, totalCount);
            //视图对象
            MallSearchModel model = new MallSearchModel()
            {
                Word                  = word,
                CateId                = cateId,
                BrandId               = brandId,
                FilterPrice           = filterPrice,
                FilterAttr            = filterAttr,
                OnlyStock             = onlyStock,
                SortColumn            = sortColumn,
                SortDirection         = sortDirection,
                FilterAttrValueIdList = attrValueIdList,
                CategoryInfo          = categoryInfo,
                CatePriceRangeList    = catePriceRangeList,
                AAndVList             = cateAAndVList,
                CategoryList          = categoryList,
                BrandInfo             = brandInfo,
                BrandList             = brandList,
                PageModel             = pageModel,
                ProductList           = productList,
                UserBrowseHistory     = userBrowseHistory
            };

            //异步保存搜索历史
            Asyn.UpdateSearchHistory(WorkContext.Uid, word);

            return(View(model));
        }