public Result UpdateState(string userId, string shopNo, int state, JArray data) { Ele_ShopDTO eleShopDto = _shopService.Get(userId, shopNo); if (eleShopDto == null) { return(Tools.ResultErr("未找到此门店")); } int num1 = data.Count <JToken>(); int count = 50; int num2 = (num1 + count - 1) / count; string msg = ""; for (int index = 0; index < num2; ++index) { IEnumerable <JToken> jtokens = data.Skip <JToken>(index * count).Take <JToken>(count); System.Collections.Generic.List <long> itemIds = new System.Collections.Generic.List <long>(); foreach (JToken jtoken in jtokens) { itemIds.Add(long.Parse(jtoken[(object)"ProdCode"].ToString().Split(';')[0])); } EleResult result = new EleResult(); if (state == 0) { result = _foodApiService.BatchListItems(eleShopDto.AccessToken, itemIds); } else if (state == 1) { result = _foodApiService.BatchDelistItems(eleShopDto.AccessToken, itemIds); } msg += this.Good(result); } return(string.IsNullOrEmpty(msg) ? Tools.ResultOk() : Tools.ResultErr(msg)); }
public string Good(EleResult result) { if (result.error != null) { return("ERR," + result.error.message); } JObject jobject = JObject.Parse(result.result.ToString()); if (((JContainer)jobject["failures"]).Count <= 0) { return(""); } string str = ""; foreach (JToken jtoken in JArray.Parse(jobject["failures"].ToString())) { str = str + jtoken["id"]?.ToString() + ":" + jtoken["description"]?.ToString() + ";"; } return(str); }