/// <summary> /// 获得商铺详细信息 /// </summary> /// <param name="sellerSysNo"></param> /// <returns></returns> public StoreDetailModel GetStoreDetailInfo(int sellerSysNo) { //商家信息 StoreBasicInfo storeinfo = StoreFacade.QueryStoreBasicInfo(sellerSysNo); if (storeinfo == null) { //提示商品找不到 throw new BusinessException("商家找不到啦,请进入其他店铺,谢谢。"); } //头部信息 string header = StoreFacade.QueryStorePageHeader(storeinfo.SellerSysNo.Value); //导航 QueryResult <StoreNavigation> StoreNavigation = StoreFacade.QueryStoreNavigationList(new StorePageListQueryFilter { PageIndex = 0, PageSize = 100 }, storeinfo.SellerSysNo.Value); //店铺网页的主信息 StorePage homeinfo = StoreFacade.QueryHomePage(storeinfo.SellerSysNo.Value); //获得店铺的页面,如果是预览则查询ECStore..StorePageInfo,否则查询ECStore..[PublishedStorePageInfo] StorePage pageinfo = StoreFacade.QueryStorePage(new StorePageFilter { SellerSysNo = storeinfo.SellerSysNo.Value, PublishPageSysNo = homeinfo.SysNo, IsPreview = false }); bool IfDecorate = false;//如果按照装修元素确定店铺新品和一周排行设置为true,否则设置为false //店铺新品商品10个 List <RecommendProduct> newStoreRecommendList = new List <RecommendProduct>(); //一周排行10个 List <RecommendProduct> WeekRankingProduct = new List <RecommendProduct>(); if (IfDecorate) { //店铺新品 bool NewProducts = false; //一周排行 bool WeekRanking = false; if (pageinfo != null) { if (pageinfo.StorePageTemplate.StorePageLayouts.Count > 0) { foreach (var item in pageinfo.StorePageTemplate.StorePageLayouts) { //店铺新品 if (item.StorePageElements.Exists(x => x.Key == "NewProducts")) { NewProducts = true; } //一周排行 if (item.StorePageElements.Exists(x => x.Key == "WeekRanking")) { WeekRanking = true; } } } } if (NewProducts) { newStoreRecommendList = StoreFacade.QueryStoreNewRecommendProduct(storeinfo.SellerSysNo.Value, null, 10, ConstValue.LanguageCode, ConstValue.CompanyCode); } if (WeekRanking) { WeekRankingProduct = StoreFacade.QueryWeekRankingForCategoryCode(storeinfo.SellerSysNo.Value, null, 10, ConstValue.LanguageCode, ConstValue.CompanyCode); } } else { //店铺新品商品10个 newStoreRecommendList = StoreFacade.QueryStoreNewRecommendProduct(storeinfo.SellerSysNo.Value, null, 10, ConstValue.LanguageCode, ConstValue.CompanyCode); //一周排行10个 WeekRankingProduct = StoreFacade.QueryWeekRankingForCategoryCode(storeinfo.SellerSysNo.Value, null, 10, ConstValue.LanguageCode, ConstValue.CompanyCode); } StoreDetailModel result = new StoreDetailModel(); //商铺基本信息 result.StoreBasicInfo = Transformstoreinfo(storeinfo); //头部信息 result.HeaderInfo = header; //导航 if (StoreNavigation.ResultList.Count > 0) { result.StoreNavigationInfo = Transformsstorenavigation(StoreNavigation); } //店铺新品商品10个 if (newStoreRecommendList.Count > 0) { result.StoreNewProductRecommendInfo = Transformsnewstorerecommend(newStoreRecommendList); } //一周排行10个 if (WeekRankingProduct.Count > 0) { result.StoreWeekRankingProductInfo = TransformsWeekrankingproduct(WeekRankingProduct); } return(result); }
/// <summary> /// 获取商品详情 /// </summary> /// <param name="id">系统编号</param> /// <param name="isGroupBuy">0--标识id为商品系统编号,1--标识id为团购活动系统编号</param> /// <returns></returns> public ProductDetailModel GetProductDetails(int id, int isGroupBuy) { int productSysNo = 0; GroupBuyingInfo groupBuyInfo = null; if (isGroupBuy == 1) { groupBuyInfo = GroupBuyingFacade.GetGroupBuyingInfoBySysNo(id); if (groupBuyInfo == null) { //提示团购活动找不到 throw new BusinessException("团购活动找不到啦,请选购其它商品,谢谢。"); } productSysNo = groupBuyInfo.ProductSysNo; } else { productSysNo = id; } //商品基本信息 ProductBasicInfo basicInfo = ProductFacade.GetProductBasicInfoBySysNo(productSysNo); //商品销售信息 ProductSalesInfo salesInfo = ProductFacade.GetProductSalesInfoBySysNo(productSysNo); if (basicInfo == null || salesInfo == null) { //提示商品找不到 throw new BusinessException("商品找不到啦,请选购其它商品,谢谢。"); } //如果是不展示或下架 if (basicInfo.ProductStatus == ProductStatus.NotShow || basicInfo.ProductStatus == ProductStatus.Abandon) { //提示商品状态已下架或已作废 throw new BusinessException("商品已下架或已作废,请选购其它商品,谢谢。"); } //商品组信息 List <ProductPropertyView> propertyView = ProductFacade.GetProductPropetyView(productSysNo, basicInfo.ProductCommonInfoSysNo); //商品附件 List <ProductItemInfo> attachmentList = ProductFacade.GetProductAttachmentList(productSysNo); //商品配件 List <ProductAccessories> accessoriesList = ProductFacade.GetProductAccessoriesList(productSysNo); //商家信息 StoreBasicInfo storeinfo = StoreFacade.QueryStoreBasicInfo(basicInfo.VendorSysno); //商品促销信息 ProductPromotionInfo promotionInfo = Nesoft.ECWeb.Facade.Product.ProductFacade.GetProductPromotionInfo(productSysNo); //商品组图片信息 List <ProductImage> productImages = ProductFacade.GetProductImages(basicInfo.ProductCommonInfoSysNo); //商品内容(商品详情,规格参数,售后服务,购买须知等) List <ProductContent> contentList = ProductFacade.GetProductContentList(basicInfo); ProductDetailModel result = new ProductDetailModel(); //基本信息 result.BasicInfo = TransformBasicInfo(basicInfo); //商品销售(价格,库存等)信息 result.SalesInfo = TransformSalesInfo(basicInfo, salesInfo); //商品图片列表 result.ImageList = TransformImageList(productImages); //商品描述信息 result.DescInfo = TransformDescInfo(contentList); //if (result.DescInfo != null && basicInfo != null) // result.DescInfo.Performance = basicInfo.Performance; //分组属性 result.GroupPropertyInfo = TransformGroupProperty(propertyView); //附件信息 result.AttachmentInfo = TransformAttachmentInfo(attachmentList); //配件信息 result.AccessoryList = TransformAccessoryInfo(accessoriesList); //商家信息 result.StoreBasicInfo = Transformstoreinfo(storeinfo); //限时抢购,赠品,套餐等促销信息 result.PromoInfo = TransformPromoInfo(promotionInfo); //如果是团购商品进一步加载团购详情 if (promotionInfo != null && promotionInfo.GroupBuySysNo > 0) { if (groupBuyInfo == null) { groupBuyInfo = GroupBuyingFacade.GetGroupBuyingInfoBySysNo(promotionInfo.GroupBuySysNo); } if (groupBuyInfo == null) { result.PromoInfo.GroupBuyingSysNo = 0; } else { //团购图片特殊处理,用活动设置的图片 result.BasicInfo.DefaultImageUrl = groupBuyInfo.GroupBuyingPicUrl; result.ImageList.Clear(); ProductImageModel groupBuyImage = new ProductImageModel(); groupBuyImage.ImageUrlBig = groupBuyInfo.GroupBuyingPicUrl; groupBuyImage.ImageUrlHuge = groupBuyInfo.GroupBuyingPicUrl; result.ImageList.Add(groupBuyImage); //海外团购商品,算税 if (groupBuyInfo.GroupBuyingTypeSysNo == 0) { result.SalesInfo.TariffPrice = salesInfo.CurrentPrice * salesInfo.TariffRate; if (result.SalesInfo.TariffPrice <= ConstValue.TariffFreeLimit) { result.SalesInfo.FreeEntryTax = true; result.SalesInfo.TotalPrice = salesInfo.CurrentPrice; } else { result.SalesInfo.FreeEntryTax = false; result.SalesInfo.TotalPrice = salesInfo.CurrentPrice + result.SalesInfo.TariffPrice; } decimal snapShotTariffPrice = groupBuyInfo.SnapShotCurrentPrice * salesInfo.TariffRate; if (snapShotTariffPrice <= ConstValue.TariffFreeLimit) { snapShotTariffPrice = 0; } result.SalesInfo.BasicPrice = groupBuyInfo.SnapShotCurrentPrice + groupBuyInfo.SnapShotCashRebate + snapShotTariffPrice; } else { result.SalesInfo.BasicPrice = groupBuyInfo.SnapShotCurrentPrice + groupBuyInfo.SnapShotCashRebate; result.SalesInfo.TotalPrice = salesInfo.CurrentPrice; result.SalesInfo.TariffPrice = 0; result.SalesInfo.FreeEntryTax = false; } groupBuyInfo.MarketPrice = result.SalesInfo.BasicPrice; result.GroupBuyInfo = MapGroupBuyInfo(groupBuyInfo); } } if (promotionInfo != null && promotionInfo.Countdown != null) { //限时抢购重算市场价 decimal snapShotTariffPrice = promotionInfo.Countdown.SnapShotCurrentPrice * salesInfo.TariffRate; if (snapShotTariffPrice <= ConstValue.TariffFreeLimit) { snapShotTariffPrice = 0; } result.SalesInfo.BasicPrice = promotionInfo.Countdown.SnapShotCurrentPrice + promotionInfo.Countdown.SnapShotCashRebate + snapShotTariffPrice; } result.ActionInfo = MapActionInfo(result); return(result); }