Esempio n. 1
0
        /// <summary>
        /// 团购查询
        /// </summary>
        /// <param name="criteria">查询条件</param>
        /// <returns></returns>
        public GroupBuyQueryResult GetGroupBuyList(GroupBuyQueryModel criteria)
        {
            GroupBuyingQueryInfo queryInfo = new GroupBuyingQueryInfo()
            {
                PageInfo = new Entity.PageInfo()
                {
                    PageIndex = criteria.PageIndex,
                    PageSize  = criteria.PageSize
                },
                SortType = criteria.SortType
            };

            //仅查询普通团购
            queryInfo.GroupBuyingTypeSysNo = 0;
            if (criteria.CatSysNo > 0)
            {
                queryInfo.CategorySysNo = criteria.CatSysNo;
            }
            else
            {
                queryInfo.CategorySysNo = null;
            }

            GroupBuyQueryResult result = new GroupBuyQueryResult();

            if (criteria.GetFilters)
            {
                var categoryList = GroupBuyingFacade.GetGroupBuyingCategory();

                result.Filters = MapCatList(categoryList);
                if (result.Filters.Count > 0)
                {
                    //增加一个全部选项
                    GroupBuyCatModel allCat = new GroupBuyCatModel();
                    allCat.CateSysNo = 0;
                    allCat.Name      = "全部";
                    result.Filters.Insert(0, allCat);
                }
            }

            var groupBuyResult = GroupBuyingFacade.QueryGroupBuyingInfo(queryInfo);

            result.Result = MapItemList(groupBuyResult);

            return(result);
        }
Esempio n. 2
0
        private List <GroupBuyCatModel> MapCatList(List <GroupBuyingCategoryInfo> categoryList)
        {
            categoryList = categoryList ?? new List <GroupBuyingCategoryInfo>();
            List <GroupBuyCatModel> result = new List <GroupBuyCatModel>();

            foreach (var cat in categoryList)
            {
                GroupBuyCatModel model = new GroupBuyCatModel();
                model.CateSysNo = cat.SysNo;
                model.IsHotKey  = cat.IsHotKey;
                model.Name      = cat.Name;

                result.Add(model);
            }

            return(result);
        }