private Response_Product ProductFactory(Product_Response p) { Response_Product resp = new Response_Product(); if (p.data.Count > 0) { resp.ProductCode = p.data[0].ProductCode; resp.ProductName = p.data[0].ProductName; resp.ProductDescrCH = p.data[0].ProductDescrCH; resp.ProductDescrEN = p.data[0].ProductDescrEN; resp.PackageCH = p.data[0].PackageCH; resp.VendorName = p.data[0].VendorName; resp.SpecificationModel = p.data[0].SpecificationModel; resp.MadeInCH = p.data[0].MadeInCH; resp.MadeInEN = p.data[0].MadeInEN; resp.ModelCode = p.data[0].ModelCode; resp.QuantityUnitCH = p.data[0].QuantityUnitCH; resp.QuantityUnitConvertCH = p.data[0].QuantityUnitConvertCH; resp.QuantityUnitConvertEN = p.data[0].QuantityUnitConvertEN; resp.Remark = p.data[0].Remark; resp.IsBatchNumberMatch = p.data[0].IsBatchNumberMatch; resp.ImgUrl = p.data[0].ImgUrl; } return(resp); }
/// <summary> /// 备件基础信息 /// </summary> /// <param name="reqdata"></param> /// <returns></returns> public string Product(string reqdata) { string res = ""; try { Product_Request reqd = JsonConvert.DeserializeObject <Product_Request>(reqdata); //reqd.PhoneNumber = reqd.PhoneNumber.Replace("15827002712", "18717764701"); reqd.key = AppSettingUtil.InsideApiKey2; Product_Response prespon = stockhttpdal.product(JsonConvert.SerializeObject(reqd)); if (prespon.code == 200) { Response_Product proinfo = ProductFactory(prespon); proinfo.StockQty = GetStockQty(reqd); //库存 ShoppingCartModel scm = shopcartdal.GetShoppingCartByPro(reqd.UnionId, reqd.keyValue, reqd.LocationName, reqd.SerialNumber, reqd.BatchNumber); proinfo.cartGoodsCount = scm != null ? scm.number : 0; //购物车数量 CollectAndFootPrintModel cfm = cfdal.GetCollectOrFootPrint(reqd.UnionId, reqd.keyValue, reqd.LocationName, reqd.SerialNumber, reqd.BatchNumber, "Collect"); proinfo.IsCollect = cfm == null ? 0 : 1; //收藏状态 res = JsonConvert.SerializeObject(new { code = 0, msg = "ok", ProductData = proinfo }); } else { res = JsonConvert.SerializeObject(new { code = 10002, msg = "api异常" }); } } catch (Exception ex) { res = JsonConvert.SerializeObject(new { code = 10003, msg = "系统故障", count = 0 }); LogHelper.ErrorLog(ex.Message + "," + ex.StackTrace); } return(res); }