Exemplo n.º 1
0
        public string ChangLogistics(string tid, string company_name, string out_sid)
        {
            OrderInfo orderInfo = OrderHelper.GetOrderInfo(tid);

            if (orderInfo == null || string.IsNullOrEmpty(orderInfo.OrderId))
            {
                return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Trade_not_Exists, "tid"));
            }
            if (orderInfo.OrderStatus == OrderStatus.Refunded || orderInfo.OrderStatus == OrderStatus.Returned || orderInfo.OrderStatus == OrderStatus.Closed || (orderInfo.OrderStatus != OrderStatus.BuyerAlreadyPaid && (!(orderInfo.Gateway == "hishop.plugins.payment.podrequest") || orderInfo.OrderStatus != OrderStatus.WaitBuyerPay) && orderInfo.OrderStatus != OrderStatus.SellerAlreadySent))
            {
                return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Trade_Status_Print, "orderstatue"));
            }
            ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNode(company_name);

            orderInfo.ExpressCompanyAbb  = expressCompanyInfo.Kuaidi100Code;
            orderInfo.ExpressCompanyName = expressCompanyInfo.Name;
            orderInfo.IsPrinted          = true;
            orderInfo.ShipOrderNumber    = out_sid;
            if (!OrderHelper.UpdateOrder(orderInfo))
            {
                return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Trade_Print_Faild, "order"));
            }
            string format = "{{\"logistics_change_response\":{{\"shipping\":{{\"is_success\":{0}}}}}}}";

            return(string.Format(format, "true"));
        }
Exemplo n.º 2
0
        public static IList <ExpressCompanyInfo> GetAllExpress(bool IsContainClose)
        {
            IList <ExpressCompanyInfo> list = new List <ExpressCompanyInfo>();
            XmlDocument xmlNode             = ExpressHelper.GetXmlNode();
            XmlNode     xmlNode2            = xmlNode.SelectSingleNode("companys");

            foreach (XmlNode childNode in xmlNode2.ChildNodes)
            {
                ExpressCompanyInfo expressCompanyInfo = new ExpressCompanyInfo();
                expressCompanyInfo.Name          = childNode.Attributes["name"].Value;
                expressCompanyInfo.Kuaidi100Code = childNode.Attributes["Kuaidi100Code"].Value;
                expressCompanyInfo.TaobaoCode    = childNode.Attributes["TaobaoCode"].Value;
                if (childNode.Attributes["JDCode"] != null)
                {
                    expressCompanyInfo.JDCode = childNode.Attributes["JDCode"].Value;
                }
                if (childNode.Attributes["CloseStatus"] != null)
                {
                    expressCompanyInfo.CloseStatus = childNode.Attributes["CloseStatus"].Value.ToBool();
                }
                if (!IsContainClose)
                {
                    if (expressCompanyInfo.CloseStatus)
                    {
                        list.Add(expressCompanyInfo);
                    }
                }
                else
                {
                    list.Add(expressCompanyInfo);
                }
            }
            return(list);
        }
Exemplo n.º 3
0
        private void btnGetAndSendGoods_Click(object sender, EventArgs e)
        {
            int         replaceId   = this.Page.Request["replaceId"].ToInt(0);
            ReplaceInfo replaceInfo = TradeHelper.GetReplaceInfo(replaceId);

            if (replaceInfo == null)
            {
                this.ShowMsg("错误的换货信息", false);
            }
            else
            {
                string arg = "自己门店";
                if (this.UserStoreId == 0)
                {
                    arg = "平台";
                }
                if (replaceInfo.StoreId != this.UserStoreId)
                {
                    this.ShowMsg(string.Format("只能由发货的店铺或者平台处理", arg), false);
                }
                else
                {
                    string             text  = "";
                    string             text2 = "";
                    ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNode(this.expressDropDownList.SelectedValue);
                    if (expressCompanyInfo != null)
                    {
                        text  = expressCompanyInfo.Kuaidi100Code;
                        text2 = expressCompanyInfo.Name;
                        string text3 = this.txtShipOrderNumber.Text;
                        if (string.IsNullOrEmpty(text3) || text3.Length > 20)
                        {
                            this.ShowMsg("请输入运单编号,长度在1-20位之间", false);
                        }
                        else if (TradeHelper.ReplaceShopSendGoods(replaceId, text, text2, text3, replaceInfo.OrderId, replaceInfo.SkuId))
                        {
                            if (text.ToUpper() == "HTKY")
                            {
                                ExpressHelper.GetDataByKuaidi100(text, text3);
                            }
                            OrderInfo  orderInfo = OrderHelper.GetOrderInfo(replaceInfo.OrderId);
                            MemberInfo user      = Users.GetUser(orderInfo.UserId);
                            replaceInfo.HandleStatus = ReplaceStatus.MerchantsDelivery;
                            Messenger.AfterSaleDeal(user, orderInfo, null, replaceInfo);
                            this.ShowMsg("换货发货成功!", true, HttpContext.Current.Request.Url.ToString());
                        }
                        else
                        {
                            this.ShowMsg("换货发货失败,原因未知", false);
                        }
                    }
                    else
                    {
                        this.ShowMsg("请选择快递公司", false);
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void btnUpDate_Click(object sender, EventArgs e)
        {
            ShippingModeInfo info3 = new ShippingModeInfo();

            info3.Name        = Globals.HtmlEncode(txtModeName.Text.Trim());
            info3.ModeId      = modeId;
            info3.Description = fck.Text.Replace("\r\n", "").Replace("\r", "").Replace("\n", "");
            ShippingModeInfo target = info3;

            if (shippingTemplatesDropDownList.SelectedValue.HasValue)
            {
                target.TemplateId = shippingTemplatesDropDownList.SelectedValue.Value;
            }
            else
            {
                ShowMsg("请选择配送模板", false);
                return;
            }
            foreach (ListItem item in expressCheckBoxList.Items)
            {
                if (item.Selected)
                {
                    ExpressCompanyInfo info2 = new ExpressCompanyInfo();
                    info2.ExpressCompanyName = item.Text;
                    info2.ExpressCompanyAbb  = item.Value;
                    target.ExpressCompany.Add(info2);
                }
            }
            if (target.ExpressCompany.Count == 0)
            {
                ShowMsg("至少要选择一个配送公司", false);
            }
            else
            {
                ValidationResults results = Hishop.Components.Validation.Validation.Validate <ShippingModeInfo>(target, new string[] { "ValShippingModeInfo" });
                string            msg     = string.Empty;
                if (!results.IsValid)
                {
                    foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                    {
                        msg = msg + Formatter.FormatErrorMessage(result.Message);
                    }
                    ShowMsg(msg, false);
                }
                else if (SalesHelper.UpdateShippMode(target))
                {
                    Page.Response.Redirect("EditShippingType.aspx?modeId=" + target.ModeId + "&isUpdate=true");
                }
                else
                {
                    ShowMsg("更新失败", false);
                }
            }
        }
Exemplo n.º 5
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            ShippingModeInfo target = new ShippingModeInfo();

            target.Name        = Globals.HtmlEncode(txtModeName.Text.Trim());
            target.Description = fck.Text.Replace("\r\n", "").Replace("\r", "").Replace("\n", "");
            if (shippingTemplatesDropDownList.SelectedValue.HasValue)
            {
                target.TemplateId = shippingTemplatesDropDownList.SelectedValue.Value;
            }
            else
            {
                ShowMsg("请选择配送模板", false);
                return;
            }
            foreach (ListItem item in expressCheckBoxList.Items)
            {
                if (item.Selected)
                {
                    ExpressCompanyInfo expressCompanyInfo = new ExpressCompanyInfo();
                    expressCompanyInfo.ExpressCompanyName = item.Text;
                    expressCompanyInfo.ExpressCompanyAbb  = item.Value;
                    target.ExpressCompany.Add(expressCompanyInfo);
                }
            }
            if (target.ExpressCompany.Count == 0)
            {
                ShowMsg("至少要选择一个配送公司", false);
            }
            else
            {
                ValidationResults results = Hishop.Components.Validation.Validation.Validate <ShippingModeInfo>(target, new string[] { "ValShippingModeInfo" });
                string            msg     = string.Empty;
                if (!results.IsValid)
                {
                    foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                    {
                        msg = msg + Formatter.FormatErrorMessage(result.Message);
                    }
                    ShowMsg(msg, false);
                }
                else if (SalesHelper.CreateShippingMode(target))
                {
                    ClearControlValue();
                    ShowMsg("成功添加了一个配送方式", true);
                }
                else
                {
                    ShowMsg("添加失败,请确定填写了所有必填项", false);
                }
            }
        }
Exemplo n.º 6
0
        public static IList <ExpressCompanyInfo> GetAllExpress()
        {
            IList <ExpressCompanyInfo> list = new List <ExpressCompanyInfo>();

            foreach (XmlNode node2 in GetXmlNode().SelectSingleNode("companys").ChildNodes)
            {
                ExpressCompanyInfo item = new ExpressCompanyInfo {
                    Name          = node2.Attributes["name"].Value,
                    Kuaidi100Code = node2.Attributes["Kuaidi100Code"].Value,
                    TaobaoCode    = node2.Attributes["TaobaoCode"].Value
                };
                list.Add(item);
            }
            return(list);
        }
Exemplo n.º 7
0
        public static ExpressCompanyInfo FindNodeByCode(string code)
        {
            ExpressCompanyInfo expressCompanyInfo = null;
            XmlDocument        xmlNode            = ExpressHelper.GetXmlNode();
            string             xpath    = string.Format("//company[@TaobaoCode='{0}']", code);
            XmlNode            xmlNode2 = xmlNode.SelectSingleNode(xpath);

            if (xmlNode2 != null)
            {
                expressCompanyInfo               = new ExpressCompanyInfo();
                expressCompanyInfo.Name          = xmlNode2.Attributes["name"].Value;
                expressCompanyInfo.Kuaidi100Code = xmlNode2.Attributes["Kuaidi100Code"].Value;
                expressCompanyInfo.TaobaoCode    = code;
            }
            return(expressCompanyInfo);
        }
Exemplo n.º 8
0
        public static ExpressCompanyInfo FindNodeByCode(string code)
        {
            ExpressCompanyInfo info    = null;
            XmlDocument        xmlNode = GetXmlNode();
            string             xpath   = string.Format("//company[@TaobaoCode='{0}']", code);

            System.Xml.XmlNode node = xmlNode.SelectSingleNode(xpath);
            if (node != null)
            {
                info               = new ExpressCompanyInfo();
                info.Name          = node.Attributes["name"].Value;
                info.Kuaidi100Code = node.Attributes["Kuaidi100Code"].Value;
                info.TaobaoCode    = code;
            }
            return(info);
        }
Exemplo n.º 9
0
 private void grdOrderGoods_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
 {
     if (e.Row.RowType == System.Web.UI.WebControls.DataControlRowType.DataRow)
     {
         string orderId = (string)this.grdOrderGoods.DataKeys[e.Row.RowIndex].Value;
         System.Web.UI.WebControls.DropDownList dropDownList = e.Row.FindControl("dropExpress") as System.Web.UI.WebControls.DropDownList;
         OrderInfo orderInfo = OrderHelper.GetOrderInfo(orderId);
         if (orderInfo != null && orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid)
         {
             ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNode(orderInfo.ExpressCompanyName);
             if (expressCompanyInfo != null)
             {
                 dropDownList.SelectedValue = expressCompanyInfo.Kuaidi100Code;
             }
         }
     }
 }
 private void grdOrderGoods_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         string       orderId   = (string)this.grdOrderGoods.DataKeys[e.Row.RowIndex].Value;
         DropDownList list      = e.Row.FindControl("dropExpress") as DropDownList;
         OrderInfo    orderInfo = OrderHelper.GetOrderInfo(orderId);
         if ((orderInfo != null) && (orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid))
         {
             ExpressCompanyInfo info2 = ExpressHelper.FindNode(orderInfo.ExpressCompanyName);
             if (info2 != null)
             {
                 list.SelectedValue = info2.Kuaidi100Code;
             }
         }
     }
 }
Exemplo n.º 11
0
        public static ExpressCompanyInfo FindNode(string company)
        {
            ExpressCompanyInfo info    = null;
            XmlDocument        xmlNode = GetXmlNode();
            string             xpath   = string.Format("//company[@name='{0}']", company);
            XmlNode            node    = xmlNode.SelectSingleNode(xpath);

            if (node != null)
            {
                info = new ExpressCompanyInfo {
                    Name          = company,
                    Kuaidi100Code = node.Attributes["Kuaidi100Code"].Value,
                    TaobaoCode    = node.Attributes["TaobaoCode"].Value
                };
            }
            return(info);
        }
Exemplo n.º 12
0
        public static ExpressCompanyInfo FindNodeByCode(string code)
        {
            ExpressCompanyInfo expressCompanyInfo = null;
            XmlDocument        xmlNode            = ExpressHelper.GetXmlNode();
            string             xpath    = $"//company[@TaobaoCode='{code}']";
            XmlNode            xmlNode2 = xmlNode.SelectSingleNode(xpath);

            if (xmlNode2 != null)
            {
                expressCompanyInfo               = new ExpressCompanyInfo();
                expressCompanyInfo.Name          = xmlNode2.Attributes["name"].Value;
                expressCompanyInfo.Kuaidi100Code = xmlNode2.Attributes["Kuaidi100Code"].Value;
                expressCompanyInfo.TaobaoCode    = code;
                expressCompanyInfo.JDCode        = xmlNode2.Attributes["JDCode"].Value;
                expressCompanyInfo.CloseStatus   = xmlNode2.Attributes["CloseStatus"].Value.ToBool();
            }
            return(expressCompanyInfo);
        }
Exemplo n.º 13
0
        private IList <ExpressCompanyInfo> GetDataSource()
        {
            IList <ExpressCompanyInfo> list = null;
            XmlDocument xmlNode             = GetXmlNode();
            XmlNode     node = null;

            if (xmlNode != null)
            {
                XmlNode node2 = xmlNode.SelectSingleNode("expressapi");
                if (node2 == null)
                {
                    return(list);
                }
                XmlNode node3 = node2.SelectSingleNode("kuaidi100");
                if (node3 != null)
                {
                    node = node3.SelectSingleNode("companys");
                }
                if ((node == null) || (node.ChildNodes.Count <= 0))
                {
                    return(list);
                }
                list = new List <ExpressCompanyInfo>();
                foreach (XmlNode node4 in node.ChildNodes)
                {
                    string str  = node4["name"].InnerText.ToString();
                    string str2 = node4["abb"].InnerText.ToString();
                    if (!(string.IsNullOrEmpty(str) || string.IsNullOrEmpty(str2)))
                    {
                        ExpressCompanyInfo item = new ExpressCompanyInfo();
                        item.ExpressCompanyAbb  = str2;
                        item.ExpressCompanyName = str;
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Exemplo n.º 14
0
 public ApiErrorCode SendOrders(PurchaseOrderInfo purchaseorder, ShippingModeInfo shippingmode, string out_id, ExpressCompanyInfo express)
 {
     if (string.IsNullOrEmpty(out_id))
     {
         return(ApiErrorCode.ShipingOrderNumber_Error);
     }
     if (purchaseorder == null)
     {
         return(ApiErrorCode.NoExists_Error);
     }
     if (purchaseorder.PurchaseStatus != OrderStatus.BuyerAlreadyPaid)
     {
         return(ApiErrorCode.NoPay_Error);
     }
     if (shippingmode.ModeId <= 0)
     {
         return(ApiErrorCode.NoShippingMode);
     }
     if (string.IsNullOrEmpty(express.Name))
     {
         return(ApiErrorCode.Empty_Error);
     }
     purchaseorder.RealShippingModeId = shippingmode.ModeId;
     purchaseorder.RealModeName       = shippingmode.Name;
     purchaseorder.ExpressCompanyName = express.Name;
     purchaseorder.ExpressCompanyAbb  = express.Kuaidi100Code;
     purchaseorder.ShipOrderNumber    = out_id;
     if (SalesHelper.SendAPIPurchaseOrderGoods(purchaseorder))
     {
         return(ApiErrorCode.Success);
     }
     return(ApiErrorCode.Unknown_Error);
 }
Exemplo n.º 15
0
        public void ProcessRequest(HttpContext context)
        {
            string        oldValue       = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            string        str2           = "";
            string        str3           = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            string        str4           = "";
            SiteSettings  masterSettings = SettingsManager.GetMasterSettings(false);
            string        format         = "<trade><Oid>{0}</Oid><SellerUid>{1}</SellerUid><BuyerNick>{2}</BuyerNick><BuyerEmail>{3}</BuyerEmail><ReceiverName>{4}</ReceiverName><ReceiverState>{5}</ReceiverState><ReceiverCity>{6}</ReceiverCity><ReceiverDistrict>{7}</ReceiverDistrict><ReceiverAddress>{8}</ReceiverAddress><ReceiverZip>{9}</ReceiverZip><ReceiverMobile>{10}</ReceiverMobile><ReceiverPhone>{11}</ReceiverPhone><BuyerMemo>{12}</BuyerMemo><OrderMark>{13}</OrderMark><SellerMemo>{14}</SellerMemo><Nums>{15}</Nums><Price>{16}</Price><Payment>{17}</Payment><PostFee>{18}</PostFee><Profit>{19}</Profit><PurchaseTotal>{20}</PurchaseTotal><PaymentTs>{21}</PaymentTs><SentTs>{22}</SentTs><RefundStatus>{23}</RefundStatus><RefundAmount>{24}</RefundAmount><RefundRemark>{25}</RefundRemark><Status>{26}</Status><orders list=\"{27}\">{28}</orders></trade>";
            string        orderitemfomat = "<order><Tid>{0}</Tid><Oid>{1}</Oid><GoodsIid>{2}</GoodsIid><Title>{3}</Title><OuterId>{4}</OuterId><SKUContent>{5}</SKUContent><Nums>{6}</Nums><Price>{7}</Price><Payment>{8}</Payment><CostPrice>{9}</CostPrice></order>";
            StringBuilder builder        = new StringBuilder();

            str2 = context.Request.QueryString["action"].ToString();
            string      sign      = context.Request.Form["sign"];
            string      checkCode = masterSettings.CheckCode;
            string      str9      = context.Request.Form["format"];
            XmlDocument node      = new XmlDocument();
            SortedDictionary <string, string> tmpParas = new SortedDictionary <string, string>();
            string str22 = str2;

            if (str22 != null)
            {
                if (!(str22 == "tradelist"))
                {
                    string str15;
                    if (str22 == "tradedetails")
                    {
                        str15 = "";
                        if (!string.IsNullOrEmpty(context.Request.Form["tid"].Trim()))
                        {
                            str15    = context.Request.Form["tid"].Trim();
                            tmpParas = new SortedDictionary <string, string>();
                            tmpParas.Add("tid", context.Request.Form["tid"]);
                            tmpParas.Add("format", str9);
                            if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                            {
                                string str16 = context.Request.Form["tid"].Replace("\r\n", "\n");
                                if (!string.IsNullOrEmpty(str16))
                                {
                                    str15 = str16;
                                    PurchaseOrderInfo purchaseOrder = SalesHelper.GetPurchaseOrder(str15);
                                    builder.Append("<trade_get_response>");
                                    builder.Append(this.GetOrderDetails(format, orderitemfomat, purchaseOrder).ToString());
                                    builder.Append("</trade_get_response>");
                                    this.message = oldValue + builder.ToString();
                                }
                                else
                                {
                                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "tid");
                                }
                            }
                            else
                            {
                                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "signature");
                            }
                        }
                        else
                        {
                            str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid");
                        }
                    }
                    else if (str22 == "send")
                    {
                        string str17 = context.Request.Form["tid"].Trim();
                        string str18 = context.Request.Form["out_sid"].Trim();
                        string str19 = context.Request.Form["company_code"].Trim();
                        if ((!string.IsNullOrEmpty(str17) && !string.IsNullOrEmpty(str19)) && !string.IsNullOrEmpty(str18))
                        {
                            tmpParas.Add("tid", str17);
                            tmpParas.Add("out_sid", str18);
                            tmpParas.Add("company_code", str19);
                            tmpParas.Add("format", str9);
                            if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                            {
                                ExpressCompanyInfo express = ExpressHelper.FindNodeByCode(str19);
                                if (!string.IsNullOrEmpty(express.Name))
                                {
                                    ShippingModeInfo  shippingModeByCompany = SalesHelper.GetShippingModeByCompany(express.Name);
                                    PurchaseOrderInfo purchaseorder         = SalesHelper.GetPurchaseOrder(str17);
                                    if (purchaseorder != null)
                                    {
                                        ApiErrorCode messageenum = this.SendOrders(purchaseorder, shippingModeByCompany, str18, express);
                                        if (messageenum == ApiErrorCode.Success)
                                        {
                                            builder.Append("<trade_get_response>");
                                            purchaseorder = SalesHelper.GetPurchaseOrder(str17);
                                            builder.Append(this.GetOrderDetails(format, orderitemfomat, purchaseorder).ToString());
                                            builder.Append("</trade_get_response>");
                                            this.message = oldValue + builder.ToString();
                                        }
                                        else
                                        {
                                            str4 = MessageInfo.ShowMessageInfo(messageenum, "It");
                                        }
                                    }
                                    else
                                    {
                                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "tid");
                                    }
                                }
                                else
                                {
                                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "company_code");
                                }
                            }
                            else
                            {
                                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                            }
                        }
                        else
                        {
                            str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramters");
                        }
                    }
                    else if (str22 == "mark")
                    {
                        string str20 = context.Request.Form["order_mark"].Trim();
                        string str21 = context.Request.Form["seller_memo"].Trim();
                        if ((!string.IsNullOrEmpty(context.Request.Form["tid"].Trim()) && !string.IsNullOrEmpty(str20)) && !string.IsNullOrEmpty(str21))
                        {
                            if ((Convert.ToInt32(str20) > 0) && (Convert.ToInt32(str20) < 7))
                            {
                                str15 = context.Request.Form["tid"].Trim();
                                tmpParas.Add("tid", str15);
                                tmpParas.Add("order_mark", str20);
                                tmpParas.Add("seller_memo", str21);
                                tmpParas.Add("format", str9);
                                if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                                {
                                    PurchaseOrderInfo info5 = SalesHelper.GetPurchaseOrder(str15);
                                    info5.ManagerMark   = new OrderMark?((OrderMark)Enum.Parse(typeof(OrderMark), str20, true));
                                    info5.ManagerRemark = Globals.HtmlEncode(str21);
                                    if (SalesHelper.SaveAPIPurchaseOrderRemark(info5))
                                    {
                                        builder.Append("<trade_get_response>");
                                        builder.Append(this.GetOrderDetails(format, orderitemfomat, info5).ToString());
                                        builder.Append("</trade_get_response>");
                                        this.message = oldValue + builder.ToString();
                                    }
                                    else
                                    {
                                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "save is failure ");
                                    }
                                }
                                else
                                {
                                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                                }
                            }
                            else
                            {
                                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "order_mark");
                            }
                        }
                        else
                        {
                            str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid or order_mark or seller_memo");
                        }
                    }
                }
                else
                {
                    PurchaseOrderQuery query2 = new PurchaseOrderQuery();
                    query2.PageSize = 100;
                    PurchaseOrderQuery query = query2;
                    int    totalrecords      = 0;
                    string str10             = context.Request.Form["status"].Trim();
                    string str11             = context.Request.Form["buynick"].Trim();
                    string str12             = context.Request.Form["pageindex"].Trim();
                    string str13             = context.Request.Form["starttime"].Trim();
                    string str14             = context.Request.Form["endtime"].Trim();
                    if (!string.IsNullOrEmpty(str10) && (Convert.ToInt32(str10) >= 0))
                    {
                        query.PurchaseStatus = (OrderStatus)Enum.Parse(typeof(OrderStatus), str10, true);
                    }
                    else
                    {
                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "status");
                    }
                    if (!string.IsNullOrEmpty(str12) && (Convert.ToInt32(str12) > 0))
                    {
                        query.PageIndex = Convert.ToInt32(str12);
                    }
                    else
                    {
                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "pageindex");
                    }
                    if (string.IsNullOrEmpty(str4))
                    {
                        tmpParas.Add("status", str10);
                        tmpParas.Add("buynick", str11);
                        tmpParas.Add("pageindex", str12);
                        tmpParas.Add("starttime", str13);
                        tmpParas.Add("endtime", str14);
                        tmpParas.Add("format", str9);
                        if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                        {
                            if (!string.IsNullOrEmpty(str11))
                            {
                                query.DistributorName = str11;
                            }
                            if (!string.IsNullOrEmpty(str13))
                            {
                                query.StartDate = new DateTime?(Convert.ToDateTime(str13));
                            }
                            if (!string.IsNullOrEmpty(str14))
                            {
                                query.EndDate = new DateTime?(Convert.ToDateTime(str14));
                            }
                            query.SortOrder = SortAction.Desc;
                            query.SortBy    = "PurchaseDate";
                            builder.Append("<trade_get_response>");
                            builder.Append(this.GetOrderList(query, format, orderitemfomat, out totalrecords));
                            builder.Append("<totalrecord>" + totalrecords + "</totalrecord>");
                            builder.Append("</trade_get_response>");
                            this.message = oldValue + builder.ToString();
                        }
                        else
                        {
                            str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                        }
                    }
                    else
                    {
                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramter");
                    }
                }
            }
            if (this.message == "")
            {
                this.message = this.message + str3 + str4;
            }
            context.Response.ContentType = "text/xml";
            if (str9 == "json")
            {
                this.message = this.message.Replace(oldValue, "");
                node.Load(new MemoryStream(Encoding.GetEncoding("UTF-8").GetBytes(this.message)));
                this.message = JavaScriptConvert.SerializeXmlNode(node);
                context.Response.ContentType = "text/json";
            }
            context.Response.Write(this.message);
        }
        public ApiErrorCode SendOrders(OrderInfo order, ShippingModeInfo shippingmode, string out_id, ExpressCompanyInfo express)
        {
            if ((order.GroupBuyId > 0) && (order.GroupBuyStatus != GroupBuyStatus.Success))
            {
                return(ApiErrorCode.Group_Error);
            }
            if (!order.CheckAction(OrderActions.SELLER_SEND_GOODS))
            {
                return(ApiErrorCode.NoPay_Error);
            }
            if (shippingmode.ModeId <= 0)
            {
                return(ApiErrorCode.NoShippingMode);
            }
            if (string.IsNullOrEmpty(out_id) || (out_id.Length > 20))
            {
                return(ApiErrorCode.ShipingOrderNumber_Error);
            }
            order.RealShippingModeId = shippingmode.ModeId;
            order.RealModeName       = shippingmode.Name;
            order.ExpressCompanyName = express.Name;
            order.ExpressCompanyAbb  = express.Kuaidi100Code;
            order.ShipOrderNumber    = out_id;
            if (!OrderHelper.SendAPIGoods(order))
            {
                return(ApiErrorCode.Unknown_Error);
            }
            if (!string.IsNullOrEmpty(order.GatewayOrderId) && (order.GatewayOrderId.Trim().Length > 0))
            {
                PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(order.PaymentTypeId);
                if (paymentMode != null)
                {
                    PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), order.OrderId, order.GetTotal(), "订单发货", "订单号-" + order.OrderId, order.EmailAddress, order.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), "").SendGoods(order.GatewayOrderId, order.RealModeName, order.ShipOrderNumber, "EXPRESS");
                }
            }
            int userId = order.UserId;

            if (userId == 0x44c)
            {
                userId = 0;
            }
            IUser user = Users.GetUser(userId);

            Messenger.OrderShipping(order, user);
            order.OnDeliver();
            return(ApiErrorCode.Success);
        }
        public void ProcessRequest(HttpContext context)
        {
            string        s              = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            string        str2           = "";
            string        str3           = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            string        str4           = "";
            SiteSettings  masterSettings = SettingsManager.GetMasterSettings(false);
            string        format         = "<trade><Oid>{0}</Oid><SellerUid>{1}</SellerUid><BuyerNick>{2}</BuyerNick><BuyerEmail>{3}</BuyerEmail><ReceiverName>{4}</ReceiverName><ReceiverState>{5}</ReceiverState><ReceiverCity>{6}</ReceiverCity><ReceiverDistrict>{7}</ReceiverDistrict><ReceiverAddress>{8}</ReceiverAddress><ReceiverZip>{9}</ReceiverZip><ReceiverMobile>{10}</ReceiverMobile><ReceiverPhone>{11}</ReceiverPhone><BuyerMemo>{12}</BuyerMemo><OrderMark>{13}</OrderMark><SellerMemo>{14}</SellerMemo><Nums>{15}</Nums><Price>{16}</Price><Payment>{17}</Payment><PostFee>{18}</PostFee><DiscountFee>{19}</DiscountFee><AdjustFee>{20}</AdjustFee><PaymentTs>{21}</PaymentTs><SentTs>{22}</SentTs><RefundStatus>{23}</RefundStatus><RefundAmount>{24}</RefundAmount><RefundRemark>{25}</RefundRemark><Status>{26}</Status><orders list=\"{27}\">{28}</orders></trade>";
            string        orderitemfomat = "<order><Tid>{0}</Tid><Oid>{1}</Oid><GoodsIid>{2}</GoodsIid><Title>{3}</Title><OuterId>{4}</OuterId><SKUContent>{5}</SKUContent><Nums>{6}</Nums><Price>{7}</Price><Payment>{8}</Payment></order>";
            StringBuilder builder        = new StringBuilder();

            str2 = context.Request.QueryString["action"].ToString();
            string sign      = context.Request.Form["sign"];
            string checkCode = masterSettings.CheckCode;
            string str9      = context.Request.Form["format"];

            new Dictionary <string, string>();
            SortedDictionary <string, string> tmpParas = new SortedDictionary <string, string>();

            try
            {
                string str15;
                string str17;
                string str20;
                if (string.IsNullOrEmpty(str2))
                {
                    goto Label_07D6;
                }
                string str22 = str2;
                if (str22 == null)
                {
                    goto Label_07B9;
                }
                if (!(str22 == "tradelist"))
                {
                    if (str22 == "tradedetails")
                    {
                        goto Label_0336;
                    }
                    if (str22 == "send")
                    {
                        goto Label_046D;
                    }
                    if (str22 == "mark")
                    {
                        goto Label_0613;
                    }
                    goto Label_07B9;
                }
                OrderQuery query2 = new OrderQuery();
                query2.PageSize = 100;
                OrderQuery query        = query2;
                int        totalrecords = 0;
                string     str10        = context.Request.Form["status"].Trim();
                string     str11        = context.Request.Form["buyernick"].Trim();
                string     str12        = context.Request.Form["pageindex"].Trim();
                string     str13        = context.Request.Form["starttime"].Trim();
                string     str14        = context.Request.Form["endtime"].Trim();
                if (!string.IsNullOrEmpty(str10) && (Convert.ToInt32(str10) >= 0))
                {
                    query.Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), str10, true);
                }
                else
                {
                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "status");
                }
                if (!string.IsNullOrEmpty(str12) && (Convert.ToInt32(str12) > 0))
                {
                    query.PageIndex = Convert.ToInt32(str12);
                }
                else
                {
                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "pageindex");
                }
                if (string.IsNullOrEmpty(str4))
                {
                    tmpParas.Add("status", str10);
                    tmpParas.Add("buyernick", str11);
                    tmpParas.Add("pageindex", str12);
                    tmpParas.Add("starttime", str13);
                    tmpParas.Add("endtime", str14);
                    tmpParas.Add("format", str9);
                    if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                    {
                        if (!string.IsNullOrEmpty(str11))
                        {
                            query.UserName = str11;
                        }
                        if (!string.IsNullOrEmpty(str13))
                        {
                            query.StartDate = new DateTime?(Convert.ToDateTime(str13));
                        }
                        if (!string.IsNullOrEmpty(str14))
                        {
                            query.EndDate = new DateTime?(Convert.ToDateTime(str14));
                        }
                        builder.Append("<trade_get_response>");
                        builder.Append(this.GetOrderList(query, format, orderitemfomat, out totalrecords).ToString());
                        builder.Append("<totalrecord>" + totalrecords + "</totalrecord>");
                        builder.Append("</trade_get_response>");
                    }
                    else
                    {
                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                    }
                }
                else
                {
                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramter");
                }
                goto Label_07C6;
Label_0336:
                str15 = "";
                if (!string.IsNullOrEmpty(context.Request.Form["tid"].Trim()))
                {
                    str15    = context.Request.Form["tid"].Trim();
                    tmpParas = new SortedDictionary <string, string>();
                    tmpParas.Add("tid", context.Request.Form["tid"]);
                    tmpParas.Add("format", str9);
                    if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                    {
                        string str16 = context.Request.Form["tid"].Replace("\r\n", "\n");
                        if (!string.IsNullOrEmpty(str16))
                        {
                            str15 = str16;
                            OrderInfo orderInfo = OrderHelper.GetOrderInfo(str15);
                            builder.Append("<trade_get_response>");
                            builder.Append(this.GetOrderDetails(format, orderitemfomat, orderInfo).ToString());
                            builder.Append("</trade_get_response>");
                        }
                        else
                        {
                            str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "tid");
                        }
                    }
                    else
                    {
                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "signature");
                    }
                }
                else
                {
                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid");
                }
                goto Label_07C6;
Label_046D:
                str17 = context.Request.Form["tid"].Trim();
                string str18 = context.Request.Form["out_sid"].Trim();
                string str19 = context.Request.Form["company_code"].Trim();
                if ((!string.IsNullOrEmpty(str17) && !string.IsNullOrEmpty(str19)) && !string.IsNullOrEmpty(str18))
                {
                    tmpParas.Add("tid", str17);
                    tmpParas.Add("out_sid", str18);
                    tmpParas.Add("company_code", str19);
                    tmpParas.Add("format", str9);
                    if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                    {
                        ExpressCompanyInfo express = ExpressHelper.FindNodeByCode(str19);
                        if (!string.IsNullOrEmpty(express.Name))
                        {
                            ShippingModeInfo shippingModeByCompany = SalesHelper.GetShippingModeByCompany(express.Name);
                            OrderInfo        order = OrderHelper.GetOrderInfo(str17);
                            if (order != null)
                            {
                                ApiErrorCode messageenum = this.SendOrders(order, shippingModeByCompany, str18, express);
                                if (messageenum == ApiErrorCode.Success)
                                {
                                    builder.Append("<trade_get_response>");
                                    order = OrderHelper.GetOrderInfo(str17);
                                    builder.Append(this.GetOrderDetails(format, orderitemfomat, order).ToString());
                                    builder.Append("</trade_get_response>");
                                }
                                else
                                {
                                    str4 = MessageInfo.ShowMessageInfo(messageenum, "It");
                                }
                            }
                            else
                            {
                                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "tid");
                            }
                        }
                        else
                        {
                            str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "company_code");
                        }
                    }
                    else
                    {
                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                    }
                }
                else
                {
                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramters");
                }
                goto Label_07C6;
Label_0613:
                str20 = context.Request.Form["order_mark"].Trim();
                string str21 = context.Request.Form["seller_memo"].Trim();
                if ((!string.IsNullOrEmpty(context.Request.Form["tid"].Trim()) && !string.IsNullOrEmpty(str20)) && !string.IsNullOrEmpty(str21))
                {
                    if ((Convert.ToInt32(str20) > 0) && (Convert.ToInt32(str20) < 7))
                    {
                        str15 = context.Request.Form["tid"].Trim();
                        tmpParas.Add("tid", str15);
                        tmpParas.Add("order_mark", str20);
                        tmpParas.Add("seller_memo", str21);
                        tmpParas.Add("format", str9);
                        if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                        {
                            OrderInfo info5 = OrderHelper.GetOrderInfo(str15);
                            info5.ManagerMark   = new OrderMark?((OrderMark)Enum.Parse(typeof(OrderMark), str20, true));
                            info5.ManagerRemark = Globals.HtmlEncode(str21);
                            if (OrderHelper.SaveRemarkAPI(info5))
                            {
                                builder.Append("<trade_get_response>");
                                builder.Append(this.GetOrderDetails(format, orderitemfomat, info5).ToString());
                                builder.Append("</trade_get_response>");
                            }
                            else
                            {
                                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "save is failure ");
                            }
                        }
                        else
                        {
                            str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                        }
                    }
                    else
                    {
                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "order_mark");
                    }
                }
                else
                {
                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid or order_mark or seller_memo");
                }
                goto Label_07C6;
Label_07B9:
                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "paramters");
Label_07C6:
                s = s + builder.ToString();
                goto Label_07FB;
Label_07D6:
                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "sign");
            }
            catch (Exception exception)
            {
                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Unknown_Error, exception.Message);
            }
Label_07FB:
            if (!string.IsNullOrEmpty(str4))
            {
                s = str3 + str4;
            }
            context.Response.ContentType = "text/xml";
            context.Response.Write(s);
        }
Exemplo n.º 18
0
        private string sendGoods(HttpContext context)
        {
            string text  = context.Request["OrderNO"].Trim();
            string text2 = context.Request["SndStyle"].Trim();
            string text3 = context.Request["BillID"].Trim();
            IDictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary.Add("OrderId", text);
            dictionary.Add("SndStyle", text2);
            dictionary.Add("BillID", text3);
            dictionary.Add("ErrorMsg", "");
            if (text.IndexOf(',') > 0)
            {
                return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{不支持合并发货,请选择单个订单}]]></Cause></Rsp>");
            }
            OrderInfo orderInfo = OrderHelper.GetOrderInfo(text);

            if (orderInfo == null)
            {
                return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{未找到此订单}]]></Cause></Rsp>");
            }
            if (orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && OrderHelper.NeedUpdateStockWhenSendGoods(orderInfo) && !OrderHelper.CheckStock(orderInfo))
            {
                return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{订单有商品库存不足,请补充库存后发货!}]]></Cause></Rsp>");
            }
            if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success)
            {
                return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{当前订单为团购订单,团购活动还未成功结束,所以不能发货!}]]></Cause></Rsp>");
            }
            if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS))
            {
                return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{当前订单状态没有付款或不是等待发货的订单,所以不能发货!}]]></Cause></Rsp>");
            }
            if (string.IsNullOrEmpty(text3.Trim()) || text3.Trim().Length > 20)
            {
                return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{运单号码不能为空,在1至20个字符之间!}]]></Cause></Rsp>");
            }
            ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNodeLikeName(text2);

            if (expressCompanyInfo != null)
            {
                orderInfo.ExpressCompanyAbb  = expressCompanyInfo.Kuaidi100Code;
                orderInfo.ExpressCompanyName = expressCompanyInfo.Name;
            }
            else
            {
                orderInfo.ExpressCompanyAbb  = "";
                orderInfo.ExpressCompanyName = text2;
            }
            orderInfo.ShipOrderNumber = text3;
            if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && orderInfo.OuterOrderId.StartsWith("jd_") && (expressCompanyInfo == null || string.IsNullOrWhiteSpace(expressCompanyInfo.JDCode)))
            {
                return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{此订单是京东订单,所选物流公司不被京东支持!}]]></Cause></Rsp>");
            }
            if (OrderHelper.SendAPIGoods(orderInfo, true))
            {
                string text4 = "";
                if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest")
                {
                    try
                    {
                        SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                        PayClient    payClient      = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey, "", "", "");
                        DeliverInfo  deliverInfo    = new DeliverInfo();
                        deliverInfo.TransId    = orderInfo.GatewayOrderId;
                        deliverInfo.OutTradeNo = orderInfo.OrderId;
                        MemberOpenIdInfo memberOpenIdInfo = Users.GetUser(orderInfo.UserId).MemberOpenIds.FirstOrDefault((MemberOpenIdInfo item) => item.OpenIdType.ToLower() == "hishop.plugins.openid.weixin");
                        if (memberOpenIdInfo != null)
                        {
                            deliverInfo.OpenId = memberOpenIdInfo.OpenId;
                        }
                        payClient.DeliverNotify(deliverInfo);
                    }
                    catch (Exception ex)
                    {
                        dictionary["ErrrorMsg"] = "同步微信支付发货状态失败";
                        Globals.WriteExceptionLog(ex, dictionary, "APISendGoods");
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0)
                    {
                        try
                        {
                            PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway);
                            if (paymentMode != null && !string.IsNullOrEmpty(paymentMode.Settings))
                            {
                                string         hIGW           = paymentMode.Gateway.Replace(".", "_");
                                PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.PayOrderId, orderInfo.GetTotal(false), "订单发货", "订单号-" + orderInfo.PayOrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(""), Globals.FullPath(RouteConfig.GetRouteUrl(HttpContext.Current, "PaymentReturn_url", new
                                {
                                    HIGW = hIGW
                                })), Globals.FullPath(RouteConfig.GetRouteUrl(HttpContext.Current, "PaymentNotify_url", new
                                {
                                    HIGW = hIGW
                                })), "");
                                paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS");
                            }
                        }
                        catch (Exception ex2)
                        {
                            dictionary["ErrrorMsg"] = "同步支付接口发货状态失败";
                            Globals.WriteExceptionLog(ex2, dictionary, "APISendGoods");
                        }
                    }
                    if (!string.IsNullOrEmpty(orderInfo.OuterOrderId))
                    {
                        if (orderInfo.OuterOrderId.StartsWith("tb_"))
                        {
                            string text5 = orderInfo.OuterOrderId.Replace("tb_", "");
                            try
                            {
                                string     requestUriString = $"http://order2.kuaidiangtong.com/UpdateShipping.ashx?tid={text5}&companycode={expressCompanyInfo.TaobaoCode}&outsid={orderInfo.ShipOrderNumber}&Host={HiContext.Current.SiteUrl}";
                                WebRequest webRequest       = WebRequest.Create(requestUriString);
                                webRequest.GetResponse();
                            }
                            catch (Exception ex3)
                            {
                                dictionary["ErrrorMsg"] = "同步淘宝发货状态失败";
                                Globals.WriteExceptionLog(ex3, dictionary, "APISendGoods");
                            }
                        }
                        else if (orderInfo.OuterOrderId.StartsWith("jd_"))
                        {
                            string text5 = orderInfo.OuterOrderId.Replace("jd_", "");
                            try
                            {
                                SiteSettings masterSettings2 = SettingsManager.GetMasterSettings();
                                JDHelper.JDOrderOutStorage(masterSettings2.JDAppKey, masterSettings2.JDAppSecret, masterSettings2.JDAccessToken, expressCompanyInfo.JDCode, orderInfo.ShipOrderNumber, text5);
                            }
                            catch (Exception ex4)
                            {
                                dictionary["ErrrorMsg"] = "同步京东发货失败";
                                Globals.WriteExceptionLog(ex4, dictionary, "APISendGoods");
                                text4 = $"同步京东发货失败,京东订单号:{text5},{ex4.Message}\r\n";
                            }
                        }
                    }
                }
                MemberInfo user = Users.GetUser(orderInfo.UserId);
                Messenger.OrderShipping(orderInfo, user);
                orderInfo.OnDeliver();
                return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>1</Result><Cause></Cause></Rsp>");
            }
            return("<?xml version='1.0' encoding='utf-8'?><Rsp><Result>0</Result><Cause><![CDATA[{发货失败,可能是商品库存不足,订单中有商品正在退货、换货状态!}]]></Cause></Rsp>");
        }
Exemplo n.º 19
0
        private void btnSendGoods_Click(object sender, System.EventArgs e)
        {
            OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.orderId);

            if (orderInfo == null)
            {
                return;
            }
            if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success)
            {
                this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false);
                return;
            }
            if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS))
            {
                this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false);
                return;
            }
            if (!this.radioShippingMode.SelectedValue.HasValue)
            {
                this.ShowMsg("请选择配送方式", false);
                return;
            }
            if (string.IsNullOrEmpty(this.txtShipOrderNumber.Text.Trim()) || this.txtShipOrderNumber.Text.Trim().Length > 20)
            {
                this.ShowMsg("运单号码不能为空,在1至20个字符之间", false);
                return;
            }
            if (string.IsNullOrEmpty(this.expressRadioButtonList.SelectedValue))
            {
                this.ShowMsg("请选择物流公司", false);
                return;
            }
            ShippingModeInfo shippingMode = SalesHelper.GetShippingMode(this.radioShippingMode.SelectedValue.Value, true);

            orderInfo.RealShippingModeId = this.radioShippingMode.SelectedValue.Value;
            orderInfo.RealModeName       = shippingMode.Name;

            orderInfo.ShippingModeId = this.radioShippingMode.SelectedValue.Value;
            orderInfo.ModeName       = shippingMode.Name;

            ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNode(this.expressRadioButtonList.SelectedValue);

            if (expressCompanyInfo != null)
            {
                orderInfo.ExpressCompanyAbb  = expressCompanyInfo.Kuaidi100Code;
                orderInfo.ExpressCompanyName = expressCompanyInfo.Name;
            }
            orderInfo.ShipOrderNumber = this.txtShipOrderNumber.Text;

            orderInfo.ShippingDate = DateTime.Now;
            if (OrderHelper.SendGoods(orderInfo))
            {
                SendNoteInfo sendNoteInfo = new SendNoteInfo();
                sendNoteInfo.NoteId   = Globals.GetGenerateId();
                sendNoteInfo.OrderId  = this.orderId;
                sendNoteInfo.Operator = HiContext.Current.User.Username;
                sendNoteInfo.Remark   = "后台" + sendNoteInfo.Operator + "发货成功";
                OrderHelper.SaveSendNote(sendNoteInfo);
                if (orderInfo.Gateway == "Ecdev.plugins.payment.weixinrequest")
                {
                    SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
                    PayClient    payClient      = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey);
                    payClient.DeliverNotify(new DeliverInfo
                    {
                        TransId    = orderInfo.GatewayOrderId,
                        OutTradeNo = orderInfo.OrderId,
                        OpenId     = MemberHelper.GetMember(orderInfo.UserId).OpenId
                    });
                }
                else
                {
                    if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0)
                    {
                        PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway);
                        if (paymentMode != null && !string.IsNullOrEmpty(paymentMode.Settings) &&  paymentMode.Settings != "1hSUSkKQ/ENo0JDZah8KKQweixin")
                        {
                            PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[]
                            {
                                paymentMode.Gateway
                            })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[]
                            {
                                paymentMode.Gateway
                            })), "");
                            paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS");
                        }
                    }
                    if (!string.IsNullOrEmpty(orderInfo.TaobaoOrderId))
                    {
                        try
                        {
                            string requestUriString = string.Format("http://vip.ecdev.cn/UpdateShipping.ashx?tid={0}&companycode={1}&outsid={2}&Host={3}", new object[]
                            {
                                orderInfo.TaobaoOrderId,
                                expressCompanyInfo.TaobaoCode,
                                orderInfo.ShipOrderNumber,
                                HiContext.Current.SiteUrl
                            });
                            System.Net.WebRequest webRequest = System.Net.WebRequest.Create(requestUriString);
                            webRequest.GetResponse();
                        }
                        catch
                        {
                        }
                    }
                }
                int num = orderInfo.UserId;
                if (num == 1100)
                {
                    num = 0;
                }
                IUser user = Users.GetUser(num);
                Messenger.OrderShipping(orderInfo, user);
                orderInfo.OnDeliver();
                //this.ShowMsg("发货成功", true);
                this.CloseWindow();
                return;
            }
            this.ShowMsg("发货失败", false);
        }
Exemplo n.º 20
0
        private void btnSendGoods_Click(object sender, EventArgs e)
        {
            int num = this.txtSendGoodType.Value.ToInt(0);

            if (this.grdOrderGoods.Items.Count <= 0)
            {
                this.ShowMsg("没有要进行发货的订单。", false);
            }
            else
            {
                int num2 = 0;
                for (int i = 0; i < this.grdOrderGoods.Items.Count; i++)
                {
                    HiddenField hiddenField = (HiddenField)this.grdOrderGoods.Items[i].FindControl("txtDeliveryNo");
                    string      text        = hiddenField.Value.ToNullString();
                    if (num != 2 || !(text == ""))
                    {
                        HiddenField         hiddenField2        = (HiddenField)this.grdOrderGoods.Items[i].FindControl("hidorderId");
                        string              value               = hiddenField2.Value;
                        TextBox             textBox             = (TextBox)this.grdOrderGoods.Items[i].FindControl("txtShippOrderNumber");
                        ExpressDropDownList expressDropDownList = this.grdOrderGoods.Items[i].FindControl("expressList1") as ExpressDropDownList;
                        OrderInfo           orderInfo           = OrderHelper.GetOrderInfo(value);
                        if ((orderInfo.GroupBuyId <= 0 || orderInfo.GroupBuyStatus == GroupBuyStatus.Success) && ((orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && orderInfo.Gateway == "hishop.plugins.payment.podrequest") || orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid))
                        {
                            ExpressCompanyInfo expressCompanyInfo = null;
                            switch (num)
                            {
                            case 1:
                                if (!string.IsNullOrEmpty(expressDropDownList.SelectedValue))
                                {
                                    expressCompanyInfo = ExpressHelper.FindNode(expressDropDownList.SelectedValue);
                                }
                                if (expressCompanyInfo != null)
                                {
                                    orderInfo.ExpressCompanyName = expressCompanyInfo.Name;
                                    orderInfo.ExpressCompanyAbb  = expressCompanyInfo.Kuaidi100Code;
                                    orderInfo.ShipOrderNumber    = textBox.Text;
                                }
                                break;

                            case 2:
                                orderInfo.ExpressCompanyName = "同城物流配送";
                                orderInfo.ExpressCompanyAbb  = "";
                                orderInfo.ShipOrderNumber    = "";
                                orderInfo.DadaStatus         = DadaStatus.WaitOrder;
                                break;

                            default:
                                orderInfo.ExpressCompanyName = "";
                                orderInfo.ExpressCompanyAbb  = "";
                                orderInfo.ShipOrderNumber    = "";
                                break;
                            }
                            OrderStatus orderStatus = orderInfo.OrderStatus;
                            if (OrderHelper.SendGoods(orderInfo))
                            {
                                if (expressCompanyInfo != null && !string.IsNullOrEmpty(orderInfo.ExpressCompanyAbb) && orderInfo.ExpressCompanyAbb.ToUpper() == "HTKY")
                                {
                                    ExpressHelper.GetDataByKuaidi100(orderInfo.ExpressCompanyAbb, orderInfo.ShipOrderNumber);
                                }
                                if (orderStatus == OrderStatus.WaitBuyerPay)
                                {
                                    OrderHelper.ChangeStoreStockAndWriteLog(orderInfo);
                                }
                                if (orderInfo.Gateway.ToLower() == "hishop.plugins.payment.podrequest")
                                {
                                    OrderHelper.SetOrderIsStoreCollect(orderInfo.OrderId);
                                    ProductStatisticsHelper.UpdateOrderSaleStatistics(orderInfo);
                                    TransactionAnalysisHelper.AnalysisOrderTranData(orderInfo);
                                }
                                if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0)
                                {
                                    PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway);
                                    if (paymentMode != null)
                                    {
                                        string         hIGW           = paymentMode.Gateway.Replace(".", "_");
                                        PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.TryDecypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(false), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(""), Globals.FullPath(base.GetRouteUrl("PaymentReturn_url", new
                                        {
                                            HIGW = hIGW
                                        })), Globals.FullPath(base.GetRouteUrl("PaymentNotify_url", new
                                        {
                                            HIGW = hIGW
                                        })), "");
                                        paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS");
                                    }
                                }
                                if (orderInfo.ExpressCompanyName == "同城物流配送" && !string.IsNullOrEmpty(text))
                                {
                                    SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                                    DadaHelper.addAfterQuery(masterSettings.DadaSourceID, text);
                                }
                                if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && expressCompanyInfo != null)
                                {
                                    if (orderInfo.OuterOrderId.StartsWith("tb_"))
                                    {
                                        string text2 = orderInfo.OuterOrderId.Replace("tb_", "");
                                        try
                                        {
                                            string     requestUriString = $"http://order2.kuaidiangtong.com/UpdateShipping.ashx?tid={text2}&companycode={expressCompanyInfo.TaobaoCode}&outsid={orderInfo.ShipOrderNumber}&Host={HiContext.Current.SiteUrl}";
                                            WebRequest webRequest       = WebRequest.Create(requestUriString);
                                            webRequest.GetResponse();
                                        }
                                        catch
                                        {
                                        }
                                    }
                                    else if (orderInfo.OuterOrderId.StartsWith("jd_"))
                                    {
                                        string text2 = orderInfo.OuterOrderId.Replace("jd_", "");
                                    }
                                }
                                MemberInfo user = Users.GetUser(orderInfo.UserId);
                                Messenger.OrderShipping(orderInfo, user);
                                orderInfo.OnDeliver();
                                num2++;
                            }
                        }
                    }
                }
                if (num2 == 0)
                {
                    this.ShowMsg("批量发货失败,商品库存不足或者有商品正在退货,换货中的订单不能发货!", false);
                }
                else if (num2 > 0)
                {
                    this.BindData();
                    this.ShowMsg($"批量发货成功!发货数量{num2}个,商品库存不足或者有商品正在退货,换货中的订单不能发货!", true);
                }
            }
        }
Exemplo n.º 21
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;
            }
        }
Exemplo n.º 22
0
        private void btnSendGoods_Click(object sender, EventArgs e)
        {
            OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.orderId);
            int       num       = this.radio_sendGoodType.SelectedValue.ToInt(0);
            string    text      = this.txtDeliveryNo.Value.ToNullString();

            if (orderInfo != null)
            {
                if (orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && OrderHelper.NeedUpdateStockWhenSendGoods(orderInfo) && !OrderHelper.CheckStock(orderInfo))
                {
                    this.ShowMsg("订单有商品库存不足,请补充库存后发货!", false);
                }
                else if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success)
                {
                    this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false);
                }
                else if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS))
                {
                    this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false);
                }
                else if (num == 2 && text == "")
                {
                    this.ShowMsg("使用同城物流发货需要正确的物流编号", false);
                }
                else
                {
                    ExpressCompanyInfo expressCompanyInfo = null;
                    if (num == 1 && !string.IsNullOrEmpty(this.expressRadioButtonList.SelectedValue))
                    {
                        expressCompanyInfo = ExpressHelper.FindNode(this.expressRadioButtonList.SelectedValue);
                        if (expressCompanyInfo != null)
                        {
                            orderInfo.ExpressCompanyAbb  = expressCompanyInfo.Kuaidi100Code;
                            orderInfo.ExpressCompanyName = expressCompanyInfo.Name;
                        }
                        orderInfo.ShipOrderNumber = this.txtShipOrderNumber.Text;
                        if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && !string.IsNullOrEmpty(orderInfo.ShipOrderNumber) && orderInfo.OuterOrderId.StartsWith("jd_") && string.IsNullOrWhiteSpace(expressCompanyInfo.JDCode))
                        {
                            this.ShowMsg("此订单是京东订单,所选物流公司不被京东支持", false);
                            return;
                        }
                    }
                    else if (num == 2)
                    {
                        orderInfo.ExpressCompanyName = "同城物流配送";
                        orderInfo.ExpressCompanyAbb  = "";
                        orderInfo.ShipOrderNumber    = "";
                        orderInfo.DadaStatus         = DadaStatus.WaitOrder;
                        if (orderInfo.ExpressCompanyName == "同城物流配送" && !string.IsNullOrEmpty(text))
                        {
                            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                            DadaHelper.addAfterQuery(masterSettings.DadaSourceID, text);
                        }
                    }
                    if (OrderHelper.SendGoods(orderInfo))
                    {
                        if (!string.IsNullOrEmpty(orderInfo.ExpressCompanyAbb) && orderInfo.ExpressCompanyAbb.ToUpper() == "HTKY")
                        {
                            ExpressHelper.GetDataByKuaidi100(orderInfo.ExpressCompanyAbb, orderInfo.ShipOrderNumber);
                        }
                        if (orderInfo.Gateway.ToNullString().ToLower() == "hishop.plugins.payment.podrequest")
                        {
                            ProductStatisticsHelper.UpdateOrderSaleStatistics(orderInfo);
                            TransactionAnalysisHelper.AnalysisOrderTranData(orderInfo);
                        }
                        string text2 = "";
                        if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest")
                        {
                            SiteSettings masterSettings2 = SettingsManager.GetMasterSettings();
                            PayClient    payClient       = new PayClient(masterSettings2.WeixinAppId, masterSettings2.WeixinAppSecret, masterSettings2.WeixinPartnerID, masterSettings2.WeixinPartnerKey, masterSettings2.WeixinPaySignKey, "", "", "");
                            DeliverInfo  deliverInfo     = new DeliverInfo();
                            deliverInfo.TransId    = orderInfo.GatewayOrderId;
                            deliverInfo.OutTradeNo = orderInfo.OrderId;
                            MemberOpenIdInfo memberOpenIdInfo = Users.GetUser(orderInfo.UserId).MemberOpenIds.FirstOrDefault((MemberOpenIdInfo item) => item.OpenIdType.ToLower() == "hishop.plugins.openid.weixin");
                            if (memberOpenIdInfo != null)
                            {
                                deliverInfo.OpenId = memberOpenIdInfo.OpenId;
                            }
                            payClient.DeliverNotify(deliverInfo);
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0)
                            {
                                try
                                {
                                    PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway);
                                    if (paymentMode != null && !string.IsNullOrEmpty(paymentMode.Settings))
                                    {
                                        string         hIGW           = paymentMode.Gateway.Replace(".", "_");
                                        PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(false), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(""), Globals.FullPath(base.GetRouteUrl("PaymentReturn_url", new
                                        {
                                            HIGW = hIGW
                                        })), Globals.FullPath(base.GetRouteUrl("PaymentNotify_url", new
                                        {
                                            HIGW = hIGW
                                        })), "");
                                        paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS");
                                    }
                                }
                                catch (Exception)
                                {
                                }
                            }
                            if (!string.IsNullOrEmpty(orderInfo.OuterOrderId))
                            {
                                if (orderInfo.OuterOrderId.StartsWith("tb_"))
                                {
                                    string text3 = orderInfo.OuterOrderId.Replace("tb_", "");
                                    try
                                    {
                                        if (expressCompanyInfo != null)
                                        {
                                            string     requestUriString = $"http://order2.kuaidiangtong.com/UpdateShipping.ashx?tid={text3}&companycode={expressCompanyInfo.TaobaoCode}&outsid={orderInfo.ShipOrderNumber}&Host={HiContext.Current.SiteUrl}";
                                            WebRequest webRequest       = WebRequest.Create(requestUriString);
                                            webRequest.GetResponse();
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                                else if (orderInfo.OuterOrderId.StartsWith("jd_") && expressCompanyInfo != null)
                                {
                                    string text3 = orderInfo.OuterOrderId.Replace("jd_", "");
                                    try
                                    {
                                        SiteSettings masterSettings3 = SettingsManager.GetMasterSettings();
                                        JDHelper.JDOrderOutStorage(masterSettings3.JDAppKey, masterSettings3.JDAppSecret, masterSettings3.JDAccessToken, expressCompanyInfo.JDCode, orderInfo.ShipOrderNumber, text3);
                                    }
                                    catch (Exception ex2)
                                    {
                                        text2 = $"同步京东发货失败,京东订单号:{text3},{ex2.Message}\r\n";
                                    }
                                }
                            }
                        }
                        MemberInfo user = Users.GetUser(orderInfo.UserId);
                        Messenger.OrderShipping(orderInfo, user);
                        orderInfo.OnDeliver();
                        if (string.IsNullOrWhiteSpace(text2))
                        {
                            this.ShowMsg("发货成功", true);
                            StringBuilder stringBuilder = new StringBuilder();
                            for (int i = 0; i < base.Request.QueryString.Count && base.Request.QueryString.Keys[i] != null; i++)
                            {
                                string text4 = base.Request.QueryString.Keys[i].ToLower();
                                string text5 = base.Request.QueryString[text4];
                                if (!(text4 == "orderid") && !string.IsNullOrEmpty(text5))
                                {
                                    text4 = ((text4 == "searchorderid") ? "orderid" : text4);
                                    stringBuilder.Append("&" + text4 + "=" + text5);
                                }
                            }
                            if (string.IsNullOrWhiteSpace(base.JsCallBack))
                            {
                                base.CloseWindowGo("../sales/manageorder.aspx?1=1" + stringBuilder.ToString());
                            }
                            else
                            {
                                base.CloseWindow(null);
                            }
                        }
                        else
                        {
                            this.ShowMsg($"发货成功\r\n{text2}", true);
                        }
                    }
                    else
                    {
                        this.ShowMsg("发货失败,可能是商品库存不足,订单中有商品正在退货、换货状态", false);
                    }
                }
            }
        }
Exemplo n.º 23
0
        private void btnSendGoods_Click(object sender, EventArgs e)
        {
            OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.orderId);

            if (orderInfo != null)
            {
                if (orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && OrderHelper.NeedUpdateStockWhenSendGoods(orderInfo) && !OrderHelper.CheckStock(orderInfo))
                {
                    this.ShowMsg("订单有商品库存不足,请补充库存后发货!", false);
                }
                else if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success)
                {
                    this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false);
                }
                else if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS))
                {
                    this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false);
                }
                else
                {
                    ExpressCompanyInfo expressCompanyInfo = null;
                    if (!string.IsNullOrEmpty(this.expressRadioButtonList.SelectedValue))
                    {
                        expressCompanyInfo = ExpressHelper.FindNode(this.expressRadioButtonList.SelectedValue);
                        if (expressCompanyInfo != null)
                        {
                            orderInfo.ExpressCompanyAbb  = expressCompanyInfo.Kuaidi100Code;
                            orderInfo.ExpressCompanyName = expressCompanyInfo.Name;
                        }
                        orderInfo.ShipOrderNumber = this.txtShipOrderNumber.Text;
                        if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && orderInfo.OuterOrderId.StartsWith("jd_") && string.IsNullOrWhiteSpace(expressCompanyInfo.JDCode))
                        {
                            this.ShowMsg("此订单是京东订单,所选物流公司不被京东支持", false);
                            return;
                        }
                    }
                    if (OrderHelper.SendGoods(orderInfo))
                    {
                        if (!string.IsNullOrEmpty(orderInfo.ExpressCompanyAbb) && orderInfo.ExpressCompanyAbb.ToUpper() == "HTKY")
                        {
                            ExpressHelper.GetDataByKuaidi100(orderInfo.ExpressCompanyAbb, orderInfo.ShipOrderNumber);
                        }
                        string text = "";
                        if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest")
                        {
                            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                            PayClient    payClient      = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey, "", "", "");
                            DeliverInfo  deliverInfo    = new DeliverInfo();
                            deliverInfo.TransId    = orderInfo.GatewayOrderId;
                            deliverInfo.OutTradeNo = orderInfo.OrderId;
                            MemberOpenIdInfo memberOpenIdInfo = Users.GetUser(orderInfo.UserId).MemberOpenIds.FirstOrDefault((MemberOpenIdInfo item) => item.OpenIdType.ToLower() == "hishop.plugins.openid.weixin");
                            if (memberOpenIdInfo != null)
                            {
                                deliverInfo.OpenId = memberOpenIdInfo.OpenId;
                            }
                            payClient.DeliverNotify(deliverInfo);
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0)
                            {
                                try
                                {
                                    PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway);
                                    if (paymentMode != null && !string.IsNullOrEmpty(paymentMode.Settings))
                                    {
                                        string         hIGW           = paymentMode.Gateway.Replace(".", "_");
                                        PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(false), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(""), Globals.FullPath(base.GetRouteUrl("PaymentReturn_url", new
                                        {
                                            HIGW = hIGW
                                        })), Globals.FullPath(base.GetRouteUrl("PaymentNotify_url", new
                                        {
                                            HIGW = hIGW
                                        })), "");
                                        paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS");
                                    }
                                }
                                catch (Exception)
                                {
                                }
                            }
                            if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && expressCompanyInfo != null)
                            {
                                if (orderInfo.OuterOrderId.StartsWith("tb_"))
                                {
                                    string text2 = orderInfo.OuterOrderId.Replace("tb_", "");
                                    try
                                    {
                                        string     requestUriString = $"http://order2.kuaidiangtong.com/UpdateShipping.ashx?tid={text2}&companycode={expressCompanyInfo.TaobaoCode}&outsid={orderInfo.ShipOrderNumber}&Host={HiContext.Current.SiteUrl}";
                                        WebRequest webRequest       = WebRequest.Create(requestUriString);
                                        webRequest.GetResponse();
                                    }
                                    catch
                                    {
                                    }
                                }
                                else if (orderInfo.OuterOrderId.StartsWith("jd_") && expressCompanyInfo != null)
                                {
                                    string text2 = orderInfo.OuterOrderId.Replace("jd_", "");
                                    try
                                    {
                                        SiteSettings masterSettings2 = SettingsManager.GetMasterSettings();
                                        JDHelper.JDOrderOutStorage(masterSettings2.JDAppKey, masterSettings2.JDAppSecret, masterSettings2.JDAccessToken, expressCompanyInfo.JDCode, orderInfo.ShipOrderNumber, text2);
                                    }
                                    catch (Exception ex2)
                                    {
                                        text = $"\r\n同步京东发货失败,京东订单号:{text2},{ex2.Message}\r\n";
                                    }
                                }
                            }
                        }
                        MemberInfo user = Users.GetUser(orderInfo.UserId);
                        Messenger.OrderShipping(orderInfo, user);
                        orderInfo.OnDeliver();
                        if (string.IsNullOrWhiteSpace(text))
                        {
                            this.ShowMsg("发货成功", true);
                            this.CloseWindow("../sales/manageorder.aspx");
                        }
                        else
                        {
                            this.ShowMsg($"发货成功{text}", true);
                        }
                    }
                    else
                    {
                        this.ShowMsg("发货失败,可能是商品库存不足,订单中有商品正在退货、换货状态", false);
                    }
                }
            }
        }
Exemplo n.º 24
0
        private void btnupdatepost_Click(object sender, EventArgs e)
        {
            string value = this.txt_expressCompanyName.Value;

            this.order.ShipOrderNumber    = this.txtpost.Text.Trim();
            this.order.ExpressCompanyName = value;
            string             arg = "";
            ExpressCompanyInfo expressCompanyInfo = null;

            if (!"".Equals(value))
            {
                expressCompanyInfo = ExpressHelper.FindNode(value);
                if (expressCompanyInfo != null)
                {
                    this.order.ExpressCompanyAbb  = expressCompanyInfo.Kuaidi100Code;
                    this.order.ExpressCompanyName = expressCompanyInfo.Name;
                }
                if (!string.IsNullOrEmpty(this.order.OuterOrderId) && !string.IsNullOrEmpty(this.order.ShipOrderNumber) && this.order.OuterOrderId.StartsWith("jd_") && string.IsNullOrWhiteSpace(expressCompanyInfo.JDCode))
                {
                    this.ShowMsg("此订单是京东订单,所选物流公司不被京东支持", false);
                    return;
                }
                if (this.order.ExpressCompanyAbb != null && this.order.ExpressCompanyAbb.ToUpper() == "HTKY")
                {
                    ExpressHelper.GetDataByKuaidi100(this.order.ExpressCompanyAbb, this.order.ShipOrderNumber);
                }
                if (this.order.Gateway != null && this.order.Gateway.ToLower() == "hishop.plugins.payment.podrequest")
                {
                    ProductStatisticsHelper.UpdateOrderSaleStatistics(this.order);
                    TransactionAnalysisHelper.AnalysisOrderTranData(this.order);
                }
                if (!string.IsNullOrEmpty(this.order.OuterOrderId))
                {
                    if (this.order.OuterOrderId.StartsWith("tb_"))
                    {
                        string text = this.order.OuterOrderId.Replace("tb_", "");
                        try
                        {
                            if (expressCompanyInfo != null)
                            {
                                string     requestUriString = $"http://order2.kuaidiangtong.com/UpdateShipping.ashx?tid={text}&companycode={expressCompanyInfo.TaobaoCode}&outsid={this.order.ShipOrderNumber}&Host={HiContext.Current.SiteUrl}";
                                WebRequest webRequest       = WebRequest.Create(requestUriString);
                                webRequest.GetResponse();
                            }
                        }
                        catch
                        {
                        }
                    }
                    else if (this.order.OuterOrderId.StartsWith("jd_"))
                    {
                        string text = this.order.OuterOrderId.Replace("jd_", "");
                        try
                        {
                            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                            JDHelper.JDOrderOutStorage(masterSettings.JDAppKey, masterSettings.JDAppSecret, masterSettings.JDAccessToken, expressCompanyInfo.JDCode, this.order.ShipOrderNumber, text);
                        }
                        catch (Exception ex)
                        {
                            arg = $"\r\n同步京东发货失败,京东订单号:{text},{ex.Message}\r\n";
                        }
                    }
                }
            }
            string expresssCompanyAbb = string.IsNullOrEmpty(this.order.ExpressCompanyAbb) ? "" : this.order.ExpressCompanyAbb;

            OrderHelper.SetOrderShipNumber(this.order.OrderId, expresssCompanyAbb, this.order.ExpressCompanyName, this.order.ShipOrderNumber);
            this.ShowMsg($"修改发货单号成功{arg}", true);
            this.LoadControl();
        }
        private void btnSendGoodsReturns_Click(object sender, EventArgs e)
        {
            string text = base.GetParameter("ReturnUrl", false).ToNullString();

            if (string.IsNullOrEmpty(text))
            {
                text = this.Page.Request.UrlReferrer.ToNullString();
                if (text == this.Page.Request.Url.ToString())
                {
                    text = "/User/UserOrders";
                }
            }
            ReturnInfo returnInfo = TradeHelper.GetReturnInfo(this.returnsId);

            if (returnInfo == null)
            {
                this.ShowMessage("错误的退货信息", false, "", 1);
            }
            else
            {
                string    skuId     = returnInfo.SkuId;
                OrderInfo orderInfo = TradeHelper.GetOrderInfo(returnInfo.OrderId);
                if (orderInfo == null)
                {
                    this.ShowMessage("错误的订单信息", false, "", 1);
                }
                else if (orderInfo.LineItems.ContainsKey(skuId))
                {
                    if (orderInfo.LineItems[skuId].Status != LineItemStatus.MerchantsAgreedForReturn && orderInfo.LineItems[skuId].Status != LineItemStatus.DeliveryForReturn)
                    {
                        this.ShowMessage("商品退货状态不正确", false, "", 1);
                    }
                    else
                    {
                        string value  = this.hidExpressCompanyName.Value;
                        string value2 = this.hidShipOrderNumber.Value;
                        if (string.IsNullOrEmpty(value))
                        {
                            this.ShowMessage("请选择一个快递公司!", false, "", 1);
                        }
                        else
                        {
                            string             text2 = "";
                            string             text3 = "";
                            ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNode(value);
                            if (value != null)
                            {
                                text2 = expressCompanyInfo.Kuaidi100Code;
                                text3 = expressCompanyInfo.Name;
                                if (value2.Trim() == "" || value2.Length > 20)
                                {
                                    this.ShowMessage("请输入快递编号,长度为1-20位!", false, "", 1);
                                }
                                else if (TradeHelper.UserSendGoodsForReturn(returnInfo.ReturnId, text2, text3, value2, orderInfo.OrderId, skuId))
                                {
                                    if (text2.ToUpper() == "HTKY")
                                    {
                                        ExpressHelper.GetDataByKuaidi100(text2, value2);
                                    }
                                    this.ShowMessage("发货成功", true, text, 2);
                                    this.BindOrderItems(orderInfo);
                                }
                                else
                                {
                                    this.ShowMessage("发货失败!", false, "", 1);
                                }
                            }
                            else
                            {
                                this.ShowMessage("请选择快递公司", false, "", 1);
                            }
                        }
                    }
                }
                else
                {
                    this.ShowMessage("订单中不包含商品信息", false, "", 1);
                }
            }
        }
Exemplo n.º 26
0
        protected void btnBatchSend_Click(object sender, System.EventArgs e)//新增上传excel来发货
        {
            this.btnBatchSend.Enabled = false;
            HttpPostedFile file = this.excelFile.PostedFile;

            if (file.ContentLength == 0)
            {
                this.btnBatchSend.Enabled = true;
                this.ShowMsg("请选择文件!", false);
                return;
            }
            string expandName = file.FileName.Substring(file.FileName.LastIndexOf('.') + 1);
            int    excelType  = 0;

            if (expandName == "xls")
            {
                excelType = 1;
            }
            else if (expandName == "xlsx")
            {
                excelType = 2;
            }
            else
            {
                this.btnBatchSend.Enabled = true;
                this.ShowMsg("请上传excel文件!", false);
                return;
            }
            ExcelHelper excelHelper = new ExcelHelper(file.InputStream);
            DataTable   dtExcel     = excelHelper.ExcelToDataTable("", true, excelType);

            if (dtExcel == null || dtExcel.Columns.Count < 4)
            {
                this.btnBatchSend.Enabled = true;
                this.ShowMsg("excel表格列数错误!", false);
                return;
            }
            if (!(dtExcel.Columns[0].ToString() == "订单编号" && dtExcel.Columns[1].ToString() == "发货时间" && dtExcel.Columns[2].ToString() == "快递公司" && dtExcel.Columns[3].ToString() == "快递单号"))
            {
                this.btnBatchSend.Enabled = true;
                this.ShowMsg("excel表格列名称错误!", false);
                return;
            }
            List <string>               orderIds                 = new List <string>();
            List <string>               expressCompanyName       = new List <string>();
            List <string>               ShipOrderNumber          = new List <string>();
            List <DateTime>             deliveryTimes            = new List <DateTime>();
            Dictionary <string, string> deliverFailOrders        = new Dictionary <string, string>();
            List <deliverFailOrderInfo> listdeliverFailOrderInfo = new List <deliverFailOrderInfo>();
            int num = 0;

            #region 整理发货单数据
            if (dtExcel != null)
            {
                int count = dtExcel.Rows.Count;
                for (int i = 0; i < count; i++)
                {
                    string   tmpOrderId            = string.Empty;
                    string   tmpexpressCompanyName = string.Empty;
                    string   tmpkuaidi100Code      = string.Empty;
                    DateTime tmpdeliveryTime       = DateTime.Now;

                    tmpOrderId = dtExcel.Rows[i][0].ToString();
                    DateTime.TryParse(dtExcel.Rows[i][1].ToString(), out tmpdeliveryTime);
                    tmpexpressCompanyName = dtExcel.Rows[i][2].ToString();
                    tmpkuaidi100Code      = dtExcel.Rows[i][3].ToString();
                    string[] singleLineOrderIds = tmpOrderId.Split(',');//单行可能多个订单号
                    for (int j = 0; j < singleLineOrderIds.Length; j++)
                    {
                        tmpOrderId = singleLineOrderIds[j];
                        if (string.IsNullOrEmpty(tmpOrderId))
                        {
                            continue;
                        }
                        orderIds.Add(tmpOrderId);
                        deliveryTimes.Add(tmpdeliveryTime);
                        expressCompanyName.Add(tmpexpressCompanyName);
                        ShipOrderNumber.Add(tmpkuaidi100Code);
                    }
                }
            }
            #endregion

            #region 发货业务逻辑处理
            for (int i = 0; i < orderIds.Count; i++)
            {
                deliverFailOrderInfo failOrderInfo = null;
                if (string.IsNullOrEmpty(orderIds[i]) && string.IsNullOrEmpty(expressCompanyName[i]) && string.IsNullOrEmpty(ShipOrderNumber[i]))
                {
                    if (!deliverFailOrders.ContainsKey(orderIds[i]))
                    {
                        failOrderInfo                    = new deliverFailOrderInfo();
                        failOrderInfo.OrderId            = orderIds[i];
                        failOrderInfo.FailInfo           = "订单号、快递公司或快递单号不能为空";
                        failOrderInfo.ExpressCompanyCode = ShipOrderNumber[i];
                        failOrderInfo.ExpressCompanyName = expressCompanyName[i];
                        listdeliverFailOrderInfo.Add(failOrderInfo);
                        deliverFailOrders.Add(orderIds[i], "订单号、快递公司或快递单号不能为空");

                        continue;
                    }
                }
                OrderInfo orderInfo = OrderHelper.GetOrderInfo(orderIds[i]);
                if (orderInfo == null)
                {
                    if (!deliverFailOrders.ContainsKey(orderIds[i]))
                    {
                        failOrderInfo                    = new deliverFailOrderInfo();
                        failOrderInfo.OrderId            = orderIds[i];
                        failOrderInfo.FailInfo           = "不存在该订单";
                        failOrderInfo.ExpressCompanyCode = ShipOrderNumber[i];
                        failOrderInfo.ExpressCompanyName = expressCompanyName[i];
                        listdeliverFailOrderInfo.Add(failOrderInfo);
                        deliverFailOrders.Add(orderIds[i], "不存在该订单");
                    }
                    continue;
                }
                if ((orderInfo.GroupBuyId <= 0 || orderInfo.GroupBuyStatus == GroupBuyStatus.Success) && ((orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && orderInfo.Gateway == "hishop.plugins.payment.podrequest") || orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid))
                {
                    string           exCompanyName         = expressCompanyName[i];
                    ShippingModeInfo shippingModeByCompany = SalesHelper.GetShippingModeByCompany(exCompanyName);
                    if (shippingModeByCompany != null)
                    {
                        if (shippingModeByCompany.ModeId > 0)
                        {
                            orderInfo.RealModeName       = shippingModeByCompany.Name;
                            orderInfo.RealShippingModeId = shippingModeByCompany.ModeId;
                        }
                        else
                        {
                            orderInfo.RealShippingModeId = 2;//配送方式
                            orderInfo.RealModeName       = "圆通";
                        }
                    }
                    else
                    {
                        orderInfo.RealShippingModeId = 2;//配送方式
                        orderInfo.RealModeName       = "圆通";
                    }

                    ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNode(expressCompanyName[i]);//物流公司
                    if (expressCompanyInfo == null)
                    {
                        if (!deliverFailOrders.ContainsKey(orderIds[i]))
                        {
                            failOrderInfo                    = new deliverFailOrderInfo();
                            failOrderInfo.OrderId            = orderIds[i];
                            failOrderInfo.FailInfo           = "不存在物流公司";
                            failOrderInfo.ExpressCompanyCode = ShipOrderNumber[i];
                            failOrderInfo.ExpressCompanyName = expressCompanyName[i];
                            listdeliverFailOrderInfo.Add(failOrderInfo);
                            deliverFailOrders.Add(orderIds[i], "不存在物流公司");
                        }
                        continue;
                    }
                    orderInfo.ExpressCompanyName = expressCompanyInfo.Name;
                    orderInfo.ExpressCompanyAbb  = expressCompanyInfo.Kuaidi100Code;
                    orderInfo.ShipOrderNumber    = ShipOrderNumber[i];
                    orderInfo.ShippingDate       = deliveryTimes[i];
                    //todo 发货时间
                    if (OrderHelper.SendGoods(orderInfo))
                    {
                        SendNoteInfo sendNoteInfo = new SendNoteInfo();
                        sendNoteInfo.NoteId   = Globals.GetGenerateId() + num;
                        sendNoteInfo.OrderId  = orderIds[i];
                        sendNoteInfo.Operator = HiContext.Current.User.Username;
                        sendNoteInfo.Remark   = "后台" + sendNoteInfo.Operator + "发货成功";
                        OrderHelper.SaveSendNote(sendNoteInfo);
                        if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0)
                        {
                            PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway);
                            if (paymentMode != null && !string.IsNullOrEmpty(paymentMode.Settings) && paymentMode.Settings != "1hSUSkKQ/ENo0JDZah8KKQweixin")
                            {
                                PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[]
                                {
                                    paymentMode.Gateway
                                })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[]
                                {
                                    paymentMode.Gateway
                                })), "");
                                if (paymentRequest != null)
                                {
                                    paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS");
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(orderInfo.TaobaoOrderId))
                        {
                            try
                            {
                                string requestUriString = string.Format("http://order2.ecdev.cn/UpdateShipping.ashx?tid={0}&companycode={1}&outsid={2}&Host={3}", new object[]
                                {
                                    orderInfo.TaobaoOrderId,
                                    expressCompanyInfo.TaobaoCode,
                                    orderInfo.ShipOrderNumber,
                                    HiContext.Current.SiteUrl
                                });
                                System.Net.WebRequest webRequest = System.Net.WebRequest.Create(requestUriString);
                                webRequest.GetResponse();
                            }
                            catch
                            {
                            }
                        }
                        int num3 = orderInfo.UserId;
                        if (num3 == 1100)
                        {
                            num3 = 0;
                        }
                        IUser user = Users.GetUser(num3);
                        Messenger.OrderShipping(orderInfo, user);
                        orderInfo.OnDeliver();
                        num++;
                    }
                    else
                    {
                        if (!deliverFailOrders.ContainsKey(orderIds[i]))
                        {
                            failOrderInfo                    = new deliverFailOrderInfo();
                            failOrderInfo.OrderId            = orderIds[i];
                            failOrderInfo.FailInfo           = "发货失败";
                            failOrderInfo.ExpressCompanyCode = ShipOrderNumber[i];
                            failOrderInfo.ExpressCompanyName = expressCompanyName[i];
                            listdeliverFailOrderInfo.Add(failOrderInfo);
                            deliverFailOrders.Add(orderIds[i], "发货失败");
                        }
                    }
                }
                else
                {
                    if (!deliverFailOrders.ContainsKey(orderIds[i]))
                    {
                        failOrderInfo                    = new deliverFailOrderInfo();
                        failOrderInfo.OrderId            = orderIds[i];
                        failOrderInfo.FailInfo           = "该订单不满足发货条件";
                        failOrderInfo.ExpressCompanyCode = ShipOrderNumber[i];
                        failOrderInfo.ExpressCompanyName = expressCompanyName[i];
                        listdeliverFailOrderInfo.Add(failOrderInfo);
                        deliverFailOrders.Add(orderIds[i], "该订单不满足发货条件");
                    }
                }
            }
            #endregion

            #region 失败订单抛出
            if (deliverFailOrders.Count > 0)
            {
                System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                stringBuilder.AppendLine("<html><head><meta http-equiv=Content-Type content=\"text/html; charset=gb2312\"></head><body>");
                stringBuilder.AppendLine("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\" border=\"1\">");
                stringBuilder.AppendLine("<caption style='text-align:center;'>发货未成功订单列表</caption>");
                stringBuilder.AppendLine("<tr style=\"font-weight: bold; white-space: nowrap;\">");
                stringBuilder.AppendLine("<td>订单号</td>");
                stringBuilder.AppendLine("<td>物流公司</td>");
                stringBuilder.AppendLine("<td>物流单号</td>");
                stringBuilder.AppendLine("<td>错误信息</td>");
                stringBuilder.AppendLine("</tr>");

                foreach (deliverFailOrderInfo failOrderInfo in listdeliverFailOrderInfo)
                {
                    stringBuilder.AppendLine("<tr>");
                    stringBuilder.AppendLine(string.Format("<td style=\"vnd.ms-excel.numberformat:@\">{0}</td>", failOrderInfo.OrderId));
                    stringBuilder.AppendLine(string.Format("<td style=\"vnd.ms-excel.numberformat:@\">{0}</td>", failOrderInfo.ExpressCompanyName));
                    stringBuilder.AppendLine(string.Format("<td style=\"vnd.ms-excel.numberformat:@\">{0}</td>", failOrderInfo.ExpressCompanyCode));
                    stringBuilder.AppendLine(string.Format("<td style=\"vnd.ms-excel.numberformat:@\">{0}</td>", failOrderInfo.FailInfo));
                    stringBuilder.AppendLine("</tr>");
                }
                stringBuilder.AppendLine("</table>");
                stringBuilder.AppendLine("</body></html>");
                base.Response.Clear();
                base.Response.Buffer  = false;
                base.Response.Charset = "GB2312";
                base.Response.AppendHeader("Content-Disposition", "attachment;filename=发货未成功订单_" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");
                base.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
                base.Response.ContentType     = "application/ms-excel";
                this.EnableViewState          = false;
                base.Response.Write(stringBuilder.ToString());
            }
            #endregion
            this.btnBatchSend.Enabled = true;
            this.ShowMsg("操作完成!", true);
            //base.Response.End();
        }
Exemplo n.º 27
0
 private void btnSendGoods_Click(object sender, EventArgs e)
 {
     if (this.grdOrderGoods.Items.Count <= 0)
     {
         this.ShowMsg("没有要进行发货的订单。", false);
     }
     else
     {
         StringBuilder stringBuilder  = new StringBuilder();
         SiteSettings  masterSettings = SettingsManager.GetMasterSettings();
         int           num            = 0;
         for (int i = 0; i < this.grdOrderGoods.Items.Count; i++)
         {
             HiddenField         hiddenField         = (HiddenField)this.grdOrderGoods.Items[i].FindControl("hidorderId");
             string              value               = hiddenField.Value;
             TextBox             textBox             = (TextBox)this.grdOrderGoods.Items[i].FindControl("txtShippOrderNumber");
             ExpressDropDownList expressDropDownList = this.grdOrderGoods.Items[i].FindControl("expressList1") as ExpressDropDownList;
             OrderInfo           orderInfo           = OrderHelper.GetOrderInfo(value);
             if ((orderInfo.GroupBuyId <= 0 || orderInfo.GroupBuyStatus == GroupBuyStatus.Success) && ((orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && orderInfo.Gateway == "hishop.plugins.payment.podrequest") || orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid))
             {
                 ExpressCompanyInfo expressCompanyInfo = null;
                 if (!string.IsNullOrEmpty(expressDropDownList.SelectedValue))
                 {
                     expressCompanyInfo = ExpressHelper.FindNode(expressDropDownList.SelectedValue);
                 }
                 if (expressCompanyInfo != null)
                 {
                     if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && orderInfo.OuterOrderId.StartsWith("jd_") && string.IsNullOrWhiteSpace(expressCompanyInfo.JDCode))
                     {
                         continue;
                     }
                     orderInfo.ExpressCompanyName = expressCompanyInfo.Name;
                     orderInfo.ExpressCompanyAbb  = expressCompanyInfo.Kuaidi100Code;
                     orderInfo.ShipOrderNumber    = textBox.Text;
                 }
                 if (OrderHelper.SendGoods(orderInfo) && expressCompanyInfo != null && !string.IsNullOrEmpty(orderInfo.ExpressCompanyAbb) && orderInfo.ExpressCompanyAbb.ToUpper() == "HTKY")
                 {
                     ExpressHelper.GetDataByKuaidi100(orderInfo.ExpressCompanyAbb, orderInfo.ShipOrderNumber);
                 }
                 if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0)
                 {
                     PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.Gateway);
                     if (paymentMode != null)
                     {
                         string         hIGW           = paymentMode.Gateway.Replace(".", "_");
                         PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.PayOrderId, orderInfo.GetTotal(false), "订单发货", "订单号-" + orderInfo.PayOrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(""), Globals.FullPath(base.GetRouteUrl("PaymentReturn_url", new
                         {
                             HIGW = hIGW
                         })), Globals.FullPath(base.GetRouteUrl("PaymentNotify_url", new
                         {
                             HIGW = hIGW
                         })), "");
                         paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS");
                     }
                 }
                 if (!string.IsNullOrEmpty(orderInfo.OuterOrderId) && expressCompanyInfo != null)
                 {
                     if (orderInfo.OuterOrderId.StartsWith("tb_"))
                     {
                         string text = orderInfo.OuterOrderId.Replace("tb_", "");
                         try
                         {
                             string     requestUriString = $"http://order2.kuaidiangtong.com/UpdateShipping.ashx?tid={text}&companycode={expressCompanyInfo.TaobaoCode}&outsid={orderInfo.ShipOrderNumber}&Host={HiContext.Current.SiteUrl}";
                             WebRequest webRequest       = WebRequest.Create(requestUriString);
                             webRequest.GetResponse();
                         }
                         catch
                         {
                         }
                     }
                     else if (orderInfo.OuterOrderId.StartsWith("jd_") && expressCompanyInfo != null)
                     {
                         string text = orderInfo.OuterOrderId.Replace("jd_", "");
                         try
                         {
                             JDHelper.JDOrderOutStorage(masterSettings.JDAppKey, masterSettings.JDAppSecret, masterSettings.JDAccessToken, expressCompanyInfo.JDCode, orderInfo.ShipOrderNumber, text);
                         }
                         catch (Exception ex)
                         {
                             stringBuilder.Append($"订单:{orderInfo.OrderId}同步京东发货失败,京东订单号:{text},{ex.Message}\r\n");
                         }
                     }
                 }
                 int num2 = orderInfo.UserId;
                 if (num2 == 1100)
                 {
                     num2 = 0;
                 }
                 MemberInfo user = Users.GetUser(num2);
                 Messenger.OrderShipping(orderInfo, user);
                 orderInfo.OnDeliver();
                 num++;
             }
         }
         if (num == 0)
         {
             this.ShowMsg("批量发货失败,您填写的信息不完整!", false);
         }
         else if (num > 0)
         {
             this.ShowMsgCloseWindow(string.Format("批量发货成功!发货数量{0}个!{1}", num, (stringBuilder.Length > 0) ? stringBuilder.ToString() : ""), true);
         }
     }
 }
Exemplo n.º 28
0
        private void btnSendGoods_Click(object sender, EventArgs e)
        {
            OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.orderId);

            if (orderInfo != null)
            {
                ManagerInfo currentManager = ManagerHelper.GetCurrentManager();
                if (currentManager != null)
                {
                    if ((orderInfo.GroupBuyId > 0) && (orderInfo.GroupBuyStatus != GroupBuyStatus.Success))
                    {
                        this.ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false);
                    }
                    else if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS))
                    {
                        this.ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false);
                    }
                    else if (!this.radioShippingMode.SelectedValue.HasValue)
                    {
                        this.ShowMsg("请选择配送方式", false);
                    }
                    else if (string.IsNullOrEmpty(this.txtShipOrderNumber.Text.Trim()) || (this.txtShipOrderNumber.Text.Trim().Length > 20))
                    {
                        this.ShowMsg("运单号码不能为空,在1至20个字符之间", false);
                    }
                    else if (string.IsNullOrEmpty(this.expressRadioButtonList.SelectedValue))
                    {
                        this.ShowMsg("请选择物流公司", false);
                    }
                    else
                    {
                        ShippingModeInfo shippingMode = SalesHelper.GetShippingMode(this.radioShippingMode.SelectedValue.Value, true);
                        orderInfo.RealShippingModeId = this.radioShippingMode.SelectedValue.Value;
                        orderInfo.RealModeName       = shippingMode.Name;
                        ExpressCompanyInfo info4 = ExpressHelper.FindNode(this.expressRadioButtonList.SelectedValue);
                        if (info4 != null)
                        {
                            orderInfo.ExpressCompanyAbb  = info4.Kuaidi100Code;
                            orderInfo.ExpressCompanyName = info4.Name;
                        }
                        orderInfo.ShipOrderNumber = this.txtShipOrderNumber.Text;
                        if (OrderHelper.SendGoods(orderInfo))
                        {
                            SendNoteInfo info5 = new SendNoteInfo();

                            info5.NoteId   = Globals.GetGenerateId();
                            info5.OrderId  = this.orderId;
                            info5.Operator = currentManager.UserName;
                            info5.Remark   = "后台" + info5.Operator + "发货成功";

                            OrderHelper.SaveSendNote(info5);
                            MemberInfo member = MemberHelper.GetMember(orderInfo.UserId);
                            Messenger.OrderShipping(orderInfo, member);
                            if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && (orderInfo.GatewayOrderId.Trim().Length > 0))
                            {
                                if (orderInfo.Gateway == "hishop.plugins.payment.ws_wappay.wswappayrequest")
                                {
                                    PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.PaymentTypeId);
                                    if (paymentMode != null)
                                    {
                                        PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), "").SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS");
                                    }
                                }
                                if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest")
                                {
                                    SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
                                    PayClient    client         = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey);
                                    DeliverInfo  deliver        = new DeliverInfo
                                    {
                                        TransId    = orderInfo.GatewayOrderId,
                                        OutTradeNo = orderInfo.OrderId,
                                        OpenId     = MemberHelper.GetMember(orderInfo.UserId).OpenId
                                    };
                                    client.DeliverNotify(deliver);
                                }
                            }
                            orderInfo.OnDeliver();
                            this.ShowMsg("发货成功", true);
                        }
                        else
                        {
                            this.ShowMsg("发货失败", false);
                        }
                    }
                }
            }
        }
Exemplo n.º 29
0
        public string SendLogistic(string tid, string company_name, string out_sid)
        {
            OrderInfo orderInfo = OrderHelper.GetOrderInfo(tid);

            if (orderInfo == null || string.IsNullOrEmpty(orderInfo.OrderId))
            {
                return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Trade_not_Exists, "tid"));
            }
            if (orderInfo.GroupBuyId > 0 && orderInfo.GroupBuyStatus != GroupBuyStatus.Success)
            {
                return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Trade_Status_Send, "group order"));
            }
            if (!orderInfo.CheckAction(OrderActions.SELLER_SEND_GOODS))
            {
                return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Trade_Status_Send, "orderstatue"));
            }
            if (string.IsNullOrEmpty(out_sid))
            {
                return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Missing_Required_Arguments, "out_sid"));
            }
            ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNode(company_name);

            if (expressCompanyInfo == null)
            {
                return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Company_not_Exists, "company_name"));
            }
            orderInfo.ExpressCompanyAbb  = expressCompanyInfo.Kuaidi100Code;
            orderInfo.ExpressCompanyName = expressCompanyInfo.Name;
            orderInfo.ShipOrderNumber    = out_sid;
            if (!OrderHelper.SendGoods(orderInfo))
            {
                return(OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Trade_Status_Send, "send good"));
            }
            Express.SubscribeExpress100(orderInfo.ExpressCompanyAbb, out_sid);
            OrderHelper.SaveSendNote(new SendNoteInfo
            {
                NoteId   = Globals.GetGenerateId(),
                OrderId  = orderInfo.OrderId,
                Operator = orderInfo.UserId.ToString(),
                Remark   = "接口发货成功"
            });
            if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && orderInfo.GatewayOrderId.Trim().Length > 0)
            {
                if (orderInfo.Gateway == "hishop.plugins.payment.ws_wappay.wswappayrequest")
                {
                    PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.PaymentTypeId);
                    if (paymentMode != null)
                    {
                        PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[]
                        {
                            paymentMode.Gateway
                        })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[]
                        {
                            paymentMode.Gateway
                        })), "");
                        paymentRequest.SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS");
                    }
                }
                if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest")
                {
                    SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
                    PayClient    payClient;
                    if (masterSettings.EnableSP)
                    {
                        payClient = new PayClient(masterSettings.Main_AppId, masterSettings.WeixinAppSecret, masterSettings.Main_Mch_ID, masterSettings.Main_PayKey, true, masterSettings.WeixinAppId, masterSettings.WeixinPartnerID);
                    }
                    else
                    {
                        payClient = new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, false, "", "");
                    }
                    payClient.DeliverNotify(new DeliverInfo
                    {
                        TransId    = orderInfo.GatewayOrderId,
                        OutTradeNo = orderInfo.OrderId,
                        OpenId     = MemberHelper.GetMember(orderInfo.UserId).OpenId
                    });
                }
            }
            orderInfo.OnDeliver();
            string format = "{{\"logistics_send_response\":{{\"shipping\":{{\"is_success\":{0}}}}}}}";

            return(string.Format(format, "true"));
        }
Exemplo n.º 30
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;
            }
        }