예제 #1
0
        /// <summary>
        /// 获取物流单号
        /// </summary>
        /// <param name="orderSysNo"></param>
        /// <returns></returns>
        /// <remarks>2016-05-25 陈海裕 创建</remarks>
        public override Result GetOrderExpressno(string orderSysNo)
        {
            Result result = new Result();

            try
            {
                CrossBorderLogisticsOrder cbLogiOrder = BLL.CrossBorderLogistics.CrossBorderLogisticsOrderBo.Instance.GetEntityByOrderSysNo(Convert.ToInt32(orderSysNo));
                if (cbLogiOrder != null)
                {
                    ServiceRefEightDT.APIWebServiceSoapClient newService = new ServiceRefEightDT.APIWebServiceSoapClient();
                    string         tempR       = newService.getPackage(cbLogiOrder.LogisticsOrderId, CoustomerID, Secretkey);
                    List <Package> packageList = Util.Serialization.JsonUtil.ToObject <List <Package> >(tempR);
                    Package        package     = packageList.FirstOrDefault();
                    if (!string.IsNullOrWhiteSpace(package.TrackingNo))
                    {
                        result.Message = package.TrackingNo;
                        result.Status  = true;
                    }
                }
                else
                {
                    result.Message = "找不到对应订单的跨境物流订单号";
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.ToString();
            }

            return(result);
        }
예제 #2
0
        /// <summary>
        /// 添加交易订单
        /// </summary>
        /// <param name="orderSysno"></param>
        /// <returns>2016-04-09 陈海裕 创建</returns>
        public override Result AddOrderTrade(int orderSysno)
        {
            // 订单id,用于日志记录
            _orderSysNo = orderSysno;

            Result result = new Result();

            result.Status     = false;
            result.StatusCode = 0;
            result.Message    = "接口调用失败";

            if (orderSysno <= 0)
            {
                return(result);
            }

            lock (lockHelper)
            {
                try
                {
                    SoOrder order = BLL.Order.SoOrderBo.Instance.GetEntity(orderSysno);
                    if (order == null)
                    {
                        result.Message = "该订单不存在";
                        return(result);
                    }
                    if (order.CBLogisticsSendStatus == 1)
                    {
                        result.Message = "该订单已推送,不能重复操作";
                        return(result);
                    }
                    order.ReceiveAddress = BLL.Order.SoOrderBo.Instance.GetOrderReceiveAddress(order.ReceiveAddressSysNo);
                    order.OrderItemList  = DataAccess.Order.ISoOrderItemDao.Instance.GetOrderItemsByOrderSysNo(order.SysNo);
                    ParaVoucherFilter voucherFilter = new ParaVoucherFilter();
                    voucherFilter.SourceSysNo = order.SysNo;
                    CBFnReceiptVoucher recVoucher = BLL.Finance.FinanceBo.Instance.GetReceiptVouchers(voucherFilter).Rows.FirstOrDefault();
                    recVoucher.VoucherItems = BLL.Finance.FnReceiptVoucherBo.Instance.GetReceiptVoucherItem(recVoucher.SysNo);
                    // 收货人 区 市 省
                    BsArea receiverDistrict = BLL.Basic.BasicAreaBo.Instance.GetArea(order.ReceiveAddress.AreaSysNo);
                    BsArea receiverCity     = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverDistrict.ParentSysNo);
                    BsArea receiverProvince = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverCity.ParentSysNo);
                    // 发货人 市
                    CBWhWarehouse warehouse   = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(order.DefaultWarehouseSysNo);
                    BsArea        shipperCity = BLL.Basic.BasicAreaBo.Instance.GetArea(warehouse.CitySysNo);

                    DsDealer dealer = BLL.Distribution.DsDealerBo.Instance.GetDsDealer(order.DealerSysNo);

                    LgDeliveryType deliveryType = BLL.Logistics.DeliveryTypeBo.Instance.GetDeliveryType(order.DeliveryTypeSysNo);

                    EDTOrder newOrder = new EDTOrder();
                    newOrder.Address1 = order.ReceiveAddress.StreetAddress;
                    //newOrder.Base_ChannelInfoID = "1";
                    newOrder.Base_ChannelInfoID = "HKKJ";
                    newOrder.City           = receiverCity.AreaName;
                    newOrder.ConsigneeName  = order.ReceiveAddress.Name;
                    newOrder.Contact        = !string.IsNullOrWhiteSpace(order.ReceiveAddress.MobilePhoneNumber) ? order.ReceiveAddress.MobilePhoneNumber : order.ReceiveAddress.PhoneNumber;
                    newOrder.Country        = "CN";
                    newOrder.CusRemark      = order.Remarks;
                    newOrder.GFF_CustomerID = CoustomerID;
                    newOrder.OrderStatus    = "3";
                    newOrder.State          = receiverProvince.AreaName;
                    newOrder.Style          = "1";
                    //newOrder.ShippingService = "GZBC";
                    List <EDTOrderProduct> productList = new List <EDTOrderProduct>();
                    EDTOrderProduct        product     = null;
                    foreach (var item in order.OrderItemList)
                    {
                        PdProductStock productStock = BLL.Warehouse.PdProductStockBo.Instance.GetEntityByWP(order.DefaultWarehouseSysNo, item.ProductSysNo);
                        product               = new EDTOrderProduct();
                        product.CnName        = item.ProductName;
                        product.EnName        = "";
                        product.MaterialRefNo = TConvert.ToString(productStock.ProductSku);
                        product.Price         = item.SalesUnitPrice.ToString();
                        product.Quantity      = item.Quantity.ToString();
                        product.Weight        = "";
                        product.WarehouseID   = warehouse.LogisWarehouseCode;
                        productList.Add(product);
                    }

                    if (product == null)
                    {
                        result.Message = "订单明细不存在";
                        return(result);
                    }

                    StringBuilder strorderinfo = new StringBuilder();
                    strorderinfo.Append("Style:" + newOrder.Style + ";");
                    strorderinfo.Append("GFF_CustomerID:" + newOrder.GFF_CustomerID + ";");
                    strorderinfo.Append("GFF_ReceiveSendAddressID:;");
                    strorderinfo.Append("ConsigneeName:" + newOrder.ConsigneeName + ";");
                    strorderinfo.Append("Country:" + newOrder.Country + ";");
                    strorderinfo.Append("Base_ChannelInfoID:" + newOrder.Base_ChannelInfoID + ";");
                    strorderinfo.Append("State:" + newOrder.State + ";");
                    strorderinfo.Append("City:" + newOrder.City + ";");
                    strorderinfo.Append("OrderStatus:" + newOrder.OrderStatus + ";");
                    strorderinfo.Append("Address1:" + newOrder.Address1 + ";");
                    strorderinfo.Append("Address2:;");
                    strorderinfo.Append("CsRefNo:;");
                    strorderinfo.Append("Zipcode:;");
                    strorderinfo.Append("Contact:" + newOrder.Contact + ";");
                    strorderinfo.Append("CusRemark:" + newOrder.CusRemark + ";");
                    strorderinfo.Append("TrackingNo:;");
                    //strorderinfo.Append("ShippingService:" + newOrder.ShippingService + ";");
                    StringBuilder strorderproduct = new StringBuilder();
                    for (int i = 0; i < productList.Count; i++)
                    {
                        strorderproduct.Append("MaterialRefNo:" + productList[i].MaterialRefNo + ",");
                        //strorderproduct.Append("MaterialRefNo:123456,");
                        strorderproduct.Append("Quantity:" + productList[i].Quantity + ",");
                        strorderproduct.Append("Price:" + productList[i].Price + ",");
                        strorderproduct.Append("Weight:" + productList[i].Weight + ",");
                        strorderproduct.Append("EnName:" + productList[i].EnName + ",");
                        strorderproduct.Append("WarehouseID:" + productList[i].WarehouseID + ",");
                        strorderproduct.Append("ProducingArea:,");
                        productList[i].CnName = Regex.Replace(productList[i].CnName, @"[/\(\)(),]", "");
                        strorderproduct.Append("CnName:" + productList[i].CnName + ",;");
                    }

                    ServiceRefEightDT.APIWebServiceSoapClient newService = new ServiceRefEightDT.APIWebServiceSoapClient();

                    string strResult = newService.InsertUpdateOrder(strorderinfo.ToString(), strorderproduct.ToString(), "", Secretkey);
                    if (strResult.Contains("成功"))
                    {
                        try
                        {
                            CrossBorderLogisticsOrder cbOrder = BLL.CrossBorderLogistics.CrossBorderLogisticsOrderBo.Instance.GetEntityByOrderSysNo(orderSysno);
                            if (cbOrder == null)
                            {
                                Model.CrossBorderLogisticsOrder logisticsOrder = new Model.CrossBorderLogisticsOrder();
                                logisticsOrder.SoOrderSysNo     = orderSysno;
                                logisticsOrder.LogisticsOrderId = Regex.Match(strResult, "[a-zA-Z0-9]+").ToString();
                                logisticsOrder.LogisticsCode    = (int)this.Code;
                                BLL.CrossBorderLogistics.CrossBorderLogisticsOrderBo.Instance.InsertEntity(logisticsOrder);
                            }
                            // 更新订单状态
                            BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus(1, 3, orderSysno);
                        }
                        catch (Exception ex)
                        {
                            BLL.Log.SysLog.Instance.Error(LogStatus.系统日志来源.后台, "订单" + orderSysno + "保存跨境物流返回的单号失败。", ex);
                        }

                        result.Status = true;
                    }

                    result.Message = strResult;
                }
                catch (Exception ex)
                {
                    result.Message = "向" + this.Code + "物流推送订单报错:" + ex.StackTrace;
                    return(result);
                }
            }

            return(result);
        }