/// <summary> /// 删除属性值 /// </summary> /// <param name="attrValueId">属性值id</param> /// <returns>-2代表此属性值不存在,-1代表此属性值为输入属性值,0代表此属性值下还有商品未删除,1代表删除成功</returns> public static int DeleteAttributeValueById(int attrValueId) { AttributeValueInfo attributeValueInfo = GetAttributeValueById(attrValueId); if (attributeValueInfo == null) { return(-2); } if (attributeValueInfo.IsInput == 1) { return(-1); } if (AdminProducts.AdminGetAttrValueProductCount(attrValueId) > 0) { return(0); } AttributeInfo attributeInfo = GetAttributeById(attributeValueInfo.AttrId); NStore.Data.Categories.DeleteAttributeValueById(attrValueId); if (attributeInfo.IsFilter == 1) { NStore.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_FILTERAANDVLIST + attributeInfo.CateId); } NStore.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_AANDVLISTJSONCACHE + attributeInfo.CateId); return(1); }
/// <summary> /// 删除品牌 /// </summary> /// <param name="brandId">品牌id</param> /// <returns>0代表此品牌下还有商品未删除,1代表删除成功</returns> public static int DeleteBrandById(int brandId) { if (AdminProducts.AdminGetBrandProductCount(brandId) > 0) { return(0); } NStore.Data.Brands.DeleteBrandById(brandId); NStore.Core.BMACache.Remove(CacheKeys.MALL_BRAND_INFO + brandId); NStore.Core.BMACache.Remove(CacheKeys.MALL_BRAND_CATEGORYLIST + brandId); return(1); }
/// <summary> /// 删除店铺配送模板 /// </summary> /// <param name="storeSTid">店铺配送模板id</param> /// <returns>-1代表此店铺模板下还有商品未删除,0代表此店铺模板不存在,1代表删除成功</returns> public static int DeleteStoreShipTemplateById(int storeSTid) { StoreShipTemplateInfo storeShipTemplateInfo = GetStoreShipTemplateById(storeSTid); if (storeShipTemplateInfo == null) { return(0); } if (AdminProducts.AdminGetStoreShipTemplateProductCount(storeSTid) > 0) { return(-1); } NStore.Data.Stores.DeleteStoreShipTemplateById(storeSTid); NStore.Core.BMACache.Remove(CacheKeys.MALL_STORE_SHIPTEMPLATEINFO + storeSTid); return(1); }
/// <summary> /// 删除店铺 /// </summary> /// <param name="storeId">店铺id</param> /// <returns>-1代表此店铺下还有商品未删除,0代表此店铺不存在,1代表删除成功</returns> public static int DeleteStoreById(int storeId) { StoreInfo storeInfo = GetStoreById(storeId); if (storeInfo != null) { if (AdminProducts.AdminGetStoreProductCount(storeId) > 0) { return(-1); } NStore.Data.Stores.DeleteStoreById(storeId); NStore.Core.BMACache.Remove(CacheKeys.MALL_STORE_CLASSLIST + storeId); return(1); } return(0); }
/// <summary> /// 删除分类 /// </summary> /// <param name="cateId">分类id</param> /// <returns>-3代表分类不存在,-2代表此分类下还有子分类未删除,-1代表此分类下还有属性分组未删除,0代表此分类下还有商品未删除,1代表删除成功</returns> public static int DeleteCategoryById(int cateId) { List <CategoryInfo> categoryList = NStore.Data.Categories.GetCategoryList(); CategoryInfo categoryInfo = categoryList.Find(x => x.CateId == cateId); if (categoryInfo == null) { return(-3); } if (categoryInfo.HasChild == 1) { return(-2); } if (GetAttributeGroupListByCateId(cateId).Count > 0) { return(-1); } if (AdminProducts.AdminGetCategoryProductCount(cateId) > 0) { return(0); } NStore.Data.Categories.DeleteCategoryById(cateId); if (categoryInfo.Layer > 1 && categoryList.FindAll(x => x.ParentId == categoryInfo.ParentId).Count == 1) { CategoryInfo parentCategoryInfo = categoryList.Find(x => x.CateId == categoryInfo.ParentId); parentCategoryInfo.HasChild = 0; NStore.Data.Categories.UpdateCategory(parentCategoryInfo); } NStore.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_LIST); NStore.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_BRANDLIST + cateId); NStore.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_FILTERAANDVLIST + cateId); NStore.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_AANDVLISTJSONCACHE + cateId); WriteMallAdminCategorySelectListCache(GetCategoryList()); return(1); }