//APP首页配置共用于安卓和IOS,这里的平台类型写的为IOS,安卓调用首页接口数据时平台类型也选IOS public APPHome Get(int pageNo, int pageSize) { var slideImageSettings = ServiceProvider.Instance <ISlideAdsService> .Create.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.IOSShopHome); var images = ServiceProvider.Instance <ISlideAdsService> .Create.GetImageAds(0, Himall.CommonModel.ImageAdsType.APPSpecial).ToList(); var mhproser = ServiceProvider.Instance <IMobileHomeProductsService> .Create; var data = mhproser.GetMobileHomeProducts(0, PlatformType.IOS, pageNo, pageSize); var totalProducts = data.Total; var homeProducts = data.Models; decimal discount = 1M; if (CurrentUser != null) { discount = CurrentUser.MemberDiscount; } var products = new List <HomeProduct>(); var limitService = ServiceProvider.Instance <ILimitTimeBuyService> .Create; var fight = FightGroupApplication.GetFightGroupPrice(); var allProducts = ProductManagerApplication.GetProducts(homeProducts.Select(p => p.ProductId)); var allShops = ShopApplication.GetShops(allProducts.Select(p => p.ShopId)); foreach (var item in homeProducts) { var limitBuy = limitService.GetLimitTimeMarketItemByProductId(item.ProductId); var product = allProducts.FirstOrDefault(p => p.Id == item.ProductId); var shop = allShops.FirstOrDefault(p => p.Id == product.ShopId); decimal minSalePrice = shop.IsSelf ? product.MinSalePrice * discount : product.MinSalePrice; if (limitBuy != null) { minSalePrice = limitBuy.MinPrice; //限时购不打折 } var isFight = fight.Where(r => r.ProductId == item.ProductId).FirstOrDefault(); long activeId = 0; if (isFight != null) { minSalePrice = isFight.ActivePrice; activeId = isFight.ActiveId; } products.Add(new HomeProduct() { Id = item.ProductId.ToString(), ImageUrl = HimallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)CommonModel.ImageSize.Size_220), Name = product.ProductName, MarketPrice = product.MarketPrice.ToString(), SalePrice = minSalePrice.ToString("f2"), Discount = product.MarketPrice <= 0 ? "0" : (minSalePrice / product.MarketPrice).ToString("0.0"), Url = Core.HimallIO.GetRomoteImagePath("/m-ios/product/detail/" + item.ProductId), FightGroupId = activeId }); } var iconSettings = ServiceProvider.Instance <ISlideAdsService> .Create.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.APPIcon); var icon = iconSettings.ToArray().Select(item => new HomeSlides { Desc = item.Description, ImageUrl = Core.HimallIO.GetRomoteImagePath(item.ImageUrl), Url = item.Url }); var services = CustomerServiceApplication.GetPlatformCustomerService(true, true); //var meiqia = CustomerServiceApplication.GetPlatformCustomerService(true, false).FirstOrDefault(p => p.Tool == Entities.CustomerServiceInfo.ServiceTool.MeiQia); //if (meiqia != null) // services.Insert(0, meiqia); APPHome appHome = new APPHome(); appHome.success = true; //2017年9月1号 商城首页接口修改(把原广告图片的去掉,只保留商品) appHome.TotalProduct = totalProducts; appHome.Icon = icon; //appHome.Slide = slides;//轮播图数组 //appHome.Topic = homeImage;//专题数组 appHome.Product = products; appHome.CustomerServices = services; return(appHome); }
//APP首页配置共用于安卓和IOS,这里的平台类型写的为IOS,安卓调用首页接口数据时平台类型也选IOS public APPHome Get(int pageNo, int pageSize) { var slideImageSettings = ServiceProvider.Instance <ISlideAdsService> .Create.GetSlidAds(0, SlideAdInfo.SlideAdType.IOSShopHome); //var slides = slideImageSettings.ToArray().Select(item => new HomeSlides { ImageUrl = "http://" + Url.Request.RequestUri.Host + item.ImageUrl, Url = item.Url }); var slides = slideImageSettings.ToArray().Select(item => new HomeSlides { ImageUrl = Core.HimallIO.GetRomoteImagePath(item.ImageUrl), Url = item.Url }); var images = ServiceProvider.Instance <ISlideAdsService> .Create.GetImageAds(0, Himall.CommonModel.ImageAdsType.APPSpecial).ToList(); //var images = ServiceProvider.Instance<ISlideAdsService>.Create.GetImageAds(0).Take(5).ToList(); var homeImage = images.Select(item => new HomeImage { //ImageUrl = "http://" + Url.Request.RequestUri.Host + item.ImageUrl, ImageUrl = Core.HimallIO.GetRomoteImagePath(item.ImageUrl), Url = item.Url }); var totalProducts = ServiceProvider.Instance <IMobileHomeProductsService> .Create.GetMobileHomePageProducts(0, Core.PlatformType.IOS).Count().ToString(); var homeProducts = ServiceProvider.Instance <IMobileHomeProductsService> .Create.GetMobileHomePageProducts(0, Core.PlatformType.IOS).OrderBy(item => item.Sequence).ThenByDescending(o => o.Id).Skip((pageNo - 1) * pageSize).Take(pageSize); decimal discount = 1M; if (CurrentUser != null) { discount = CurrentUser.MemberDiscount; } var products = new List <HomeProduct>(); if (homeProducts != null) { var limitService = ServiceProvider.Instance <ILimitTimeBuyService> .Create; foreach (var item in homeProducts.ToArray()) { var limitBuy = limitService.GetLimitTimeMarketItemByProductId(item.ProductId); decimal minSalePrice = item.Himall_Products.Himall_Shops.IsSelf ? item.Himall_Products.MinSalePrice * discount : item.Himall_Products.MinSalePrice; var isValidLimitBuy = "false"; if (limitBuy != null) { minSalePrice = limitBuy.MinPrice; //限时购不打折 } products.Add(new HomeProduct() { Id = item.ProductId.ToString(), // //ImageUrl = "http://" + Url.Request.RequestUri.Host + item.Himall_Products.GetImage(ProductInfo.ImageSize.Size_220), ImageUrl = Core.HimallIO.GetRomoteProductSizeImage(item.Himall_Products.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_220), Name = item.Himall_Products.ProductName, MarketPrice = item.Himall_Products.MarketPrice.ToString(), SalePrice = minSalePrice.ToString("f2"), Discount = (minSalePrice / item.Himall_Products.MarketPrice).ToString("0.0"), //Url = "http://" + Url.Request.RequestUri.Host + "/m-ios/product/detail/" + item.ProductId Url = Core.HimallIO.GetRomoteImagePath("/m-ios/product/detail/" + item.ProductId) }); } } //var products = homeProducts.ToArray().Select(item => new HomeProduct //{ //CommentsCount=item.Himall_Products.Himall_Shops.IsSelf // Id = item.ProductId.ToString(), // //ImageUrl = "http://" + Url.Request.RequestUri.Host + item.Himall_Products.GetImage(ProductInfo.ImageSize.Size_220), // ImageUrl = Core.HimallIO.GetRomoteProductSizeImage(item.Himall_Products.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_220), // Name = item.Himall_Products.ProductName, // MarketPrice = item.Himall_Products.MarketPrice.ToString(), // // SalePrice = item.Himall_Products.MinSalePrice.ToString(), // SalePrice = item.Himall_Products.Himall_Shops.IsSelf ? item.Himall_Products.MinSalePrice * discount.ToString() : item.Himall_Products.MinSalePrice.ToString(), // Discount = (item.Himall_Products.MinSalePrice / item.Himall_Products.MarketPrice).ToString("0.0"), // //Url = "http://" + Url.Request.RequestUri.Host + "/m-ios/product/detail/" + item.ProductId // Url = Core.HimallIO.GetRomoteImagePath("/m-ios/product/detail/" + item.ProductId) //}); var iconSettings = ServiceProvider.Instance <ISlideAdsService> .Create.GetSlidAds(0, SlideAdInfo.SlideAdType.APPIcon); var icon = iconSettings.ToArray().Select(item => new HomeSlides { Desc = item.Description, ImageUrl = Core.HimallIO.GetRomoteImagePath(item.ImageUrl), Url = item.Url }); var services = CustomerServiceApplication.GetPlatformCustomerService(true, true); var meiqia = CustomerServiceApplication.GetPlatformCustomerService(true, false).FirstOrDefault(p => p.Tool == CustomerServiceInfo.ServiceTool.MeiQia); if (meiqia != null) { services.Insert(0, meiqia); } APPHome appHome = new APPHome(); appHome.Success = "true"; appHome.TotalProduct = totalProducts; appHome.Icon = icon; appHome.Slide = slides; appHome.Topic = homeImage; appHome.Product = products; appHome.CustomerServices = services; return(appHome); }