예제 #1
0
        public static List <ProductPriceModel> ForProductListAsync(ProductListRequest request, PagerModel pager,
                                                                   bool isExport = false)
        {
            //var task1 = Task.Run(() => BuildProductMin_maoliValue());
            //var task2 = Task.Run(() => FetchProductList(request, pager, true));
            //await Task.WhenAll(task1, task2);
            var result = FetchProductList(request, pager, true);

            if (!string.IsNullOrEmpty(request.Min_maoliValue) && (request.Min_maoliStatus == 1 || request.Min_maoliStatus == -1))
            {
                if (decimal.TryParse(request.Min_maoliValue, out var temp))
                {
                    result = request.Min_maoliStatus == 1 ?
                             result.Where(x => x.Min_maoliValue.HasValue && x.Min_maoliValue.Value >= temp)?.ToList()
                        : result.Where(x => x.Min_maoliValue.HasValue && x.Min_maoliValue.Value <= temp)?.ToList();
                }
            }

            if (!string.IsNullOrEmpty(request.Website_maoliValue) && (request.Website_maoliStatus == 1 || request.Website_maoliStatus == -1))
            {
                if (decimal.TryParse(request.Website_maoliValue, out var temp))
                {
                    result = request.Website_maoliStatus == 1 ?
                             result.Where(x => x.WebSiteCouponPrice.HasValue && x.WebSiteCouponPrice.Value >= temp)?.ToList()
                        : result.Where(x => x.WebSiteCouponPrice.HasValue && x.WebSiteCouponPrice.Value <= temp)?.ToList();
                }
            }

            return(result?.ToList());
            //var result = await Task.WhenAll(Task.Run(() => { return BuildProductMin_maoliValue(); }},Task.);
        }
예제 #2
0
 public ProductListViewModel Index(ProductListRequest request)
 {
     return new ProductListViewModel
                {
                    Products = _repository.All<Product>()
                };
 }
예제 #3
0
 public ProductListViewModel Index(ProductListRequest request)
 {
     return(new ProductListViewModel
     {
         Products = _repository.All <Product>()
     });
 }
예제 #4
0
 public PageResult <object> GetProductList([FromBody] ProductListRequest requestParams)
 {
     if (requestParams.BaseList == null)
     {
         throw new MessageException("BaseList为空!");
     }
     return(ProductService.GetProductsForAPI(requestParams.BaseList.PageIndex, requestParams.BaseList.PageSize, requestParams.FirstSN, requestParams.SecondSN, requestParams.ThreeSN, requestParams.Barcode));
 }
예제 #5
0
        public FileContentResult ListExcel(IDbConnection connection, ProductListRequest request)
        {
            var data   = List(connection, request).Entities;
            var report = new DynamicDataReport(data, request.IncludeColumns, typeof(Columns.ProductColumns));
            var bytes  = new ReportRepository().Render(report);

            return(ExcelContentResult.Create(bytes, "ProductList_" +
                                             DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx"));
        }
예제 #6
0
        public void GetListOfProducts_FilterWithRangeOfPriceFromCategory_ResultContainsAllProductsFromCategory()
        {
            AutoMapper.Mapper.Reset();
            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.AddProfile <ProductMappingProfile>();
            });

            List <Product> productList = fullListOfProducts();

            List <Category> categoryList = fullListOfCategory();

            ProductListRequest productListRequest = new ProductListRequest()
            {
                CatgoryId        = 1,
                MaxPrice         = null,
                MinPrice         = null,
                SearchedProducts = null,
                Page             = 1
            };

            var productListFromCategory = new List <Product>();

            productListFromCategory.Add(productList[0]);
            productListFromCategory.Add(productList[1]);
            productListFromCategory.Add(productList[2]);
            productListFromCategory.Add(productList[3]);

            PagedResponse <ProductViewModel> pagingListResponse = new PagedResponse <ProductViewModel>()
            {
                ListOfItems = Mapper.Map <List <ProductViewModel> >(productListFromCategory),
                CurrentPage = 1,
                PageCount   = 1
            };

            //Arrange
            var categoryRepository = Substitute.For <ICategoryRepository>();
            var productRepository  = Substitute.For <IProductRepository>();
            var pagingService      = Substitute.For <IPagingService>();

            productRepository.GetProductsByCategory(1).Returns(productListFromCategory);
            categoryRepository.GetCategoryById(1).Returns(categoryList[0]);
            pagingService.GetOnePageOfProducts <ProductViewModel>(Arg.Any <List <ProductViewModel> >(), 1).Returns(pagingListResponse);
            var sut = new ProductService(productRepository, categoryRepository, pagingService);

            //Act
            var firstResult = sut.GetListOfProducts(productListRequest);

            productListRequest.MaxPrice = firstResult.MaxPrice;
            productListRequest.MinPrice = firstResult.MinPrice;
            var secondResult = sut.GetListOfProducts(productListRequest);

            //Assert
            secondResult.Should().BeOfType(typeof(ProductListResponse));
            secondResult.PagedResponse.ListOfItems.Count.Should().Be(4);
        }
예제 #7
0
        public ProductListResponse ListResponse(ProductListRequest request)
        {
            var products = _productRepository.Get(request.Page, request.Term, request.CategoryFilterId).ToList();

            return(new ProductListResponse()
            {
                Values = products.Select(x => ProductDtoBuilder.ToDto(x)).ToList(),
                Total = _productRepository.Get(title: request.Term, categoryFilterId: request.CategoryFilterId).Count()
            });
        }
        public Product[] GetProductList()
        {
            var productListRequest = new ProductListRequest {
                AgentCode = _agentCode,
                AgentUID  = _agentUiId,
                ApiKey    = _apiKey
            };
            var tourlist = _clientApi.ProductList(productListRequest);

            return(tourlist.Products);
        }
예제 #9
0
        public override async Task <Any> OnInvoke(InvokeEnvelope request, ServerCallContext context)
        {
            switch (request.Method)
            {
            case "GetAllProducts":
                ProductListRequest         productListRequest = ProductListRequest.Parser.ParseFrom(request.Data.Value);
                ProductList.V1.ProductList productsList       = await _productListService.GetAllProducts(productListRequest, context);

                return(Any.Pack(productsList));
            }
            return(null);
        }
예제 #10
0
        public async Task <List <Product> > GetProducts(ProductListRequest query)
        {
            var products = from s in _context.Products
                           select s;

            if (query.shopId is not null && !query.shopId.Equals(""))
            {
                products = products.Where(s => s.Store.StoreId.Equals(new Guid(query.shopId)));
            }

            if (!String.IsNullOrEmpty(query.categoryId))
            {
                products = products.Where(s => s.Category.CategoryId.Equals(new Guid(query.categoryId)));
            }
            if (!String.IsNullOrEmpty(query.searchString))
            {
                products = products.Where(s => s.ProductName.Contains(query.searchString) ||
                                          s.Category.CategoryName.Contains(query.searchString));
            }

            //if (query.status > 0)
            //{
            //    products = products.Where(s => s.TinhTrang.Equals(query.status));
            //}

            switch (query.sortOrder)
            {
            case "price_desc":
                products = products.OrderByDescending(s => s.UnitPrice);
                break;

            case "price_asc":
                products = products.OrderBy(s => s.UnitPrice);
                break;

            case "date_desc":
                products = products.OrderByDescending(s => s.CreatedDate);
                break;

            case "date_asc":
                products = products.OrderBy(s => s.CreatedDate);
                break;

            default:
                products = products.OrderByDescending(s => s.CreatedDate);
                break;
            }

            var res = await products.Include(o => o.Store).AsNoTracking().ToListAsync();

            return(res);
        }
예제 #11
0
        public IActionResult Index(int?categoryId = null, string searchedProduct = null, int?minPrice = null, int?maxPrice = null, int pageNo = 1)
        {
            ProductListRequest productListRequest = new ProductListRequest
            {
                CatgoryId        = categoryId,
                SearchedProducts = searchedProduct,
                MinPrice         = minPrice,
                MaxPrice         = maxPrice,
                Page             = pageNo
            };
            var toReturn = _productService.GetListOfProducts(productListRequest);

            return(View("Index", toReturn));
        }
        public async Task <ProductListResponse> Get(ProductListRequest request)
        {
            var productQuery = base.AccessManager.Filter(_productDataService.Query).AsNoTracking()
                               .FilterByProductQuery(request.Query)
                               .Include(x => x.Creator).Include(x => x.Pictures).Include(x => x.PrimaryCategory);

            return
                (new ProductListResponse()
            {
                Access = ResponseAccess.Granted,
                Count = await productQuery.LongCountAsync(),
                Products = (await productQuery.Paginate(request.Query).ToListAsync()).MapToViewModel()
            });
        }
        public void Display()
        {
            var productListRequest = new ProductListRequest {
                CustomerType = _productListView.CustomerType
            };
            var productListResponse = _productService.GetAllProductsFor(productListRequest);

            if (productListResponse.Success)
            {
                _productListView.Display(productListResponse.Products);
            }
            else
            {
                _productListView.ErrorMessage = productListResponse.Message;
            }
        }
예제 #14
0
        public PartialViewResult ProductList(ProductListRequest request)
        {
            PagerModel pager  = new PagerModel(request.PageIndex, request.PageSize);
            var        result = ThirdShopManager.ForProductListAsync(request, pager, true);

            if (result.Any())
            {
                pager.TotalItem = result.Count;
                result          = result.Skip((request.PageIndex - 1) * request.PageSize).Take(request.PageSize).ToList();
            }
            ViewBag.Request = request;
            return(PartialView(new ListModel <ProductPriceModel>()
            {
                Pager = pager, Source = result
            }));
        }
예제 #15
0
        public override async Task <ProductList.V1.ProductList> GetAllProducts(ProductListRequest request, ServerCallContext context)
        {
            IList <Product> results = await _productContext.Products.ToListAsync();

            var productList = new ProductList.V1.ProductList();

            foreach (Product item in results)
            {
                productList.Results.Add(new ProductList.V1.Product
                {
                    ID = item.ProductID.ToString()
                });
            }

            return(productList);
        }
예제 #16
0
        public void Display()
        {
            ProductListRequest productListRequest = new ProductListRequest();

            productListRequest.CustomerType = productListView.CustomerType;

            ProductListResponse productResponse =
                productService.GetAllProductsFor(productListRequest);

            if (productResponse.Success)
            {
                productListView.Display(productResponse.Products);
            }
            else
            {
                productListView.ErrorMessage = productResponse.Message;
            }
        }
예제 #17
0
        public IActionResult List([FromQuery] ProductListRequest request)
        {
            IEnumerable <ProductListResponse> result;

            using (var conn = GetDbConnection())
            {
                conn.Open();

                var query = @"SELECT Id, Name, Price FROM Products ";
                if (request != null && !string.IsNullOrEmpty(request.Name))
                {
                    query += $"WHERE Name LIKE N'%{request.Name}%'";
                }

                result = conn.Query <ProductListResponse>(query);
            }

            ViewBag.Request = request ?? new ProductListRequest();
            return(View(result));
        }
예제 #18
0
        public ProductListResponse GetAllProductsFor(ProductListRequest request)
        {
            ProductListResponse productListResponse = new ProductListResponse();

            try
            {
                IDiscountStrategy discountStrategy = DiscountFactory.GetDiscountStrategyFor(request.CustomerType);
                IList <Product>   products         = _productRepository.FindAll();
                products.Apply(discountStrategy);

                productListResponse.Products = products.ConvertToProductListViewModel();
                productListResponse.Success  = true;
            }
            catch (Exception ex)
            {
                productListResponse.Success = false;
                productListResponse.Message = ex.Message;
            }

            return(productListResponse);
        }
        public Product[] GetProductList(ICacheProvider cacheProvider)
        {
            var tourList = cacheProvider.GetFromCache <Product[]>(ProductListCacheName);

            if (tourList != null)
            {
                return(tourList);
            }

            var productListRequest = new ProductListRequest
            {
                AgentCode = _agentCode,
                AgentUID  = _agentUiId,
                ApiKey    = _apiKey
            };

            var tourlist = _clientApi.ProductList(productListRequest);

            cacheProvider.AddToCache(ProductListCacheName, tourlist.Products, DateTime.Now.AddMinutes(20));

            return(tourlist.Products);
        }
예제 #20
0
        public override async Task GetProductList(
            ProductListRequest request,
            IServerStreamWriter <ProductModel> responseStream,
            ServerCallContext context)
        {
            List <ProductModel> products = new List <ProductModel>
            {
                new ProductModel
                {
                    ProductName = "pen",
                    ProductType = "bic",
                    ProductDesc = "blue pen for writing",
                    Price       = 5
                },

                new ProductModel
                {
                    ProductName = "paper",
                    ProductType = "oxford",
                    ProductDesc = "a4 notepad for taking notes",
                    Price       = 4
                },
                new ProductModel
                {
                    ProductName = "eraser",
                    ProductType = "HB",
                    ProductDesc = "Eraser for removing pencil markings",
                    Price       = 3
                },
            };

            foreach (var prod in products)
            {
                await responseStream.WriteAsync(prod);
            }
        }
예제 #21
0
        public static List <ProductPriceModel> FetchProductList(ProductListRequest request, PagerModel pager,
                                                                bool isExport = false)
        {
            var result = DALThirdShop.FetchProductList(request, pager, isExport);

            Parallel.ForEach(result, new ParallelOptions()
            {
                MaxDegreeOfParallelism = 4
            }, item =>
            {
                var lowestCouponPrice = new List <decimal>();
                if (item.Price != null)
                {
                    if (item.CanUseCoupon.HasValue && !item.CanUseCoupon.Value)
                    {
                        item.LowestPrice = item.Price;
                    }
                    else
                    {
                        item.LowestPrice = FetchLowestPrice("自有平台", item.Price ?? 0, request.MaxTireCount)?.Item1 ?? item.Price;
                    }
                    if (item.LowestPrice != null)
                    {
                        lowestCouponPrice.Add(item.LowestPrice.Value);
                    }
                }
                if (item.TBPrice != null)
                {
                    item.TBLowestPrice = FetchLowestPrice("途虎淘宝", item.TBPrice ?? 0, request.MaxTireCount)?.Item1 ?? item.TBPrice;
                    if (item.TBLowestPrice != null)
                    {
                        lowestCouponPrice.Add(item.TBLowestPrice.Value);
                    }
                }
                if (item.TB2Price != null)
                {
                    item.TB2LowestPrice =
                        FetchLowestPrice("途虎淘宝2", item.TB2Price ?? 0, request.MaxTireCount)?.Item1 ?? item.TB2Price;
                    if (item.TB2LowestPrice != null)
                    {
                        lowestCouponPrice.Add(item.TB2LowestPrice.Value);
                    }
                }
                if (item.TM1Price != null)
                {
                    item.TM1LowestPrice =
                        FetchLowestPrice("途虎天猫1", item.TM1Price ?? 0, request.MaxTireCount)?.Item1 ?? item.TM1Price;
                    if (item.TM1LowestPrice != null)
                    {
                        lowestCouponPrice.Add(item.TM1LowestPrice.Value);
                    }
                }
                if (item.TM2Price != null)
                {
                    item.TM2LowestPrice =
                        FetchLowestPrice("途虎天猫2", item.TM2Price ?? 0, request.MaxTireCount)?.Item1 ?? item.TM2Price;
                    if (item.TM2LowestPrice != null)
                    {
                        lowestCouponPrice.Add(item.TM2LowestPrice.Value);
                    }
                }
                if (item.TM3Price != null)
                {
                    item.TM3LowestPrice =
                        FetchLowestPrice("途虎天猫3", item.TM3Price ?? 0, request.MaxTireCount)?.Item1 ?? item.TM3Price;
                    if (item.TM3LowestPrice != null)
                    {
                        lowestCouponPrice.Add(item.TM3LowestPrice.Value);
                    }
                }
                if (item.TM4Price != null)
                {
                    item.TM4LowestPrice =
                        FetchLowestPrice("途虎天猫4", item.TM4Price ?? 0, request.MaxTireCount)?.Item1 ?? item.TM4Price;
                    if (item.TM4LowestPrice != null)
                    {
                        lowestCouponPrice.Add(item.TM4LowestPrice.Value);
                    }
                }
                if (item.JDPrice != null)
                {
                    item.JDLowestPrice = FetchLowestPrice("途虎京东", item.JDPrice ?? 0, request.MaxTireCount)?.Item1 ?? item.JDPrice;
                    if (item.JDLowestPrice != null)
                    {
                        lowestCouponPrice.Add(item.JDLowestPrice.Value);
                    }
                }
                if (item.JDFlagShipPrice != null)
                {
                    item.JDFlagShipLowestPrice =
                        FetchLowestPrice("途虎京东旗舰", item.JDFlagShipPrice ?? 0, request.MaxTireCount)?.Item1 ?? item.JDFlagShipPrice;
                    if (item.JDFlagShipLowestPrice != null)
                    {
                        lowestCouponPrice.Add(item.JDFlagShipLowestPrice.Value);
                    }
                }
                if (lowestCouponPrice.Any() && item.Cost != null)
                {
                    item.Min_maoliValue = lowestCouponPrice.Min() - item.Cost;
                }
            });
            return(result.OrderByDescending(x => x.num_threemonth).ToList());
        }
예제 #22
0
        public async Task <IActionResult> GetProductList([FromQuery] ProductListRequest query)
        {
            List <Product> listProducts = await _service.GetProducts(query);

            return(Ok(listProducts));
        }
예제 #23
0
        public static int FetchProductListCount(ProductListRequest request)
        {
            #region SQL
            var SqlStr = @"SELECT	COUNT(1)
FROM	Tuhu_productcatalog..vw_Products AS T WITH ( NOLOCK )
		LEFT JOIN Tuhu_productcatalog..TireLowestPrice AS P WITH ( NOLOCK ) ON T.PID = P.PID
		LEFT JOIN Tuhu_bi..dm_Product_SalespredictData AS S WITH ( NOLOCK ) ON T.PID = S.PID
WHERE	T.IsShow = 1
		AND ( ( T.PID LIKE '%' + @pid + '%'
				OR @pid IS NULL
				)
				AND T.PID LIKE 'TR-%'
			)
		AND ( T.DisplayName LIKE '%' + @productname + '%'
				OR @productname IS NULL
			)
		AND ( T.CP_Brand = @Brand
				OR @Brand IS NULL
			)
		AND ( @OnSaleStatus = 0
				OR @OnSaleStatus = 1
				AND T.OnSale = 1
				OR @OnSaleStatus = 2
				AND T.OnSale = 0
			)
		AND ( {0}
			);"            ;
            #endregion

            List <string> ManyCustomPrice   = request.ManyCustomPrice?.Split('|').ToList();
            int           Contrast          = request.Contrast;
            string        SingleCustomPrice = GetSqlParameter(request.SingleCustomPrice);
            double        Proportion        = request.Proportion;
            var           sqlPara           = "1=1";
            if (request.Type > 0 && ManyCustomPrice != null && !string.IsNullOrWhiteSpace(SingleCustomPrice) && Contrast != 0)
            {
                sqlPara = "1 <> 1";
                var ContrastSig = Contrast == -1 ? "<=" : ">=";
                foreach (var item in ManyCustomPrice)
                {
                    var realPara = GetSqlParameter(item);
                    if (!string.IsNullOrWhiteSpace(realPara))
                    {
                        sqlPara += $@" OR ( ISNULL({realPara}, 0) > 0
						AND {realPara} / IIF(ISNULL({SingleCustomPrice}, 0) = 0, 1, {SingleCustomPrice}) {ContrastSig} {Proportion})"                        ;
                    }
                }
            }
            SqlStr = string.Format(SqlStr, sqlPara);
            using (var dbHelper = new SqlDbHelper(ConnectionHelper.GetDecryptConn("Tuhu_Gungnir_BI")))
            {
                using (var cmd = new SqlCommand(SqlStr))
                {
                    cmd.CommandTimeout = 3 * 60;
                    cmd.CommandType    = CommandType.Text;
                    cmd.Parameters.AddWithValue("@pid", request.PID);
                    cmd.Parameters.AddWithValue("@productname", request.ProductName);
                    cmd.Parameters.AddWithValue("@OnSaleStatus", request.OnSale);
                    cmd.Parameters.AddWithValue("@Brand", request.Brand);
                    var result = dbHelper.ExecuteScalar(cmd);
                    if (Int32.TryParse(result?.ToString(), out int value))
                    {
                        return(value);
                    }
                    return(0);
                }
            }
        }
예제 #24
0
        public static List <ProductPriceModel> FetchProductList(ProductListRequest request, PagerModel pager, bool isExport)
        {
            #region SQL
            var SqlStr = @"SELECT	T.CP_Brand AS Brand ,
		T.PID AS PID ,
		T.DisplayName AS ProductName ,
		S.cost AS Cost ,
		P.LowestPrice AS LowestLimit ,
		T.cy_list_price AS Price ,
		S.taobao_tuhuid AS TBPID ,
		S.taobao_tuhuprice AS TBPrice ,
		S.taobao2_tuhuid AS TB2PID ,
		S.taobao2_tuhuprice AS TB2Price ,
		S.tianmao1_tuhuprice AS TM1Price ,
		S.tianmao1_tuhuid AS TM1PID ,
		S.tianmao2_tuhuprice AS TM2Price ,
		S.tianmao2_tuhuid AS TM2PID ,
		S.tianmao3_tuhuprice AS TM3Price ,
		S.tianmao3_tuhuid AS TM3PID ,
		S.tianmao4_tuhuid AS TM4PID ,
		S.tianmao4_tuhuprice AS TM4Price ,
		S.jingdongflagship_tuhuprice AS JDFlagShipPrice ,
		S.jingdongflagship_tuhuid AS JDFlagShipPID ,
		S.jingdong_tuhuprice AS JDPrice ,
		S.jingdong_tuhuid AS JDPID,
        e.CanUseCoupon as CanUseCoupon,
        s.num_threemonth
FROM	Tuhu_productcatalog..vw_Products AS T WITH ( NOLOCK )
		LEFT JOIN Tuhu_productcatalog..TireLowestPrice AS P WITH ( NOLOCK ) ON T.PID = P.PID
		LEFT JOIN Tuhu_bi..dm_Product_SalespredictData AS S WITH ( NOLOCK ) ON T.PID = S.PID
        left join Tuhu_productcatalog..tbl_ProductExtraProperties as e  WITH ( NOLOCK ) on e.pid=t.pid
WHERE	T.IsShow = 1
		AND ( ( T.PID LIKE '%' + @pid + '%'
				OR @pid IS NULL
				)
				AND T.PID LIKE 'TR-%'
			)
		AND ( T.DisplayName LIKE '%' + @productname + '%'
				OR @productname IS NULL
			)
		AND ( T.CP_Brand = @Brand
				OR @Brand IS NULL
			)
		AND ( @OnSaleStatus = 0
				OR @OnSaleStatus = 1
				AND T.OnSale = 1
				OR @OnSaleStatus = 2
				AND T.OnSale = 0
			)
		AND ( {0}
			)"            ;
            SqlStr += isExport ? ";" : @"ORDER BY s.num_threemonth desc
		OFFSET @start ROWS FETCH NEXT @step ROWS ONLY;"        ;
            #endregion +
            pager.TotalItem = FetchProductListCount(request);
            List <string> ManyCustomPrice   = request.ManyCustomPrice?.Split('|').ToList();
            int           Contrast          = request.Contrast;
            string        SingleCustomPrice = GetSqlParameter(request.SingleCustomPrice);
            double        Proportion        = request.Proportion;
            var           sqlPara           = "1 = 1";
            if (request.Type > 0 && ManyCustomPrice != null && !string.IsNullOrWhiteSpace(SingleCustomPrice) && Contrast != 0)
            {
                sqlPara = "1 <> 1";
                var ContrastSig = Contrast == -1 ? "<=" : ">=";
                foreach (var item in ManyCustomPrice)
                {
                    var realPara = GetSqlParameter(item);
                    if (!string.IsNullOrWhiteSpace(realPara))
                    {
                        sqlPara += $@" OR ( ISNULL({realPara}, 0) > 0
						AND {realPara} / IIF(ISNULL({SingleCustomPrice}, 0) = 0, 1, {SingleCustomPrice}) {ContrastSig} {Proportion})"                        ;
                    }
                }
            }
            //string.Format(SqlStr, sqlPara);
            SqlStr = string.Format(SqlStr, sqlPara);
            using (var dbHelper = new SqlDbHelper(ConnectionHelper.GetDecryptConn("Tuhu_Gungnir_BI")))
            {
                using (var cmd = new SqlCommand(SqlStr))
                {
                    cmd.CommandTimeout = 3 * 60;
                    cmd.CommandType    = CommandType.Text;
                    cmd.Parameters.AddWithValue("@pid", request.PID);
                    cmd.Parameters.AddWithValue("@productname", request.ProductName);
                    cmd.Parameters.AddWithValue("@OnSaleStatus", request.OnSale);
                    cmd.Parameters.AddWithValue("@Brand", request.Brand);
                    cmd.Parameters.AddWithValue("@start", (request.PageIndex - 1) * request.PageSize);
                    cmd.Parameters.AddWithValue("@step", request.PageSize);
                    var result = dbHelper.ExecuteDataTable(cmd);
                    return(result.ConvertTo <ProductPriceModel>()?.ToList() ?? new List <ProductPriceModel>());
                }
            }
        }
예제 #25
0
        public FileResult ExportExcel(ProductListRequest request)
        {
            PagerModel pager    = new PagerModel(request.PageIndex, request.PageSize);
            var        result   = ThirdShopManager.ForProductListAsync(request, pager, true);
            var        pagesize = int.Parse(System.Configuration.ConfigurationManager.AppSettings["ExportSize"]);
            var        book     = new HSSFWorkbook();

            NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1");
            NPOI.SS.UserModel.IRow   row    = sheet1.CreateRow(0);
            var fileName = $"第三方平台{ThreadIdentity.Operator.Name.Split('@')[0]}.xls";

            row.CreateCell(0).SetCellValue("品牌");
            row.CreateCell(1).SetCellValue("PID");
            row.CreateCell(2).SetCellValue("产品名称");
            row.CreateCell(3).SetCellValue("进货价");
            row.CreateCell(4).SetCellValue("最小毛利");
            row.CreateCell(5).SetCellValue("可用券");
            row.CreateCell(6).SetCellValue("官网价格");
            row.CreateCell(7).SetCellValue("自有平台最低价");
            row.CreateCell(8).SetCellValue("途虎淘宝");
            row.CreateCell(9).SetCellValue("途虎淘宝最低价");
            row.CreateCell(10).SetCellValue("途虎淘宝2");
            row.CreateCell(11).SetCellValue("途虎淘宝2最低价");
            row.CreateCell(12).SetCellValue("途虎天猫1");
            row.CreateCell(13).SetCellValue("途虎天猫1最低价");
            row.CreateCell(14).SetCellValue("途虎天猫2");
            row.CreateCell(15).SetCellValue("途虎天猫2最低价");
            row.CreateCell(16).SetCellValue("途虎天猫3");
            row.CreateCell(17).SetCellValue("途虎天猫3最低价");
            row.CreateCell(18).SetCellValue("途虎天猫4");
            row.CreateCell(19).SetCellValue("途虎天猫4最低价");
            row.CreateCell(20).SetCellValue("途虎京东2");
            row.CreateCell(21).SetCellValue("途虎京东2最低价");
            row.CreateCell(22).SetCellValue("途虎京东旗舰");
            row.CreateCell(23).SetCellValue("途虎京东旗舰最低价");
            row.CreateCell(24).SetCellValue("最低面价(平时)");
            row.CreateCell(25).SetCellValue("最低面价(大促)");
            row.CreateCell(26).SetCellValue("最低券后价(平时)");
            row.CreateCell(27).SetCellValue("最低券后价(大促)");
            var i = 0;

            foreach (var item in result)
            {
                NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(++i);
                rowtemp.CreateCell(0).SetCellValue(item.Brand);
                rowtemp.CreateCell(1).SetCellValue(item.PID);
                rowtemp.CreateCell(2).SetCellValue(item.ProductName);
                rowtemp.CreateCell(3).SetCellValue(item.Cost == null ? "" : item.Cost.Value.ToString("0.00"));
                rowtemp.CreateCell(4).SetCellValue(item.Min_maoliValue == null ? "" : item.Min_maoliValue.Value.ToString("0.00"));
                rowtemp.CreateCell(5).SetCellValue(item.CanUseCoupon.HasValue ? (item.CanUseCoupon.Value ? "是" : "否") : "是");
                rowtemp.CreateCell(6).SetCellValue(item.Price == null ? "" : item.Price.Value.ToString("0.00"));
                rowtemp.CreateCell(7).SetCellValue(item.LowestPrice == null ? "" : item.LowestPrice.Value.ToString("0.00"));
                rowtemp.CreateCell(8).SetCellValue(item.TBPrice == null ? "" : item.TBPrice.Value.ToString("0.00"));
                rowtemp.CreateCell(9).SetCellValue(item.TBLowestPrice == null ? "" : item.TBLowestPrice.Value.ToString("0.00"));
                rowtemp.CreateCell(10).SetCellValue(item.TB2Price == null ? "" : item.TB2Price.Value.ToString("0.00"));
                rowtemp.CreateCell(11).SetCellValue(item.TB2LowestPrice == null ? "" : item.TB2LowestPrice.Value.ToString("0.00"));
                rowtemp.CreateCell(12).SetCellValue(item.TM1Price == null ? "" : item.TM1Price.Value.ToString("0.00"));
                rowtemp.CreateCell(13).SetCellValue(item.TM1LowestPrice == null ? "" : item.TM1LowestPrice.Value.ToString("0.00"));
                rowtemp.CreateCell(14).SetCellValue(item.TM2Price == null ? "" : item.TM2Price.Value.ToString("0.00"));
                rowtemp.CreateCell(15).SetCellValue(item.TM2LowestPrice == null ? "" : item.TM2LowestPrice.Value.ToString("0.00"));
                rowtemp.CreateCell(16).SetCellValue(item.TM3Price == null ? "" : item.TM3Price.Value.ToString("0.00"));
                rowtemp.CreateCell(17).SetCellValue(item.TM3LowestPrice == null ? "" : item.TM3LowestPrice.Value.ToString("0.00"));
                rowtemp.CreateCell(18).SetCellValue(item.TM4Price == null ? "" : item.TM4Price.Value.ToString("0.00"));
                rowtemp.CreateCell(19).SetCellValue(item.TM4LowestPrice == null ? "" : item.TM4LowestPrice.Value.ToString("0.00"));
                rowtemp.CreateCell(20).SetCellValue(item.JDPrice == null ? "" : item.JDPrice.Value.ToString("0.00"));
                rowtemp.CreateCell(21).SetCellValue(item.JDLowestPrice == null ? "" : item.JDLowestPrice.Value.ToString("0.00"));
                rowtemp.CreateCell(22).SetCellValue(item.JDFlagShipPrice == null ? "" : item.JDFlagShipPrice.Value.ToString("0.00"));
                rowtemp.CreateCell(23).SetCellValue(item.JDFlagShipLowestPrice == null ? "" : item.JDFlagShipLowestPrice.Value.ToString("0.00"));
                rowtemp.CreateCell(24).SetCellValue(item.LowestPrice_Normal.HasValue ? item.LowestPrice_Normal.Value.ToString("0.00") : "");
                rowtemp.CreateCell(25).SetCellValue(item.LowestPrice_Promotion.HasValue ? item.LowestPrice_Promotion.Value.ToString("0.00") : "");
                rowtemp.CreateCell(26).SetCellValue(item.CouponPrice_Normal.HasValue ? item.CouponPrice_Normal.Value.ToString("0.00") : "");
                rowtemp.CreateCell(27).SetCellValue(item.CouponPrice_Promotion.HasValue ? item.CouponPrice_Promotion.Value.ToString("0.00") : "");
            }
            var ms = new MemoryStream();

            book.Write(ms);
            ms.Seek(0, SeekOrigin.Begin);
            return(File(ms, "application/vnd.ms-excel", fileName));
        }
예제 #26
0
 public ListResponse <MyRow> List(IDbConnection connection, ProductListRequest request)
 {
     return(new MyRepository().List(connection, request));
 }
예제 #27
0
 public IActionResult GetList([FromQuery] ProductListRequest request)
 {
     return(Ok(_productService.ListResponse(request)));
 }
예제 #28
0
        public static List <ProductPriceModel> ForProductListAsync(ProductListRequest request, PagerModel pager,
                                                                   bool isExport = false)
        {
            //var task1 = Task.Run(() => BuildProductMin_maoliValue());
            //var task2 = Task.Run(() => FetchProductList(request, pager, true));
            //await Task.WhenAll(task1, task2);
            var result = FetchProductList(request, pager, true);

            if (!string.IsNullOrEmpty(request.Min_maoliValue) && (request.Min_maoliStatus == 1 || request.Min_maoliStatus == -1))
            {
                if (decimal.TryParse(request.Min_maoliValue, out var temp))
                {
                    result = request.Min_maoliStatus == 1 ?
                             result.Where(x => x.Min_maoliValue.HasValue && x.Min_maoliValue.Value >= temp)?.ToList()
                        : result.Where(x => x.Min_maoliValue.HasValue && x.Min_maoliValue.Value <= temp)?.ToList();
                }
            }

            if (!string.IsNullOrEmpty(request.Website_maoliValue) && (request.Website_maoliStatus == 1 || request.Website_maoliStatus == -1))
            {
                if (decimal.TryParse(request.Website_maoliValue, out var temp))
                {
                    result = request.Website_maoliStatus == 1 ?
                             result.Where(x => x.WebSiteCouponPrice.HasValue && x.WebSiteCouponPrice.Value >= temp)?.ToList()
                        : result.Where(x => x.WebSiteCouponPrice.HasValue && x.WebSiteCouponPrice.Value <= temp)?.ToList();
                }
            }
            if (!string.IsNullOrEmpty(request.CanUseCouponStatus))
            {
                if (request.CanUseCouponStatus == "1")
                {
                    result = result.Where(x => !x.CanUseCoupon.HasValue || x.CanUseCoupon.Value).ToList();
                }
                else
                {
                    result = result.Where(x => x.CanUseCoupon.HasValue && !x.CanUseCoupon.Value).ToList();
                }
            }

            //Func<decimal?, decimal> getprice = price => price.HasValue ? price.Value : 0;

            if (!string.IsNullOrEmpty(request.CouponPriceStatus) && !string.IsNullOrEmpty(request.CouponPriceValue))
            {
                if (request.CouponPriceValue == "1")
                {
                    if (request.CouponPriceStatus == "1")
                    {
                        result = result.Where(x => x.CouponPrice_Normal.HasValue && x.LowestPrices.Where(s => s.HasValue).Any(s => s.Value > x.CouponPrice_Normal)).ToList();
                    }
                    else if (request.CouponPriceStatus == "0")
                    {
                        result = result.Where(x => x.CouponPrice_Normal.HasValue && x.LowestPrices.Where(s => s.HasValue).Any(s => s.Value == x.CouponPrice_Normal)).ToList();
                    }
                    else if (request.CouponPriceStatus == "-1")
                    {
                        result = result.Where(x => x.CouponPrice_Normal.HasValue && x.LowestPrices.Where(s => s.HasValue).Any(s => s.Value < x.CouponPrice_Normal)).ToList();
                    }
                }
                if (request.CouponPriceValue == "-1")
                {
                    if (request.CouponPriceStatus == "1")
                    {
                        result = result.Where(x => x.CouponPrice_Promotion.HasValue && x.LowestPrices.Where(s => s.HasValue).Any(s => s.Value > x.CouponPrice_Promotion)).ToList();
                    }
                    else if (request.CouponPriceStatus == "0")
                    {
                        result = result.Where(x => x.CouponPrice_Promotion.HasValue && x.LowestPrices.Where(s => s.HasValue).Any(s => s.Value == x.CouponPrice_Promotion)).ToList();
                    }
                    else if (request.CouponPriceStatus == "-1")
                    {
                        result = result.Where(x => x.CouponPrice_Promotion.HasValue && x.LowestPrices.Where(s => s.HasValue).Any(s => s.Value < x.CouponPrice_Promotion)).ToList();
                    }
                }
            }

            if (!string.IsNullOrEmpty(request.LowestPriceStatus) && !string.IsNullOrEmpty(request.LowestPriceValue))
            {
                if (request.LowestPriceValue == "1")
                {
                    if (request.LowestPriceStatus == "1")
                    {
                        result = result.Where(x => x.LowestPrice_Normal.HasValue && x.NormalPrices.Where(s => s.HasValue).Any(s => s.Value > x.LowestPrice_Normal)).ToList();
                    }
                    else if (request.LowestPriceStatus == "0")
                    {
                        result = result.Where(x => x.LowestPrice_Normal.HasValue && x.NormalPrices.Where(s => s.HasValue).Any(s => s.Value == x.LowestPrice_Normal)).ToList();
                    }
                    else if (request.LowestPriceStatus == "-1")
                    {
                        result = result.Where(x => x.LowestPrice_Normal.HasValue && x.NormalPrices.Where(s => s.HasValue).Any(s => s.Value < x.LowestPrice_Normal)).ToList();
                    }
                }
                if (request.LowestPriceValue == "-1")
                {
                    if (request.LowestPriceStatus == "1")
                    {
                        result = result.Where(x => x.LowestPrice_Promotion.HasValue && x.NormalPrices.Where(s => s.HasValue).Any(s => s.Value > x.LowestPrice_Promotion)).ToList();
                    }
                    else if (request.LowestPriceStatus == "0")
                    {
                        result = result.Where(x => x.LowestPrice_Promotion.HasValue && x.NormalPrices.Where(s => s.HasValue).Any(s => s.Value == x.LowestPrice_Promotion)).ToList();
                    }
                    else if (request.LowestPriceStatus == "-1")
                    {
                        result = result.Where(x => x.LowestPrice_Promotion.HasValue && x.NormalPrices.Where(s => s.HasValue).Any(s => s.Value < x.LowestPrice_Promotion)).ToList();
                    }
                }
            }
            return(result?.ToList());
            //var result = await Task.WhenAll(Task.Run(() => { return BuildProductMin_maoliValue(); }},Task.);
        }
예제 #29
0
 public ListResponse <MyRow> List(IDbConnection connection, ProductListRequest request)
 {
     return(new MyListHandler().Process(connection, request));
 }