/// <summary> /// 更新商品属性 /// </summary> /// <param name="pid">商品id</param> /// <param name="attrId">属性id</param> /// <param name="attrValueId">属性值id</param> /// <param name="inputValue">输入值</param> /// <param name="type">更新类型</param> /// <returns></returns> public ActionResult UpdateProductAttribute(int pid = -1, int attrId = -1, int attrValueId = -1, string inputValue = "", int type = -1) { PartProductInfo partProductInfo = AdminProducts.AdminGetPartProductById(pid); if (partProductInfo == null || partProductInfo.StoreId != WorkContext.StoreId) { return(Content("0")); } bool result = false; ProductAttributeInfo productAttributeInfo = AdminProducts.GetProductAttributeByPidAndAttrId(pid, attrId); if (productAttributeInfo == null) { productAttributeInfo = new ProductAttributeInfo(); productAttributeInfo.Pid = pid; productAttributeInfo.AttrId = attrId; productAttributeInfo.AttrValueId = attrValueId; if (AdminCategories.GetAttributeValueById(attrValueId).IsInput == 0 || string.IsNullOrWhiteSpace(inputValue)) { productAttributeInfo.InputValue = ""; } else { productAttributeInfo.InputValue = inputValue; } result = AdminProducts.CreateProductAttribute(productAttributeInfo); } else { if (type == 1) { productAttributeInfo.AttrValueId = attrValueId; productAttributeInfo.InputValue = inputValue; result = AdminProducts.UpdateProductAttribute(productAttributeInfo); } else if (type == 0) { productAttributeInfo.AttrValueId = attrValueId; productAttributeInfo.InputValue = ""; result = AdminProducts.UpdateProductAttribute(productAttributeInfo); } } if (result) { AddStoreAdminLog("修改商品属性", "修改商品属性,商品属性ID:" + pid + "_" + attrId); return(Content("1")); } else { return(Content("0")); } }