/// <summary> ///商品促销信息分页查询 /// </summary> /// <param name="model">输入查询参数对象</param> /// <returns></returns> /// <remarks>added by jimmy,2015-7-10</remarks> public ResultModel Select(SearchProductRuleModel model) { var sr = _database.Db.ProductRule; //商品促销 var product = _database.Db.Product; //订单对象 var salesRule = _database.Db.SalesRule; //促销规则 var productlang = _database.Db.Product_Lang; var whereParam = new SimpleExpression(1, 1, SimpleExpressionType.Equal); if (model.ProductId != 0) { whereParam = new SimpleExpression(whereParam, sr.ProductId == model.ProductId, SimpleExpressionType.And); } if (model.SalesRuleId != 0) { whereParam = new SimpleExpression(whereParam, sr.SalesRuleId == model.SalesRuleId, SimpleExpressionType.And); } dynamic pl; dynamic _srule; dynamic pd; var sd = sr.Query(). LeftJoin(product, out pd).On(pd.ProductId == sr.ProductId). LeftJoin(salesRule, out _srule).On(_srule.SalesRuleId == sr.SalesRuleId). LeftJoin(productlang, out pl).On(pl.ProductId == sr.ProductId). Where(pl.LanguageID == model.LanguageID). Select( sr.ProductRuleId, pl.ProductName, sr.ProductId, salesRule.RuleName, salesRule.SalesRuleId, sr.PrdoctRuleName, sr.BuyQty, sr.SendQty, sr.Discount, pd.HKPrice, (pd.HKPrice * sr.Discount).As("SalePrice"), sr.Price, pd.Status, sr.StarDate, sr.EndDate). Where(sr.SalesRuleId > 1). Where(whereParam). OrderByProductRuleIdDescending(); var result = new ResultModel { Data = new SimpleDataPagedList <ProductRuleModel>(sd, model.PagedIndex, model.PagedSize) }; return(result); }
/// <summary> /// 查询商品促销信息列表 /// </summary> /// <param name="model">搜索实体对象</param> /// <returns></returns> /// <remarks>added by jimmy,2015-7-3</remarks> public JsonResult List(SearchProductRuleModel model) { model.PagedSize = model.PagedSize == 0 ? 10 : model.PagedSize; var list = _productRuleService.Select(new SearchProductRuleModel { PagedIndex = model.PagedIndex, PagedSize = model.PagedSize, SalesRuleId = model.SalesRuleId, ProductId = model.ProductId, LanguageID = ACultureHelper.GetLanguageID }); var data = new { rows = list.Data, total = list.Data.TotalCount }; return(Json(data, JsonRequestBehavior.AllowGet)); }