public ActionResult EditAttribute(int attrId = -1) { AttributeInfo attributeInfo = AdminCategories.GetAttributeById(attrId); if (attributeInfo == null) { return(PromptView("属性不存在")); } AttributeModel model = new AttributeModel(); model.AttributName = attributeInfo.Name; model.AttrGroupId = attributeInfo.AttrGroupId; model.ShowType = attributeInfo.ShowType; model.IsFilter = attributeInfo.IsFilter; model.DisplayOrder = attributeInfo.DisplayOrder; CategoryInfo categoryInfo = AdminCategories.GetCategoryById(attributeInfo.CateId); ViewData["cateId"] = categoryInfo.CateId; ViewData["categoryName"] = categoryInfo.Name; ViewData["attributeGroupList"] = GetAttributeGroupSelectList(categoryInfo.CateId); ViewData["referer"] = ShopUtils.GetAdminRefererCookie(); return(View(model)); }
public ActionResult AddCategory(CategoryModel model) { if (AdminCategories.GetCateIdByName(model.CategroyName) > 0) { ModelState.AddModelError("CategroyName", "名称已经存在"); } if (model.ParentCateId != 0 && AdminCategories.GetCategoryById(model.ParentCateId) == null) { ModelState.AddModelError("ParentCateId", "父分类不存在"); } if (ModelState.IsValid) { CategoryInfo categoryInfo = new CategoryInfo() { DisplayOrder = model.DisplayOrder, Name = model.CategroyName, ParentId = model.ParentCateId, PriceRange = CommonHelper.StringArrayToString(CommonHelper.RemoveArrayItem(StringHelper.SplitString(CommonHelper.TBBRTrim(model.PriceRange).Replace(",", ",")))) }; AdminCategories.CreateCategory(categoryInfo); AddAdminOperateLog("添加分类", "添加分类,分类为:" + model.CategroyName); return(PromptView("分类添加成功")); } Load(); return(View(model)); }
public ActionResult EditProduct(int pid = -1) { ProductInfo productInfo = AdminProducts.AdminGetProductById(pid); if (productInfo == null) { return(PromptView("商品不存在")); } CategoryInfo vCategoryInfo = AdminCategories.GetCategoryById(productInfo.CateId); string vCateName = ""; if (vCategoryInfo != null) { vCateName = vCategoryInfo.Name; } EditProductModel model = new EditProductModel(); model.PSN = productInfo.PSN; model.CateId = productInfo.CateId; model.CategoryName = vCateName; model.BrandId = productInfo.BrandId; model.ProductName = productInfo.Name; model.ShopPrice = productInfo.ShopPrice; model.MarketPrice = productInfo.MarketPrice; model.CostPrice = productInfo.CostPrice; model.State = productInfo.State; model.IsBest = productInfo.IsBest == 1 ? true : false; model.IsHot = productInfo.IsHot == 1 ? true : false; model.IsNew = productInfo.IsNew == 1 ? true : false; model.DisplayOrder = productInfo.DisplayOrder; model.Weight = productInfo.Weight; model.Description = productInfo.Description; model.BrandName = AdminBrands.GetBrandById(productInfo.BrandId).Name; //库存信息 ProductStockInfo productStockInfo = AdminProducts.GetProductStockByPid(pid); model.StockNumber = productStockInfo.Number; model.StockLimit = productStockInfo.Limit; //商品属性列表 List <ProductAttributeInfo> productAttributeList = Products.GetProductAttributeList(pid); //商品sku项列表 DataTable productSKUItemList = AdminProducts.GetProductSKUItemList(productInfo.Pid); ViewData["pid"] = productInfo.Pid; ViewData["cateId"] = productInfo.CateId; ViewData["categoryName"] = vCateName; ViewData["productAttributeList"] = productAttributeList; ViewData["productSKUItemList"] = productSKUItemList; ViewData["referer"] = ShopUtils.GetAdminRefererCookie(); return(View(model)); }
public ActionResult EditAttributeGroup(AttributeGroupModel model, int attrGroupId = -1) { AttributeGroupInfo attributeGroupInfo = AdminCategories.GetAttributeGroupById(attrGroupId); if (attributeGroupInfo == null) { return(PromptView("属性分组不存在")); } int attrGroupId2 = AdminCategories.GetAttributeGroupIdByCateIdAndName(attributeGroupInfo.CateId, model.AttributeGroupName); if (attrGroupId2 > 0 && attrGroupId2 != attrGroupId) { ModelState.AddModelError("AttributeGroupName", "名称已经存在"); } if (ModelState.IsValid) { attributeGroupInfo.Name = model.AttributeGroupName; attributeGroupInfo.DisplayOrder = model.DisplayOrder; AdminCategories.UpdateAttributeGroup(attributeGroupInfo); AddAdminOperateLog("修改属性分组", "修改属性分组,属性分组ID为:" + attrGroupId); return(PromptView("属性分组修改成功")); } CategoryInfo categoryInfo = AdminCategories.GetCategoryById(attributeGroupInfo.CateId); ViewData["cateId"] = categoryInfo.CateId; ViewData["categoryName"] = categoryInfo.Name; ViewData["referer"] = ShopUtils.GetAdminRefererCookie(); return(View(model)); }
public ActionResult AddAttributeGroup(AttributeGroupModel model, int cateId = -1) { CategoryInfo categoryInfo = AdminCategories.GetCategoryById(cateId); if (categoryInfo == null) { return(PromptView("分类不存在")); } if (AdminCategories.GetAttributeGroupIdByCateIdAndName(cateId, model.AttributeGroupName) > 0) { ModelState.AddModelError("AttributeGroupName", "名称已经存在"); } if (ModelState.IsValid) { AttributeGroupInfo attributeGroupInfo = new AttributeGroupInfo() { Name = model.AttributeGroupName, CateId = categoryInfo.CateId, DisplayOrder = model.DisplayOrder }; AdminCategories.CreateAttributeGroup(attributeGroupInfo); AddAdminOperateLog("添加属性分组", "添加属性分组,属性分组为:" + model.AttributeGroupName); return(PromptView("属性分组添加成功")); } ViewData["cateId"] = categoryInfo.CateId; ViewData["categoryName"] = categoryInfo.Name; ViewData["referer"] = ShopUtils.GetAdminRefererCookie(); return(View(model)); }
public ActionResult EditProduct(EditProductModel model, int pid = -1) { ProductInfo productInfo = AdminProducts.AdminGetProductById(pid); if (productInfo == null) { return(PromptView("商品不存在")); } int pid2 = AdminProducts.AdminGetProductIdByName(model.ProductName); if (pid2 > 0 && pid2 != pid) { ModelState.AddModelError("ProductName", "名称已经存在"); } if (ModelState.IsValid) { productInfo.PSN = model.PSN ?? ""; productInfo.BrandId = model.BrandId; productInfo.StoreCid = model.StoreCid; productInfo.StoreSTid = model.StoreSTid; productInfo.Name = model.ProductName; productInfo.ShopPrice = model.ShopPrice; productInfo.MarketPrice = model.MarketPrice; productInfo.CostPrice = model.CostPrice; productInfo.State = model.State; productInfo.IsBest = model.IsBest == true ? 1 : 0; productInfo.IsHot = model.IsHot == true ? 1 : 0; productInfo.IsNew = model.IsNew == true ? 1 : 0; productInfo.DisplayOrder = model.DisplayOrder; productInfo.Weight = model.Weight; productInfo.Description = model.Description ?? ""; productInfo.Spec = model.Spec ?? ""; AdminProducts.UpdateProduct(productInfo, model.StockNumber, model.StockLimit); AddMallAdminLog("修改商品", "修改商品,商品ID为:" + pid); return(PromptView("商品修改成功")); } //商品属性列表 List <ProductAttributeInfo> productAttributeList = Products.GetProductAttributeList(pid); //商品sku项列表 DataTable productSKUItemList = AdminProducts.GetProductSKUItemList(productInfo.Pid); ViewData["pid"] = productInfo.Pid; ViewData["storeId"] = productInfo.StoreId; ViewData["storeName"] = AdminStores.GetStoreById(productInfo.StoreId).Name; ViewData["cateId"] = productInfo.CateId; ViewData["categoryName"] = AdminCategories.GetCategoryById(productInfo.CateId).Name; ViewData["productAttributeList"] = productAttributeList; ViewData["productSKUItemList"] = productSKUItemList; ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return(View(model)); }
/// <summary> /// 展示优惠劵类型 /// </summary> /// <param name="couponTypeId">优惠劵类型id</param> public ActionResult ShowCouponType(int couponTypeId = -1) { CouponTypeInfo couponTypeInfo = AdminCoupons.AdminGetCouponTypeById(couponTypeId); if (couponTypeInfo == null) { return(PromptView("优惠劵类型不存在")); } CouponTypeModel model = new CouponTypeModel(); model.CouponTypeName = couponTypeInfo.Name; model.Money = couponTypeInfo.Money; model.Count = couponTypeInfo.Count; model.SendModel = couponTypeInfo.SendMode; model.GetModel = couponTypeInfo.GetMode; model.UseModel = couponTypeInfo.UseMode; model.UserRankLower = couponTypeInfo.UserRankLower; model.OrderAmountLower = couponTypeInfo.OrderAmountLower; model.LimitCateId = couponTypeInfo.LimitCateId; model.LimitBrandId = couponTypeInfo.LimitBrandId; model.LimitProduct = couponTypeInfo.LimitProduct; model.SendStartTime = couponTypeInfo.SendStartTime; model.SendEndTime = couponTypeInfo.SendEndTime; model.UseTimeType = couponTypeInfo.UseExpireTime > 0 ? 1 : 0; model.UseExpireTime = couponTypeInfo.UseExpireTime; model.UseStartTime = couponTypeInfo.UseStartTime; model.UseEndTime = couponTypeInfo.UseEndTime; model.State = couponTypeInfo.State; CategoryInfo categoryInfo = AdminCategories.GetCategoryById(model.LimitCateId); if (categoryInfo != null) { model.LimitCateName = categoryInfo.Name; } else { model.LimitCateName = "未限制分类"; } BrandInfo brandInfo = AdminBrands.GetBrandById(model.LimitBrandId); if (brandInfo != null) { model.LimitBrandName = brandInfo.Name; } else { model.LimitBrandName = "未限制品牌"; } LoadCouponType(); return(View(model)); }
public ActionResult EditCategory(CategoryModel model, int cateId = -1) { CategoryInfo categoryInfo = AdminCategories.GetCategoryById(cateId); if (categoryInfo == null) { return(PromptView("此分类不存在")); } int cateId2 = AdminCategories.GetCateIdByName(model.CategroyName); if (cateId2 > 0 && cateId2 != cateId) { ModelState.AddModelError("CategroyName", "名称已经存在"); } if (model.ParentCateId == categoryInfo.CateId) { ModelState.AddModelError("ParentCateId", "不能将自己作为父分类"); } if (model.ParentCateId != 0 && AdminCategories.GetCategoryById(model.ParentCateId) == null) { ModelState.AddModelError("ParentCateId", "父分类不存在"); } if (model.ParentCateId != 0 && AdminCategories.GetChildCategoryList(categoryInfo.CateId, categoryInfo.Layer, true).Exists(x => x.CateId == model.ParentCateId)) { ModelState.AddModelError("ParentCateId", "不能将分类调整到自己的子分类下"); } if (ModelState.IsValid) { int oldParentId = categoryInfo.ParentId; categoryInfo.DisplayOrder = model.DisplayOrder; categoryInfo.Name = model.CategroyName; categoryInfo.ParentId = model.ParentCateId; categoryInfo.PriceRange = CommonHelper.StringArrayToString(CommonHelper.RemoveArrayItem(StringHelper.SplitString(CommonHelper.TBBRTrim(model.PriceRange).Replace(",", ",")))); AdminCategories.UpdateCategory(categoryInfo, oldParentId); AddAdminOperateLog("修改分类", "修改分类,分类ID为:" + cateId); return(PromptView("商品修改成功")); } Load(); return(View(model)); }
public ActionResult AddAttributeGroup(int cateId = -1) { CategoryInfo categoryInfo = AdminCategories.GetCategoryById(cateId); if (categoryInfo == null) { return(PromptView("分类不存在")); } AttributeGroupModel model = new AttributeGroupModel(); ViewData["cateId"] = categoryInfo.CateId; ViewData["categoryName"] = categoryInfo.Name; ViewData["referer"] = ShopUtils.GetAdminRefererCookie(); return(View(model)); }
public ActionResult EditAttribute(AttributeModel model, int attrId = -1) { AttributeInfo attributeInfo = AdminCategories.GetAttributeById(attrId); if (attributeInfo == null) { return(PromptView("属性不存在")); } int attrId2 = AdminCategories.GetAttrIdByCateIdAndName(attributeInfo.CateId, model.AttributName); if (attrId2 > 0 && attrId2 != attrId) { ModelState.AddModelError("AttributName", "名称已经存在"); } AttributeGroupInfo attributeGroupInfo = AdminCategories.GetAttributeGroupById(model.AttrGroupId); if (attributeGroupInfo == null || attributeGroupInfo.CateId != attributeInfo.CateId) { ModelState.AddModelError("AttrGroupId", "属性组不存在"); } if (ModelState.IsValid) { attributeInfo.Name = model.AttributName; attributeInfo.AttrGroupId = model.AttrGroupId; attributeInfo.IsFilter = model.IsFilter; attributeInfo.ShowType = model.ShowType; attributeInfo.DisplayOrder = model.DisplayOrder; AdminCategories.UpdateAttribute(attributeInfo); AddAdminOperateLog("编辑分类属性", "编辑分类属性,分类属性ID为:" + attrId); return(PromptView("分类属性修改成功")); } CategoryInfo categoryInfo = AdminCategories.GetCategoryById(attributeInfo.CateId); ViewData["cateId"] = categoryInfo.CateId; ViewData["categoryName"] = categoryInfo.Name; ViewData["attributeGroupList"] = GetAttributeGroupSelectList(categoryInfo.CateId); ViewData["referer"] = ShopUtils.GetAdminRefererCookie(); return(View(model)); }
public ActionResult EditCategory(int cateId = -1) { CategoryInfo categortInfo = AdminCategories.GetCategoryById(cateId); if (categortInfo == null) { return(PromptView("此分类不存在")); } CategoryModel model = new CategoryModel(); model.CategroyName = categortInfo.Name; model.ParentCateId = categortInfo.ParentId; model.DisplayOrder = categortInfo.DisplayOrder; model.PriceRange = categortInfo.PriceRange; Load(); return(View(model)); }
/// <summary> /// 属性列表 /// </summary> public ActionResult AttributeList(int cateId = -1) { CategoryInfo categoryInfo = AdminCategories.GetCategoryById(cateId); if (categoryInfo == null) { return(PromptView("分类不存在")); } AttributeListModel model = new AttributeListModel() { AttributeList = AdminCategories.AdminGetAttributeList(cateId), CateId = cateId, CategoryName = categoryInfo.Name }; ShopUtils.SetAdminRefererCookie(string.Format("{0}?cateId={1}", Url.Action("attributelist"), cateId)); return(View(model)); }
public ActionResult AddAttribute(AttributeModel model, int cateId = -1) { CategoryInfo categoryInfo = AdminCategories.GetCategoryById(cateId); if (categoryInfo == null) { return(PromptView("分类不存在")); } if (AdminCategories.GetAttrIdByCateIdAndName(cateId, model.AttributName) > 0) { ModelState.AddModelError("AttributName", "名称已经存在"); } AttributeGroupInfo attributeGroupInfo = AdminCategories.GetAttributeGroupById(model.AttrGroupId); if (attributeGroupInfo == null || attributeGroupInfo.CateId != cateId) { ModelState.AddModelError("AttrGroupId", "属性组不存在"); } if (ModelState.IsValid) { AttributeInfo attributeInfo = new AttributeInfo(); attributeInfo.Name = model.AttributName; attributeInfo.CateId = cateId; attributeInfo.AttrGroupId = model.AttrGroupId; attributeInfo.ShowType = model.ShowType; attributeInfo.IsFilter = model.IsFilter; attributeInfo.DisplayOrder = model.DisplayOrder; AdminCategories.CreateAttribute(attributeInfo, attributeGroupInfo); AddAdminOperateLog("添加分类属性", "添加分类属性,属性为:" + model.AttributName); return(PromptView("分类属性添加成功")); } ViewData["cateId"] = categoryInfo.CateId; ViewData["categoryName"] = categoryInfo.Name; ViewData["attributeGroupList"] = GetAttributeGroupSelectList(cateId); ViewData["referer"] = ShopUtils.GetAdminRefererCookie(); return(View(model)); }
public ActionResult EditAttributeGroup(int attrGroupId = -1) { AttributeGroupInfo attributeGroupInfo = AdminCategories.GetAttributeGroupById(attrGroupId); if (attributeGroupInfo == null) { return(PromptView("属性分组不存在")); } AttributeGroupModel model = new AttributeGroupModel(); model.AttributeGroupName = attributeGroupInfo.Name; model.DisplayOrder = attributeGroupInfo.DisplayOrder; CategoryInfo categoryInfo = AdminCategories.GetCategoryById(attributeGroupInfo.CateId); ViewData["cateId"] = categoryInfo.CateId; ViewData["categoryName"] = categoryInfo.Name; ViewData["referer"] = ShopUtils.GetAdminRefererCookie(); return(View(model)); }
/// <summary> /// 属性列表 /// </summary> public ActionResult AttributeList(string sortColumn, string sortDirection, int cateId = -1) { CategoryInfo categoryInfo = AdminCategories.GetCategoryById(cateId); if (categoryInfo == null) { return(PromptView("分类不存在")); } string sort = AdminBrands.AdminGetBrandListSort(sortColumn, sortDirection); AttributeListModel model = new AttributeListModel() { AttributeList = AdminCategories.AdminGetAttributeList(cateId, sort), SortColumn = sortColumn, SortDirection = sortDirection, CateId = cateId, CategoryName = categoryInfo.Name }; MallUtils.SetAdminRefererCookie(string.Format("{0}?cateId={1}&sortColumn={2}&sortDirection={3}", Url.Action("attributelist"), cateId, sortColumn, sortDirection)); return(View(model)); }