Exemplo n.º 1
0
        public async Task <IEnumerable <ServiceDTO> > GetNearbyServices(double longitude, double latitude, int pageIndex, int pageSize, string key, string category, string subCategory, string appId = "GOOIOS001")
        {
            var services  = new List <ServiceDTO>();
            var skipCount = (pageIndex - 1) * pageSize;

            var result = _serviceRepository.GetPaged(pageIndex, pageSize,
                                                     o => (o.Title.Contains(key) || string.IsNullOrEmpty(key)) &&
                                                     (o.Category == category || string.IsNullOrEmpty(category)) &&
                                                     (o.SubCategory == subCategory || string.IsNullOrEmpty(subCategory)) &&
                                                     (o.Status != ServiceStatus.Deleted) &&
                                                     (string.IsNullOrEmpty(appId) || o.ApplicationId == appId) &&
                                                     (o.ServeScope >= (GetDistance(longitude, latitude, o.Longitude, o.Latitude) / 1000) || o.ServeScope == 0),
                                                     o => GetDistance(longitude, latitude, o.Longitude, o.Latitude), true);

            foreach (var o in result)
            {
                o.ResolveAddress();

                var serviceImgs = _serviceImageRepository.GetFiltered(g => g.ServiceId == o.Id)?.ToList() ?? new List <ServiceImage>();
                var ids         = serviceImgs.Select(i => i.ImageId).ToList();
                var imgs        = await _imageServiceProxy.GetImagesByIds(ids);

                var servicePhone = "";
                var organization = await _organizationServiceProxy.GetOrganizationById(o.OrganizationId);

                var logoImgUrl = "";
                if (organization != null)
                {
                    var logoImg = await _imageServiceProxy.GetImageById(organization.LogoImageId);

                    logoImgUrl   = logoImg?.HttpPath;
                    servicePhone = organization.CustomServicePhone;
                }

                services.Add(new ServiceDTO
                {
                    Category       = o.Category,
                    Id             = o.Id,
                    Introduction   = o.Introduction,
                    OrganizationId = o.OrganizationId,
                    ServeScope     = o.ServeScope,
                    SincerityGold  = o.SincerityGold,
                    Station        = o.Station,
                    Status         = o.Status,
                    SubCategory    = o.SubCategory,
                    Title          = o.Title,
                    Images         = imgs?.Select(img => new ServiceImageDTO {
                        Description = img.Description, HttpPath = img.HttpPath, ImageId = img.Id, ServiceId = o.Id, Title = img.Title
                    }) ?? new List <ServiceImageDTO>(),
                    OrganizationLogoUrl = logoImgUrl,
                    OrganizationName    = organization?.ShortName,
                    Distance            = ProcessDistance(GetDistance(longitude, latitude, o.Longitude, o.Latitude)),
                    ServicePhone        = servicePhone,
                    IsAdvertisement     = o.IsAdvertisement,
                    PersonalizedPageUri = o.PersonalizedPageUri,
                    ApplicationId       = o.ApplicationId
                });
            }
            return(services);
        }
Exemplo n.º 2
0
        public async Task <IEnumerable <TopicDTO> > GetNearbyTopics(double longitude, double latitude, int pageIndex, int pageSize, string key = "", string appId = "")
        {
            var topics    = new List <TopicDTO>();
            var skipCount = (pageIndex - 1) * pageSize;

            var result = _topicRepository.GetPaged(pageIndex, pageSize,
                                                   o => (o.Title.Contains(key) || string.IsNullOrEmpty(key)) && (o.ApplicationId == appId || string.IsNullOrEmpty(appId)) && (o.IsSuspend == false),
                                                   o => GetDistance(longitude, latitude, o.Longitude, o.Latitude), true);

            foreach (var o in result)
            {
                o.ResolveAddress();

                var serviceImgs  = _topicImageRepository.GetFiltered(g => g.TopicId == o.Id)?.ToList() ?? new List <TopicImage>();
                var servicePhone = "";
                var organization = await _organizationServiceProxy.GetOrganizationById(o.OrganizationId);

                var logoImgUrl = "";
                var shortName  = "";
                if (organization != null)
                {
                    var logoImg = await _imageServiceProxy.GetImageById(organization.LogoImageId);

                    logoImgUrl   = logoImg?.HttpPath;
                    servicePhone = organization.CustomServicePhone;
                    shortName    = organization.ShortName;
                }

                topics.Add(new TopicDTO
                {
                    Address  = o.Address,
                    Category = o.Category,
                    //ContentImages = imgs,
                    CreatedBy           = o.CreatedBy,
                    CreatedOn           = o.CreatedOn,
                    CustomTopicUrl      = o.CustomTopicUrl,
                    EndDate             = o.EndDate,
                    FaceImageUrl        = o.FaceImageUrl,
                    Id                  = o.Id,
                    Introduction        = o.Introduction,
                    IsCustom            = o.IsCustom,
                    IsSuspend           = o.IsSuspend,
                    LastUpdBy           = o.LastUpdBy,
                    LastUpdOn           = o.LastUpdOn,
                    OrganizationId      = o.OrganizationId,
                    OrganizationName    = shortName,
                    StartDate           = o.StartDate,
                    Title               = o.Title,
                    Distance            = ProcessDistance(GetDistance(longitude, latitude, o.Longitude, o.Latitude)),
                    OrganizationLogoUrl = logoImgUrl,
                    CreatorName         = o.CreatorName,
                    CreatorPortraitUrl  = o.CreatorPortraitUrl
                });
            }
            return(topics);
        }
Exemplo n.º 3
0
        public async Task <IEnumerable <GoodsDTO> > GetNearbyGoods(double longitude, double latitude, string category, string subCategory, int pageIndex, int pageSize = 10, string appId = "GOOIOS001")
        {
            var goods = new List <GoodsDTO>();

            var result = _onlineGoodsRepository.GetPaged(pageIndex, pageSize,
                                                         o => (o.Status == GoodsStatus.Shelved || o.Status == GoodsStatus.SoldOut || o.Status == GoodsStatus.UnShelved) &&
                                                         (o.Category == category || string.IsNullOrEmpty(category)) &&
                                                         (o.SubCategory == subCategory || string.IsNullOrEmpty(subCategory)) &&
                                                         (string.IsNullOrEmpty(appId) || o.ApplicationId == appId) &&
                                                         (o.DistributionScope >= (GetDistance(longitude, latitude, o.Longitude, o.Latitude) / 1000) || o.DistributionScope == 0),
                                                         o => GetDistance(longitude, latitude, o.Longitude, o.Latitude), true);

            foreach (var item in result)
            {
                var organization = await _organizationServiceProxy.GetOrganizationById(item.StoreId);

                var logoImgUrl = "";
                if (organization != null)
                {
                    var logoImg = await _imageServiceProxy.GetImageById(organization.LogoImageId);

                    logoImgUrl = logoImg?.HttpPath;
                }

                var conditions = _grouponConditionRepository.GetFiltered(o => o.GoodsId == item.Id);

                goods.Add(new GoodsDTO
                {
                    Category    = item.Category,
                    Description = item.Description,
                    Detail      = item.Detail,
                    Id          = item.Id,
                    ItemNumber  = item.ItemNumber,
                    MarketPrice = item.MarketPrice,
                    OptionalPropertyJsonObject = item.OptionalPropertyJsonObject,
                    Status              = item.Status,
                    Stock               = item.Stock,
                    StoreId             = item.StoreId,
                    SubCategory         = item.SubCategory,
                    Title               = item.Title,
                    Unit                = item.Unit,
                    UnitPrice           = item.UnitPrice,
                    Address             = item.Address,
                    Distance            = ProcessDistance(GetDistance(longitude, latitude, item.Longitude, item.Latitude)),
                    DistributionScope   = item.DistributionScope,
                    ApplicationId       = item.ApplicationId,
                    OrganizationId      = organization?.Id,
                    OrganizationLogoUrl = logoImgUrl,
                    VideoPath           = item.VideoPath,
                    OrganizationName    = organization?.ShortName,
                    Order               = item.Order,
                    RecommendLevel      = item.RecommendLevel,
                    GoodsCategoryName   = item.GoodsCategoryName,
                    GrouponConditions   = conditions?.Select(obj => new GrouponConditionDTO
                    {
                        GoodsId        = obj.GoodsId,
                        Id             = obj.Id,
                        MoreThanNumber = obj.MoreThanNumber,
                        Price          = obj.Price
                    }).OrderBy(g => g.MoreThanNumber).ToList()
                });
            }

            if (goods != null && goods.Count() > 0)
            {
                foreach (var item in goods)
                {
                    item.GoodsImages = _onlineGoodsImageRepository.GetFiltered(o => o.GoodsId == item.Id).Select(image => new GoodsImageDTO {
                        ImageId = image.ImageId, GoodsId = image.GoodsId, Id = image.Id
                    }).ToList();

                    var imageIds = item.GoodsImages.Select(o => o.ImageId).ToList();
                    var images   = await _imageServiceProxy.GetImagesByIds(imageIds);

                    foreach (var img in item.GoodsImages)
                    {
                        var pic = images.FirstOrDefault(o => o.Id == img.ImageId);

                        img.HttpPath    = pic?.HttpPath;
                        img.Title       = pic?.Title;
                        img.Description = pic?.Description;
                    }
                }
            }
            return(goods);
        }
Exemplo n.º 4
0
        public async Task <IEnumerable <ServicerDTO> > GetNearbyServicers(double longitude, double latitude, int pageIndex, int pageSize, string key, string category, string subCategory, string appId = "GOOIOS001")
        {
            var services  = new List <ServicerDTO>();
            var skipCount = (pageIndex - 1) * pageSize;
            var result    = _servicerRepository.GetPaged(pageIndex, pageSize,
                                                         o => (o.Name == key || string.IsNullOrEmpty(key)) &&
                                                         (o.Category == category || string.IsNullOrEmpty(category)) &&
                                                         (o.SubCategory == subCategory || string.IsNullOrEmpty(subCategory)) &&
                                                         (string.IsNullOrEmpty(appId) || o.ApplicationId == appId), o => GetDistance(longitude, latitude, o.Longitude, o.Latitude), true);

            foreach (var o in result)
            {
                o.ResolveAddress();

                var servicerImgs = _servicerImageRepository.GetFiltered(g => g.ServicerId == o.Id).ToList();
                var ids          = servicerImgs.Select(i => i.ImageId).ToList();
                var imgs         = await _imageServiceProxy.GetImagesByIds(ids);

                var organization = await _organizationServiceProxy.GetOrganizationById(o.OrganizationId);

                var logoImgUrl = "";
                if (organization != null)
                {
                    var logoImg = await _imageServiceProxy.GetImageById(organization.LogoImageId);

                    logoImgUrl = logoImg?.HttpPath;
                }

                var portrailImageUrl = "";
                var portrailImage    = await _imageServiceProxy.GetImageById(o.PortraitImageId);

                if (portrailImage != null)
                {
                    portrailImageUrl = portrailImage.HttpPath;
                }

                services.Add(new ServicerDTO
                {
                    Category             = o.Category,
                    Id                   = o.Id,
                    PersonalIntroduction = o.PersonalIntroduction,
                    OrganizationId       = o.OrganizationId,
                    Address              = o.Address,
                    BirthDay             = o.BirthDay,
                    Gender               = o.Gender,
                    IsSuspend            = o.IsSuspend,
                    SubCategory          = o.SubCategory,
                    JobNumber            = o.JobNumber,
                    Images               = imgs?.Select(img => new ServicerImageDTO {
                        Description = img.Description, HttpPath = img.HttpPath, ImageId = img.Id, ServicerId = o.Id, Title = img.Title
                    }),
                    PortraitImageId       = o.PortraitImageId,
                    PortraitImageUrl      = portrailImageUrl,
                    Name                  = o.Name,
                    SincerityGoldRate     = o.SincerityGoldRate,
                    StartRelevantWorkTime = o.StartRelevantWorkTime,
                    TechnicalGrade        = o.TechnicalGrade,
                    TechnicalTitle        = o.TechnicalTitle,
                    SincerityGold         = o.SincerityGold,
                    ApplicationId         = o.ApplicationId
                });
            }
            return(services);
        }