예제 #1
0
        /// <summary>
        /// 获取门店 有效参数:AppId(必填),SubName(非必填)
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public ResultDTO <StoreSResultDTO> GetAppStoresExt(StoreLocationParam search)
        {
            ResultDTO <StoreSResultDTO> result = new ResultDTO <StoreSResultDTO>()
            {
                isSuccess = true, Message = "Success", ResultCode = 0, Data = new StoreSResultDTO()
            };

            if (search == null || search.AppId == Guid.Empty)
            {
                result.isSuccess  = false;
                result.ResultCode = -1;
                result.Message    = "参数为空";
                return(result);
            }

            var queryList = new List <IMongoQuery>();
            var q1        = Query <StoreMgDTO> .Where(n => n.AppId == search.AppId);

            queryList.Add(q1);
            if (!search.SubName.IsNullVauleFromWeb())
            {
                queryList.Add(Query <StoreMgDTO> .Where(n => n.Name.Contains(search.SubName)));
            }
            result.Data.Count = MongoCollections.Store.Find(Query.And(queryList)).Count();
            var mglist = MongoCollections.Store.Find(Query.And(queryList)).SetSortOrder(SortBy.Descending("SubTime")).SetSkip((search.CurrentPageIndex - 1) * search.PageSize).SetLimit(search.PageSize).ToList();

            result.Data.Stroes = mglist.ConvertAll(MongoToDto);
            return(result);
        }
예제 #2
0
        /// <summary>
        /// 获取附近门店 有效参数:AppId(必填),Longitude(必填),Latitude(必填),MaxDistance(非必填)
        /// <para>Service Url: http://devbtp.sv.iuoooo.com/Jinher.AMP.BTP.SV.StoreSV.svc/GetAppStoresByLocation
        /// </para>
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public ResultDTO <List <StoreSDTO> > GetAppStoresByLocationExt(StoreLocationParam search)
        {
            ResultDTO <List <StoreSDTO> > result = new ResultDTO <List <StoreSDTO> >()
            {
                isSuccess = true, Message = "Success", ResultCode = 0, Data = new List <StoreSDTO>()
            };

            if (search == null || search.AppId == Guid.Empty)
            {
                result.isSuccess  = false;
                result.ResultCode = -1;
                result.Message    = "参数为空";
                return(result);
            }
            if (search.Longitude > 180 || search.Longitude < -180 || search.Latitude > 90 || search.Latitude < -90)
            {
                result.isSuccess  = false;
                result.ResultCode = -2;
                result.Message    = "参数有误";
                return(result);
            }

            if (search.CurrentPageIndex < 1)
            {
                search.CurrentPageIndex = 1;
            }
            if (search.PageSize <= 0)
            {
                search.PageSize = 20;
            }

            var queryList = new List <IMongoQuery>();

            queryList.Add(Query <StoreMgDTO> .Where(c => c.AppId == search.AppId));
            double maxDistance = 1.0;

            if (search.MaxDistance > 0)
            {
                maxDistance = (double)search.MaxDistance / DistanceHelper.EarthRadius;
            }
            queryList.Add(Query <StoreMgDTO> .Near(c => c.Location, (double)search.Longitude, (double)search.Latitude, maxDistance, true));
            var list = MongoCollections.Store.Find(Query.And(queryList)).SetSkip((search.CurrentPageIndex - 1) * search.PageSize).SetLimit(search.PageSize).ToList();

            if (list.Any())
            {
                result.Data = list.ConvertAll(c => MongoToDto3(c, search.Latitude, search.Longitude));
            }
            return(result);
        }
예제 #3
0
        /// <summary>
        ///  获取门店列表(按用户当前位置到门店的距离排序)
        /// <para>Service Url: http://testbtp.iuoooo.com/Jinher.AMP.BTP.SV.StoreSV.svc/GetStoreByLocation
        /// </para>
        /// </summary>
        /// <param name="slp">参数实体类</param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.NStoreSDTO GetStoreByLocationExt(StoreLocationParam slp)
        {
            if (slp == null)
            {
                return(null);
            }
            else if (slp.AppId == Guid.Empty)
            {
                return(null);
            }
            else if (slp.Longitude > 180 || slp.Longitude < -180)
            {
                return(null);
            }
            else if (slp.Latitude > 90 || slp.Latitude < -90)
            {
                return(null);
            }

            if (slp.CurrentPageIndex < 1)
            {
                slp.CurrentPageIndex = 1;
            }
            if (slp.PageSize <= 0)
            {
                slp.PageSize = 20;
            }

            //GeoNearOptions.SetSpherical
            var queryList = new List <IMongoQuery>();

            queryList.Add(Query <StoreMgDTO> .Where(c => c.AppId == slp.AppId));

            GeoNearResult <StoreMgDTO> ss = MongoCollections.Store.GeoNear(Query.And(queryList), (double)slp.Longitude, (double)slp.Latitude, int.MaxValue);
            var storeMgs = ss.Hits.Skip((slp.CurrentPageIndex - 1) * slp.PageSize).Take(slp.PageSize).ToList();

            NStoreSDTO nsr = new NStoreSDTO();

            if (storeMgs.Any())
            {
                List <StoreSDTO> srList     = storeMgs.ConvertAll <StoreSDTO>(MongoToDto2);
                List <string>    proviences = srList.Select(s => s.Province).Distinct().ToList();
                nsr.Proviences = proviences;
                nsr.Stroes     = srList;
            }
            return(nsr);
        }
예제 #4
0
        public ResultDTO <List <StoreSDTO> > GetAppStoresByLocation(StoreLocationParam search)
        {
            //定义返回值
            ResultDTO <List <StoreSDTO> > result;

            try
            {
                //调用代理方法
                result = base.Channel.GetAppStoresByLocation(search);
            }
            catch
            {
                //抛异常
                throw;
            }
            finally
            {
                //关链接
                ChannelClose();
            }            //返回结果
            return(result);
        }
예제 #5
0
        /// <summary>
        /// 获取餐饮平台聚合门店
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.NStoreSDTO GetCateringPlatformStoreExt(StoreLocationParam param)
        {
            if (param == null)
            {
                return(null);
            }
            else if (param.AppId == Guid.Empty)
            {
                return(null);
            }
            else if (param.Longitude > 180 || param.Longitude < -180)
            {
                return(null);
            }
            else if (param.Latitude > 90 || param.Latitude < -90)
            {
                return(null);
            }

            if (param.CurrentPageIndex < 1)
            {
                param.CurrentPageIndex = 1;
            }
            if (param.PageSize <= 0)
            {
                param.PageSize = 20;
            }
            GeoNearResult <StoreMgDTO> storeList;
            //if (JAP.Cache.GlobalCacheWrapper.ContainsCache("StoreFromMongo", "BTPArea"))
            //{
            //    storeList = (GeoNearResult<StoreMgDTO>)JAP.Cache.GlobalCacheWrapper.GetDataCache("StoreFromMongo", "BTPArea");
            //    int cnt = 0;
            //    if (storeList != null)
            //        cnt = storeList.Hits.Count();
            //    LogHelper.Info("Get_StoreFromMongo___数量:"+cnt);
            //}
            //else
            //{
            List <Guid> pavilionApp = GetPavilionApp(new ZPH.Deploy.CustomDTO.QueryPavilionAppParam {
                Id = param.AppId, pageIndex = 1, pageSize = int.MaxValue
            });
            var queryList = new List <IMongoQuery>();

            queryList.Add(Query <StoreMgDTO> .Where(c => pavilionApp.Contains(c.AppId)));
            storeList = MongoCollections.Store.GeoNear(Query.And(queryList), (double)param.Longitude, (double)param.Latitude, int.MaxValue);
            //JAP.Cache.GlobalCacheWrapper.AddCache("StoreFromMongo", storeList, 300, "BTPArea");
            var storeMgs = storeList.Hits.Skip((param.CurrentPageIndex - 1) * param.PageSize).Take(param.PageSize).ToList();

            NStoreSDTO nsr = new NStoreSDTO();

            if (storeMgs.Any())
            {
                List <StoreSDTO> srList     = storeMgs.ConvertAll <StoreSDTO>(MongoToDto2);
                List <string>    proviences = srList.Select(s => s.Province).Distinct().ToList();
                nsr.Proviences = proviences;
                nsr.Stroes     = srList;
            }
            return(nsr);
        }
예제 #6
0
 /// <summary>
 /// 获取附近门店 有效参数:AppId(必填),Longitude(必填),Latitude(必填),MaxDistance(非必填)
 /// <para>Service Url: http://devbtp.sv.iuoooo.com/Jinher.AMP.BTP.SV.StoreSV.svc/GetAppStoresByLocation
 /// </para>
 /// </summary>
 /// <param name="search"></param>
 /// <returns></returns>
 public ResultDTO <List <StoreSDTO> > GetAppStoresByLocation(StoreLocationParam search)
 {
     base.Do(false);
     return(this.GetAppStoresByLocationExt(search));
 }
예제 #7
0
 /// <summary>
 /// 获取门店 有效参数:AppId(必填),SubName(非必填)
 /// </summary>
 /// <param name="search"></param>
 /// <returns></returns>
 public ResultDTO <StoreSResultDTO> GetAppStores(StoreLocationParam search)
 {
     base.Do(false);
     return(this.GetAppStoresExt(search));
 }