/// <summary> /// 新增产品 /// </summary> public void SaveGoods() { var id = GetInt("id"); var title = GetString("title"); var imgUrls = GetString("imgUrls"); var logoUrl = GetString("logoUrl"); var nowPrice = GetFloat("nowPrice"); var originalPrice = GetFloat("originalPrice"); var tags = GetString("tags"); var cid = GetInt("cid"); var content = GetString("content"); var isHot = GetInt("isHot"); //var isRecommend = GetInt("isRecommend"); var goods = new Goods(); if (id > 0) { goods = GoodsHelper.GetGoods(id); if (goods.SellerId != CurSellerId && CurrentUser.RoleType >= RoleType.Merchant) { ReturnErrorMsg("没有权限修改改该商户产品"); return; } } goods.Title = title; goods.ImageUrlList = Utility.GetListstring(imgUrls); goods.LogoUrl = logoUrl; goods.Nowprice = nowPrice; goods.OriginalPrice = originalPrice; goods.TagList = Utility.GetListstring(tags); if (goods.Cid != cid) {//改变产品分类的商品个数 统计 var data = new List <ChangeCountItem>(); if (goods.Cid > 0) { data.Add(new ChangeCountItem() { Id = goods.Cid, Change = -1 }); } data.Add(new ChangeCountItem() { Id = cid, Change = 1 }); GoodsCategoriesHelper.UpdateGoodsCategoriesCount(data); } goods.Cid = cid; goods.Content = content; goods.IsHot = isHot; //goods.IsRecommend = isRecommend; goods.SellerId = CurSellerId; var num = GoodsHelper.SaveGoods(goods); if (num > 0) { if (id > 0) { ReturnCorrectMsg("编辑成功"); } else { ReturnCorrectMsg("添加成功"); } } else if (id > 0) { ReturnErrorMsg("编辑失败"); } else { ReturnErrorMsg("添加失败"); } }