/// <summary>
        /// 根据查询条件获取产品总行数
        /// </summary>
        /// <param name="sqlcon"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public int QueryProductsForProductLibraryCount(SeachProducts model)
        {
            Func <SqlConnection, int> action = (connection)
                                               => ProductLibraryConfigDAL.QueryProductsForProductLibraryCount(connection, model);

            return(dbManager.Execute(action));
        }
示例#2
0
        /// <summary>
        /// 根据查询条件获取产品总行数
        /// </summary>
        /// <param name="sqlcon"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int QueryProductsForProductLibraryCount(SqlConnection sqlcon, SeachProducts model)
        {
            StringBuilder       strSql     = new StringBuilder();
            List <SqlParameter> paramsList = new List <SqlParameter>();

            strSql.Append(@"
             SELECT COUNT(1)           
FROM  Tuhu_productcatalog..CarPAR_CatalogHierarchy AS tab3 WITH ( NOLOCK )
  INNER JOIN Tuhu_productcatalog..[CarPAR_zh-CN] AS tab1
  WITH ( NOLOCK ) ON tab3.child_oid = tab1.oid AND tab1.PID IS NOT NULL
  LEFT JOIN Configuration..SE_ProductLibraryConfig AS tab2
  WITH ( NOLOCK ) ON tab1.oid = tab2.Oid
 WHERE  1 = 1 
            ");
            //拼接条件
            var strCondition = GetQueryProductsCondition(paramsList, model);

            strSql.Append(strCondition);
            object count = SqlHelper.ExecuteScalar(sqlcon, CommandType.Text, strSql.ToString(), paramsList.ToArray());

            if (count == null)
            {
                return(0);
            }
            return(Convert.ToInt32(count));
        }
        /// <summary>
        /// 根据查询条件获取产品库优惠券数据列表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public IEnumerable <QueryProductsModel> QueryProductsForProductLibrary(SeachProducts model)
        {
            Func <SqlConnection, IEnumerable <QueryProductsModel> > action = (connection)
                                                                             => ProductLibraryConfigDAL.QueryProductsForProductLibrary(connection, model);

            return(dbManager.Execute(action));
        }
        public static QueryProductsListModel QueryProductsForProductLibrary(SeachProducts model)
        {
            if (!string.IsNullOrWhiteSpace(model.category))
            {
                model.category = !model.category.EndsWith(".") ? model.category + "." : model.category;
                QueryProductsListModel _QueryProductsListModel = new QueryProductsListModel();
                var data = _ProductLibraryConfigManage.QueryProductsForProductLibrary(model);

                if (data != null)
                {
                    _QueryProductsListModel.QueryProducts = data.OrderByDescending(x => x.Maoli).ToList();//list as IEnumerable<QueryProductsModel>;
                    string sessionKey = $"ProductLibraryConfigBrandList{model.category}";
                    using (var client = CacheHelper.CreateCacheClient(nameof(ProductLibraryConfigController)))
                    {
                        var QueryProductsListModel = client.GetOrSet <QueryProductsListModel>(sessionKey, () =>
                        {
                            var queryProductsListModel = new QueryProductsListModel();
                            System.Data.DataSet _FilterConditionItems =
                                _ProductLibraryConfigManage.GetFilterCondition(model.category);
                            if (_FilterConditionItems != null && _FilterConditionItems.Tables.Count <= 3)
                            {
                                if (_FilterConditionItems.Tables[0] != null && _FilterConditionItems.Tables[0].Rows.Count > 0)
                                {
                                    queryProductsListModel.CP_BrandList = _FilterConditionItems.Tables[0].ConvertTo <FilterConditionModel>().ToList() ?? new List <FilterConditionModel>();
                                }

                                if (_FilterConditionItems.Tables[2] != null && _FilterConditionItems.Tables[2].Rows.Count > 0)
                                {
                                    queryProductsListModel.CP_Tire_RimList = _FilterConditionItems.Tables[2].ConvertTo <FilterConditionModel>().ToList() ?? new List <FilterConditionModel>();
                                }

                                if (_FilterConditionItems.Tables[1] != null && _FilterConditionItems.Tables[1].Rows.Count > 0)
                                {
                                    IEnumerable <FilterConditionModel> CP_tabList = _FilterConditionItems.Tables[1].ConvertTo <FilterConditionModel>() ?? new List <FilterConditionModel>();

                                    List <string> tabList = new List <string>();
                                    foreach (var item in CP_tabList)
                                    {
                                        if (!string.IsNullOrWhiteSpace(item.Name))
                                        {
                                            string[] tabArr = item.Name.Split(';');
                                            foreach (var itemarr in tabArr)
                                            {
                                                tabList.Add(itemarr);
                                            }
                                        }
                                    }
                                    queryProductsListModel.CP_tabList = new HashSet <string>(tabList);
                                }
                            }
                            return(queryProductsListModel);
                        }, TimeSpan.FromHours(1)).Value;
                        QueryProductsListModel.QueryProducts = _QueryProductsListModel.QueryProducts;
                        return(QueryProductsListModel);
                    }
                }
                return(_QueryProductsListModel);
            }
            return(null);
        }
示例#5
0
        /// <summary>
        /// 查询产品信息
        /// </summary>
        /// <returns></returns>
        public IEnumerable <QueryProductsModel> QueryProducts(SeachProducts model)
        {
            IEnumerable <QueryProductsModel> result = new List <QueryProductsModel>();

            try
            {
                result = handler.QueryProducts(model);
            }
            catch (Exception ex)
            {
                logger.Log(Level.Error, ex.ToString());
                return(null);
            }
            return(result);
        }
        /// <summary>
        /// 查询产品库优惠券配置
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static QueryProductsListModel QueryProductsForProductLibrary(SeachProducts model)
        {
            if (string.IsNullOrWhiteSpace(model.Category))
            {
                return(null);
            }
            model.Category = !model.Category.EndsWith(".") ? model.Category + "." : model.Category;
            var queryProductModel = new QueryProductsListModel();
            var data = _ProductLibraryConfigManage.QueryProductsForProductLibrary(model, out int queryProductTotalCount);

            if (data == null)
            {
                return(queryProductModel);
            }
            queryProductModel.ProductsTotalCount = queryProductTotalCount;
            queryProductModel.QueryProducts      = data.OrderByDescending(x => x.Maoli).ToList();
            return(queryProductModel);
        }
 /// <summary>
 /// 根据查询条件获取产品库优惠券数据列表
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public IEnumerable <QueryProductsModel> QueryProductsForProductLibrary(SeachProducts model, out int totalCount)
 {
     totalCount = 0;
     try
     {
         List <QueryProductsModel> result = handler.QueryProductsForProductLibrary(model).ToList();
         totalCount = handler.QueryProductsForProductLibraryCount(model);
         if (!result.Any())
         {
             return(result ?? new List <QueryProductsModel>());
         }
         var pids      = new List <string>(result.Count);
         var rulePkIds = new Dictionary <int, bool>(result.Count);
         result.ForEach(r =>
         {
             pids.Add(r.PID);
             r.CouponIds?.Split(',')?.ToList().ForEach(t =>
             {
                 int.TryParse(t, out int id);
                 if (id > 0 && !rulePkIds.ContainsKey(id))
                 {
                     rulePkIds.Add(id, true);
                 }
             });
         });
         var data     = QueryProductSalesInfo(pids);
         var rulesDic = ActivityManager.GetPCodeModelByRulePKIDS(rulePkIds.Keys);
         if (data == null)
         {
             data = new Dictionary <string, ProductSalesPredic>();
         }
         foreach (var x in result)
         {
             data.TryGetValue(x.PID, out ProductSalesPredic p);
             x.cy_list_price = p?.OfficialWebsitePrice ?? 0;
             x.cy_cost       = p?.Cost ?? 0;
             x.Maoli         = x.cy_list_price - x.cy_cost;
             var useCouponEffects = new List <UseCouponEffect>();
             x.CouponIds?.Split(',')?.ToList().ForEach(t =>
             {
                 int.TryParse(t, out int id);
                 if (id > 0 && rulesDic.TryGetValue(id, out GetPCodeModel rule))
                 {
                     if (rule != null)
                     {
                         var useCouponEffect = CalculateUseCouponEffect(x, rule);
                         if (useCouponEffect != null)
                         {
                             useCouponEffects.Add(useCouponEffect);
                         }
                     }
                 }
             });
             if (useCouponEffects.Any())
             {
                 x.UseCouponEffects = useCouponEffects;
                 x.PriceAfterCoupon = useCouponEffects.Min(t => t.PriceAfterCoupon.GetValueOrDefault());
                 x.GrossProfit      = useCouponEffects.Min(t => t.GrossProfit.GetValueOrDefault());
             }
         }
         ;
         return(result);
     }
     catch (Exception ex)
     {
         logger.Log(Level.Error, ex.ToString());
         return(new List <QueryProductsModel>());
     }
 }
        public ActionResult ProductCouponList(SeachProducts search)
        {
            search = search ?? new SeachProducts();
            if (search.PageIndex <= 0)
            {
                search.PageIndex = 1;
            }
            if (search.PageSize <= 0)
            {
                search.PageSize = 100;
            }
            ViewBag.pageIndex = search.PageIndex;
            if (string.IsNullOrWhiteSpace(search.Category))
            {
                search.Category = "1";
            }
            ViewBag.ErrorPId = "";
            search.PidList   = new List <string>();
            if (!string.IsNullOrWhiteSpace(search.PId))
            {
                var pids = search.PId.Split(',');
                foreach (var pid in pids)
                {
                    if (string.IsNullOrWhiteSpace(pid))
                    {
                        continue;
                    }
                    search.PidList.Add(pid.Trim());
                }
            }
            var products = QueryProductsForProductLibrary(search);

            //判断导入PID是否有错误
            if (search.PidList != null && search.PidList.Count > 1 && products != null && products.QueryProducts != null)
            {
                var getPIds = products.QueryProducts.Select(t => t.PID);
                if (getPIds != null && getPIds.Any())
                {
                    var strbErrorPId = new StringBuilder();
                    foreach (var searchPId in search.PidList)
                    {
                        if (!getPIds.Contains(searchPId.Trim()))
                        {
                            strbErrorPId.AppendFormat("{0},", searchPId);
                        }
                    }
                    if (strbErrorPId.Length > 0)
                    {
                        strbErrorPId = strbErrorPId.Remove(strbErrorPId.Length - 1, 1);
                    }
                    ViewBag.ErrorPId = strbErrorPId.ToString();
                }
            }

            if (products != null && products.QueryProducts != null && products.QueryProducts.Any())
            {
                IEnumerable <QueryProductsModel> queryResult = products.QueryProducts;
                if (!string.IsNullOrEmpty(search.SalePriceAfter))//筛选券后最低价
                {
                    var salePriceAfter = search.SalePriceAfter.Split('|');
                    if (salePriceAfter.Length == 2)
                    {
                        queryResult = queryResult.Where(x => x.PriceAfterCoupon >= decimal.Parse(salePriceAfter[0].Trim()) && x.PriceAfterCoupon <= decimal.Parse(salePriceAfter[1].Trim()));
                    }
                }
                else if (!string.IsNullOrEmpty(search.MaoliAfter))//筛选券后毛利
                {
                    var maoliAfter = search.MaoliAfter.Split('|');
                    if (maoliAfter.Length == 2)
                    {
                        queryResult = queryResult.Where(x => x.GrossProfit >= decimal.Parse(maoliAfter[0].Trim()) && x.GrossProfit <= decimal.Parse(maoliAfter[1].Trim()));
                    }
                }
                else if (!string.IsNullOrEmpty(search.Price))//筛选销售价
                {
                    var salePrice = search.Price.Split('|');
                    if (salePrice.Length == 2)
                    {
                        queryResult = queryResult.Where(x => x.cy_list_price >= decimal.Parse(salePrice[0].Trim()) && x.cy_list_price <= decimal.Parse(salePrice[1].Trim()));
                    }
                }
                else if (!string.IsNullOrEmpty(search.CostPrice))//筛选成本价
                {
                    var costPrice = search.CostPrice.Split('|');
                    if (costPrice.Length == 2)
                    {
                        queryResult = queryResult.Where(x => x.cy_cost >= decimal.Parse(costPrice[0].Trim()) && x.cy_cost <= decimal.Parse(costPrice[1].Trim()));
                    }
                }
                if (!string.IsNullOrEmpty(search.MaoliSort) && search.FiltrateType == "SalePriceAfter")
                {
                    if (search.MaoliSort.Contains("asc"))
                    {
                        queryResult = queryResult.OrderBy(x => x.PriceAfterCoupon.GetValueOrDefault());
                    }
                    else
                    {
                        queryResult = queryResult.OrderByDescending(x => x.PriceAfterCoupon.GetValueOrDefault());
                    }
                }
                else if (!string.IsNullOrEmpty(search.MaoliSort) && search.FiltrateType == "GrossMarginAfter")
                {
                    if (search.MaoliSort.Contains("asc"))
                    {
                        queryResult = queryResult.OrderBy(x => x.GrossProfit.GetValueOrDefault());
                    }
                    else
                    {
                        queryResult = queryResult.OrderByDescending(x => x.GrossProfit.GetValueOrDefault());
                    }
                }
                else if (!string.IsNullOrEmpty(search.MaoliSort) && search.FiltrateType == "SalePrice")
                {
                    if (search.MaoliSort.Contains("asc"))
                    {
                        queryResult = queryResult.OrderBy(x => x.cy_list_price);
                    }
                    else
                    {
                        queryResult = queryResult.OrderByDescending(x => x.cy_list_price);
                    }
                }
                else if (!string.IsNullOrEmpty(search.MaoliSort) && search.FiltrateType == "CostPrice")
                {
                    if (search.MaoliSort.Contains("asc"))
                    {
                        queryResult = queryResult.OrderBy(x => x.cy_cost);
                    }
                    else
                    {
                        queryResult = queryResult.OrderByDescending(x => x.cy_cost);
                    }
                }

                products.QueryProducts = queryResult.ToList();
            }

            ViewBag.SearchModel = search;
            if (products.ProductsTotalCount % search.PageSize == 0)
            {
                ViewBag.TotalCount = products.ProductsTotalCount / search.PageSize;
            }
            else
            {
                ViewBag.TotalCount = products.ProductsTotalCount / search.PageSize + 1;
            }

            ViewBag.ProductList = products.QueryProducts;
            ViewBag.pageSize    = search.PageSize;
            return(View());
        }
示例#9
0
        /// <summary>
        /// 生成产品列表查询条件
        /// </summary>
        /// <param name="paramsList">参数化赋值集合</param>
        /// <param name="model">查询条件对象</param>
        /// <returns></returns>
        private static string GetQueryProductsCondition(List <SqlParameter> paramsList, SeachProducts model)
        {
            if (model == null)
            {
                return("");
            }
            if (paramsList == null)
            {
                paramsList = new List <SqlParameter>();
            }
            var strbWhere = new StringBuilder();

            strbWhere.Append("  AND tab3.NodeNo like @NodeNo ");
            paramsList.Add(new SqlParameter("@NodeNo", model.Category + "%"));

            //品牌
            if (!string.IsNullOrWhiteSpace(model.Brand))
            {
                var brandValues = model.Brand.Split(',');
                strbWhere.Append("AND tab1.CP_Brand IN(");
                for (int i = 0; i < brandValues.Length; i++)
                {
                    strbWhere.AppendFormat("@CP_Brand{0},", i);
                    paramsList.Add(new SqlParameter("@CP_Brand" + i, brandValues[i]));
                }
                strbWhere = strbWhere.Remove(strbWhere.Length - 1, 1);
                strbWhere.Append(")");
            }
            //标签
            if (!string.IsNullOrWhiteSpace(model.Tab))
            {
                var tabValues = model.Tab.Split(',');
                strbWhere.Append("AND tab1.CP_Tab IN(");
                for (int i = 0; i < tabValues.Length; i++)
                {
                    strbWhere.AppendFormat("@CP_Tab{0},", i);
                    paramsList.Add(new SqlParameter("@CP_Tab" + i, tabValues[i]));
                }
                strbWhere = strbWhere.Remove(strbWhere.Length - 1, 1);
                strbWhere.Append(")");
            }
            //尺寸
            if (!string.IsNullOrWhiteSpace(model.Rim))
            {
                var rimValues = model.Rim.Split(',');
                strbWhere.Append("AND tab1.CP_Tire_Rim IN(");
                for (int i = 0; i < rimValues.Length; i++)
                {
                    strbWhere.AppendFormat("@CP_Tire_Rim{0},", i);
                    paramsList.Add(new SqlParameter("@CP_Tire_Rim" + i, rimValues[i]));
                }
                strbWhere = strbWhere.Remove(strbWhere.Length - 1, 1);
                strbWhere.Append(")");
            }
            if (model.PidList != null && model.PidList.Any())
            {
                strbWhere.AppendFormat(" And (tab1.OrigProductID IN('{0}') or tab1.PID in ('{0}'))", string.Join("','", model.PidList));
            }
            //优惠券
            if (!string.IsNullOrWhiteSpace(model.CouponIds))
            {
                strbWhere.Append(" AND tab2.CouponIds LIKE @CouponIds ");
                paramsList.Add(new SqlParameter("@CouponIds", "%" + model.CouponIds.Trim() + "%"));
            }
            //花纹
            if (!string.IsNullOrWhiteSpace(model.Pattern))
            {
                strbWhere.Append("AND tab1.CP_Tire_Pattern=@CP_Tire_Pattern ");
                paramsList.Add(new SqlParameter("@CP_Tire_Pattern", model.Pattern.Trim()));
            }
            //是否显示
            if (model.IsShow.HasValue && model.IsShow.Value >= 0)
            {
                strbWhere.AppendFormat(" AND tab4.IsShow={0} ", model.IsShow.Value);
            }
            //上下架
            if (model.OnSale.HasValue)
            {
                strbWhere.AppendFormat(" AND tab1.OnSale={0} ", model.OnSale.Value);
            }

            return(strbWhere.ToString());
        }
示例#10
0
        /// <summary>
        /// 根据查询条件获取产品列表
        /// </summary>
        /// <param name="sqlcon">链接对象</param>
        /// <param name="model">查询对象</param>
        /// <returns></returns>
        public static IEnumerable <QueryProductsModel> QueryProductsForProductLibrary(SqlConnection sqlcon, SeachProducts model)
        {
            if (string.IsNullOrWhiteSpace(model.Category))
            {
                return(null);
            }
            StringBuilder       strSql     = new StringBuilder();
            List <SqlParameter> paramsList = new List <SqlParameter>();

            #region 查询脚本
            strSql.Append(@"
                    SELECT * From(
                    SELECT 
	                    ROW_NUMBER() over(order by   tab1.OrigProductID desc ) rowNumber,
                        tab1.PrimaryParentCategory AS Category ,
                        tab1.oid ,
                        tab1.DisplayName ,
                        tab1.CP_Brand ,
                        tab1.CP_Tab ,
                        tab1.CP_ShuXing5 ,
                        tab1.OnSale ,
                        tab1.PID ,
                        tab1.CP_Tire_Pattern ,
                        tab1.CP_Tire_Rim ,
                        tab1.cy_marketing_price ,
                        tab2.CouponIds ,
                        tab3.NodeNo ,
	                    tab4.IsShow              
                    FROM  Tuhu_productcatalog..CarPAR_CatalogHierarchy AS tab3 WITH ( NOLOCK )
                      INNER JOIN Tuhu_productcatalog..[CarPAR_zh-CN] AS tab1
                      WITH ( NOLOCK ) ON tab3.child_oid = tab1.oid AND tab1.PID IS NOT NULL
                      INNER JOIN Tuhu_productcatalog.dbo.[CarPAR_CatalogProducts] AS tab4 WITH(NOLOCK) ON tab1.oid=tab4.oid 
                      LEFT JOIN Configuration..SE_ProductLibraryConfig AS tab2
                      WITH ( NOLOCK ) ON tab1.oid = tab2.Oid
                     WHERE  1 = 1  
                ");
            #endregion

            //拼接条件
            var strCondition = GetQueryProductsCondition(paramsList, model);
            strSql.Append(strCondition);
            //分页条件
            strSql.AppendFormat(" ) temp where temp.rowNumber>{0} and temp.rowNumber<={1}",
                                (model.PageIndex - 1) * model.PageSize, model.PageSize * model.PageIndex);

            var r = new List <QueryProductsModel>();
            string GetString(SqlDataReader reader, string name) => reader[name] != DBNull.Value ? reader[name].ToString() : null;
            decimal GetDecimal(SqlDataReader reader, string name) => reader[name] != DBNull.Value ? Convert.ToDecimal(reader[name]) : 0;
            int GetInt(SqlDataReader reader, string name) => reader[name] != DBNull.Value ? Convert.ToInt32(reader[name]) : 0;
            bool GetBool(SqlDataReader reader, string name) => reader[name] != DBNull.Value && Convert.ToBoolean(reader[name]);

            using (var reader = SqlHelper.ExecuteReader(sqlcon, CommandType.Text, strSql.ToString(),
                                                        paramsList.ToArray()))
            {
                while (reader.Read())
                {
                    var item = new QueryProductsModel
                    {
                        Oid                = GetInt(reader, "oid"),
                        DisplayName        = GetString(reader, "DisplayName"),
                        CP_Brand           = GetString(reader, "CP_Brand"),
                        CP_Tab             = GetString(reader, "CP_Tab"),
                        CP_ShuXing5        = GetString(reader, "CP_ShuXing5"),
                        OnSale             = GetBool(reader, "OnSale"),
                        PID                = GetString(reader, "PID"),
                        CP_Tire_Pattern    = GetString(reader, "CP_Tire_Pattern"),
                        CP_Tire_Rim        = GetString(reader, "CP_Tire_Rim"),
                        cy_marketing_price = GetDecimal(reader, "cy_marketing_price"),
                        CouponIds          = GetString(reader, "CouponIds"),
                        IsShow             = GetBool(reader, "IsShow") ? 1 : 0
                    };
                    r.Add(item);
                }
            }
            return(r);
        }
        public ActionResult Edit()
        {
            if (Session["ProductLibraryConfigPattern"] != null)
            {
                ViewBag.Pattern = Session["ProductLibraryConfigPattern"] as List <string>;
            }
            else
            {
                List <string> Pattern = _ProductLibraryConfigManage.GetPattern();
                Session["ProductLibraryConfigPattern"] = Pattern;
                ViewBag.Pattern = Pattern;
            }


            int           pageCount = 0;
            SeachProducts search    = new SeachProducts()
            {
                category                                = Request.QueryString["Category"] ?? "Tires",
                brand                                   = Request.QueryString["CP_Brand"] ?? "",
                tab                                     = Request.QueryString["CP_Tab"] ?? "",
                rim                                     = Request.QueryString["CP_Tire_Rim"] ?? "",
                couponIds                               = Request.QueryString["S_Coupon"] ?? "",
                price                                   = Request.QueryString["S_Price"] ?? "",
                SalePriceAfter                          = Request.QueryString["SalePriceAfter"] ?? "",
                CostPrice                               = Request.QueryString["S_CostPrice"] ?? "",
                pid                                     = Request.QueryString["S_PID"] ?? "",
                pattern                                 = Request.QueryString["S_Figure"] ?? "",
                soft                                    = Request.QueryString["S_PiceSoft"] ?? "",
                pageIndex                               = Request.QueryString["pageIndex"] != null?int.Parse(Request.QueryString["pageIndex"]) : 1,
                                               pageSize = Request.QueryString["pageSize"] != null?int.Parse(Request.QueryString["pageSize"]) : 100,
                                                              onSale       = Request.QueryString["onSale"] ?? "",
                                                              maoli        = Request.QueryString["maoli"] ?? "",
                                                              MaoliAfter   = Request.QueryString["maoliAfter"] ?? "",
                                                              maoliSort    = Request.QueryString["maoliSort"] ?? "",
                                                              isShow       = Request.QueryString["S_IsShow"] ?? "",
                                                              FiltrateType = Request.QueryString["filtrateType"] ?? ""
            };

            var products = QueryProductsForProductLibrary(search);

            if (products != null && products.QueryProducts != null && products.QueryProducts.Any())
            {
                //products.QueryProducts = _ProductLibraryConfigManage.CalculateUseCouponEffects(products.QueryProducts).ToList(); //这一行的逻辑已经合并到query里去了,因为多个循环太慢了
                IEnumerable <QueryProductsModel> queryResult = products.QueryProducts;
                if (!string.IsNullOrEmpty(search.SalePriceAfter))//筛选券后最低价
                {
                    var salePriceAfter = search.SalePriceAfter.Split('|');
                    if (salePriceAfter.Length == 2)
                    {
                        queryResult = queryResult.Where(x => x.PriceAfterCoupon >= decimal.Parse(salePriceAfter[0].Trim()) && x.PriceAfterCoupon <= decimal.Parse(salePriceAfter[1].Trim()));
                    }
                }
                else if (!string.IsNullOrEmpty(search.MaoliAfter)) //筛选券后毛利
                {
                    var maoliAfter = search.MaoliAfter.Split('|');
                    if (maoliAfter.Length == 2)
                    {
                        queryResult = queryResult.Where(x => x.GrossProfit >= decimal.Parse(maoliAfter[0].Trim()) && x.GrossProfit <= decimal.Parse(maoliAfter[1].Trim()));
                    }
                }
                else if (!string.IsNullOrEmpty(search.price)) //筛选销售价
                {
                    var salePrice = search.price.Split('|');
                    if (salePrice.Length == 2)
                    {
                        queryResult = queryResult.Where(x => x.cy_list_price >= decimal.Parse(salePrice[0].Trim()) && x.cy_list_price <= decimal.Parse(salePrice[1].Trim()));
                    }
                }
                else if (!string.IsNullOrEmpty(search.CostPrice)) //筛选成本价
                {
                    var costPrice = search.CostPrice.Split('|');
                    if (costPrice.Length == 2)
                    {
                        queryResult = queryResult.Where(x => x.cy_cost >= decimal.Parse(costPrice[0].Trim()) && x.cy_cost <= decimal.Parse(costPrice[1].Trim()));
                    }
                }
                if (!string.IsNullOrEmpty(search.maoliSort) && search.FiltrateType == "SalePriceAfter")
                {
                    if (search.maoliSort.Contains("asc"))
                    {
                        queryResult = queryResult.OrderBy(x => x.PriceAfterCoupon.GetValueOrDefault());
                    }
                    else
                    {
                        queryResult = queryResult.OrderByDescending(x => x.PriceAfterCoupon.GetValueOrDefault());
                    }
                }
                else if (!string.IsNullOrEmpty(search.maoliSort) && search.FiltrateType == "GrossMarginAfter")
                {
                    if (search.maoliSort.Contains("asc"))
                    {
                        queryResult = queryResult.OrderBy(x => x.GrossProfit.GetValueOrDefault());
                    }
                    else
                    {
                        queryResult = queryResult.OrderByDescending(x => x.GrossProfit.GetValueOrDefault());
                    }
                }
                else if (!string.IsNullOrEmpty(search.maoliSort) && search.FiltrateType == "SalePrice")
                {
                    if (search.maoliSort.Contains("asc"))
                    {
                        queryResult = queryResult.OrderBy(x => x.cy_list_price);
                    }
                    else
                    {
                        queryResult = queryResult.OrderByDescending(x => x.cy_list_price);
                    }
                }
                else if (!string.IsNullOrEmpty(search.maoliSort) && search.FiltrateType == "CostPrice")
                {
                    if (search.maoliSort.Contains("asc"))
                    {
                        queryResult = queryResult.OrderBy(x => x.cy_cost);
                    }
                    else
                    {
                        queryResult = queryResult.OrderByDescending(x => x.cy_cost);
                    }
                }

                products.QueryProducts = queryResult.ToList();
                if (products.QueryProducts.Count % search.pageSize == 0)
                {
                    pageCount = products.QueryProducts.Count / search.pageSize;
                }
                else
                {
                    pageCount = (products.QueryProducts.Count / search.pageSize) + 1;
                }
                products.QueryProducts = products.QueryProducts.Skip(search.pageSize * (search.pageIndex - 1))
                                         .Take(search.pageSize).Select(
                    i =>
                {
                    i.PageCount = pageCount;
                    return(i);
                }).ToList();
            }
            QueryProductsListModel model = products;

            ViewBag.pageIndex = Request.QueryString["pageIndex"] != null?int.Parse(Request.QueryString["pageIndex"]) : 1;

            ViewBag.pageSize = Request.QueryString["pageSize"] != null?int.Parse(Request.QueryString["pageSize"]) : 100;

            return(View(model));
        }