Beispiel #1
0
        /// <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);

            BrnMall.Data.Categories.DeleteAttributeValueById(attrValueId);
            if (attributeInfo.IsFilter == 1)
            {
                BrnMall.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_FILTERAANDVLIST + attributeInfo.CateId);
            }
            BrnMall.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_AANDVLISTJSONCACHE + attributeInfo.CateId);
            return(1);
        }
Beispiel #2
0
        /// <summary>
        /// 删除店铺分类
        /// </summary>
        /// <param name="storeId">店铺id</param>
        /// <param name="storeCid">店铺分类id</param>
        /// <returns>-2代表店铺分类不存在,-1代表有子店铺分类,0代表店铺分类下还有商品,1代表删除成功</returns>
        public static int DeleteStoreClassByStoreIdAndStoreCid(int storeId, int storeCid)
        {
            List <StoreClassInfo> storeClassList = BrnMall.Data.Stores.GetStoreClassList(storeId);
            StoreClassInfo        storeClassInfo = storeClassList.Find(x => x.StoreCid == storeCid);

            if (storeClassInfo == null)
            {
                return(-2);
            }
            if (storeClassInfo.HasChild == 1)
            {
                return(-1);
            }
            if (AdminProducts.AdminGetStoreClassProductCount(storeCid) > 0)
            {
                return(0);
            }

            BrnMall.Data.Stores.DeleteStoreClassById(storeCid);

            if (storeClassInfo.Layer > 1 && storeClassList.FindAll(x => x.ParentId == storeClassInfo.ParentId).Count == 1)
            {
                StoreClassInfo parentStoreClassInfo = storeClassList.Find(x => x.StoreCid == storeClassInfo.ParentId);
                parentStoreClassInfo.HasChild = 0;
                BrnMall.Data.Stores.UpdateStoreClass(parentStoreClassInfo);
            }

            BrnMall.Core.BMACache.Remove(CacheKeys.MALL_STORE_CLASSLIST + storeId);
            return(1);
        }
Beispiel #3
0
 /// <summary>
 /// 删除品牌
 /// </summary>
 /// <param name="brandId">品牌id</param>
 /// <returns>0代表此品牌下还有商品未删除,1代表删除成功</returns>
 public static int DeleteBrandById(int brandId)
 {
     if (AdminProducts.AdminGetBrandProductCount(brandId) > 0)
     {
         return(0);
     }
     BrnMall.Data.Brands.DeleteBrandById(brandId);
     BrnMall.Core.BMACache.Remove(CacheKeys.MALL_BRAND_INFO + brandId);
     return(1);
 }
Beispiel #4
0
        /// <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);
            }
            BrnMall.Data.Stores.DeleteStoreShipTemplateById(storeSTid);
            BrnMall.Core.BMACache.Remove(CacheKeys.MALL_STORE_SHIPTEMPLATEINFO + storeSTid);
            return(1);
        }
Beispiel #5
0
        /// <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);
                }

                BrnMall.Data.Stores.DeleteStoreById(storeId);
                BrnMall.Core.BMACache.Remove(CacheKeys.MALL_STORE_CLASSLIST + storeId);
                return(1);
            }
            return(0);
        }
Beispiel #6
0
        /// <summary>
        /// 删除分类
        /// </summary>
        /// <param name="cateId">分类id</param>
        /// <returns>-3代表分类不存在,-2代表此分类下还有子分类未删除,-1代表此分类下还有属性分组未删除,0代表此分类下还有商品未删除,1代表删除成功</returns>
        public static int DeleteCategoryById(int cateId)
        {
            List <CategoryInfo> categoryList = BrnMall.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);
            }

            BrnMall.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;
                BrnMall.Data.Categories.UpdateCategory(parentCategoryInfo);
            }

            BrnMall.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_LIST);
            BrnMall.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_BRANDLIST + cateId);
            BrnMall.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_FILTERAANDVLIST + cateId);
            BrnMall.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_AANDVLISTJSONCACHE + cateId);

            WriteMallAdminCategorySelectListCache(GetCategoryList());
            return(1);
        }