Exemplo n.º 1
0
        public JsonResult GetWXSmallProducts(int page, int rows, string keyWords, string shopName, long?categoryId = null)
        {
            ProductQuery productQuery = new ProductQuery()
            {
                CategoryId = categoryId,
                KeyWords   = keyWords,
                ShopName   = shopName
            };
            var datasql = _iWXSmallProgramService.GetWXSmallProducts(page, rows,
                                                                     productQuery);

            var products = datasql.Models.ToArray().Select(item => new ProductModel()
            {
                name        = item.ProductName,
                brandName   = item.BrandName,
                id          = item.Id,
                imgUrl      = item.GetImage(ImageSize.Size_50),
                price       = item.MinSalePrice,
                state       = item.ShowProductState,
                productCode = item.ProductCode,
                shopName    = item.ShopName
            });
            var dataGrid = new DataGridModel <ProductModel>()
            {
                rows = products, total = datasql.Total
            };

            return(Json(dataGrid));
        }
        public JsonResult GetWXSmallProducts(int page, int rows, string keyWords, long?categoryId = null)
        {
            Himall.Model.ObsoletePageModel <Himall.Model.ProductInfo> datasql = _iWXSmallProgramService.GetWXSmallProducts(page, rows);

            IEnumerable <ProductModel> products = datasql.Models.ToArray().Select(item => new ProductModel()
            {
                name        = item.ProductName,
                brandName   = item.BrandName,
                id          = item.Id,
                imgUrl      = item.GetImage(ImageSize.Size_50),
                price       = item.MinSalePrice,
                state       = item.ShowProductState,
                productCode = item.ProductCode
            });
            DataGridModel <ProductModel> dataGrid = new DataGridModel <ProductModel>()
            {
                rows = products, total = datasql.Total
            };

            return(Json(dataGrid));
        }
        public static void SetWXSmallProducts(string productIds)
        {
            List <Himall.Model.ProductInfo> lProductInfo = new List <Model.ProductInfo>();
            var lbId = _iWXSmallProgramService.GetWXSmallProducts().Select(item => item.ProductId).ToList();

            if (!string.IsNullOrEmpty(productIds))
            {
                var productIdsArr = productIds.Split(',').Select(item => long.Parse(item)).ToList();
                lProductInfo = _iProductService.GetAllProductByIds(productIdsArr);
                foreach (Himall.Model.ProductInfo item in lProductInfo)
                {
                    if (!lbId.Contains(Convert.ToInt32(item.Id)))
                    {
                        Himall.Model.WXSmallChoiceProductsInfo mProductsInfo = new Model.WXSmallChoiceProductsInfo()
                        {
                            ProductId = Convert.ToInt32(item.Id)
                        };
                        _iWXSmallProgramService.AddWXSmallProducts(mProductsInfo);
                    }
                }
            }
        }