public JsonResult GetProductList(string skey, int rows, int page, string categoryPatha, string categoryPathb, string categoryPathc, long categoryId = 0) { //查询条件 ProductBrokerageQuery query = new ProductBrokerageQuery(); query.skey = skey; query.PageSize = rows; query.PageNo = page; query.ProductBrokerageState = ProductBrokerageInfo.ProductBrokerageStatus.Normal; query.ShopId = curshopid; if (categoryId != 0) { query.CategoryId = categoryId; } query.CategoryPathA = categoryPatha; query.CategoryPathB = categoryPathb; query.CategoryPathC = categoryPathc; ObsoletePageModel <ProductBrokerageInfo> datasql = _iDistributionService.GetDistributionProducts(query); List <DistributionProductListModel> datalist = new List <DistributionProductListModel>(); if (datasql.Models != null) { datalist = datasql.Models.Select(d => new DistributionProductListModel { BrokerageId = d.Id, ProductId = d.ProductId, ProductName = d.Product.ProductName, //Image = d.Product.GetImage(ProductInfo.ImageSize.Size_50), CategoryId = d.Product.CategoryId, CategoryName = d.CategoryName, DistributorRate = d.rate, ProductBrokerageState = d.Status, ProductSaleState = d.Product.SaleStatus, SellPrice = d.Product.MinSalePrice, ShowProductBrokerageState = d.Status.ToDescription(), ShowProductSaleState = d.Product.ShowProductState }).ToList(); } var result = new { rows = datalist, total = datasql.Total }; return(Json(result)); }
public JsonResult ProductLists(long?categoryId, string brandName, string productCode, int?auditStatus, string ids, int page, int rows, string keyWords, string shopName, int?saleStatus) { ProductBrokerageQuery query = new ProductBrokerageQuery() { CategoryId = categoryId, PageNo = page, PageSize = rows, skey = keyWords, ProductIds = ids, ProductBrokerageState = ProductBrokerageInfo.ProductBrokerageStatus.Normal, OnlyShowNormal = true }; Himall.Model.ObsoletePageModel <Himall.Model.ProductBrokerageInfo> datasql = _iDistributionService.GetDistributionProducts(query); IEnumerable <ProductModel> products = datasql.Models.ToArray().Select(item => new ProductModel() { name = item.Product.ProductName, brandName = item.Product.BrandName, categoryName = item.Product.CategoryNames, id = item.Product.Id, imgUrl = item.Product.GetImage(ImageSize.Size_50), price = item.Product.MinSalePrice, state = item.Product.ShowProductState, auditStatus = (int)item.Product.AuditStatus, url = "", auditReason = item.Product.ProductDescriptionInfo != null ? item.Product.ProductDescriptionInfo.AuditReason : "", shopName = "", saleStatus = (int)item.Product.SaleStatus, productCode = item.Product.ProductCode }); DataGridModel <ProductModel> dataGrid = new DataGridModel <ProductModel>() { rows = products, total = datasql.Total }; return(Json(dataGrid)); }
public JsonResult ProductList(string skey, int page, long categoryId = 0, long shopId = 0, int sort = 0) { //查询条件 ProductBrokerageQuery query = new ProductBrokerageQuery(); query.skey = skey; query.PageSize = 5; query.PageNo = page; query.ProductBrokerageState = ProductBrokerageInfo.ProductBrokerageStatus.Normal; query.OnlyShowNormal = true; if (categoryId != 0) { query.CategoryId = categoryId; } if (shopId != 0) { query.ShopId = shopId; } query.Sort = ProductBrokerageQuery.EnumProductSort.AgentNum; switch (sort) { case 1: query.Sort = ProductBrokerageQuery.EnumProductSort.SalesNumber; break; case 3: query.Sort = ProductBrokerageQuery.EnumProductSort.Brokerage; break; case 4: query.Sort = ProductBrokerageQuery.EnumProductSort.PriceAsc; break; case 5: query.Sort = ProductBrokerageQuery.EnumProductSort.PriceDesc; break; case 2: query.Sort = ProductBrokerageQuery.EnumProductSort.AgentNum; break; case 6: query.Sort = ProductBrokerageQuery.EnumProductSort.MonthDesc; break; case 7: query.Sort = ProductBrokerageQuery.EnumProductSort.WeekDesc; break; } ObsoletePageModel <ProductBrokerageInfo> datasql = _iDistributionService.GetDistributionProducts(query); List <ProductBrokerageInfo> datalist = new List <ProductBrokerageInfo>(); List <DistributionProductListModel> result = new List <DistributionProductListModel>(); if (datasql.Models != null) { datalist = datasql.Models.ToList(); List <long> proids = datalist.Select(d => d.ProductId.Value).ToList(); List <long> canAgentIds = _iDistributionService.GetCanAgentProductId(proids, curUserId).ToList(); result = datalist.Select(d => new DistributionProductListModel { ShopId = d.ShopId, ProductId = d.ProductId, ProductName = d.Product.ProductName, ShortDescription = d.Product.ShortDescription, Image = d.Product.GetImage(ImageSize.Size_350), CategoryId = d.Product.CategoryId, CategoryName = d.CategoryName, DistributorRate = d.rate, ProductBrokerageState = d.Status, ProductSaleState = d.Product.SaleStatus, SellPrice = d.Product.MinSalePrice, ShowProductBrokerageState = d.Status.ToDescription(), ShowProductSaleState = d.Product.SaleStatus.ToDescription(), SaleNum = d.SaleNum, AgentNum = d.AgentNum, ForwardNum = d.ForwardNum, isHasAgent = (!canAgentIds.Contains(d.ProductId.Value)) }).ToList(); } return(Json(result)); }