Esempio n. 1
0
        /// <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;
            }
        }
Esempio n. 2
0
        /// <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;
            }
        }