/// <summary> /// 更新商品 /// </summary> /// <param name="product">修改后的商品</param> /// <param name="pics">需要转移的商品图片地址</param> /// <param name="skus">skus,至少要有一项</param> /// <param name="description">描述</param> /// <param name="attributes">商品属性</param> /// <param name="goodsCategory">商家分类</param> /// <param name="sellerSpecifications">商家自定义规格</param> public static void UpdateProduct(Product product, string[] pics, SKU[] skus, ProductDescription description, ProductAttribute[] attributes, long[] goodsCategory, SellerSpecificationValue[] sellerSpecifications) { var productInfo = _productService.GetProduct(product.Id); if (productInfo == null) { throw new HimallException("指定id对应的数据不存在"); } var editStatus = (ProductInfo.ProductEditStatus)productInfo.EditStatus; if (product.ProductName != productInfo.ProductName) { editStatus = GetEditStatus(editStatus); } if (product.ShortDescription != productInfo.ShortDescription) { editStatus = GetEditStatus(editStatus); } product.AddedDate = productInfo.AddedDate; if (productInfo.SaleStatus != ProductInfo.ProductSaleStatus.InDraft) { product.SaleStatus = productInfo.SaleStatus; } product.AuditStatus = productInfo.AuditStatus; product.DisplaySequence = productInfo.DisplaySequence; product.ShopId = productInfo.ShopId; product.HasSKU = productInfo.HasSKU; product.ImagePath = productInfo.ImagePath; product.SaleCounts = productInfo.SaleCounts; if (pics != null) { if (pics.Any(path => string.IsNullOrWhiteSpace(path) || !path.StartsWith(productInfo.ImagePath))) //有任何修改过的图片 { editStatus = GetEditStatus(editStatus); } } product.DynamicMap(productInfo); productInfo.EditStatus = (int)editStatus; var skuInofs = skus.Map <SKUInfo[]>(); var descriptionInfo = description.Map <ProductDescriptionInfo>(); var attributeInfos = attributes.Map <ProductAttributeInfo[]>(); var sellerSpecificationInfos = sellerSpecifications.Map <SellerSpecificationValueInfo[]>(); _productService.UpdateProduct(productInfo, pics, skuInofs, descriptionInfo, attributeInfos, goodsCategory, sellerSpecificationInfos); CreateHtml(product.Id); }
/// <summary> /// 更新诊疗项目 /// </summary> /// <param name="product">修改后的诊疗项目</param> /// <param name="pics">需要转移的诊疗项目图片地址</param> /// <param name="skus">skus,至少要有一项</param> /// <param name="description">描述</param> /// <param name="attributes">诊疗项目属性</param> /// <param name="goodsCategory">诊所分类</param> /// <param name="sellerSpecifications">诊所自定义规格</param> public static void UpdateProduct(Product product, string[] pics, SKU[] skus, ProductDescription description, ProductAttribute[] attributes, long[] goodsCategory, SellerSpecificationValue[] sellerSpecifications) { Func <string, bool> predicate = null; ProductInfo productInfo = _productService.GetProduct(product.Id); if (productInfo == null) { throw new HimallException("指定id对应的数据不存在"); } ProductInfo.ProductEditStatus editStatus = (ProductInfo.ProductEditStatus)productInfo.EditStatus; if (product.ProductName != productInfo.ProductName) { editStatus = GetEditStatus(editStatus); } if (product.ShortDescription != productInfo.ShortDescription) { editStatus = GetEditStatus(editStatus); } product.AddedDate = productInfo.AddedDate; if (productInfo.SaleStatus != ProductInfo.ProductSaleStatus.InDraft) { product.SaleStatus = productInfo.SaleStatus; } product.AuditStatus = productInfo.AuditStatus; product.DisplaySequence = productInfo.DisplaySequence; product.ShopId = productInfo.ShopId; product.HasSKU = productInfo.HasSKU; product.ImagePath = productInfo.ImagePath; product.SaleCounts = productInfo.SaleCounts; if (pics != null) { if (predicate == null) { predicate = path => string.IsNullOrWhiteSpace(path) || !path.StartsWith(productInfo.ImagePath); } if (pics.Any <string>(predicate)) { editStatus = GetEditStatus(editStatus); } } product.DynamicMap <Himall.DTO.Product.Product, ProductInfo>(productInfo); productInfo.EditStatus = (int)editStatus; SKUInfo[] infoArray = skus.Map <SKUInfo[]>(); ProductDescriptionInfo info = description.Map <ProductDescriptionInfo>(); ProductAttributeInfo[] infoArray2 = attributes.Map <ProductAttributeInfo[]>(); SellerSpecificationValueInfo[] infoArray3 = sellerSpecifications.Map <SellerSpecificationValueInfo[]>(); _productService.UpdateProduct(productInfo, pics, infoArray, info, infoArray2, goodsCategory, infoArray3); CreateHtml(product.Id); }