コード例 #1
0
        public async Task <ProductListResponse> List(ProductClassifyRequest request)
        {
            var qing    = qingtaokeApiDataRepository.ItemList(request);
            var zhushou = taokeZhushouApiDataRepository.Search(new ProductSearchRequest()
            {
                Cat      = request.Cat,
                Sort     = request.Sort,
                PageSize = request.PageSize,
                PageNo   = request.PageNo
            });
            var jidi = taokeJidiApiDataRepository.Classify(request);

            return(await Task.WhenAll(qing, zhushou, jidi).ContinueWith(task =>
            {
                List <TbkProductInfo> lstResult = new List <TbkProductInfo>();

                task.Result.ToList().ForEach(item =>
                {
                    if (item == null)
                    {
                        return;
                    }
                    lstResult.AddRange(item);
                });

                lstResult = lstResult.Distinct(new ProductIdComparer()).Sort(request.Sort).ToList();

                return new ProductListResponse()
                {
                    Datas = lstResult,
                    Total = lstResult.Count
                };
            }));
        }
コード例 #2
0
        public async Task <ProductListResponse> List(ProductSearchRequest request)
        {
            var qing    = qingtaokeApiDataRepository.Search(request);
            var zhushou = taokeZhushouApiDataRepository.Search(request);
            var jidi    = taokeJidiApiDataRepository.Search(request);

            var datas = await Task.WhenAll(qing, zhushou, jidi).ContinueWith(task =>
            {
                List <TbkProductInfo> lstResult = new List <TbkProductInfo>();
                task.Result.ToList().ForEach(item =>
                {
                    if (item == null)
                    {
                        return;
                    }
                    lstResult.AddRange(item);
                });
                return(lstResult.Distinct(new ProductIdComparer()).Sort(request.Sort, false).ToList());
            });

            if (datas == null || datas.Count <= 0)
            {
                List <TbkProductInfo> lstTao = await sdkDataRepository.Search(request);

                if (null != lstTao)
                {
                    datas = lstTao;
                }
                else
                {
                    datas = new List <TbkProductInfo>();
                }
            }

            return(new ProductListResponse()
            {
                Datas = datas,
                Total = datas.Count
            });
        }
コード例 #3
0
        public async Task <ProductListResponse> WeiXin(ProductTopicRequest request)
        {
            List <Task <List <TbkProductInfo> > > lstTask = new List <Task <List <TbkProductInfo> > >();

            switch (request.Type)
            {
            case 1:
                lstTask.Add(dataokeApiDataRepository.Top100(request));
                lstTask.Add(taokeJidiApiDataRepository.Top100(request));
                break;

            case 2:
                lstTask.Add(qingtaokeApiDataRepository.BaoKuan(request));
                lstTask.Add(taokeZhushouApiDataRepository.TopHour(request));
                break;

            case 3:
                lstTask.Add(dataokeApiDataRepository.XiaoLiang(request));
                lstTask.Add(taokeZhushouApiDataRepository.TopDay(request));
                break;

            case 4:
                lstTask.Add(qingtaokeApiDataRepository.ItemList(new ProductClassifyRequest()
                {
                    TodayNew = 1,
                    PageNo   = request.PageNo,
                    Sort     = request.Sort
                }));
                lstTask.Add(taokeZhushouApiDataRepository.Search(new ProductSearchRequest()
                {
                    TodayNew = 1,
                    Sort     = request.Sort,
                    PageNo   = request.PageNo
                }));
                break;

            case 5:
                lstTask.Add(taokeZhushouApiDataRepository.Search(new ProductSearchRequest()
                {
                    Juhuasuan = 1,
                    Sort      = request.Sort,
                    PageNo    = request.PageNo
                }));
                lstTask.Add(qingtaokeApiDataRepository.ItemList(new ProductClassifyRequest()
                {
                    Juhuasuan = 1,
                    PageNo    = request.PageNo,
                    Sort      = request.Sort
                }));
                break;

            case 6:
                lstTask.Add(qingtaokeApiDataRepository.ItemList(new ProductClassifyRequest()
                {
                    Taoqianggou = 1,
                    PageNo      = request.PageNo,
                    Sort        = request.Sort
                }));
                lstTask.Add(taokeZhushouApiDataRepository.Search(new ProductSearchRequest()
                {
                    Taoqianggou = 1,
                    Sort        = request.Sort,
                    PageNo      = request.PageNo
                }));
                break;

            case 7:
                lstTask.Add(qingtaokeApiDataRepository.ItemList(new ProductClassifyRequest()
                {
                    MinPrice = 0,
                    MaxPrice = 9.9F,
                    PageNo   = request.PageNo,
                    Sort     = request.Sort,
                }));
                lstTask.Add(taokeZhushouApiDataRepository.Search(new ProductSearchRequest()
                {
                    MinPrice = 0,
                    MaxPrice = 9.9F,
                    Sort     = request.Sort,
                    PageNo   = request.PageNo
                }));
                break;

            case 8:
                lstTask.Add(qingtaokeApiDataRepository.ItemList(new ProductClassifyRequest()
                {
                    MinPrice = 10,
                    MaxPrice = 20,
                    PageNo   = request.PageNo,
                    Sort     = request.Sort
                }));
                lstTask.Add(taokeZhushouApiDataRepository.Search(new ProductSearchRequest()
                {
                    MinPrice = 10,
                    MaxPrice = 20,
                    Sort     = request.Sort,
                    PageNo   = request.PageNo
                }));
                break;

            case 9:
                lstTask.Add(taokeZhushouApiDataRepository.Search(new ProductSearchRequest()
                {
                    Haitao = 1,
                    Sort   = request.Sort,
                    PageNo = request.PageNo
                }));
                break;

            case 10:
                lstTask.Add(taokeJidiApiDataRepository.PinPai(request));
                break;
            }
            return(await GetProductList(request, lstTask, request.Type != 9));
        }