public ApiResult CreateCollect(Guid goodsId) { if (goodsId.Equals(Guid.Empty)) { throw new WebApiInnerException("0001", "商品Id不合法"); } if (_markupService.MarkupExist(goodsId, MallModule.Key, AuthorizedUser.Id, MarkupType.Collect)) { throw new WebApiInnerException("0002", "已经收藏过了"); } _markupService.CreateMarkup(goodsId, MallModule.Key, AuthorizedUser.Id, MarkupType.Collect); return(new ApiResult()); }
public ApiResult GetGoodsAttrubiteAndSingleGoods(Guid goodId) { if (goodId == Guid.Empty) { throw new WebApiInnerException("3011", "商品Id无效"); } var goods = _currencyService.GetSingleById <Goods>(goodId); if (goods == null) { throw new WebApiInnerException("3012", "无此商品"); } var hasCollect = false; if (AuthorizedUser != null) { if (_markupService.MarkupExist(goodId, MallModule.Key, AuthorizedUser.Id, MarkupType.Collect)) { hasCollect = true; } } //商品主图 var mainImage = _storageFileService.GetFiles(goodId, MallModule.Key, "MainImage"); //单品 var attr = _goodsService.GetGoodsAttributeValues(goodId); var defaultShipping = _shippingAreaService.GetDefaultShippingArea(); var result = new ApiResult(); var data = new { Name = goods.Name, OriginalPrice = goods.OriginalPrice, Price = goods.ShopPrice, Stock = goods.Stock, SalesVolume = goods.SalesVolume, PaymentAmount = goods.PaymentAmount, MainImage = mainImage?.Select(x => x.Simplified()).ToList(), AttributeValues = attr, SingleGoogsList = _goodsService.LoadFullGoods(goodId).SingleGoods.Where(x => x.Stock > 0).Select(me => new SingleGoodsModel(me)).ToList(), Description = goods.Description, HasCollect = hasCollect, IsGroupon = goods.IsGroupon && ((goods.GrouponStartTime <= DateTime.Now && goods.GrouponEndTime >= DateTime.Now) ? true : false), GrouponPrice = goods.GrouponPrice, GrouponStartTime = goods.GrouponStartTime, GrouponEndTime = goods.GrouponEndTime, FreeShipping = goods.FreeShipping ? 0 : (defaultShipping?.Freight ?? 0) }; result.SetData(data); return(result); }