/// <summary>
        /// 获取酒店详细信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public InformationDetail GetDetail(GetInformationDetail input)
        {
            var result = new InformationDetail();

            using (var db = new RTDbContext())
            {
                var information = db.TouristInformations.FirstOrDefault(p => p.Id == input.Id);
                if (information == null)
                {
                    throw new RTException("所选数据不存在");
                }
                if (information.Type != TouristInformationType.Hotel && information.Type != TouristInformationType.Winery)
                {
                    throw new RTException("酒店数据,才有详细信息");
                }

                double distance            = 0;
                string distanceDescription = "";
                if (information.Type == TouristInformationType.Hotel || information.Type == TouristInformationType.Winery)
                {
                    distance = LongitudeAndLatitudeToDistance.GetDistance(input.Longitude, input.Latitude, information.Longitude, information.Latitude);
                    if (distance > 1000)
                    {
                        distanceDescription = string.Format("距我{0}km", (distance / 1000).ToString("f2"));
                    }
                    else
                    {
                        distanceDescription = string.Format("距我{0}m", distance.ToString("f0"));
                    }
                }
                //result.Distance = information.Distance;
                result.Position            = information.Position;
                result.Distance            = distance;
                result.DistanceDescription = distanceDescription;
                result.Name  = information.Name;
                result.Phone = information.Phone;
                result.Price = information.Price;

                var detail = _detail.GetDetail(new GetDetailInput
                {
                    Classify  = (int)information.Type,
                    ProjectId = information.Id
                }, db);
                if (detail == null)
                {
                    return(result);
                }

                result.BigImgUrl = detail.ImgUrl;
                result.Contents  = detail.Paragraphs;
            }
            return(result);
        }
        /// <summary>
        /// 获取旅游信息列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public List <InformationForView> GetList(GetInformationListInput input)
        {
            var result = new List <InformationForView>();

            using (var db = new RTDbContext())
            {
                var list = db.TouristInformations.Where(p => p.Type == input.Type);
                if (list != null && list.Count() != 0)
                {
                    foreach (var item in list)
                    {
                        double distance            = 0;
                        string distanceDescription = "";
                        if (item.Type == TouristInformationType.Hotel || item.Type == TouristInformationType.Winery)
                        {
                            distance = LongitudeAndLatitudeToDistance.GetDistance(input.Longitude, input.Latitude, item.Longitude, item.Latitude);
                            if (distance > 1000)
                            {
                                distanceDescription = string.Format("距我{0}km", (distance / 1000).ToString("f2"));
                            }
                            else
                            {
                                distanceDescription = string.Format("距我{0}m", distance.ToString("f0"));
                            }
                        }

                        result.Add(new InformationForView
                        {
                            Id = item.Id,
                            //Distance = item.Distance,
                            SmallImgUrl         = item.ImgUrl,
                            Name                = item.Name,
                            Phone               = item.Phone,
                            Price               = item.Price,
                            Distance            = distance,
                            DistanceDescription = distanceDescription,
                            Position            = item.Position,
                        });
                    }
                    if (input.Type == TouristInformationType.Hotel)
                    {
                        result = result.OrderBy(p => p.Distance).ToList();
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取地图景点简介信息
        /// </summary>
        public ViewSpotInfoOutput ViewSpotInfo(ViewSpotInfoInput input)
        {
            if (input == null)
            {
                throw new RTException("输入参数不能为空");
            }
            var result = new ViewSpotInfoOutput();

            using (var db = new RTDbContext())
            {
                var viewPort = db.WisdomGuideViewSpots.FirstOrDefault(p => p.Id == input.Id);
                if (viewPort == null)
                {
                    throw new RTException("所选数据不存在");
                }

                #region 根据经纬度计算距离
                double distance            = 0;
                string distanceDescription = "";

                distance = LongitudeAndLatitudeToDistance.GetDistance(input.Longitude, input.Latitude, viewPort.Longitude, viewPort.Latitude);
                if (distance > 1000)
                {
                    distanceDescription = string.Format("距我{0}km", (distance / 1000).ToString("f2"));
                }
                else
                {
                    distanceDescription = string.Format("距我{0}m", distance.ToString("f0"));
                }
                #endregion

                result.ViewSpotName = viewPort.ViewSpotName;
                //result.ViewSpotDescribe = viewPort.ViewSpotDescribe;
                result.Position            = viewPort.Position;
                result.Phone               = viewPort.Phone;
                result.Distance            = distance;
                result.ImgUrl              = viewPort.ImgUrl;
                result.Longitude           = viewPort.Longitude;
                result.Latitude            = viewPort.Latitude;
                result.DistanceDescription = distanceDescription;

                var map = db.WisdomGuideMaps.FirstOrDefault(p => p.WisdomGuideId == viewPort.WisdomGuideId);
                if (map != null)
                {
                    result.MapImgUrl = map.ImgUrl;
                }

                #region 详情
                var detail = _detail.GetDetail(new GetDetailInput
                {
                    ProjectId = viewPort.Id
                }, db);
                if (detail == null)
                {
                    return(result);
                }

                result.BigImgUrl = detail.ImgUrl;
                result.Contents  = detail.Paragraphs;
                #endregion

                result.HasMoreView = false;
                var videoList = db.WisdomGuideViewSpotVideos.Where(p => p.WisdomGuideViewSpotId == viewPort.Id).ToList();
                if (videoList != null && videoList.Count != 0)
                {
                    var video = videoList.FirstOrDefault();
                    result.FirstVoice                       = new ViewSpotVideoDto();
                    result.FirstVoice.ImgUrl                = video.ImgUrl;
                    result.FirstVoice.VoiceUrl              = video.VoiceUrl;
                    result.FirstVoice.VoiceName             = video.VoiceName;
                    result.FirstVoice.WisdomGuideViewSpotId = video.WisdomGuideViewSpotId;

                    if (videoList.Count > 1)
                    {
                        result.HasMoreView = true;
                        result.VoiceList   = new List <ViewSpotVideoDto>();
                        videoList.ForEach(item => {
                            result.VoiceList.Add(new ViewSpotVideoDto {
                                ImgUrl                = item.ImgUrl,
                                VoiceName             = item.VoiceName,
                                VoiceUrl              = item.VoiceUrl,
                                WisdomGuideViewSpotId = item.WisdomGuideViewSpotId
                            });
                        });
                    }
                }
            }
            return(result);
        }