/// <summary> /// 分页获取促销 /// </summary> /// <param name="filter">筛选条件</param> /// <returns>分页列表</returns> /// <remarks> /// 2013-08-21 黄志勇 创建 /// 2014-01-09 朱家宏 增加使用平台查询 /// </remarks> public Pager <SpPromotion> DoPromotionQuery(ParaPromotion filter) { if (filter.UsePlatform != null) { switch (filter.UsePlatform) { case (int)PromotionStatus.促销使用平台.PC商城: filter.WebPlatform = 1; break; case (int)PromotionStatus.促销使用平台.门店: filter.ShopPlatform = 1; break; case (int)PromotionStatus.促销使用平台.手机商城: filter.MallAppPlatform = 1; break; case (int)PromotionStatus.促销使用平台.物流App: filter.LogisticsAppPlatform = 1; break; } } return(ISpPromotionDao.Instance.GetPromotion(filter)); }
/// <summary> /// 分页获取促销 /// </summary> /// <param name="filter">筛选条件</param> /// <returns>分页列表</returns> /// <remarks> /// 2013-08-21 黄志勇 创建 /// 2013-12-31 朱家宏 添加过期时间 /// 2014-01-09 朱家宏 添加使用平台查询 /// </remarks> public override Pager <SpPromotion> GetPromotion(ParaPromotion filter) { const string sql = @"(select a.* from SpPromotion a where (@0 is null or charindex(a.Name,@0)>0) and --促销名称 (@1 is null or a.PromotionType=@1) and --优惠券类型 (@2 is null or a.Status=@2) and --状态 (@3 is null or a.StartTime>=@3) and --开始时间 (@4 is null or a.EndTime<@4) and --结束时间 (@5 is null or a.IsUsePromotionCode=@5) and --是否使用促销代码 (@6 = 0 or not exists(select 1 from SpPromotionOverlay where PromotionSysNo=a.SysNo)) and --是否为促销叠加 (@7 is null or a.EndTime>=@7) and --过期时间 (@8 is null or a.WebPlatform=@8) and (@9 is null or a.ShopPlatform=@9) and (@10 is null or a.MallAppPlatform=@10) and (@11 is null or a.LogisticsAppPlatform=@11) ) tb"; var dataList = Context.Select <SpPromotion>("tb.*").From(sql); var dataCount = Context.Select <int>("count(0)").From(sql); //查询日期上限+1 filter.EndTime = filter.EndTime == null ? (DateTime?)null : filter.EndTime.Value.AddDays(1); var paras = new object[] { filter.Name, filter.PromotionType, filter.Status, filter.StartTime, filter.EndTime, filter.IsUsePromotionCode, filter.IsOverlay, filter.ExpiredTime, filter.WebPlatform, filter.ShopPlatform, filter.MallAppPlatform, filter.LogisticsAppPlatform }; dataList.Parameters(paras); dataCount.Parameters(paras); var pager = new Pager <SpPromotion> { CurrentPage = filter.Id, PageSize = filter.PageSize }; var totalRows = dataCount.QuerySingle(); var rows = dataList.OrderBy("tb.CreatedDate desc").Paging(pager.CurrentPage, pager.PageSize).QueryMany(); pager.TotalRows = totalRows; pager.Rows = rows; return(pager); }
/// <summary> /// 分页获取促销 /// </summary> /// <param name="filter">筛选条件</param> /// <returns>分页列表</returns> /// <remarks>2013-08-21 黄志勇 创建</remarks> public abstract Pager <SpPromotion> GetPromotion(ParaPromotion filter);