コード例 #1
0
        /// <summary>
        /// 通用搜索
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <PagedModel <string> > ProductCommonQuery(ProductCommonQueryRequest request)
        {
            using (var client = new ShopProductClient())
            {
                var clientResult = await client.ProductCommonQueryAsync(request);

                clientResult.ThrowIfException(true);
                return(clientResult.Result);
            }
        }
コード例 #2
0
        /// <summary>
        /// 调用接口筛选pid
        /// </summary>
        /// <param name="catalogId"></param>
        /// <param name="onSale"></param>
        /// <param name="isDaifa"></param>
        /// <param name="stockOut"></param>
        /// <param name="hasPintuanPrice"></param>
        /// <param name="keyWord"></param>
        /// <param name="keyWordSearchType"></param>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        static async Task <OperationResult <PagedModel <string> > > GetPidsByFilter(string catalogId, int onSale,
                                                                                    int isDaifa, int stockOut, int hasPintuanPrice, string keyWord, int keyWordSearchType, int page, int pageSize, string ProductName = "")
        {
            using (var client = new ShopProductClient())
            {
                var dics = new Dictionary <string, ProductCommonQuery>();

                #region 查询条件
                if (!string.IsNullOrWhiteSpace(catalogId))
                {
                    dics.Add(nameof(ProductCommonQueryModel.CategoryOid), new ProductCommonQuery
                    {
                        CompareType = CompareType.Equal,
                        Value       = catalogId
                    });
                }
                else
                {
                    dics.Add("NodeNo", new ProductCommonQuery
                    {
                        CompareType = CompareType.Equal,
                        Value       = 28349
                    });
                }

                if (!string.IsNullOrWhiteSpace(ProductName))
                {
                    dics.Add(nameof(ProductCommonQueryModel.ProductName), new ProductCommonQuery
                    {
                        CompareType = CompareType.Equal,
                        Value       = ProductName
                    });
                }

                if (onSale != -1)
                {
                    dics.Add(nameof(ProductCommonQueryModel.IsOnSale), new ProductCommonQuery
                    {
                        CompareType = CompareType.Equal,
                        Value       = (onSale == 1)
                    });
                }
                if (isDaifa != -1)
                {
                    dics.Add(nameof(ProductCommonQueryModel.IsDaiFa), new ProductCommonQuery
                    {
                        CompareType = CompareType.Equal,
                        Value       = (isDaifa == 1)
                    });
                }
                if (stockOut != -1)
                {
                    dics.Add(nameof(ProductCommonQueryModel.Stockout), new ProductCommonQuery
                    {
                        CompareType = CompareType.Equal,
                        Value       = (stockOut == 1)
                    });
                }
                if (hasPintuanPrice != -1)
                {
                    dics.Add(nameof(ProductCommonQueryModel.IsPinTuanProduct), new ProductCommonQuery
                    {
                        CompareType = CompareType.Equal,
                        Value       = (hasPintuanPrice == 1)
                    });
                }
                if (!string.IsNullOrWhiteSpace(keyWord) &&
                    keyWordSearchType >= 1)
                {
                    if (keyWordSearchType == 1)
                    {
                        dics.Add(nameof(ProductCommonQueryModel.ProductName), new ProductCommonQuery
                        {
                            CompareType = CompareType.Equal,
                            Value       = keyWord
                        });
                    }
                    else
                    {
                        dics.Add(nameof(ProductCommonQueryModel.Pid), new ProductCommonQuery
                        {
                            CompareType = CompareType.Equal,
                            Value       = keyWord
                        });
                    }
                }
                #endregion

                var inputProp = new ProductCommonQueryRequest
                {
                    AndQuerys = dics,
                    PageIndex = page,
                    PageSize  = pageSize
                };

                logger.Info($"{nameof(CarProductPriceManager)}.{nameof(GetPidsByFilter)} 调用接口ProductCommonQueryAsync 入参:{JsonHelper.Serialize(inputProp)}");
                var res = await client.ProductCommonQueryAsync(inputProp);

                logger.Info($"{nameof(CarProductPriceManager)}.{nameof(GetPidsByFilter)} 调用接口ProductCommonQueryAsync 出参:res={JsonHelper.Serialize(res)} 入参:{JsonHelper.Serialize(inputProp)} ");

                res.ThrowIfException();

                return(res);
            }
        }