Beispiel #1
0
        public JsonResult SearchAutoComplete()
        {
            string keywords = Request.Params["k"];

            return(new JsonResult()
            {
                Data = ProductSearchFacade.GetProductACSearchResultBySolr(keywords)
            });
        }
Beispiel #2
0
 public ActionResult SearchResult()
 {
     ViewBag.IsSearchResultPage = 1;
     if (!string.IsNullOrEmpty(Request.QueryString["enid"]))
     {
         ViewBag.IsSearchResultPage = 0;
         ViewBag.SubCategoryID      = ProductSearchFacade.GetSubCategoryIDbyStrN(Request.QueryString["enid"]).ToString();
     }
     return(View());
 }
Beispiel #3
0
        //
        // GET: /Web/Product/

        /// <summary>
        /// 搜索结果
        /// </summary>
        /// <returns></returns>
        public ActionResult SearchResult()
        {
            //获取Condition
            ProductSearchCondition condition = GetSearchCondition();

            //获取当前页面Querystring
            queryStringCollection = Request.QueryString;

            //获取搜索结果
            ProductSearchResult result = ProductSearchFacade.GetProductSearchResultBySolr(condition, queryStringCollection);

            return(RedirectToAction("SearchResult", "Product"));
        }
Beispiel #4
0
        /// <summary>
        /// 搜索商品
        /// </summary>
        /// <param name="criteria">搜索条件</param>
        /// <returns></returns>
        public SearchResultModel Search(SearchCriteriaModel criteria)
        {
            var searchCondition = MapSearchCondition(criteria);
            var searchResult    = ProductSearchFacade.GetProductSearchResultBySolr(searchCondition);

            SearchResultModel model = new SearchResultModel();

            model.ProductListItems   = TransformResultItemList(searchResult.ProductDataList);
            model.PageInfo           = MapPageInfo(searchResult.ProductDataList);
            model.PageInfo.PageIndex = criteria.PageIndex;
            model.Filters            = MapSearchFilter(searchResult.Navigation);

            return(model);
        }
Beispiel #5
0
        /// <summary>
        /// 查询品牌下商品
        /// </summary>
        /// <param name="queryInfo"></param>
        /// <returns></returns>
        private static ProductSearchResult GetProductSearchResult(BrandZoneQueryVM queryInfo)
        {
            ProductSearchCondition condition = new ProductSearchCondition()
            {
                IsGroupQuery = true,
                KeyWord      = queryInfo.Keyword
            };

            //分页
            if (queryInfo.PageNumber <= 1)
            {
                queryInfo.PageNumber = 1;
            }
            condition.PagingInfo = new Utility.DataAccess.SearchEngine.PagingInfo()
            {
                PageNumber = queryInfo.PageNumber,
                PageSize   = 15
            };
            //排序
            if (queryInfo.SortMode <= 0)
            {
                queryInfo.SortMode = 10;
            }
            SortEntity sortEntity = SortKeyValueMappingConfig.SortItemList.Find(f => f.Key == queryInfo.SortMode);

            if (sortEntity == null)
            {
                sortEntity = SortKeyValueMappingConfig.SortItemList[0];
            }
            condition.SortItems = new List <SortItem>()
            {
                sortEntity.Item
            };

            condition.NValueList = new List <string>();
            condition.Filters    = new List <FilterBase>();
            if (queryInfo.BrandSysNo > 0)
            {
                condition.Filters.Add(new FieldFilter("p_brandid_n", (ConstValue.SINGLE_BRAND_STORE_DMSID_SEED + queryInfo.BrandSysNo).ToString()));
            }
            if (!String.IsNullOrWhiteSpace(queryInfo.SubCategoryEnID))
            {
                condition.NValueList.Add(queryInfo.SubCategoryEnID);
            }

            var result = ProductSearchFacade.GetProductSearchResultBySolr(condition);

            return(result);
        }
Beispiel #6
0
        internal static ProductSearchResultVM Search(SearchCriteriaModel criteria, NameValueCollection pageQueryString)
        {
            var searchCondition = GetSearchCondition(criteria, pageQueryString);
            var searchResult    = ProductSearchFacade.GetProductSearchResultBySolr(searchCondition);

            ProductSearchResultVM resutlVM = new ProductSearchResultVM();

            if (pageQueryString != null)
            {
                resutlVM.SortKey = pageQueryString["sort"];
            }
            if (searchResult != null)
            {
                resutlVM.ProductList = searchResult.ProductDataList;
            }
            return(resutlVM);
        }
Beispiel #7
0
        /// <summary>
        /// 根据类别查询店铺商品
        /// </summary>
        /// <param name="criteria">搜索条件</param>
        /// <returns></returns>
        public SearchResultModel GetVendorProductByCategoryCode(int sellerSysNo, int categoryCode)
        {
            List <FrontProductCategoryInfo> category = ProductFacade.GetFrontProductCategory(sellerSysNo);
            int strCurrentCategorySysNo;

            if (category.Exists(x => x.SysNo == categoryCode))
            {
                strCurrentCategorySysNo = categoryCode;
            }
            else
            {
                var defaultCate = category.First(p => p.IsLeaf == CommonYesOrNo.Yes);
                if (defaultCate != null)
                {
                    strCurrentCategorySysNo = defaultCate.SysNo;
                }
                else
                {
                    strCurrentCategorySysNo = -1;
                }
            }
            ProductSearchCondition condition = new ProductSearchCondition();

            condition.NValueList = new List <string>();
            //前台分类
            condition.NValueList.Add((ConstValue.Product_SINGLE_STORECATE_DMSID_SEED + strCurrentCategorySysNo).ToString());
            condition.Filters = new List <FilterBase>();
            //商家编号
            condition.Filters.Add(new FieldFilter("p_sellersysno", sellerSysNo.ToString()));

            var searchResult = ProductSearchFacade.GetProductSearchResultBySolr(condition);

            SearchResultModel model = new SearchResultModel();

            model.ProductListItems = TransformResultItemList(searchResult.ProductDataList);
            model.PageInfo         = MapPageInfo(searchResult.ProductDataList);
            model.Filters          = MapSearchFilter(searchResult.Navigation);

            return(model);
        }
Beispiel #8
0
        public ActionResult BrandProductSearch(string brandID)
        {
            int    brandSysno;
            string brandName = string.Empty;

            int.TryParse(brandID, out brandSysno);
            var brand = ProductFacade.GetBrandBySysNo(brandSysno);

            if (brand != null)
            {
                brandName = brand.BrandName_Ch;
            }
            ViewBag.BrandID            = brandID;
            ViewBag.BrandName          = brandName;
            ViewBag.PageType           = ((int)ECommerce.Enums.PageType.BrandProductSearch).ToString();
            ViewBag.IsSearchResultPage = 0;
            if (!string.IsNullOrEmpty(Request.QueryString["enid"]))
            {
                ViewBag.SubCategoryID = ProductSearchFacade.GetSubCategoryIDbyStrN(Request.QueryString["enid"]).ToString();
            }
            return(View("SearchResult"));
        }
Beispiel #9
0
        /// <summary>
        /// 店铺列表页面信息
        /// </summary>
        /// <param name="sellerSysNo">商铺编号</param>
        /// <param name="categoryCode">分类系统编号</param>
        /// <param name="sort">价格升序40、价格降序50,销量降序20</param>
        /// <param name="keyword">关键字</param>
        /// <returns></returns>
        public StoreProductListModel SearchVendorProduct(int sellerSysNo)
        {
            #region 旧代码
            //List<FrontProductCategoryInfo> category = ProductFacade.GetFrontProductCategoryByVendorSysNo(sellerSysNo);
            //List<FrontProductCategoryInfo> categoryall = ProductFacade.GetFrontProductCategory(sellerSysNo);
            //List<string> NValues = new List<string>();
            ////前台分类
            //if (category.Exists(x => x.SysNo == categoryCode))
            //{
            //    //p1一级分类
            //    FrontProductCategoryInfo p1 = category.Find(x => x.SysNo == categoryCode);
            //    if (p1.Children.Count > 0)
            //    {
            //        //p2二级分类
            //        foreach (FrontProductCategoryInfo p2 in p1.Children)
            //        {
            //            if (p2.Children.Count > 0)
            //            {
            //                foreach (FrontProductCategoryInfo p3 in p2.Children)
            //                {
            //                    NValues.Add((ConstValue.Product_SINGLE_STORECATE_DMSID_SEED + p3.SysNo).ToString());
            //                }
            //            }
            //            else
            //            {
            //                NValues.Add((ConstValue.Product_SINGLE_STORECATE_DMSID_SEED + p2.SysNo).ToString());
            //            }
            //        }
            //    }
            //    else
            //    {
            //        NValues.Add((ConstValue.Product_SINGLE_STORECATE_DMSID_SEED + p1.SysNo).ToString());
            //    }
            //}
            //else
            //{
            //    List<FrontProductCategoryInfo> p = categoryall.FindAll(c => c.IsLeaf == CommonYesOrNo.Yes);
            //    foreach (FrontProductCategoryInfo item in p)
            //    {
            //        NValues.Add((ConstValue.Product_SINGLE_STORECATE_DMSID_SEED + item.SysNo).ToString());
            //    }
            //}
            //PagedResult<ProductSearchResultItem> ProductSearch = new PagedResult<ProductSearchResultItem>();
            //foreach (var nitem in NValues)
            //{
            //    var filter = new SearchFilter();
            //    filter.SellerSysNo = sellerSysNo;
            //    SolrProductQueryVM vm = new SolrProductQueryVM();
            //    vm.IsSearchResultPage = 1;

            //    var condition = ProductSearchFacade.GetSearchCondition(vm);
            //    condition.NValueList = new List<string>();
            //    condition.NFilter = nitem;
            //    condition.NValueList.Add(nitem);

            //    condition.Filters = new List<FilterBase>();
            //    condition.Filters.Add(new FieldFilter("p_sellersysno", filter.SellerSysNo.ToString()));
            //    var searchresult = ProductSearchFacade.GetProductSearchResultBySolr(condition);
            //    if (searchresult.ProductDataList.Count > 0)
            //    {
            //        foreach (var productitem in searchresult.ProductDataList)
            //        {
            //            ProductSearch.Add(productitem);
            //        }
            //    }
            //}
            //var sfilter = new SearchFilter();
            //sfilter.SellerSysNo = sellerSysNo;
            //SolrProductQueryVM qvm = new SolrProductQueryVM();
            //qvm.IsSearchResultPage = 1;

            //var scondition = ProductSearchFacade.GetSearchCondition(qvm);
            //scondition.NValueList = new List<string>();
            //scondition.NFilter = "0";
            //scondition.NValueList.Add("0");

            //scondition.Filters = new List<FilterBase>();
            //scondition.Filters.Add(new FieldFilter("p_sellersysno", sfilter.SellerSysNo.ToString()));
            //var result = ProductSearchFacade.GetProductSearchResultBySolr(scondition);
            //result.ProductDataList = ProductSearch;
            //result.ProductDataList.PageNumber = 1;
            //result.ProductDataList.PageSize = 24;
            //result.ProductDataList.TotalRecords = ProductSearch.Count;
            //StoreProductListModel model = new StoreProductListModel();
            //model.ProductListItems = TransformResultItemList(result.ProductDataList);
            //model.PageInfo = MapPageInfo(result.ProductDataList);
            //model.Filters = MapSearchFilter(result.Navigation);

            #endregion
            var filter = new SearchFilter();
            filter.SellerSysNo = sellerSysNo;
            SolrProductQueryVM vm = new SolrProductQueryVM();
            vm.IsSearchResultPage = 1;

            var condition = ProductSearchFacade.GetSearchCondition(vm);
            condition.Filters = new List <Nesoft.Utility.DataAccess.SearchEngine.FilterBase>();
            condition.Filters.Add(new FieldFilter("p_sellersysno", filter.SellerSysNo.ToString()));
            var result = ProductSearchFacade.GetProductSearchResultBySolr(condition);
            result.FilterNavigation.NavigationItems.RemoveAll(p => p.ItemType == NavigationItemType.SubCategory || p.ItemType == NavigationItemType.Category);

            StoreProductListModel model = new StoreProductListModel();
            model.ProductListItems = TransformResultItemList(result.ProductDataList);
            model.PageInfo         = MapPageInfo(result.ProductDataList);
            model.Filters          = MapSearchFilter(result.Navigation);
            return(model);
        }
Beispiel #10
0
        //构造搜索引擎相关参数
        private ProductSearchCondition MapSearchCondition(SearchCriteriaModel criteria)
        {
            ProductSearchCondition condition = new ProductSearchCondition();

            condition.Filters = new List <FilterBase>();
            condition.Filters.Add(new FieldFilter("p_productstatus", "1"));
            condition.NValueList = ProductSearchFacade.GetNValueList(criteria.FilterValue);

            //使用关键字搜索
            string keyWord = criteria.Keywords;

            if (string.IsNullOrEmpty(keyWord))
            {
                keyWord = criteria.Barcode;
            }
            if (!string.IsNullOrEmpty(keyWord))
            {
                //解决“- +”号报错的bug
                if (!string.IsNullOrEmpty(keyWord) && keyWord.StartsWith("-"))
                {
                    keyWord = keyWord.Replace("-", "-");
                }
                if (!string.IsNullOrEmpty(keyWord) && keyWord.StartsWith("+"))
                {
                    keyWord = keyWord.Replace("+", "+");
                }
                condition.KeyWord = keyWord.Trim();
            }

            //使用CategoryID搜索
            if (criteria.CategoryID > 0)
            {
                //将商品分类ID转换成NValue格式
                var subCatNValue = ProductSearchFacade.GetSubcategoryDimensionValues(criteria.CategoryID.Value);
                condition.NValueList.Add(subCatNValue.ToString());
                condition.Filters.Add(new FieldFilter("Nvalue", subCatNValue.ToString()));
            }

            //使用品牌ID搜索
            if (criteria.BrandID > 0)
            {
                //将品牌ID转换成NValue格式
                var brandNValue = ProductSearchFacade.GetBrandNValue(criteria.BrandID.Value);
                condition.NValueList.Add(brandNValue.ToString());
                condition.Filters.Add(new FieldFilter("Nvalue", brandNValue.ToString()));
            }

            //分页
            if (criteria.PageIndex <= 0)
            {
                criteria.PageIndex = 1;
            }
            if (criteria.PageSize <= 0)
            {
                criteria.PageSize = 10;
            }
            condition.PagingInfo            = new Nesoft.Utility.DataAccess.SearchEngine.PagingInfo();
            condition.PagingInfo.PageNumber = criteria.PageIndex;
            condition.PagingInfo.PageSize   = criteria.PageSize;

            //排序
            if (criteria.SortValue <= 0)
            {
                criteria.SortValue = 10;
            }
            List <SortItem> sortItems = new List <SortItem>();

            sortItems.Add(SortKeyValueMappingConfig.SortItemList.Find(f => f.Key == criteria.SortValue).Item);
            condition.SortItems = sortItems;

            return(condition);
        }
Beispiel #11
0
        //构造搜索引擎相关参数
        private static ProductSearchCondition GetSearchCondition(SearchCriteriaModel criteria, NameValueCollection pageQueryString)
        {
            ProductSearchCondition condition = new ProductSearchCondition();

            condition.Filters    = new List <FilterBase>();
            condition.NValueList = new List <string>();

            //使用Category3ID搜索
            if (criteria.Category3ID > 0)
            {
                //将商品分类ID转换成NValue格式
                var subCatNValue = ProductSearchFacade.GetSubcategoryDimensionValues(criteria.Category3ID.Value);
                condition.NValueList.Add(subCatNValue.ToString());
            }

            //使用品牌ID搜索
            if (criteria.BrandID > 0)
            {
                //将品牌ID转换成NValue格式
                var brandNValue = ProductSearchFacade.GetBrandNValue(criteria.BrandID.Value);
                condition.NValueList.Add(brandNValue.ToString());
            }

            //使用Category1ID搜索
            if (criteria.Category1ID > 0)
            {
                condition.Filters.Add(new FieldFilter("p_tabstoreids", criteria.Category1ID.ToString()));
            }

            string keyWord   = string.Empty;
            int    sortKey   = 0,
                   pageIndex = criteria.PageIndex.GetValueOrDefault(),
                   pageSize  = criteria.PageSize.GetValueOrDefault();

            if (pageQueryString != null)
            {
                keyWord = pageQueryString["keyword"];
                int.TryParse(pageQueryString["sort"], out sortKey);

                int temp;
                if (int.TryParse(pageQueryString["pageIndex"], out temp))
                {
                    pageIndex = temp;
                }
                if (int.TryParse(pageQueryString["pageSize"], out temp))
                {
                    pageSize = temp;
                }
            }

            //使用关键字搜索
            if (!string.IsNullOrWhiteSpace(keyWord))
            {
                //解决“- +”号报错的bug
                if (!string.IsNullOrEmpty(keyWord) && keyWord.StartsWith("-"))
                {
                    keyWord = keyWord.Replace("-", "-");
                }
                if (!string.IsNullOrEmpty(keyWord) && keyWord.StartsWith("+"))
                {
                    keyWord = keyWord.Replace("+", "+");
                }
                condition.KeyWord = keyWord.Trim();
            }

            //分页
            if (pageIndex <= 0)
            {
                pageIndex = 0;
            }
            if (pageSize <= 0)
            {
                pageSize = 10;
            }
            condition.PagingInfo            = new Nesoft.Utility.DataAccess.SearchEngine.PagingInfo();
            condition.PagingInfo.PageNumber = (++pageIndex);
            condition.PagingInfo.PageSize   = pageSize;

            //排序
            if (sortKey <= 0)
            {
                sortKey = 10;
            }
            List <SortItem> sortItems = new List <SortItem>();

            sortItems.Add(SortKeyValueMappingConfig.SortItemList.Find(f => f.Key == sortKey).Item);
            condition.SortItems = sortItems;

            return(condition);
        }