官网页面 全城搜车条件
Inheritance: QueryModel
Exemple #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public string GetWhere(CarGlobalQueryModel query)
        {
            var sqlWhere = new StringBuilder(""); //在售和已售车辆
            //省份
            if (query.provid != null)
            {
                sqlWhere.Append($" and a.provid={query.provid}");
            }

            //城市
            if (query.cityid != null)
            {
                sqlWhere.Append($" and a.cityid={query.cityid}");
            }

            //品牌
            if (query.brand_id != null && query.brand_id != 0)
            {
                sqlWhere.Append($" and a.brand_id={query.brand_id}");
            }

            //车系
            if (query.series_id != null && query.series_id != 0)
            {
                sqlWhere.Append($" and a.series_id={query.series_id}");
            }

            //车型
            if (query.model_id != null && query.model_id != 0)
            {
                sqlWhere.Append($" and a.model_id={query.model_id}");
            }

            //销售价大于..
            if (query.minprice.HasValue)
            {
                sqlWhere.Append($" and a.price>={query.minprice}");
            }

            //销售价小于..
            if (query.maxprice.HasValue)
            {
                sqlWhere.Append($" and a.price<={query.maxprice}");
            }

            //上牌时间 <
            if (query.minyear.HasValue)
            {
                var date = DateTime.Now.AddYears(-query.minyear.Value).ToShortDateString();
                sqlWhere.Append($" and a.register_date<='{date}'");
            }

            //上牌时间 >
            if (query.maxyear.HasValue)
            {
                var date = DateTime.Now.AddYears(-query.maxyear.Value).ToShortDateString();
                sqlWhere.Append($" and a.register_date>='{date}'");
            }

            //行驶里程 >
            if (query.minmileage.HasValue)
            {
                sqlWhere.Append($" and a.mileage>='{query.minmileage}'");
            }

            //行驶里程 <
            if (query.maxmileage.HasValue)
            {
                sqlWhere.Append($" and a.mileage<='{query.maxmileage}'");
            }

            //颜色
            if (query.colorid.HasValue)
            {
                sqlWhere.Append($" and a.colorid={query.colorid}");
            }

            //排量
            if (!string.IsNullOrWhiteSpace(query.liter))
            {
                sqlWhere.Append($" and c3.liter='{query.liter.Trim()}'");
            }

            //变速箱类型
            if (!string.IsNullOrWhiteSpace(query.gear))
            {
                sqlWhere.Append($" and c3.geartype='{query.gear.Trim()}'");
            }

            //车源类型
            if (query.type.HasValue)
            {
                sqlWhere.Append($" and a.seller_type={query.type}");
            }

            //关键字搜索
            if (!string.IsNullOrWhiteSpace(query.keyword))
            {
                sqlWhere.Append($" and (c1.brandname like '%{query.keyword}%' or c2.seriesname like '%{query.keyword}%' or a.carno='{query.keyword}')");
            }
            return sqlWhere.ToString();
        }
Exemple #2
0
        /// <summary>
        /// 全城搜车(官网页面)(查询到置顶车辆)
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <param name="strwhere"></param>
        /// <returns></returns>
        public BasePageList<CarInfoListViewModel> SearchCarPageListTop(CarGlobalQueryModel query, out string strwhere)
        {
            const string spName = "sp_common_pager";
            const string tableName = @"car_info as a
                                    left join base_carbrand as c1 on a.brand_id=c1.innerid
                                    left join base_carseries as c2 on a.series_id=c2.innerid
                                    left join base_carmodel as c3 on a.model_id=c3.innerid
                                    left join base_city as ct on a.cityid=ct.innerid ";
            const string fields = "a.innerid,a.custid,a.pic_url,a.price,a.buyprice,a.dealprice,a.buytime,a.status,a.mileage,a.register_date,a.seller_type as type,c1.brandname as brand_name,c2.seriesname as series_name,c3.modelname as model_name,ct.cityname,(select count(1) from car_tipoff where carid=a.innerid and status=1) as toNum";
            var orderField = string.IsNullOrWhiteSpace(query.Order) ? "a.istop desc,a.refreshtime desc" : query.Order;

            #region 查询条件
            var sqlWhere = new StringBuilder("a.seller_type<>3 and a.status=1 and a.istop>0");
            sqlWhere.Append(GetWhere(query));
            #endregion

            strwhere = sqlWhere.ToString().Replace("a.status=1 and a.istop>0", "").Trim();   //只需要手动设置的条件
            var model = new PagingModel(spName, tableName, fields, orderField, sqlWhere.ToString(), query.PageSize, query.PageIndex);
            var list = Helper.ExecutePaging<CarInfoListViewModel>(model, query.Echo);
            return list;
        }
Exemple #3
0
        /// <summary>
        /// 查询神秘车源列表
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <returns></returns>
        public BasePageList<CarMysteriousListModel> GetMysteriousCarPageList(CarGlobalQueryModel query)
        {
            const string spName = "sp_common_pager";
            const string tableName = @"car_info as a
                                    left join base_carbrand as c1 on a.brand_id=c1.innerid
                                    left join base_carseries as c2 on a.series_id=c2.innerid
                                    left join base_carmodel as c3 on a.model_id=c3.innerid
                                    left join base_city as ct on a.cityid=ct.innerid";
            const string fields = "a.innerid,a.supplierid,a.carno,a.pic_url,a.price,a.status,a.mileage,a.register_date,c1.brandname as brand_name,c2.seriesname as series_name,c3.modelname as model_name,ct.cityname";
            var orderField = string.IsNullOrWhiteSpace(query.Order) ? "a.refreshtime desc" : query.Order;

            #region 查询条件
            var sqlWhere = new StringBuilder("a.seller_type=3 and (a.status=1 or a.status=2)"); //在售和已售车辆
            query.type = null;
            sqlWhere.Append(GetWhere(query));
            #endregion

            var model = new PagingModel(spName, tableName, fields, orderField, sqlWhere.ToString(), query.PageSize, query.PageIndex);
            var list = Helper.ExecutePaging<CarMysteriousListModel>(model, query.Echo);
            return list;
        }