public void UpdateDishCategory(UpdateDishCategoryParameter parameter) { var bodyDict = new Dictionary <string, object>(); bodyDict["shop_id"] = parameter.ErpStoreId.ToString(); bodyDict["old_name"] = parameter.OriginalCategoryName; bodyDict["name"] = parameter.CategoryName; bodyDict["rank"] = parameter.Sequence + 1; Post("dish.category.update", bodyDict); }
public void CreateDishCategory(CreateDishCategoryParameter parameter) { var updateParameter = new UpdateDishCategoryParameter(); updateParameter.ErpStoreId = parameter.ErpStoreId; updateParameter.CategoryName = parameter.CategoryName; updateParameter.Sequence = parameter.Sequence; updateParameter.Token = parameter.Token; UpdateDishCategory(updateParameter); }
public void UpdateDishCategory() { var resturant = ResturantFactory.CreateResturant(ResturantPlatformType.Ele); var updateParameter = new UpdateDishCategoryParameter(); updateParameter.ErpStoreId = ErpStoreId; updateParameter.CategoryName = "东北菜"; updateParameter.OriginalCategoryName = "东北菜"; updateParameter.Sequence = 1; updateParameter.Token = Token; resturant.UpdateDishCategory(updateParameter); }
public void UpdateDishCategory(UpdateDishCategoryParameter parameter) { var shopid = this.getShopIdByErpStoreId(parameter.Token, parameter.ErpStoreId); var categories = this.GetDishCategoryList(parameter.ErpStoreId, parameter.Token); var original = categories.FirstOrDefault(m => m.Name == parameter.OriginalCategoryName); int id; bool isNew = false; if (parameter.OriginalCategoryName == null || original == null) { //添加商品 isNew = true; var param = new Dictionary <string, object>(); param["shopId"] = shopid; param["name"] = parameter.CategoryName; var result = this.Post(parameter.Token, "eleme.product.category.createCategory", param); id = result.Value <int>("id"); DishCategory newCategory = new DishCategory() { CategoryId = id }; if (parameter.Sequence < categories.Count) { categories.Insert((int)parameter.Sequence, newCategory); } else { categories.Add(newCategory); } } else { //修改商品 id = Convert.ToInt32(original.CategoryId); var param = new Dictionary <string, object>(); param["categoryId"] = id; param["name"] = parameter.CategoryName; this.Post(parameter.Token, "eleme.product.category.updateCategory", param); } //设置排序 if (isNew || parameter.Sequence != original.Sequence) { var param = new Dictionary <string, object>(); param["categoryIds"] = categories.Select(m => m.CategoryId).ToArray(); param["shopId"] = shopid; this.Post(parameter.Token, "eleme.product.category.setCategoryPositions", param); } }
public void UpdateDishCategory(UpdateDishCategoryParameter parameter) { var postDict = new SortedDictionary <string, string>(); postDict["appAuthToken"] = parameter.Token; postDict["charset"] = "utf-8"; postDict["timestamp"] = (Helper.ConvertDateTimeInt(DateTime.Now)).ToString(); postDict["catName"] = parameter.CategoryName; postDict["oldCatName"] = parameter.OriginalCategoryName; postDict["sequence"] = parameter.Sequence.ToString(); postDict["sign"] = MeituanHelper.Sign(postDict, this.Config.SignKey); var result = Helper.PostQueryString("http://api.open.cater.meituan.com/waimai/dish/updateCat", postDict, 8000); var jsonObj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result); Newtonsoft.Json.Linq.JToken errobj; if (jsonObj.TryGetValue("error", StringComparison.CurrentCultureIgnoreCase, out errobj)) { throw new Exception(errobj.Value <string>("message")); } if (!string.Equals(jsonObj.Value <string>("data"), "ok", StringComparison.CurrentCultureIgnoreCase)) { throw new Exception("发生错误"); } }