/// <summary>
        /// Update into XMOrderInfoApp
        /// </summary>
        /// <param name="xmorderinfoapp">XMOrderInfoApp</param>
        public void UpdateXMOrderInfoApp(XMOrderInfoApp xmorderinfoapp)
        {
            if (xmorderinfoapp == null)
            {
                return;
            }

            if (this._context.IsAttached(xmorderinfoapp))
            {
                this._context.XMOrderInfoApps.Attach(xmorderinfoapp);
            }

            this._context.SaveChanges();
        }
        /// <summary>
        /// Insert into XMOrderInfoApp
        /// </summary>
        /// <param name="xmorderinfoapp">XMOrderInfoApp</param>
        public void InsertXMOrderInfoApp(XMOrderInfoApp xmorderinfoapp)
        {
            if (xmorderinfoapp == null)
            {
                return;
            }

            if (!this._context.IsAttached(xmorderinfoapp))
            {
                this._context.XMOrderInfoApps.AddObject(xmorderinfoapp);
            }

            this._context.SaveChanges();
        }
Beispiel #3
0
        public bool JingDong(XMDelivery One, XMOrderInfoApp xMorderInfoApp, XMOrderInfo xMOrderInfo)
        {
            bool   Succed  = false;
            string Waybill = One.LogisticsNumber;

            if (Waybill == "")
            {
                Waybill = null;
            }
            int paramLogisticsId = int.Parse(One.LogisticsId.ToString());

            if (One.LogisticsId == 1)
            {
                paramLogisticsId = 2170;
            }
            if (One.LogisticsId == 500 || One.LogisticsId == 1499) //中通速递
            {
                paramLogisticsId = 1499;
            }
            if (One.LogisticsId == 3049)   //德邦速递
            {
                paramLogisticsId = 3049;
            }
            var outstorage = IoC.Resolve <IXMOrderInfoAPIService>().GetOutstorage(One.OrderCode, paramLogisticsId.ToString(), Waybill, xMorderInfoApp);

            if (outstorage != null)
            {
                if (!outstorage.IsError)
                {
                    UpdateDelivery(One, xMOrderInfo, DateTime.Now.ToString());
                    Succed = true;
                }
                else
                {
                    //DeleteDelivery(One);
                }
            }
            else
            {
                //DeleteDelivery(One);
            }
            return(Succed);
        }
Beispiel #4
0
        public bool VPH(XMDelivery One, XMOrderInfoApp xMorderInfoApp, XMOrderInfo xMOrderInfo, string LogisticsName)
        {
            bool   Succed  = false;
            string Waybill = One.LogisticsNumber;

            if (Waybill == "")
            {
                Waybill = null;
            }
            var Success_num = IoC.Resolve <XMDeliveryImportDeliverAPI>().GetVPHAPIDelivery(One.OrderCode, One.LogisticsId.ToString(), Waybill, xMorderInfoApp, LogisticsName);

            if (Success_num != null)
            {
                UpdateDelivery(One, xMOrderInfo, DateTime.Now.ToString());
                Succed = true;
            }
            else
            {
                //DeleteDelivery(One);
            }
            return(Succed);
        }
Beispiel #5
0
        public bool SuNing(XMDelivery One, XMOrderInfoApp xMorderInfoApp, XMOrderInfo xMOrderInfo)
        {
            bool   Succed  = false;
            string Waybill = One.LogisticsNumber;

            if (Waybill == "")
            {
                Waybill = null;
            }
            var ModifiedDate = IoC.Resolve <XMDeliveryImportDeliverAPI>().GetSuNingAPIDelivery(One.OrderCode, One.LogisticsCode, Waybill, xMorderInfoApp);

            if (ModifiedDate != null)
            {
                UpdateDelivery(One, xMOrderInfo, DateTime.Now.ToString());
                Succed = true;
            }
            else
            {
                //DeleteDelivery(One);
            }
            return(Succed);
        }
        public string GetYHDAPIDelivery(string OrderId, string LogisticsCode, string Waybill, XMOrderInfoApp xMorderInfoApp)
        {
            try
            {
                string AppKey      = xMorderInfoApp.AppKey;
                string AppSecret   = xMorderInfoApp.AppSecret;
                string CallbackUrl = xMorderInfoApp.CallbackUrl;//"http://www.hozest.com";
                string AccessToken = xMorderInfoApp.AccessToken;

                YhdClient client = new YhdClient("http://openapi.yhd.com/app/api/rest/router", AppKey, AppSecret);
                Yhd.Api.Request.LogisticsOrderShipmentsUpdateRequest req = new Yhd.Api.Request.LogisticsOrderShipmentsUpdateRequest();
                req.OrderCode          = OrderId;
                req.ExpressNbr         = Waybill;
                req.DeliverySupplierId = long.Parse(LogisticsCode);
                Yhd.Api.Response.LogisticsOrderShipmentsUpdateResponse rsp = client.Execute(req, AccessToken);

                if (rsp != null)
                {
                    if (rsp.UpdateCount > 0)
                    {
                        return("");
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                IoC.Resolve <IRecordErrorLogs>().WriteErrorLog("负责人:" + HozestERPContext.Current.User.CustomerID.ToString() + ";   方法名:GetYHDAPIDelivery;  异常提示:" + ex.Message.ToString() + ";   InnerException:" + ex.InnerException);
            }
            return(null);
        }
        public string GetSuNingAPIDelivery(string OrderId, string LogisticsCode, string Waybill, XMOrderInfoApp xMorderInfoApp)
        {
            try
            {
                string AppKey      = xMorderInfoApp.AppKey;
                string AppSecret   = xMorderInfoApp.AppSecret;
                string CallbackUrl = xMorderInfoApp.CallbackUrl;//"http://www.hozest.com";
                string AccessToken = xMorderInfoApp.AccessToken;

                suning::suning_api_sdk.BizRequest.CustomTransactionRequest.OrderdeliveryAddRequest request = new suning::suning_api_sdk.BizRequest.CustomTransactionRequest.OrderdeliveryAddRequest();
                request.orderCode          = OrderId;
                request.expressNo          = Waybill;
                request.expressCompanyCode = LogisticsCode;

                suning::suning_api_sdk.ISuningClient client = new suning::suning_api_sdk.DefaultSuningClient("http://open.suning.com/api/http/sopRequest", AppKey, AppSecret);
                suning::suning_api_sdk.BizResponse.CustomTransactionResponse.OrderdeliveryAddResponse rsp = client.Execute(request);
                //suning::suning_api_sdk.BizResponse.CustomTransactionResponse.OrderdeliveryAddResponse m = JsonConvert.DeserializeObject<suning::suning_api_sdk.BizResponse.CustomTransactionResponse.OrderdeliveryAddResponse>(rsp.ToJson());

                if (rsp.sendDetail != null)
                {
                    if (string.IsNullOrEmpty(rsp.respError.error_code))
                    {
                        return("");
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                IoC.Resolve <IRecordErrorLogs>().WriteErrorLog("负责人:" + HozestERPContext.Current.User.CustomerID.ToString() + ";   方法名:GetSuNingAPIDelivery;  异常提示:" + ex.Message.ToString() + ";   InnerException:" + ex.InnerException);
            }
            return(null);
        }
        public string GetTMAPIDelivery(string OrderId, string LogisticsCode, string Waybill, XMOrderInfoApp xMorderInfoApp)
        {
            try
            {
                string AppKey      = xMorderInfoApp.AppKey;
                string AppSecret   = xMorderInfoApp.AppSecret;
                string CallbackUrl = xMorderInfoApp.CallbackUrl;//"http://www.hozest.com";
                string AccessToken = xMorderInfoApp.AccessToken;

                ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", AppKey, AppSecret);
                Top.Api.Request.LogisticsOfflineSendRequest req = new Top.Api.Request.LogisticsOfflineSendRequest();
                req.Tid         = long.Parse(OrderId);
                req.OutSid      = Waybill;
                req.CompanyCode = LogisticsCode;
                Top.Api.Response.LogisticsOfflineSendResponse rsp = client.Execute(req, AccessToken);
                //Top.Api.Response.LogisticsOfflineSendResponse m = JsonConvert.DeserializeObject<Top.Api.Response.LogisticsOfflineSendResponse>(rsp.Body);

                if (rsp.Shipping != null)
                {
                    if (rsp.Shipping.IsSuccess)
                    {
                        return(rsp.Shipping.Modified);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                IoC.Resolve <IRecordErrorLogs>().WriteErrorLog("负责人:" + HozestERPContext.Current.User.CustomerID.ToString() + ";   方法名:GetTMAPIDelivery;  异常提示:" + ex.Message.ToString() + ";   InnerException:" + ex.InnerException);
            }
            return(null);
        }
        public string GetVPHAPIDelivery(string OrderId, string LogisticsCode, string Waybill, XMOrderInfoApp xMorderInfoApp, string LogisticsName)
        {
            try
            {
                string AppKey      = xMorderInfoApp.AppKey;
                string AppSecret   = xMorderInfoApp.AppSecret;
                string CallbackUrl = xMorderInfoApp.CallbackUrl;//"http://www.hozest.com";
                string AccessToken = xMorderInfoApp.AccessToken;
                string posturl     = xMorderInfoApp.ServerUrl;

                DvdDeliveryServiceHelper.DvdDeliveryServiceClient client = new DvdDeliveryServiceHelper.DvdDeliveryServiceClient();
                InvocationContext invocationContext = Factory.GetInstance();
                invocationContext.SetAppKey(AppKey);
                invocationContext.SetAppSecret(AppSecret);
                invocationContext.SetAppURL(posturl);

                List <PackageProduct> packageProduct_list = new List <PackageProduct>();
                PackageProduct        packageProduct      = new PackageProduct();
                packageProduct.SetBarcode("");
                packageProduct.SetAmount(1);
                packageProduct_list.Add(packageProduct);

                List <Package> package_list = new List <Package>();
                Package        package      = new Package();
                package.SetTransport_no(Waybill);
                package.SetPackage_product_list(packageProduct_list);
                package_list.Add(package);

                List <Ship> ship_list = new List <Ship>();
                Ship        ship      = new Ship();
                ship.SetOrder_id(OrderId);
                ship.SetCarrier_code(LogisticsCode);
                ship.SetCarrier_name(LogisticsName);
                ship.SetPackage_type("1");
                ship.SetPackages(package_list);
                ship_list.Add(ship);

                ShipResult rsp = client.ship(6480, ship_list);

                if (rsp != null)
                {
                    if (rsp.GetSuccess_num() > 0 && rsp.GetFail_num() == 0)
                    {
                        return(rsp.GetSuccess_num().ToString());
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                IoC.Resolve <IRecordErrorLogs>().WriteErrorLog("负责人:" + HozestERPContext.Current.User.CustomerID.ToString() + ";   方法名:GetVPHAPIDelivery;  异常提示:" + ex.Message.ToString() + ";   InnerException:" + ex.InnerException);
            }
            return(null);
        }
Beispiel #10
0
        public string XMDelivery_ImportDeliver(string Shop, XMDelivery One, string LogisticsName)
        {
            string msg  = "";
            bool   pass = false;
            var    XMOrderInfoAppList = IoC.Resolve <IXMOrderInfoAppService>().GetXMOrderInfoAppList();
            var    xMOrderInfo        = IoC.Resolve <IXMOrderInfoService>().GetXMOrderInfoListByOrderEqs(One.OrderCode);

            XMOrderInfoApp xMorderInfoApp = new XMOrderInfoApp();

            if (xMOrderInfo != null && xMOrderInfo.Count > 0)
            {
                for (int i = 0; i < XMOrderInfoAppList.Count; i++)
                {
                    if (XMOrderInfoAppList[i].PlatformTypeId == xMOrderInfo[0].PlatformTypeId && XMOrderInfoAppList[i].NickId == xMOrderInfo[0].NickID)
                    {
                        xMorderInfoApp = XMOrderInfoAppList[i];
                        break;
                    }
                }

                if (xMorderInfoApp != null)
                {
                    if (One.LogisticsNumber != null && One.LogisticsId != null)
                    {
                        //京东
                        if (Shop.IndexOf("京东") != -1)
                        {
                            pass = JingDong(One, xMorderInfoApp, xMOrderInfo[0]);
                            if (!pass)
                            {
                                msg = "订单:" + xMOrderInfo[0].OrderCode.ToString() + ",发货失败!\r";
                            }
                        }
                        //天猫
                        else if (Shop.IndexOf("天猫") != -1)
                        {
                            pass = TM(One, xMorderInfoApp, xMOrderInfo[0]);
                            if (!pass)
                            {
                                msg = "订单:" + xMOrderInfo[0].OrderCode.ToString() + ",发货失败!\r";
                            }
                        }
                        //苏宁易购
                        else if (Shop.IndexOf("苏宁易购") != -1)
                        {
                            pass = SuNing(One, xMorderInfoApp, xMOrderInfo[0]);
                            if (!pass)
                            {
                                msg = "订单:" + xMOrderInfo[0].OrderCode.ToString() + ",发货失败!\r";
                            }
                        }
                        //一号店
                        else if (Shop.IndexOf("一号店") != -1)
                        {
                            pass = YHD(One, xMorderInfoApp, xMOrderInfo[0]);
                            if (!pass)
                            {
                                msg = "订单:" + xMOrderInfo[0].OrderCode.ToString() + ",发货失败!\r";
                            }
                        }
                        //唯品会
                        else if (Shop.IndexOf("唯品会") != -1)
                        {
                            pass = VPH(One, xMorderInfoApp, xMOrderInfo[0], LogisticsName);
                            if (!pass)
                            {
                                msg = "订单:" + xMOrderInfo[0].OrderCode.ToString() + ",发货失败!\r";
                            }
                        }
                        else
                        {
                            DeleteDelivery(One);
                        }
                    }
                    else
                    {
                        msg = "订单:" + xMOrderInfo[0].OrderCode.ToString() + ",物流单号,物流公司不能为空!\r";
                    }
                }
                else
                {
                    msg = "京东appkey、appSecret、sessionKey 不能为空!\r";
                }
            }
            else
            {
                msg = "订单:" + xMOrderInfo[0].OrderCode.ToString() + ",在订单表中不存在!\r";
            }

            return(msg);
        }