/// <summary> /// 库存查询 /// </summary> /// <param name="openid"></param> /// <returns></returns> public string StockSearch(string reqdata) { string res = ""; try { //LogHelper.InfoLog("StockSearch参数:" + reqdata); Request_StockInfo req = JsonConvert.DeserializeObject <Request_StockInfo>(reqdata); //小程序请求参数反序列化 StockInfo_Request reqtoapi = new StockInfo_Request(); //库存查询参数 reqtoapi.UnionId = req.UnionId; reqtoapi.CompanyName = req.CompanyName; //reqtoapi.PhoneNumber = req.PhoneNumber.Replace("15827002712", "18717764701"); reqtoapi.PhoneNumber = req.PhoneNumber; reqtoapi.key = AppSettingUtil.InsideApiKey2; reqtoapi.list = new List <ProLocListItem>() { new ProLocListItem() { ProductCode = req.ProductCode, LocationNames = string.Join(",", req.LocationNamesArr) } }; StockInfo_Response resstock = stockhttpdal.stockinfo(JsonConvert.SerializeObject(reqtoapi)); if (resstock.data.Count > 0) { if (req.sort == 1)//正序 { resstock.data = resstock.data.OrderBy(r => r.StockQty).ToList(); } else if (req.sort == 2)//倒序 { resstock.data = resstock.data.OrderByDescending(r => r.StockQty).ToList(); } } res = JsonConvert.SerializeObject(new { code = 0, msg = "ok", count = resstock.data.Count, StockData = resstock.data }); } catch (Exception ex) { res = JsonConvert.SerializeObject(new { code = 10003, msg = "系统故障", count = 0 }); LogHelper.ErrorLog(ex.Message + "," + ex.StackTrace); } return(res); }
/// <summary> /// 获取库存数量 /// </summary> /// <param name="sclist"></param> /// <returns></returns> private StockInfo_Response GetNewStock(List <ShoppingCartModel> sclist) { StockInfo_Response resstock = null; try { if (sclist.Count > 0) { List <ProLocListItem> list = new List <ProLocListItem>(); foreach (var item in sclist) { ProLocListItem proitem = new ProLocListItem() { ProductCode = item.ProductCode, LocationNames = item.LocationName }; list.Add(proitem); } StockInfo_Request req = new StockInfo_Request() { UnionId = sclist[0].unionid, CompanyName = sclist[0].VendName, key = AppSettingUtil.InsideApiKey2, list = list }; resstock = stockhttpdal.stockinfo(JsonConvert.SerializeObject(req)); if (resstock.code != 200 || resstock.data.Count == 0) { resstock = null; } } } catch (Exception ex) { resstock = null; LogHelper.ErrorLog(ex.Message + "," + ex.StackTrace); } return(resstock); }