Exemple #1
0
        /// <summary>
        /// 分页获取促销(有分销商)
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        /// <remarks>2016-08-29 周 创建</remarks>
        public Pager <ParaDealerPromotion> DoDealerPromotionQuery(ParaPromotionpager 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.GetDealerPromotion(filter));
        }
        /// <summary>
        /// 分页获取促销(有分销商)
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        /// <remarks>2016-08-29 周 创建</remarks>
        public override Pager <ParaDealerPromotion> GetDealerPromotion(ParaPromotionpager filter)
        {
            const string sql = @"SpPromotion a left join SpPromotionDealer pd on a.sysno=pd.PromotionSysNo left join DsDealer dea on pd.DealerSysNo = dea.SysNo";

            string 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)";
            //判断是否绑定所有分销商
            if (!filter.IsBindAllDealer)
            {
                //判断是否绑定分销商
                if (filter.IsBindDealer)
                {
                    where += " and dea.SysNo = " + filter.DealerSysNo;
                }
                else
                {
                    where += " and dea.CreatedBy = " + filter.DealerCreatedBy;
                }
            }
            if (filter.SelectedAgentSysNo != -1)
            {
                if (filter.SelectedDealerSysNo != -1)
                {
                    where += " and dea.SysNo = " + filter.SelectedDealerSysNo;
                }
                else
                {
                    where += " and dea.CreatedBy = " + filter.SelectedAgentSysNo;
                }
            }
            var dataList  = Context.Select <ParaDealerPromotion>("pd.DealerSysNo,a.*").From(sql).Where(where);
            var dataCount = Context.Select <int>("count(0)").From(sql).Where(where);

            //查询日期上限+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 <ParaDealerPromotion>
            {
                CurrentPage = filter.Id,
                PageSize    = filter.PageSize
            };
            var totalRows = dataCount.QuerySingle();
            var rows      = dataList.OrderBy("a.CreatedDate desc").Paging(pager.CurrentPage, pager.PageSize).QueryMany();

            pager.TotalRows = totalRows;
            pager.Rows      = rows;
            return(pager);
        }
Exemple #3
0
 /// <summary>
 /// 分页获取促销(有分销商)
 /// </summary>
 /// <param name="filter"></param>
 /// <returns></returns>
 /// <remarks>2016-08-29 周 创建</remarks>
 public abstract Pager <ParaDealerPromotion> GetDealerPromotion(ParaPromotionpager filter);