Пример #1
0
        public ActionResult AddSKU(AddSKUModel model)
        {
            if (AdminProducts.AdminGetProductIdByName(model.ProductName) > 0)
                ModelState.AddModelError("ProductName", "名称已经存在");
            if (model.AttrIdList == null || model.AttrIdList.Length < 1)
                ModelState.AddModelError("CateId", "请选择SKU");

            if (ModelState.IsValid)
            {
                //商品信息
                ProductInfo productInfo = new ProductInfo()
                {
                    PSN = "",
                    CateId = model.CateId,
                    BrandId = model.BrandId,
                    SKUGid = 0,
                    StoreId = model.StoreId,
                    StoreCid = model.StoreCid,
                    StoreSTid = model.StoreSTid,
                    Name = model.ProductName,
                    ShopPrice = model.ShopPrice,
                    MarketPrice = model.MarketPrice,
                    CostPrice = model.CostPrice,
                    State = (int)ProductState.OutSale,//设为下架状态
                    IsBest = model.IsBest == true ? 1 : 0,
                    IsHot = model.IsHot == true ? 1 : 0,
                    IsNew = model.IsNew == true ? 1 : 0,
                    DisplayOrder = model.DisplayOrder,
                    Weight = model.Weight,
                    ShowImg = "",
                    Description = model.Description ?? "",
                    AddTime = DateTime.Now
                };

                //SKU处理
                List<ProductSKUItemInfo> productSKUItemList = new List<ProductSKUItemInfo>();
                for (int i = 0; i < model.AttrIdList.Length; i++)
                {
                    int attrId = model.AttrIdList[i];//属性id
                    int attrValueId = model.AttrValueIdList[i];//属性值id
                    string inputValue = model.AttrInputValueList[i];//属性输入值
                    if (attrId > 0 && attrValueId > 0)
                    {
                        productSKUItemList.Add(new ProductSKUItemInfo()
                        {
                            AttrId = attrId,
                            AttrValueId = attrValueId,
                            InputValue = inputValue ?? ""
                        });
                    }
                }

                AdminProducts.AddSKU(productInfo, productSKUItemList);
                AddMallAdminLog("添加SKU商品", "添加SKU商品,商品为:" + model.ProductName);

                return PromptView(Url.Action("outsaleproductlist"), "SKU商品添加成功");
            }
            ViewData["referer"] = MallUtils.GetMallAdminRefererCookie();
            return View(model);
        }
Пример #2
0
        public ActionResult AddSKU()
        {
            AddSKUModel model = new AddSKUModel();

            string backUrl = MallUtils.GetMallAdminRefererCookie();
            if (backUrl.Length == 0 || backUrl == "/malladmin/home/mallruninfo")
            {
                backUrl = Url.Action("onsaleproductlist");
                MallUtils.SetAdminRefererCookie(backUrl);
            }
            ViewData["referer"] = backUrl;
            return View(model);
        }