示例#1
0
        private List <ProductImageModel> TransformImageList(List <ProductImage> imageList)
        {
            imageList = imageList ?? new List <ProductImage>();
            ImageSize imageSizeBig          = ImageUrlHelper.GetImageSize(ImageType.Big);
            ImageSize imageSizeHuge         = ImageUrlHelper.GetImageSize(ImageType.Huge);
            List <ProductImageModel> result = new List <ProductImageModel>();

            foreach (var image in imageList)
            {
                ProductImageModel model = new ProductImageModel();
                model.ImageUrlBig  = ProductFacade.BuildProductImage(imageSizeBig, image.ResourceUrl);
                model.ImageUrlHuge = ProductFacade.BuildProductImage(imageSizeHuge, image.ResourceUrl);

                result.Add(model);
            }

            return(result);
        }
示例#2
0
        /// <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);
        }