/// <summary> /// 分页查询商品 /// </summary> /// <param name="queryFilter"></param> /// <returns></returns> public static QueryResult <ProductCommonInfo> QueryCommonProduct(ProducCommonQueryFilter queryFilter) { if (queryFilter == null || string.IsNullOrEmpty(queryFilter.VendorSysNo)) { throw new BusinessException("商家编号不能为空"); } return(ProductDA.QueryCommonProduct(queryFilter)); }
public JsonResult QueryProductCommon() { ProducCommonQueryFilter qFilter = BuildQueryFilterEntity <ProducCommonQueryFilter>(); qFilter.VendorSysNo = UserAuthHelper.GetCurrentUser().SellerSysNo.ToString(); var result = ProductService.QueryCommonProduct(qFilter); return(AjaxGridJson(result)); }
/// <summary> /// 分页查询商品 /// </summary> /// <param name="queryFilter"></param> /// <returns></returns> public static QueryResult <ProductCommonInfo> QueryCommonProduct(ProducCommonQueryFilter queryFilter) { CustomDataCommand command = DataCommandManager.CreateCustomDataCommandFromConfig("QueryCommonProduct"); using (var sqlBuilder = new DynamicQuerySqlBuilder(command.CommandText, command, queryFilter, string.IsNullOrEmpty(queryFilter.SortFields) ? "P.[SysNo] ASC" : queryFilter.SortFields)) { if (!string.IsNullOrEmpty(queryFilter.VendorSysNo)) { sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "V.[SysNo]", DbType.Int32, "@VendorSysNo", QueryConditionOperatorType.Equal, queryFilter.VendorSysNo); } if (!string.IsNullOrEmpty(queryFilter.BrandSysNo)) { sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "P.[BrandSysNo]", DbType.Int32, "@BrandSysNo", QueryConditionOperatorType.Equal, queryFilter.BrandSysNo); } if (!string.IsNullOrEmpty(queryFilter.ProductID)) { sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "P.[ProductID]", DbType.String, "@ProductID", QueryConditionOperatorType.Like, queryFilter.ProductID); } if (!string.IsNullOrEmpty(queryFilter.ProductTitle)) { sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "P.[ProductTitle]", DbType.String, "@ProductTitle", QueryConditionOperatorType.Like, queryFilter.ProductTitle); } if (!string.IsNullOrEmpty(queryFilter.FrontCategorySysNo)) { sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "PE.[FrontCategorySysNo]", DbType.Int32 , "@FrontCategorySysNo", QueryConditionOperatorType.Like, Convert.ToInt32(queryFilter.FrontCategorySysNo)); } if (!string.IsNullOrEmpty(queryFilter.Status)) { sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "P.[Status]", DbType.Int32, "@Status", QueryConditionOperatorType.Equal, queryFilter.Status); } if (queryFilter.CreateTimeBegin != null && queryFilter.CreateTimeBegin != new DateTime()) { sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "P.[CreateTime]", DbType.DateTime, "@CreateTimeBegin", QueryConditionOperatorType.MoreThanOrEqual, queryFilter.CreateTimeBegin.ToString("yyyy-MM-dd")); } if (queryFilter.CreateTimeEnd != null && queryFilter.CreateTimeEnd != new DateTime()) { sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "P.[CreateTime]", DbType.DateTime, "@CreateTimeEnd", QueryConditionOperatorType.LessThan, queryFilter.CreateTimeEnd.AddDays(1).ToString("yyyy-MM-dd")); } if (!string.IsNullOrEmpty(queryFilter.GroupName)) { sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "PG.[ProductName]", DbType.String, "@GroupName", QueryConditionOperatorType.Like, queryFilter.GroupName); } if (!string.IsNullOrEmpty(queryFilter.ProductTradeType)) { sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "PE.[ProductTradeType]", DbType.String, "@ProductTradeType", QueryConditionOperatorType.Equal, queryFilter.ProductTradeType); } command.CommandText = sqlBuilder.BuildQuerySql(); List <ProductCommonInfo> resultList = command.ExecuteEntityList <ProductCommonInfo>(); int totalCount = Convert.ToInt32(command.GetParameterValue("@TotalCount")); return(new QueryResult <ProductCommonInfo>() { PageInfo = new PageInfo() { PageIndex = queryFilter.PageIndex, PageSize = queryFilter.PageSize, TotalCount = totalCount, SortBy = queryFilter.SortFields }, ResultList = resultList }); } }