public List<PromotionAmountDiscountQuery> Query(PromotionAmountDiscountQuery query, out int totalCount, string eventtype)
        {

            try
            {
                List<PromotionAmountDiscountQuery> _list = _padDao.Query(query, out totalCount, eventtype);
                if (_list.Count > 0)
                {
                    ShopClassDao _scDao = new ShopClassDao(connStr);
                    VipUserGroupDao _vugDao = new VipUserGroupDao(connStr);
                    SiteDao _sDao = new SiteDao(connStr);
                    foreach (PromotionAmountDiscountQuery item in _list)
                    {
                        if (item.class_id != 0)
                        {
                            item.class_name = _scDao.QueryStore(item.class_id).FirstOrDefault().class_name;
                        }
                        if (item.brand_id != 0)
                        {
                            item.brand_name = _vendorBrandDao.GetProductBrand(new VendorBrand { Brand_Id = Convert.ToUInt32(item.brand_id) }).Brand_Name;
                        }
                        if (item.group_id != 0)
                        {
                            item.group_name = _vugDao.GetModelById(Convert.ToUInt32(item.group_id)).group_name;
                        }
                        string[] arrySite = item.siteId.Split(',');
                        foreach (string i in arrySite)
                        {
                            if (i != "" && i != "0")
                            {
                                item.site += _sDao.Query(new Site { Site_Id = Convert.ToUInt32(i) }).FirstOrDefault().Site_Name + ",";
                            }
                        }
                        item.site = item.site.TrimEnd(',');
                        item.isallclass = GetProductFromProCatSetAsCid(item.category_id, 999999);
                    }
                }
                return _list;
            }
            catch (Exception ex)
            {
                throw new Exception("PromotionsAmountDiscountMgr-->Query-->" + ex.Message, ex);
            }
        }
        public HttpResponseBase DiscountZheList()
        {
            List<PromotionAmountDiscountQuery> store = new List<PromotionAmountDiscountQuery>();
            string json = string.Empty;
            try
            {
                PromotionAmountDiscountQuery query = new PromotionAmountDiscountQuery();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");

                if (!string.IsNullOrEmpty(Request.Params["limit"]))
                {
                    query.Limit = Convert.ToInt32(Request.Params["limit"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["expiredSel"]))
                {
                    query.expired = Convert.ToInt32(Request.Params["expiredSel"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["isurl"]))
                {
                    query.url_by = Convert.ToInt32(Request.Params["isurl"]);
                }
                else
                {
                    query.url_by = -1;
                }

                query.event_type = "M1";
                int totalCount = 0;
                store = _promoAmountDiscountMgr.Query(query, out totalCount, query.event_type);
                foreach (var item in store)
                {
                    if (item.banner_image != "")
                    {
                        item.banner_image = imgServerPath + promoPath + item.banner_image;
                    }
                    else
                    {
                        item.banner_image = defaultImg;
                    }
                }

                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                //listUser是准备转换的对象
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據

            }
            catch (Exception ex)
            {

                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
        /// <summary>
        /// 查詢數據 
        /// </summary>
        /// <param name="query">查詢參數</param>
        /// <param name="totalCount">查詢出來的數量</param>
        /// <param name="eventtype"></param>
        /// <returns>返回列表所需數據</returns>
        public List<PromotionAmountDiscountQuery> Query(PromotionAmountDiscountQuery query, out int totalCount, string eventtype)
        {
            query.Replace4MySQL();
            StringBuilder condition = new StringBuilder();
            StringBuilder TempCol = new StringBuilder();
            try
            {
                TempCol.Append(@"select CONCAT(pad.event_type ,right(CONCAT('00000000',pad.id),6)) as 'event_id',pad.url_by, pad.id,
                                pad.name,pad.active*1 as 'active', pad.event_desc ,pad.class_id,pad.brand_id,pad.amount,pad.quantity,pad.discount,pad.product_id,
                                pc.category_id,pc.banner_image,pc.category_link_url 'category_link_url',pad.group_id,tp.parameterName 'devicename',
                                pad.condition_id,uc.condition_name,pad.vendor_coverage,pad.site as 'siteId',pad.start 'startdate',pad.end 'enddate',pad.muser,mu.user_username ");
                condition.Append("  from  promotions_amount_discount  pad LEFT JOIN manage_user mu ON pad.muser=mu.user_id ");
                condition.Append(" left join product_category  pc on pc.category_id=pad.category_id ");
                condition.Append(" left join user_condition  uc on uc.condition_id =pad.condition_id ");
                condition.Append(" left join (select parameterCode,parameterName from t_parametersrc where parameterType='device'  ) tp on tp.parameterCode=pad.device ");

                condition.AppendFormat(" where pad.status=1 ");
                if (query.url_by != -1)
                {
                    condition.AppendFormat(" and pad.url_by = '{0}' ", query.url_by);
                }

                if (query.id > 0)
                {
                    condition.AppendFormat(" and pad.id = '{0}' ", query.id);
                }
                if (eventtype != "")
                {
                    if (eventtype == "M1")
                    {
                        condition.AppendFormat(" and (pad.event_type='{0}'  OR pad.event_type='') ", eventtype);
                    }
                    else
                    {
                        condition.AppendFormat(" and pad.event_type='{0}' ", eventtype);
                    }
                }

                if (query.expired == 0)//是未過期
                {
                    condition.AppendFormat(" and pad.end >= '{0}' ", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                else if (query.expired == 1)
                {
                    condition.AppendFormat(" and pad.end < '{0}' ", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                condition.AppendFormat(" ORDER BY pad.id desc ");
                totalCount = 0;
                if (query.IsPage)
                {
                    System.Data.DataTable _dt = _access.getDataTable("select count(pad.id) as totalCount " + condition.ToString());
                    if (_dt != null && _dt.Rows.Count > 0)
                    {
                        totalCount = Convert.ToInt32(_dt.Rows[0]["totalCount"]);
                    }
                    condition.AppendFormat(" limit {0},{1}", query.Start, query.Limit);
                }
                TempCol.Append(condition.ToString());

                return _access.getDataTableForObj<PromotionAmountDiscountQuery>(TempCol.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("PromotionsAmountDiscountDao-->Query-->" + ex.Message + TempCol.ToString(), ex);
            }
        }