private void GetItem() { int cid = GetInt("id"); var item = CouponHelper.GetItem(cid); var goodsTitles = new List <object>(); var delGoodsIds = new List <int>(); foreach (var id in item.GoodsIds) { var good = GoodsHelper.GetGoods(id); if (good == null) { delGoodsIds.Add(id); } else { goodsTitles.Add(new { id = id, title = good.Title }); } } if (delGoodsIds.Count > 0) { foreach (var id in delGoodsIds) { item.GoodsIds.Remove(id); } CouponHelper.Update(item); } var data = new { couponid = item.Id, title = item.Title, img = item.ImgUrl, extcredit = item.Extcredit, fullmoney = item.FullMoney, discountmoney = item.DiscountMoney, goodstitles = goodsTitles, expiry = item.Expiry.ToString("yyyy-MM-dd"), description = item.Description }; JsonTransfer jt = new JsonTransfer(); jt.AddSuccessParam(); jt.Add("data", data); Response.Write(DesEncrypt(jt).ToLower()); Response.End(); }
/// <summary> /// 一键保存产品列表 /// </summary> public void SaveGoodsList() { string data_save = GetString("data_save"); if (string.IsNullOrEmpty(data_save)) { ReturnErrorMsg("没有选择需要保存的商品"); return; } var json = new JavaScriptSerializer(); var list = json.Deserialize(data_save, typeof(List <ChangeGoods>)) as List <ChangeGoods>; if (list == null) { ReturnErrorMsg("没有选择需要保存的商品"); return; } var saveList = new List <Goods>(); foreach (var changeGoodse in list) { var goods = GoodsHelper.GetGoods(changeGoodse.Id); if (goods == null || goods.SellerId != CurSellerId) { ReturnErrorMsg("没有权限修改产品或者产品不存在"); return; } goods.Nowprice = changeGoodse.Nowprice; goods.OriginalPrice = changeGoodse.OriginalPrice; //goods.IsRecommend = changeGoodse.IsRecommend; goods.IsHot = changeGoodse.IsHot; saveList.Add(goods); } if (saveList.Count > 0) { if (GoodsHelper.SaveGoodsList(saveList)) { ReturnCorrectMsg("保存成功"); return; } } ReturnCorrectMsg("保存失败"); }
/// <summary> /// 获取商品详情 /// </summary> public void GetGoods() { var gid = GetInt("gid"); var goods = GoodsHelper.GetGoods(gid); if (goods == null) { ReturnErrorMsg("不存在该商品"); return; } if (goods.SellerId != CurSellerId) { ReturnErrorMsg("无权访问此商品"); return; } goods.InitThumbnails(); //返回 ReturnCorrectData(goods); }
/// <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("添加失败"); } }