Exemple #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);
        }
Exemple #2
0
        public ActionResult Ajax_QueryGroupbuying()
        {
            int category  = 0;
            int pageIndex = 0;

            int.TryParse(Request["category"], out category);
            int.TryParse(Request["page"], out pageIndex);

            GroupBuyingQueryInfo queryInfo = new GroupBuyingQueryInfo()
            {
                PageInfo = new Entity.PageInfo()
                {
                    PageIndex = pageIndex,
                    PageSize  = int.Parse(Request["size"])
                },
                SortType             = 0,
                GroupBuyingTypeSysNo = 0
            };

            if (category > 0)
            {
                queryInfo.CategorySysNo = category;
            }
            else
            {
                queryInfo.CategorySysNo = null;
            }

            var data = GroupBuyingFacade.QueryGroupBuyingInfo(queryInfo);

            data.ResultList.ForEach(p =>
            {
                p.DefaultImage = ProductFacade.BuildProductImage(ImageSize.P200, p.DefaultImage);
            });
            var result = new AjaxResult
            {
                Success = true,
                Data    = data
            };


            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        /// <summary>
        /// 团购频道页
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            int pageIndex = 0;

            if (int.TryParse(Request.Params["page"], out pageIndex))
            {
                pageIndex--;
            }
            int category = 0;

            int.TryParse(Request.Params["category"], out category);
            int sort = 0;

            int.TryParse(Request.Params["sort"], out sort);

            GroupBuyingQueryInfo queryInfo = new GroupBuyingQueryInfo()
            {
                PageInfo = new Entity.PageInfo()
                {
                    PageIndex = pageIndex,
                    PageSize  = 10
                },
                SortType = sort
            };

            if (category > 0)
            {
                queryInfo.CategorySysNo = category;
            }
            else
            {
                queryInfo.CategorySysNo = null;
            }

            GroupBuyingQueryResult result = new GroupBuyingQueryResult();

            result.QueryInfo    = queryInfo;
            result.CategoryList = GroupBuyingFacade.GetGroupBuyingCategory();
            result.Result       = GroupBuyingFacade.QueryGroupBuyingInfo(queryInfo);
            result.Result.PageInfo.PageIndex++;
            return(View(result));
        }
Exemple #4
0
 /// <summary>
 /// 查询团购
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public static QueryResult <GroupBuyingInfo> QueryGroupBuyingInfo(GroupBuyingQueryInfo query)
 {
     return(GroupBuyingDA.QueryGroupBuyingInfo(query));
 }
Exemple #5
0
        /// <summary>
        /// 查询团购
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public static QueryResult <GroupBuyingInfo> QueryGroupBuyingInfo(GroupBuyingQueryInfo query)
        {
            QueryResult <GroupBuyingInfo> result = new QueryResult <GroupBuyingInfo>();

            result.PageInfo = query.PageInfo;

            PagingInfoEntity page = new PagingInfoEntity();

            page.MaximumRows   = query.PageInfo.PageSize;
            page.StartRowIndex = query.PageInfo.PageIndex * query.PageInfo.PageSize;

            #region 排序
            string sortColumn = "";
            switch (query.SortType)
            {
            case 10:
                sortColumn = "GroupBuying.CurrentSellCount ASC";
                break;

            case 11:
                sortColumn = "GroupBuying.CurrentSellCount DESC";
                break;

            case 20:
                sortColumn = "Price.CurrentPrice ASC";
                break;

            case 21:
                sortColumn = "Price.CurrentPrice DESC";
                break;

            case 30:
                sortColumn = "ISNULL(ProductReview.ReviewCount, 0) ASC";
                break;

            case 31:
                sortColumn = "ISNULL(ProductReview.ReviewCount, 0) DESC";
                break;

            case 40:
                sortColumn = "ProductStatus.LastOnlineTime ASC";
                break;

            case 41:
                sortColumn = "ProductStatus.LastOnlineTime DESC";
                break;

            case 50:
                sortColumn = "GroupBuying.EndDate ASC";
                break;

            case 51:
                sortColumn = "GroupBuying.EndDate DESC";
                break;

            default:
                sortColumn = "GroupBuying.CurrentSellCount DESC";
                break;
            }
            #endregion

            CustomDataCommand cmd = DataCommandManager.CreateCustomDataCommandFromConfig("GroupBuying_QueryGroupBuyingInfo");
            using (var sqlBuilder = new DynamicQuerySqlBuilder(cmd.CommandText, cmd, page, sortColumn))
            {
                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "GroupBuying.[Status]", DbType.String, "@Status", QueryConditionOperatorType.Equal, "A");
                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "GroupBuying.GroupBuyingCategorySysNo", DbType.Int32, "@GroupBuyingCategorySysNo", QueryConditionOperatorType.Equal, query.CategorySysNo);
                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND,
                                                             "GroupBuying.GroupBuyingTypeSysNo",
                                                             DbType.Int32,
                                                             "@GroupBuyingTypeSysNo",
                                                             QueryConditionOperatorType.Equal,
                                                             query.GroupBuyingTypeSysNo);

                cmd.CommandText   = sqlBuilder.BuildQuerySql();
                result.ResultList = cmd.ExecuteEntityList <GroupBuyingInfo>();

                int totalCount = Convert.ToInt32(cmd.GetParameterValue("@TotalCount"));

                result.PageInfo.TotalCount = totalCount;

                return(result);
            }
        }