Example #1
0
        public BaseApiResponse GetSpecifications([FromBody] GetParamsRequest request)
        {
            request.CheckNotNull(nameof(request));

            var specifications = _goodsQueryService.GetPublishedSpecifications(request.Id);

            if (!specifications.Any())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "没有参数"
                });
            }
            return(new GetSpecificationsResponse
            {
                Specifications = specifications.Select(x => new Specification
                {
                    Id = x.Id,
                    Name = x.Name,
                    Value = x.Value,
                    Price = x.Price,
                    OriginalPrice = x.OriginalPrice,
                    Benevolence = x.Benevolence,
                    Number = x.Number,
                    BarCode = x.BarCode,
                    Stock = x.Stock,
                    Thumb = x.Thumb,
                    AvailableQuantity = x.AvailableQuantity
                }).ToList()
            });
        }
Example #2
0
        public BaseApiResponse GoodsInfo(InfoRequest request)
        {
            request.CheckNotNull(nameof(request));

            var goodsDetails   = _goodsQueryService.GetGoodsDetails(request.Id);
            var storeInfo      = _storeQueryService.Info(goodsDetails.StoreId);
            var specifications = _goodsQueryService.GetPublishedSpecifications(request.Id);
            var goodsParams    = _goodsQueryService.GetGoodsParams(request.Id);
            var comments       = _goodsQueryService.GetComments(request.Id, 5);

            if (goodsDetails == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "没有该产品"
                });
            }
            return(new GoodsInfoResponse
            {
                GoodsDetails = new GoodsDetails
                {
                    Id = goodsDetails.Id,
                    StoreId = goodsDetails.StoreId,
                    Pics = goodsDetails.Pics.Split("|", true).Select(img => img.ToOssStyleUrl(OssImageStyles.GoodsMainPic.ToDescription())).ToList(),
                    Name = goodsDetails.Name,
                    Description = goodsDetails.Description,
                    Benevolence = goodsDetails.Benevolence,
                    Price = goodsDetails.Price,
                    OriginalPrice = goodsDetails.OriginalPrice,
                    Stock = goodsDetails.Stock,
                    Is7SalesReturn = goodsDetails.Is7SalesReturn,
                    IsInvoice = goodsDetails.IsInvoice,
                    IsPayOnDelivery = goodsDetails.IsPayOnDelivery,
                    Rate = goodsDetails.Rate,
                    QualityRate = goodsDetails.QualityRate,
                    ExpressRate = goodsDetails.ExpressRate,
                    DescribeRate = goodsDetails.DescribeRate,
                    PriceRate = goodsDetails.PriceRate,
                    RateCount = goodsDetails.RateCount,
                    Sort = goodsDetails.Sort,
                    IsPublished = goodsDetails.IsPublished,
                    Status = goodsDetails.Status.ToString()
                },
                StoreInfo = new StoreInfo
                {
                    Id = storeInfo.Id,
                    Name = storeInfo.Name,
                    Description = storeInfo.Description,
                    Type = storeInfo.Type.ToDescription(),
                    Address = storeInfo.Address,
                    IsLocked = storeInfo.IsLocked
                },
                Specifications = specifications.Select(x => new Specification {
                    Id = x.Id,
                    Name = x.Name,
                    Value = x.Value,
                    Price = x.Price,
                    OriginalPrice = x.OriginalPrice,
                    Benevolence = x.Benevolence,
                    Thumb = x.Thumb,
                    Stock = x.Stock,
                    BarCode = x.BarCode,
                    Number = x.Number,
                    AvailableQuantity = x.AvailableQuantity
                }).ToList(),
                GoodsParams = goodsParams.Select(x => new GoodsParam {
                    Id = x.Id,
                    Name = x.Name,
                    Value = x.Value
                }).ToList(),
                Comments = comments.Select(x => new Comment {
                    Id = x.Id,
                    Rate = x.Rate,
                    NickName = x.NickName,
                    CreatedOn = x.CreatedOn.GetTimeSpan(),
                    Thumbs = x.Thumbs.Split("|", true).ToList(),
                    Body = x.Body
                }).ToList()
            });
        }