/// <summary> /// 商品入库状态及数量修改 /// </summary> /// <param name="data"></param> /// <param name="xmlDocument"></param> /// <param name="list"></param> /// <param name="flag"></param> /// <returns></returns> private bool UpdateEntrepotStatus(string data, XmlDocument xmlDocument, List <SimpleSKUUpdateInfo> list, bool flag) { try { XmlNode skulist = xmlDocument.SelectSingleNode("xmldata"); //商品入库状态修改 string PONumber = skulist.SelectSingleNode("PONumber").InnerText; if (!string.IsNullOrEmpty(PONumber)) { result = ReturnXML("0000", "采购入库准备:PONumber", "1", ""); WMSHelper.SaveLog("PutSKUData", data, "采购入库准备", "info", "in"); flag = ProductHelper.UpdateSkusStock(PONumber, list); if (flag) { result = ReturnXML("0000", "采购入库成功", "1", ""); WMSHelper.SaveLog("PutSKUData", data, "采购入库成功", "info", "in"); } else { result = ReturnXML("0001", "采购入库失败", "2", ""); WMSHelper.SaveLog("PutSKUData", data, "采购入库失败", "info", "in"); } } } catch (Exception ex) { WMSHelper.SaveLog("PutSKUData", data, "采购入库失败:" + ex.Message, "error", "in"); } return(flag); }
public void Execute(XmlNode node) { try { //获取订单总行数 int orderCount = EcShop.ControlPanel.Sales.OrderHelper.GetDeliveredOrderCount(); int pagesize = orderCount / pageSize + (orderCount % pageSize > 0 ? 1 : 0); for (int index = 1; index <= pagesize; index++) { DataTable dt = EcShop.ControlPanel.Sales.OrderHelper.GetDeliveredOrderDt(pageSize, index); if (dt != null && dt.Rows.Count > 0) { Dictionary <string, string> dic = new Dictionary <string, string>(); for (int i = 0; i < dt.Rows.Count; i++) { string ExpressCompanyAbb = dt.Rows[i]["ExpressCompanyAbb"].ToString(); string ExpressNum = dt.Rows[i]["ShipOrderNumber"].ToString(); //循环获取订单的签收状态 List <object> expressInfo = ExpressHelper.GetExpressInfoByNum(ExpressCompanyAbb, ExpressNum); if (expressInfo.Count > 0) { //foreach (object express in expressInfo) //{ // string Time = ExpressHelper.GetPropertyValue(express, "time").ToString(); // string Content = ExpressHelper.GetPropertyValue(express, "context").ToString(); //} string lastInfo = ExpressHelper.GetPropertyValue(expressInfo[expressInfo.Count - 1], "context").ToString(); if (lastInfo.Contains("签收")) { dic.Add(ExpressNum, "3"); } } } if (dic.Count > 0) { OrderHelper.UpdateShipOrderStatusByShipOrderNumber(dic); } } } //DataTable dt = EcShop.ControlPanel.Sales.OrderHelper.GetDeliveredOrderDt(); //if (dt != null && dt.Rows.Count > 0) //{ // Dictionary<string, string> dic = new Dictionary<string, string>(); // for (int i = 0; i < dt.Rows.Count; i++) // { // string ExpressCompanyAbb = dt.Rows[i]["ExpressCompanyAbb"].ToString(); // string ExpressNum = dt.Rows[i]["ShipOrderNumber"].ToString(); // //循环获取订单的签收状态 // List<object> expressInfo = ExpressHelper.GetExpressInfoByNum(ExpressCompanyAbb, ExpressNum); // if (expressInfo.Count > 0) // { // //foreach (object express in expressInfo) // //{ // // string Time = ExpressHelper.GetPropertyValue(express, "time").ToString(); // // string Content = ExpressHelper.GetPropertyValue(express, "context").ToString(); // //} // string lastInfo = ExpressHelper.GetPropertyValue(expressInfo[expressInfo.Count - 1], "context").ToString(); // if (lastInfo.Contains("签收")) // { // dic.Add(ExpressNum, "3"); // } // } // } // OrderHelper.UpdateShipOrderStatusByShipOrderNumber(dic); //} } catch (Exception ex) { WMSHelper.SaveLog("定时获取运单状态:ExecuteJob", "", "异常:" + ex.ToString(), "error", "in"); } }
private void SetGrossWeight(string data) { WMSHelper.SaveLog("SetGrossWeight", data, "调用方法", "info", "in"); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(data); if (xmlDocument == null) { result = ReturnXML("0001", "xml文档格式错误", "0", ""); WMSHelper.SaveLog("SetGrossWeight", data, "xml文档格式错误", "error", "in"); return; } XmlNode skulist = xmlDocument.SelectSingleNode("xmldata/skulist"); if (skulist == null) { result = ReturnXML("0001", "不包含入库信息", "0", ""); WMSHelper.SaveLog("SetGrossWeight", data, "不包含商品信息", "error", "in"); return; } try { List <SimpleSKUUpdateInfo> list = new List <SimpleSKUUpdateInfo>(); foreach (XmlNode skuNode in skulist.SelectNodes("item")) { SimpleSKUUpdateInfo info = new SimpleSKUUpdateInfo(); info.SkuId = skuNode.SelectSingleNode("skuid").InnerText; decimal grossweight; decimal.TryParse(skuNode.SelectSingleNode("grossweight").InnerText, out grossweight); info.GrossWeight = grossweight; list.Add(info); } bool flag = false; if (list.Count > 0) { List <ErrorSimpleSKUUpdateInfo> errorlist; flag = ProductHelper.SetGrossWeight(list, out errorlist); if (flag && errorlist.Count == 0) { result = ReturnXML("0000", "操作成功", "1", ""); WMSHelper.SaveLog("SetGrossWeight", data, "操作成功", "info", "in"); return; } else if (flag && errorlist.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (ErrorSimpleSKUUpdateInfo info in errorlist) { sb.Append("<resultInfo>"); sb.AppendFormat("<skuid>{0}</skuid>", info.SkuId); sb.AppendFormat("<grossweight>{0}</grossweight>", info.GrossWeight); sb.Append("<errorcode>0001</errorcode>"); sb.Append("<errordescr>sku不存在</errordescr>"); sb.Append("</resultInfo>"); } result = ReturnXML("0001", "部分操作成功", "2", sb.ToString()); WMSHelper.SaveLog("SetGrossWeight", data, "部分操作成功" + sb.ToString(), "info", "in"); return; } else { result = ReturnXML("0001", "数据库操作异常", "0", ""); WMSHelper.SaveLog("SetGrossWeight", data, "数据库操作异常", "error", "in"); } } else { result = ReturnXML("0001", "不包含商品信息", "0", ""); WMSHelper.SaveLog("SetGrossWeight", data, "不包含商品信息", "error", "in"); return; } } catch (Exception ex) { result = ReturnXML("0001", ex.ToString(), "0", ""); //ErrorLog.Write(ex.ToString()); WMSHelper.SaveLog("SetGrossWeight", data, ex.ToString(), "error", "in"); return; } }
public string EMSExpressPushAPI() { //data = HttpUtility.UrlDecode(data, Encoding.GetEncoding("utf-8")); WMSHelper.SaveLog("EMSExpressPushAPI", "", "推送开始", "info", "in"); var inputStream = HttpContext.Current.Request.InputStream; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(inputStream); //WMSHelper.SaveLog("EMSExpressPushAPI", data, "调用方法", "info", "in"); //XmlDocument xmlDocument = new XmlDocument(); //xmlDocument.LoadXml(data); if (xmlDocument == null) { result = EMSReturnXML("0", "", "格式错误"); WMSHelper.SaveLog("EMSExpressPushAPI", "null", "xml文档格式错误", "error", "in"); return(result); } XmlNode xmlOrderList = xmlDocument.SelectSingleNode("listexpressmail"); if (xmlOrderList == null) { result = EMSReturnXML("0", "xml格式错误", "xml格式错误"); WMSHelper.SaveLog("EMSExpressPushAPI", "listexpressmail is null", "不包含订单信息", "error", "in"); return(result); } string ShipOrderNumbers = string.Empty; try { //提取xml数据 Dictionary <string, string> dic = new Dictionary <string, string>(); foreach (XmlNode orderNode in xmlOrderList.SelectNodes("expressmail")) { string ShipOrderNumber = orderNode.SelectSingleNode("mailnum").InnerText; //快递单号 ShipOrderNumbers += ShipOrderNumber + ","; string action = orderNode.SelectSingleNode("action").InnerText; //业务动作 string ShipOrderStatus = string.Empty; //快递已发货状态 if (action == "50") { ShipOrderStatus = "2"; } //客户已签收 if (action == "10") { ShipOrderStatus = "3"; } if (!string.IsNullOrEmpty(ShipOrderStatus)) { dic.Add(ShipOrderNumber, ShipOrderStatus); } } if (dic.Count > 0) { //根据推送的数据更新数据库 OrderHelper.UpdateShipOrderStatusByShipOrderNumber(dic); WMSHelper.SaveLog("EMSExpressPushAPI", dic.Count.ToString(), "操作成功", "info", "in"); //return "success"; } else { WMSHelper.SaveLog("EMSExpressPushAPI", dic.Count.ToString(), "不包含订单信息", "error", "in"); //return "1"; } result = EMSReturnXML("1", "", "推送成功"); } catch (Exception ex) { result = EMSReturnXML("0", ShipOrderNumbers, ex.Message); WMSHelper.SaveLog("EMSExpressPushAPI", "catch", ex.ToString(), "error", "in"); } return(result); }
/// <summary> /// 毛重回传 /// </summary> /// <param name="data"></param> private void UpdateDeliverStatus(string data) { WMSHelper.SaveLog("UpdateDeliverStatus", data, "调用方法", "info", "in"); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(data); if (xmlDocument == null) { result = ReturnXML("0001", "xml文档格式错误", "0", ""); WMSHelper.SaveLog("UpdateDeliverStatus", data, "xml文档格式错误", "error", "in"); return; } XmlNode xmlOrderList = xmlDocument.SelectSingleNode("xmldata/orderlist"); if (xmlOrderList == null) { result = ReturnXML("0001", "不包含订单信息", "0", ""); WMSHelper.SaveLog("UpdateDeliverStatus", data, "不包含订单信息", "error", "in"); return; } try { List <DeliverStatusInfo> list = new List <DeliverStatusInfo>(); foreach (XmlNode orderNode in xmlOrderList.SelectNodes("item")) { DeliverStatusInfo info = new DeliverStatusInfo(); info.OrderId = orderNode.SelectSingleNode("orderid").InnerText; info.OrderStatus = int.Parse(orderNode.SelectSingleNode("OrderStatus").InnerText); info.Describe = orderNode.SelectSingleNode("Describe").InnerText; info.Warehouse = orderNode.SelectSingleNode("Warehouse").InnerText; info.UpdateDate = Convert.ToDateTime(orderNode.SelectSingleNode("UpdateDate").InnerText); info.ShipOrderNumber = orderNode.SelectSingleNode("ShipOrderNumber").InnerText; ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNodeByKuaidi100Code(orderNode.SelectSingleNode("ExpressCompanyName").InnerText); string getExpressCompanyName = ""; if (expressCompanyInfo != null) { getExpressCompanyName = expressCompanyInfo.Name; } info.ExpressCompanyName = getExpressCompanyName; list.Add(info); } bool flag = false; if (list.Count > 0) { List <ErrorDeliverStatusInfo> errorlist; flag = OrderHelper.AddDeliverStatus(list, out errorlist); if (flag && errorlist.Count == 0) { result = ReturnXML("0000", "操作成功", "1", ""); WMSHelper.SaveLog("UpdateDeliverStatus", data, "操作成功", "info", "in"); return; } else if (flag && errorlist.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (ErrorDeliverStatusInfo info in errorlist) { sb.Append("<resultInfo>"); sb.AppendFormat("<orderid>{0}</orderid>", info.OrderId); sb.AppendFormat("<OrderStatus>{0}</OrderStatus>", info.OrderStatus); sb.AppendFormat("<Describe>{0}</Describe>", info.Describe); sb.AppendFormat("<Warehouse>{0}</Warehouse>", info.Warehouse); sb.AppendFormat("<ShipOrderNumber>{0}</ShipOrderNumber>", info.ShipOrderNumber); sb.AppendFormat("<ExpressCompanyName>{0}</ExpressCompanyName>", info.ExpressCompanyName); //sb.AppendFormat("<UpdateDate>{0}</UpdateDate>", info.UpdateDate.ToString("YYYY-MM-DD HH:MM:SS")); sb.AppendFormat("<errorcode>{0}</errorcode>", info.errorcode); sb.AppendFormat("<errordescr>{0}</errordescr>", info.errordescr); sb.Append("</resultInfo>"); } result = ReturnXML("0001", "部分操作成功", "2", sb.ToString()); WMSHelper.SaveLog("UpdateDeliverStatus", data, "部分操作成功:" + sb.ToString(), "info", "in"); return; } else { result = ReturnXML("0001", "数据库操作异常", "0", ""); WMSHelper.SaveLog("UpdateDeliverStatus", data, "数据库操作异常", "error", "in"); return; } } else { result = ReturnXML("0001", "不包含订单信息", "0", ""); WMSHelper.SaveLog("UpdateDeliverStatus", data, "不包含订单信息", "error", "in"); return; } } catch (Exception ex) { result = ReturnXML("0001", ex.ToString(), "0", ""); WMSHelper.SaveLog("UpdateDeliverStatus", data, ex.ToString(), "error", "in"); return; } }
private void AdjustSKUData(string data) { WMSHelper.SaveLog("AdjustSKUData", data, "调用方法", "info", "in"); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(data); if (xmlDocument == null) { result = ReturnXML("0001", "xml文档格式错误", "0", ""); WMSHelper.SaveLog("AdjustSKUData", data, "xml文档格式错误", "error", "in"); return; } XmlNode skulist = xmlDocument.SelectSingleNode("xmldata/skulist"); if (skulist == null) { result = ReturnXML("0001", "不包含入库信息", "0", ""); WMSHelper.SaveLog("AdjustSKUData", data, "xml不包含入库信息", "error", "in"); return; } try { List <SimpleSKUUpdateInfo> list = new List <SimpleSKUUpdateInfo>(); foreach (XmlNode skuNode in skulist.SelectNodes("item")) { SimpleSKUUpdateInfo info = new SimpleSKUUpdateInfo(); info.SkuId = skuNode.SelectSingleNode("skuid").InnerText; info.Amount = int.Parse(skuNode.SelectSingleNode("amount").InnerText); list.Add(info); } bool flag = false; if (list.Count > 0) { List <ErrorSimpleSKUUpdateInfo> errorlist; flag = ProductHelper.AdjustSkusStock(list, out errorlist); if (flag && errorlist.Count == 0) { result = ReturnXML("0000", "操作成功", "1", ""); WMSHelper.SaveLog("AdjustSKUData", data, "操作成功", "info", "in"); return; } else if (flag && errorlist.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (ErrorSimpleSKUUpdateInfo info in errorlist) { sb.Append("<resultInfo>"); sb.AppendFormat("<skuid>{0}</skuid>", info.SkuId); sb.AppendFormat("<amount>{0}</amount>", info.Amount); sb.AppendFormat("<errorcode>{0}</errorcode>", info.errorcode); sb.AppendFormat("<errordescr>{0}</errordescr>", info.errordescr); sb.Append("</resultInfo>"); } result = ReturnXML("0001", "部分操作成功", "2", sb.ToString()); WMSHelper.SaveLog("AdjustSKUData", data, "部分操作成功:" + sb.ToString(), "info", "in"); return; } else { result = ReturnXML("0001", "数据库操作异常", "0", ""); WMSHelper.SaveLog("AdjustSKUData", data, "数据库操作异常", "error", "in"); return; } } else { result = ReturnXML("0001", "不包含库存同步信息", "0", ""); WMSHelper.SaveLog("AdjustSKUData", data, "不包含库存同步信息", "error", "in"); return; } } catch (Exception ex) { result = ReturnXML("0001", ex.ToString(), "0", ""); WMSHelper.SaveLog("AdjustSKUData", data, ex.ToString(), "error", "in"); return; } }
/// <summary> /// 发货回传接口 /// </summary> /// <param name="data"></param> private void DeliverGoodsData(string data) { WMSHelper.SaveLog("DeliverGoodsData", data, "调用方法", "info", "in"); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(data); if (xmlDocument == null) { result = ReturnXML("0001", "xml文档格式错误", "0", ""); WMSHelper.SaveLog("DeliverGoodsData", data, "xml文档格式错误", "error", "in"); return; } XmlNode orderlistxml = xmlDocument.SelectSingleNode("xmldata/orderlist"); if (orderlistxml == null) { result = ReturnXML("0001", "不包含订单信息", "0", ""); WMSHelper.SaveLog("DeliverGoodsData", data, "不包含订单信息", "error", "in"); return; } try { List <ErrorDeliverGoods> errorlist = new List <ErrorDeliverGoods>(); foreach (XmlNode orderNode in orderlistxml.SelectNodes("item")) { string orderid = orderNode.SelectSingleNode("orderid").InnerText; string ShipOrderNumber = orderNode.SelectSingleNode("ShipOrderNumber").InnerText; string ExpressCompanyName = orderNode.SelectSingleNode("ExpressCompanyName").InnerText; string ExpressCompanyCode = orderNode.SelectSingleNode("ExpressCompanyCode ").InnerText; string strExpressDate = orderNode.SelectSingleNode("ExpressDate").InnerText; #region 参数判断 DateTime ExpressDate; if (!DateTime.TryParse(strExpressDate, out ExpressDate)) { ErrorDeliverGoods erroinfo = new ErrorDeliverGoods(); erroinfo.ExpressCompanyCode = ExpressCompanyCode; erroinfo.orderid = orderid; erroinfo.ExpressCompanyName = ExpressCompanyName; erroinfo.ExpressDate = strExpressDate; erroinfo.ShipOrderNumber = ShipOrderNumber; erroinfo.errorcode = "0001"; erroinfo.errordescr = "日期格式不正确"; errorlist.Add(erroinfo); continue; } if (string.IsNullOrEmpty(orderid)) { ErrorDeliverGoods erroinfo = new ErrorDeliverGoods(); erroinfo.ExpressCompanyCode = ExpressCompanyCode; erroinfo.orderid = orderid; erroinfo.ExpressCompanyName = ExpressCompanyName; erroinfo.ExpressDate = strExpressDate; erroinfo.ShipOrderNumber = ShipOrderNumber; erroinfo.errorcode = "0001"; erroinfo.errordescr = "订单id不能为空"; errorlist.Add(erroinfo); continue; } if (string.IsNullOrEmpty(ExpressCompanyCode)) { ErrorDeliverGoods erroinfo = new ErrorDeliverGoods(); erroinfo.ExpressCompanyCode = ExpressCompanyCode; erroinfo.orderid = orderid; erroinfo.ExpressCompanyName = ExpressCompanyName; erroinfo.ExpressDate = strExpressDate; erroinfo.ShipOrderNumber = ShipOrderNumber; erroinfo.errorcode = "0001"; erroinfo.errordescr = "快递公司编号不能为空"; errorlist.Add(erroinfo); continue; } if (string.IsNullOrEmpty(ShipOrderNumber)) { ErrorDeliverGoods erroinfo = new ErrorDeliverGoods(); erroinfo.ExpressCompanyCode = ExpressCompanyCode; erroinfo.orderid = orderid; erroinfo.ExpressCompanyName = ExpressCompanyName; erroinfo.ExpressDate = strExpressDate; erroinfo.ShipOrderNumber = ShipOrderNumber; erroinfo.errorcode = "0001"; erroinfo.errordescr = "快递单号不能为空"; errorlist.Add(erroinfo); continue; } //if (string.IsNullOrEmpty(ExpressCompanyName)) //{ // ErrorDeliverGoods erroinfo = new ErrorDeliverGoods(); // erroinfo.ExpressCompanyCode = ExpressCompanyCode; // erroinfo.orderid = orderid; // erroinfo.ExpressCompanyName = ExpressCompanyName; // erroinfo.ExpressDate = strExpressDate; // erroinfo.ShipOrderNumber = ShipOrderNumber; // erroinfo.errorcode = "0001"; // erroinfo.errordescr = "快递公司名称不能为空"; // errorlist.Add(erroinfo); // continue; //} OrderInfo orderInfo = OrderHelper.GetOrderInfo(orderid); if (orderInfo == null) { ErrorDeliverGoods erroinfo1 = new ErrorDeliverGoods(); erroinfo1.ExpressCompanyCode = ExpressCompanyCode; erroinfo1.orderid = orderid; erroinfo1.ExpressCompanyName = ExpressCompanyName; erroinfo1.ExpressDate = strExpressDate; erroinfo1.ShipOrderNumber = ShipOrderNumber; erroinfo1.errorcode = "0001"; erroinfo1.errordescr = "订单不存在"; errorlist.Add(erroinfo1); continue; } if (orderInfo.OrderStatus != OrderStatus.BuyerAlreadyPaid) { ErrorDeliverGoods erroinfo1 = new ErrorDeliverGoods(); erroinfo1.ExpressCompanyCode = ExpressCompanyCode; erroinfo1.orderid = orderid; erroinfo1.ExpressCompanyName = ExpressCompanyName; erroinfo1.ExpressDate = strExpressDate; erroinfo1.ShipOrderNumber = ShipOrderNumber; erroinfo1.errorcode = "0001"; erroinfo1.errordescr = "订单状态不是已付款"; errorlist.Add(erroinfo1); continue; } #endregion ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNodeByKuaidi100Code(ExpressCompanyCode); string getExpressCompanyName = ""; if (expressCompanyInfo != null) { getExpressCompanyName = expressCompanyInfo.Name; } ShippingModeInfo shippingMode = SalesHelper.GetShippingModeByCompany(getExpressCompanyName); if (shippingMode != null) { orderInfo.RealShippingModeId = shippingMode.ModeId; orderInfo.RealModeName = shippingMode.Name; orderInfo.ShippingModeId = shippingMode.ModeId; orderInfo.ModeName = shippingMode.Name; } orderInfo.ExpressCompanyAbb = ExpressCompanyCode; orderInfo.ExpressCompanyName = getExpressCompanyName; orderInfo.ShipOrderNumber = ShipOrderNumber; orderInfo.ShippingDate = ExpressDate; if (OrderHelper.WMSSendGoods(orderInfo)) { SendNoteInfo sendNoteInfo = new SendNoteInfo(); sendNoteInfo.NoteId = Globals.GetGenerateId(); sendNoteInfo.OrderId = orderInfo.OrderId; sendNoteInfo.Operator = orderInfo.Username; sendNoteInfo.Remark = "后台" + sendNoteInfo.Operator + "发货成功"; OrderHelper.SaveSendNote(sendNoteInfo); this.PaySendGoodsNotice(orderInfo); this.SendGoodsMessage(orderInfo); orderInfo.OnDeliver(); } else { ErrorDeliverGoods erroinfo2 = new ErrorDeliverGoods(); erroinfo2.ExpressCompanyCode = ExpressCompanyCode; erroinfo2.orderid = orderid; erroinfo2.ExpressCompanyName = ExpressCompanyName; erroinfo2.ExpressDate = strExpressDate; erroinfo2.ShipOrderNumber = ShipOrderNumber; erroinfo2.errorcode = "0001"; erroinfo2.errordescr = "发货失败"; errorlist.Add(erroinfo2); } } if (errorlist.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (ErrorDeliverGoods info in errorlist) { sb.Append("<resultInfo>"); sb.AppendFormat("<orderid>{0}</orderid>", info.orderid); sb.AppendFormat("<ExpressCompanyName>{0}</ExpressCompanyName>", info.ExpressCompanyName); sb.AppendFormat("<ExpressCompanyCode>{0}</ExpressCompanyCode>", info.ExpressCompanyCode); sb.AppendFormat("<ExpressDate>{0}</ExpressDate>", info.ExpressDate); sb.AppendFormat("<errorcode>{0}</errorcode>", info.errorcode); sb.AppendFormat("<errordescr>{0}</errordescr>", info.errordescr); sb.Append("</resultInfo>"); } WMSHelper.SaveLog("DeliverGoodsData", data, "部分操作成功:" + sb.ToString(), "info", "in"); result = ReturnXML("0001", "部分操作成功", "2", sb.ToString()); return; } else { WMSHelper.SaveLog("DeliverGoodsData", data, "操作成功", "info", "in"); result = ReturnXML("0000", "操作成功", "0", ""); return; } } catch (Exception ex) { WMSHelper.SaveLog("DeliverGoodsData", data, ex.ToString(), "error", "in"); result = ReturnXML("0001", this.FilterXMLCode(ex.ToString()), "0", ""); return; } }
public string YTOExpressPushAPI() { //data = HttpUtility.UrlDecode(data, Encoding.GetEncoding("utf-8")); XmlDocument xmlDocument = new XmlDocument(); //WMSHelper.SaveLog("YTOExpressPushAPI", "Start", "调用方法", "info", "in"); try { StreamReader reader = new StreamReader(HttpContext.Current.Request.InputStream); string xmlData = reader.ReadToEnd(); string[] xmlArr = xmlData.Split('&'); string[] xmlDataArr = xmlArr[0].Split('='); string data = HttpUtility.UrlDecode(xmlDataArr[1], Encoding.GetEncoding("utf-8")); xmlDocument.LoadXml(data); if (xmlDocument == null) { //result = YTReturnXML("0001", "xml文档格式错误", "0"); WMSHelper.SaveLog("YTOExpressPushAPI", xmlDocument.ToString(), "xml文档格式错误", "error", "in"); return("0"); } XmlNode xmlOrderList = xmlDocument.SelectSingleNode("UpdateInfo"); if (xmlOrderList == null) { //result = ReturnXML("0001", "不包含订单信息", "0", ""); WMSHelper.SaveLog("YTOExpressPushAPI", xmlDocument.ToString(), "不包含订单信息", "error", "in"); return("1"); } //提取xml数据 Dictionary <string, string> dic = new Dictionary <string, string>(); string ShipOrderNumber = xmlOrderList.SelectSingleNode("txLogisticID").InnerText; //快递单号 string action = xmlOrderList.SelectSingleNode("infoContent").InnerText; //业务动作 string ShipOrderStatus = string.Empty; //快递已发货状态 if (action == "DEPARTURE") { ShipOrderStatus = "2"; } //客户已签收 if (action == "SIGNED") { ShipOrderStatus = "3"; } if (!string.IsNullOrEmpty(ShipOrderStatus)) { dic.Add(ShipOrderNumber, ShipOrderStatus); } if (dic.Count > 0) { //根据推送的数据更新数据库 OrderHelper.UpdateShipOrderStatusByShipOrderNumber(dic); result = YTOReturnXML(ShipOrderNumber, "true"); WMSHelper.SaveLog("YTOExpressPushAPI", xmlDocument.ToString(), "操作成功", "info", "in"); } else { //result = ReturnXML("0001", "不包含订单信息", "0", ""); WMSHelper.SaveLog("YTOExpressPushAPI", xmlDocument.ToString(), "不包含订单信息", "error", "in"); } } catch (Exception ex) { result = YTOReturnXML("error", "false"); WMSHelper.SaveLog("YTOExpressPushAPI", xmlDocument.ToString(), "异常:" + ex.ToString(), "error", "in"); } //HttpContext.Current.Response.Write(result); return(result); }
public void GetPO_Status(System.Web.HttpContext context) { string status = context.Request["status"].ToLower(); string id = context.Request["id"].ToLower(); string Remark = context.Request["Remark"]; string UserId = context.Request["UserId"].ToLower(); string Username = context.Request["Username"]; if (!string.IsNullOrEmpty(status) && !string.IsNullOrEmpty(id)) { //招商权限(确认、取消确认)POZS和关务权限(除确认外其他)POGW //确认和取消确认只有招商有权限 if ((status == "0" || status == "1") && !CheckPrivilegeReturn(Username, Privilege.POZS)) { this.message = "{\"success\":\"NO\",\"MSG\":\"您无权操作,请联系管理员!\"}"; return; } if (status != "0" && status != "1" && !CheckPrivilegeReturn(Username, Privilege.POGW)) { this.message = "{\"success\":\"NO\",\"MSG\":\"您无权操作,请联系管理员!\"}"; return; } //申报、确认、删除、编辑在页面判断是否是自己的 if (status == "-1") { Remark = string.Format("{0}_{1}退回,时间:{2}", UserId, Username, DateTime.Now); } if (status == "0") { Remark = string.Format("{0}_{1}取消确认,时间:{2}", UserId, Username, DateTime.Now); } //确认时必须要有明细 if (status == "1" && !PurchaseOrderHelper.IsExistsPOItem(id)) { this.message = "{\"success\":\"NO\",\"MSG\":\"确认失败,请先添加采购订单明细!\"}"; return; } //如果是申报成功先调用WMS接口,成功后再修改 if (status == "7") { //1.获取发送需要的数据 DataSet ds = PurchaseOrderHelper.GetPurchaseOrderAndItem("po.id=" + id); if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { ErrorLog.Write("执行了putASNData->PurchaseOrderHelper.GetPurchaseOrderAndItem返回查询结果:" + ds.Tables[0].Rows.Count); //构造数据 string skuData = this.CreatePOData(ds.Tables[0]); skuData = skuData.Replace("\n", "").Replace("\t", "").Replace("\r", "").Replace("+", "+"); //配置获取 HiConfiguration config = HiConfiguration.GetConfig(); XmlNode configSection = config.GetConfigSection("Ecdev/Jobs"); XmlNode configjob = configSection.SelectSingleNode("job[@name='OrderSendJob']"); string appkey = configjob.Attributes["appkey"].InnerText; // "test";//验签KEY string appSecret = configjob.Attributes["appSecret"].InnerText; //"1234567890";//秘钥存配置 string customerid = configjob.Attributes["client_customerid"].InnerText; // "XJW";//client_customerid string client_db = configjob.Attributes["client_db"].InnerText; // "WH01"; string apptoken = configjob.Attributes["apptoken"].InnerText; //"80AC1A3F-F949-492C-A024-7044B28C8025"; string url = configjob.Attributes["apiurl"].InnerText; //"http://192.168.1.120:8090/datahubWeb/FLUXWMSAPI/XJW";//apiurl //生成验签值 string tempdata = appSecret + skuData + appSecret; string md5tempdata = WMSHelper.MD5(tempdata); string basetempdata = WMSHelper.EncodingString(md5tempdata.ToLower(), System.Text.Encoding.UTF8); string sign = System.Web.HttpUtility.UrlEncode(basetempdata.ToUpper(), System.Text.Encoding.UTF8); //时间戳 string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//YYYY-MM-DD HH:MM:SS string postData = "method=putASNData&client_customerid=" + customerid + "&client_db=" + client_db + "&messageid=ASN&apptoken=" + apptoken + "&appkey=" + appkey + "&sign=" + sign + "×tamp=" + timestamp; //记录发送数据日志 ErrorLog.Write("执行了putASNData->发送数据:postData=" + postData + "&data=" + skuData); WMSHelper.SaveLog("putASNData", "postData=" + postData + "&data=" + skuData, "调用方法", "info", "out"); skuData = System.Web.HttpUtility.UrlEncode(skuData); //发送并接收回传数据 string sendResult = WMSHelper.PostData(url, postData + "&data=" + skuData); string tempResult = System.Web.HttpUtility.UrlDecode(sendResult); //保存接收消息 ErrorLog.Write("执行了putASNData->接收WMS消息:" + tempResult + "\n"); WMSHelper.SaveLog("putASNData", "", "返回结果:" + tempResult, "info", "in"); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(tempResult); XmlNode node = xmlDocument.SelectSingleNode("Response/return/returnCode"); XmlNode nodeFlag = xmlDocument.SelectSingleNode("Response/return/returnFlag"); XmlNode nodeDesc = xmlDocument.SelectSingleNode("Response/return/returnDesc"); if (node.InnerText != "0000") { //推送失败 this.message = "{\"success\":\"NO\",\"MSG\":\"采购订单传送WMS失败:" + nodeDesc.InnerText + "\"}"; return; } } else { this.message = "{\"success\":\"NO\",\"MSG\":\"获取采购订单数据失败\"}"; return; } } //执行更改 if (PurchaseOrderHelper.SetPOStatus(id, status, Remark, int.Parse(UserId), Username)) { this.message = "{\"success\":\"YES\",\"MSG\":\"操作成功\"}"; } else { this.message = "{\"success\":\"NO\",\"MSG\":\"操作失败,请检查您是否有权限,如无问题请刷新后重试。\"}"; } } else { this.message = "{\"success\":\"NO\",\"MSG\":\"参数获取失败\"}"; } }