Esempio n. 1
0
        /// <summary>
        /// 根据单号获取跟踪信息
        /// </summary>
        /// <param name="orderNumber"></param>
        /// <returns></returns>
        public static bool GetTrackInfo(string orderNumber)
        {
            Log.Info("本次获取单号为:{0}".FormatWith(orderNumber));
            var result = B2CController.GetTrackInfoXmlByNumber(orderNumber);

            try
            {
                DbUtility dbUtility = new SqlDbUtility(TrackCon);
                string    obj       = dbUtility.ExecuteScalar(
                    "exec P_ImportB2CTrackInfo {0},{1}",
                    orderNumber, result).ToString();
                var issuccess = obj == "1";
                if (issuccess)
                {
                    Log.Info("本次获取单号为:{0} 插入数据库成功!".FormatWith(orderNumber));
                }
                else
                {
                    Log.Error("本次获取单号为:{0} 插入数据库失败!".FormatWith(orderNumber));
                }
                return(issuccess);
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// 获取B2C跟新信息插入数据库按时间点
        /// </summary>
        public static bool GetTrackInfo()
        {
            var intervalHours = -1 * (IntervalHours + 4);//加4小时,是防止漏抓取B2C跟踪信息
            var datetime      = long.Parse(DateTime.UtcNow.AddHours(intervalHours).ToString("yyyyMMddHH") + "0000");

            Log.Info("本次获取UTC时间点为:{0}".FormatWith(datetime));
            var result = B2CController.GetTrackInfoXmlByTime(datetime);

            try
            {
                DbUtility dbUtility = new SqlDbUtility(TrackCon);
                string    obj       = dbUtility.ExecuteScalar(
                    "exec P_ImportB2CTrackInfo {0},{1}",
                    datetime.ToString(), result).ToString();
                var issuccess = obj == "1";
                if (issuccess)
                {
                    Log.Info("本次获取UTC时间点为:{0} 插入数据库成功!".FormatWith(datetime));
                }
                else
                {
                    Log.Error("本次获取UTC时间点为:{0} 插入数据库失败!".FormatWith(datetime));
                }
                return(issuccess);
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// 外部跟踪信息插入B2C预报记录表
        /// </summary>
        public static bool OutInsertB2CForeCastLogs()
        {
            Log.Info("LMS开始把外部跟踪信息插入B2C预报记录");
            DbUtility dbUtility = new SqlDbUtility(_TrackCon);
            var       obj       = dbUtility.ExecuteScalar("exec P_InsertB2CForeCastLogs");

            Log.Info("LMS完成把外部跟踪信息插入B2C预报记录");
            return(obj.ToString() == "1");
        }
        /// <summary>
        /// 提交顺丰错误
        /// </summary>
        /// <param name="wayBillNumber">运单号</param>
        /// <param name="failureMessage">错误原因</param>
        public static bool SubmitFailure(string wayBillNumber, string failureMessage)
        {
            Log.Info("运单号{0}提交顺丰失败,原因:{1}".FormatWith(wayBillNumber, failureMessage));
            if (string.IsNullOrWhiteSpace(wayBillNumber))
            {
                return(false);
            }
            DbUtility dbUtility = new SqlDbUtility(_lmsCon);
            var       obj       = dbUtility.ExecuteScalar("exec P_CreateNlPostAbnormalWayBill {0},{1}", wayBillNumber, failureMessage);

            return(obj.ToString() == "1");
        }
 /// <summary>
 /// 获取批次号
 /// </summary>
 /// <returns></returns>
 public static string GetSequenceNumber()
 {
     try
     {
         DbUtility dbUtility = new SqlDbUtility(_lmsCon);
         object    obj       = dbUtility.ExecuteScalar("exec P_CreateSequenceNumber N'EU',N'1'");
         if (obj != null)
         {
             return(obj.ToString());
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
     return(string.Empty);
 }
Esempio n. 6
0
        /// <summary>
        /// 插入内部跟踪信息
        /// </summary>
        /// <param name="model"></param>
        public static bool InsertInTrackingLogInfo(TotalPackageTraceInfoModel model, string shippingMethodConfig)
        {
            var result = false;

            Log.Info("LMS开始插入总包号为:{0} 的内部信息".FormatWith(model.TotalPackageNumber));
            DbUtility dbUtility = new SqlDbUtility(_lmsCon);
            var       obj       = dbUtility.ExecuteScalar("exec P_TotalPackageNumberJob {0},{1}", model.ID, shippingMethodConfig);

            if (obj != null && obj.ToString() == "1")
            {
                dbUtility.ExecuteNonQuery(
                    "UPDATE TotalPackageTraceInfos SET IsJob=1,LastUpdatedOn=GETDATE() WHERE ID={0}", model.ID);
                result = true;
            }
            Log.Info("LMS完成插入总包号为:{0} 的内部信息".FormatWith(model.TotalPackageNumber));

            return(result);
        }
Esempio n. 7
0
        /// <summary>
        /// 提交顺E宝成功
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool SubmitSuccess(SfOrderResponse model)
        {
            Log.Info("运单号{0},提交顺E宝成功".FormatWith(model.OrderId));
            if (model == null)
            {
                return(false);
            }
            if (model.OrderId.IsNullOrWhiteSpace())
            {
                return(false);
            }
            DbUtility dbUtility = new SqlDbUtility(_lmsCon);
            var       obj       = dbUtility.ExecuteScalar("exec P_CreateLithuaniaSuccessWayBill {0},{1},{2},{3},{4},{5},{6},{7},{8},{9}",
                                                          model.OrderId, _LithuaniaVenderCode, model.MailNo, model.OriginCode ?? "", model.DestCode ?? "",
                                                          model.AgentMailNo ?? "", model.Remark ?? "", 2, model.FilterResult ?? "", model.TrackNumber ?? "");

            return(obj.ToString() == "1");
        }
        /// <summary>
        /// 提交顺丰成功
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool SubmitSuccess(NetherlandsParcelModel model)
        {
            Log.Info("运单号{0},提交顺丰成功".FormatWith(model.WayBillNumber));
            if (model == null)
            {
                return(false);
            }
            if (model.WayBillNumber.IsNullOrWhiteSpace())
            {
                return(false);
            }
            model.Status = 2;
            DbUtility dbUtility = new SqlDbUtility(_lmsCon);
            var       obj       = dbUtility.ExecuteScalar("exec P_CreateNlPostSuccessWayBill {0},{1},{2},{3},{4},{5},{6},{7},{8}",
                                                          model.WayBillNumber, Int32.Parse(_NLPOSTShippingMethodID), _NLPOSTVenderCode, model.MailNo, model.OriginCode ?? "", model.DestCode ?? "",
                                                          model.AgentMailNo, model.Remark ?? "", model.Status);

            return(obj.ToString() == "1");
        }
        /// <summary>
        /// 插入客户资金记录表
        /// </summary>
        /// <param name="bill"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public static bool CreateCustomerAmountRecords(ReceivingBill bill, List <BillModel> list)
        {
            var result = false;

            Log.Info("LMS开始插入客户资金记录客户为:{1},账单号为:{0}".FormatWith(bill.ReceivingBillID, bill.CustomerCode));
            try
            {
                DbUtility dbUtility = new SqlDbUtility(_lmsCon);
                using (var transaction = new TransactionScope())
                {
                    list.ForEach(p =>
                    {
                        object obj;
                        if (p.Freight > 0)
                        {
                            obj =
                                dbUtility.ExecuteScalar(
                                    "Exec P_JobCustomerAmountRecord {0},{1},{2},{3},{4},{5},{6},{7}",
                                    bill.CustomerCode,
                                    p.WayBillNumber, p.InStorageID, 2, 3, p.Freight,
                                    "运单号:{0}扣运费".FormatWith(p.WayBillNumber), "system");
                            if (obj.ToString() != "1")
                            {
                                throw new ArgumentException("该运单号\"{0}\"生成运费扣费记录失败!".FormatWith(p.WayBillNumber));
                            }
                        }
                        else if (p.Freight < 0)
                        {
                            obj =
                                dbUtility.ExecuteScalar(
                                    "Exec P_JobCustomerAmountRecord {0},{1},{2},{3},{4},{5},{6},{7}",
                                    bill.CustomerCode,
                                    p.WayBillNumber, p.InStorageID, 3, 3, p.Freight * -1,
                                    "运单号:{0}退运费".FormatWith(p.WayBillNumber), "system");
                            if (obj.ToString() != "1")
                            {
                                throw new ArgumentException("该运单号\"{0}\"生成运费退费记录失败!".FormatWith(p.WayBillNumber));
                            }
                        }
                        if (p.Register > 0)
                        {
                            obj =
                                dbUtility.ExecuteScalar(
                                    "Exec P_JobCustomerAmountRecord {0},{1},{2},{3},{4},{5},{6},{7}",
                                    bill.CustomerCode,
                                    p.WayBillNumber, p.InStorageID, 2, 4, p.Register,
                                    "运单号:{0}扣挂号费".FormatWith(p.WayBillNumber), "system");
                            if (obj.ToString() != "1")
                            {
                                throw new ArgumentException("该运单号\"{0}\"生成挂号费扣费记录失败!".FormatWith(p.WayBillNumber));
                            }
                        }
                        else if (p.Register < 0)
                        {
                            obj =
                                dbUtility.ExecuteScalar(
                                    "Exec P_JobCustomerAmountRecord {0},{1},{2},{3},{4},{5},{6},{7}",
                                    bill.CustomerCode,
                                    p.WayBillNumber, p.InStorageID, 3, 4, p.Register * -1,
                                    "运单号:{0}退挂号费".FormatWith(p.WayBillNumber), "system");
                            if (obj.ToString() != "1")
                            {
                                throw new ArgumentException("该运单号\"{0}\"生成挂号费退费记录失败!".FormatWith(p.WayBillNumber));
                            }
                        }
                        if (p.FuelCharge > 0)
                        {
                            obj =
                                dbUtility.ExecuteScalar(
                                    "Exec P_JobCustomerAmountRecord {0},{1},{2},{3},{4},{5},{6},{7}",
                                    bill.CustomerCode,
                                    p.WayBillNumber, p.InStorageID, 2, 5, p.FuelCharge,
                                    "运单号:{0}扣燃油费".FormatWith(p.WayBillNumber), "system");
                            if (obj.ToString() != "1")
                            {
                                throw new ArgumentException("该运单号\"{0}\"生成燃油费扣费记录失败!".FormatWith(p.WayBillNumber));
                            }
                        }
                        else if (p.FuelCharge < 0)
                        {
                            obj =
                                dbUtility.ExecuteScalar(
                                    "Exec P_JobCustomerAmountRecord {0},{1},{2},{3},{4},{5},{6},{7}",
                                    bill.CustomerCode,
                                    p.WayBillNumber, p.InStorageID, 3, 5, p.FuelCharge * -1,
                                    "运单号:{0}退燃油费".FormatWith(p.WayBillNumber), "system");
                            if (obj.ToString() != "1")
                            {
                                throw new ArgumentException("该运单号\"{0}\"生成燃油费退费记录失败!".FormatWith(p.WayBillNumber));
                            }
                        }
                        if (p.Surcharge + p.SpecialFee > 0)
                        {
                            obj =
                                dbUtility.ExecuteScalar(
                                    "Exec P_JobCustomerAmountRecord {0},{1},{2},{3},{4},{5},{6},{7}",
                                    bill.CustomerCode,
                                    p.WayBillNumber, p.InStorageID, 2, 2, p.Surcharge + p.SpecialFee,
                                    "运单号:{0}扣附加费".FormatWith(p.WayBillNumber), "system");
                            if (obj.ToString() != "1")
                            {
                                throw new ArgumentException("该运单号\"{0}\"生成附加费扣费记录失败!".FormatWith(p.WayBillNumber));
                            }
                        }
                        else if (p.Surcharge + p.SpecialFee < 0)
                        {
                            obj =
                                dbUtility.ExecuteScalar(
                                    "Exec P_JobCustomerAmountRecord {0},{1},{2},{3},{4},{5},{6},{7}",
                                    bill.CustomerCode,
                                    p.WayBillNumber, p.InStorageID, 3, 2, (p.Surcharge + p.SpecialFee) * -1,
                                    "运单号:{0}退附加费".FormatWith(p.WayBillNumber), "system");
                            if (obj.ToString() != "1")
                            {
                                throw new ArgumentException("该运单号\"{0}\"生成附加费退费记录失败!".FormatWith(p.WayBillNumber));
                            }
                        }
                        if (p.TariffPrepayFee > 0)
                        {
                            obj =
                                dbUtility.ExecuteScalar(
                                    "Exec P_JobCustomerAmountRecord {0},{1},{2},{3},{4},{5},{6},{7}",
                                    bill.CustomerCode,
                                    p.WayBillNumber, p.InStorageID, 2, 6, p.TariffPrepayFee,
                                    "运单号:{0}扣关税预付服务费".FormatWith(p.WayBillNumber), "system");
                            if (obj.ToString() != "1")
                            {
                                throw new ArgumentException("该运单号\"{0}\"生成关税预付服务费扣费记录失败!".FormatWith(p.WayBillNumber));
                            }
                        }
                        else if (p.TariffPrepayFee < 0)
                        {
                            obj =
                                dbUtility.ExecuteScalar(
                                    "Exec P_JobCustomerAmountRecord {0},{1},{2},{3},{4},{5},{6},{7}",
                                    bill.CustomerCode,
                                    p.WayBillNumber, p.InStorageID, 3, 6, p.TariffPrepayFee * -1,
                                    "运单号:{0}退关税预付服务费".FormatWith(p.WayBillNumber), "system");
                            if (obj.ToString() != "1")
                            {
                                throw new ArgumentException("该运单号\"{0}\"生成关税预付服务费退费记录失败!".FormatWith(p.WayBillNumber));
                            }
                        }
                        if (p.RemoteAreaFee > 0)
                        {
                            obj =
                                dbUtility.ExecuteScalar(
                                    "Exec P_JobCustomerAmountRecord {0},{1},{2},{3},{4},{5},{6},{7}",
                                    bill.CustomerCode,
                                    p.WayBillNumber, p.InStorageID, 2, 12, p.RemoteAreaFee,
                                    "运单号:{0}扣偏远附加服务费".FormatWith(p.WayBillNumber), "system");
                            if (obj.ToString() != "1")
                            {
                                throw new ArgumentException("该运单号\"{0}\"生成偏远附加服务费扣费记录失败!".FormatWith(p.WayBillNumber));
                            }
                        }
                        else if (p.RemoteAreaFee < 0)
                        {
                            obj =
                                dbUtility.ExecuteScalar(
                                    "Exec P_JobCustomerAmountRecord {0},{1},{2},{3},{4},{5},{6},{7}",
                                    bill.CustomerCode,
                                    p.WayBillNumber, p.InStorageID, 3, 12, p.RemoteAreaFee * -1,
                                    "运单号:{0}退偏远附加服务费".FormatWith(p.WayBillNumber), "system");
                            if (obj.ToString() != "1")
                            {
                                throw new ArgumentException("该运单号\"{0}\"生成偏远附加服务费退费记录失败!".FormatWith(p.WayBillNumber));
                            }
                        }
                        //if (p.SpecialFee <= 0) return;
                        //obj =
                        //    dbUtility.ExecuteScalar(
                        //        "Exec P_JobCustomerAmountRecord {0},{1},{2},{3},{4},{5},{6},{7}",
                        //        bill.CustomerCode,
                        //        p.WayBillNumber, p.InStorageID, 2, 7, p.SpecialFee,
                        //        "运单号:{0}扣特殊费".FormatWith(p.WayBillNumber), "system");
                        //if (obj.ToString() != "1")
                        //{
                        //    throw new ArgumentException("该运单号\"{0}\"生成特殊费扣费记录失败!".FormatWith(p.WayBillNumber));
                        //}
                    });
                    dbUtility.ExecuteNonQuery("update ReceivingBills set Search=100  where ReceivingBillID='" +
                                              bill.ReceivingBillID + "' and Status=1");//限制重复扣费
                    transaction.Complete();
                }
                result = true;
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
            Log.Info("LMS完成插入客户资金记录客户为:{1},账单号为:{0}".FormatWith(bill.ReceivingBillID, bill.CustomerCode));
            return(result);
        }
Esempio n. 10
0
        /// <summary>
        /// 获取配置
        /// </summary>
        /// <returns></returns>
        public static Dictionary <int, List <ShippingMethodConfig> > GetShippingMethodConfig(List <ShippingMethodModel> list)
        {
            var dictionary = new Dictionary <int, List <ShippingMethodConfig> >();

            //var list = GetShippingMethodsByIds();
            if (list.Any())
            {
                DbUtility dbUtility = new SqlDbUtility(_lmsCon);
                var       obj       =
                    dbUtility.ExecuteScalar("select ConfigurationValue from SystemConfigurations where ConfigurationKey='" +
                                            _EUDD + "'");
                if (obj != null)
                {
                    TextReader tr   = new StringReader(obj.ToString());
                    var        xml  = XDocument.Load(tr);
                    var        text = from t in xml.Descendants("ShippingMethod")
                                      select new
                    {
                        ShippingMethodCode = t.Element("ShippingMethodCode").Value,
                        Events             = t.Elements("Event").ToList()
                    };
                    if (text.Any())
                    {
                        foreach (var s in text)
                        {
                            if (s.Events.Any())
                            {
                                var shippingmentod = list.SingleOrDefault(p => p.Code == s.ShippingMethodCode);
                                if (shippingmentod != null && shippingmentod.ShippingMethodId > 0)
                                {
                                    foreach (var x in s.Events)
                                    {
                                        int eventCode = Int32.Parse(x.Element("EventCode").Value);
                                        var config    = new List <ShippingMethodConfig>();
                                        var element   = x.Elements().Where(e => e.Attributes().Any(p => p.Name == "CountryCode"));
                                        if (element.Any())
                                        {
                                            var a = element.Select(e => e.Attribute("CountryCode").Value).Distinct();
                                            config.AddRange(a.Select(c => new ShippingMethodConfig()
                                            {
                                                CountryCode      = c,
                                                EventContent     = element.SingleOrDefault(e => e.Attribute("CountryCode").Value == c && e.Name == "EventContent").Value,
                                                ShippingMethodId = shippingmentod.ShippingMethodId,
                                                Address          = element.SingleOrDefault(e => e.Attribute("CountryCode").Value == c && e.Name == "EventAddress").Value,
                                                OffsetHours      = Int32.Parse(element.SingleOrDefault(e => e.Attribute("CountryCode").Value == c && e.Name == "EventAddress").Attribute("OffsetHours").Value),
                                                AddHours         = Int32.Parse(element.SingleOrDefault(e => e.Attribute("CountryCode").Value == c && e.Name == "EventAddress").Attribute("AddHours").Value)
                                            }));
                                        }
                                        var other = x.Elements().Where(e => e.Attributes().All(p => p.Name != "CountryCode") && e.Name != "EventCode");
                                        config.Add(new ShippingMethodConfig()
                                        {
                                            CountryCode      = "Other",
                                            EventContent     = other.SingleOrDefault(e => e.Name == "EventContent").Value,
                                            ShippingMethodId = shippingmentod.ShippingMethodId,
                                            Address          = other.SingleOrDefault(e => e.Name == "EventAddress").Value,
                                            OffsetHours      = Int32.Parse(other.SingleOrDefault(e => e.Name == "EventAddress").Attribute("OffsetHours").Value),
                                            AddHours         = Int32.Parse(other.SingleOrDefault(e => e.Name == "EventAddress").Attribute("AddHours") != null?other.SingleOrDefault(e => e.Name == "EventAddress").Attribute("AddHours").Value:"0")
                                        });
                                        if (dictionary.ContainsKey(eventCode))
                                        {
                                            dictionary[eventCode].AddRange(config);
                                        }
                                        else
                                        {
                                            dictionary.Add(eventCode, config);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(dictionary);
        }
Esempio n. 11
0
        /// <summary>
        /// 更新运单操作
        /// </summary>
        /// <param name="priceResult"></param>
        /// <param name="wayBillNumber"></param>
        /// <returns></returns>
        public static bool UpdatePriceWayBill(PriceProviderResult priceResult, string wayBillNumber)
        {
            Log.Info(string.Format("开始更新运单号为:{0}的运费成本价!", wayBillNumber));
            bool result = false;

            if (priceResult.CanShipping)
            {
                try
                {
                    DbUtility dbUtility = new SqlDbUtility(_lmsCon);
                    decimal   suttle    = 0;
                    if (decimal.TryParse(
                            dbUtility.ExecuteScalar(
                                @"SELECT SUM(Weight) FROM WaybillPackageDetails WHERE WayBillNumber={0}", wayBillNumber)
                            .ToString(), out suttle))
                    {
                        if (suttle == 0)
                        {
                            Log.Error("运单号:{0},包裹明细净重量和为0".FormatWith(wayBillNumber));
                            return(false);
                        }
                        else
                        {
                            if (suttle > priceResult.Weight)
                            {
                                UpdateJobErrorLog(wayBillNumber, string.Format("运单号:{0},运费计算中心接口计算发货结算重量和是{1}小于包裹明细净重量和为{2}", wayBillNumber, priceResult.Weight, suttle) + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + Environment.NewLine);
                                Log.Error("运单号:{0},运费计算中心接口计算发货结算重量和是{1}小于包裹明细净重量和为{2}".FormatWith(wayBillNumber, priceResult.Weight, suttle));
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        Log.Error("运单号:{0},获取包裹明细净重量和失败!".FormatWith(wayBillNumber));
                        return(false);
                    }
                    var sb = new StringBuilder();
                    priceResult.PackageDetails.ForEach(p =>
                    {
                        sb.Append("<PackageDetails>");
                        sb.Append("<Length>{0}</Length>".FormatWith(p.Length));
                        sb.Append("<SettleWeight>{0}</SettleWeight>".FormatWith(p.SettleWeight));
                        sb.Append("<Width>{0}</Width>".FormatWith(p.Width));
                        sb.Append("<Height>{0}</Height>".FormatWith(p.Height));
                        sb.Append("<Weight>{0}</Weight>".FormatWith(p.Weight));
                        //sb.Append("<LengthFee>{0}</LengthFee>".FormatWith(p.OverGirthFee));
                        //sb.Append("<WeightFee>{0}</WeightFee>".FormatWith(p.OverWeightOrLengthFee));
                        sb.Append("</PackageDetails>");
                    });
                    string obj = dbUtility.ExecuteScalar(
                        "exec P_UpdateOutStoragePriceAll {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17}",
                        wayBillNumber,
                        priceResult.VenderId ?? 0, priceResult.VenderCode ?? "", priceResult.VenderName ?? "",
                        priceResult.ShippingMethodId ?? 0,
                        priceResult.ShippingMethodName ?? "", priceResult.Weight, priceResult.ShippingFee,
                        priceResult.RemoteAreaFee,
                        priceResult.RegistrationFee, priceResult.FuelFee, priceResult.OtherFee + priceResult.HandlingFee,
                        priceResult.Message ?? "", priceResult.TariffPrepayFee, priceResult.SecurityAppendFee,
                        priceResult.OverWeightOrLengthFee + priceResult.OverGirthFee, priceResult.AddedTaxFee, sb.ToString())
                                 .ToString();
                    result = obj == "1";
                    if (result)
                    {
                        UpdateJobErrorLog(wayBillNumber, null);
                    }
                    Log.Info(string.Format("完成更新运单号为:{0}的运费成本价!", wayBillNumber));
                }
                catch (Exception ex)
                {
                    Log.Exception(ex);
                }
            }
            else
            {
                UpdateJobErrorLog(wayBillNumber, priceResult.Message + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + Environment.NewLine);
                Log.Error("运单号:{0},错误:{1}".FormatWith(wayBillNumber, priceResult.Message));
            }
            return(result);
        }
Esempio n. 12
0
        /// <summary>
        /// 更新费用
        /// </summary>
        /// <param name="priceResult"></param>
        /// <param name="wayBillNumber"></param>
        /// <returns></returns>
        public static bool UpdatePriceWayBill(PriceProviderResult priceResult, string wayBillNumber, int receivingExpenseId)
        {
            Log.Info(string.Format("开始更新运单号为:{0}的运费!", wayBillNumber));
            bool result = false;

            try
            {
                if (priceResult.CanShipping)
                {
                    if (priceResult.Weight <= 0)
                    {
                        UpdateJobErrorLog(wayBillNumber, string.Format("运单号:{0},运费计算中心接口计算结算重量为0", wayBillNumber) + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + Environment.NewLine);
                        Log.Error("运单号:{0},运费计算中心接口计算结算重量为0".FormatWith(wayBillNumber));
                        return(false);
                    }

                    DbUtility dbUtility = new SqlDbUtility(_lmsCon);
                    decimal   suttle    = 0;
                    if (decimal.TryParse(
                            dbUtility.ExecuteScalar(
                                @"SELECT SUM(Weight) FROM WaybillPackageDetails WHERE WayBillNumber={0}", wayBillNumber)
                            .ToString(), out suttle))
                    {
                        if (suttle == 0)
                        {
                            Log.Error("运单号:{0},包裹明细净重量和为0".FormatWith(wayBillNumber));
                            return(false);
                        }
                        else
                        {
                            if (suttle > priceResult.Weight)
                            {
                                UpdateJobErrorLog(wayBillNumber, string.Format("运单号:{0},运费计算中心接口计算结算重量和是{1}小于包裹明细净重量和为{2}", wayBillNumber, priceResult.Weight, suttle) + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + Environment.NewLine);
                                Log.Error("运单号:{0},运费计算中心接口计算结算重量和是{1}小于包裹明细净重量和为{2}".FormatWith(wayBillNumber, priceResult.Weight, suttle));
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        Log.Error("运单号:{0},获取包裹明细净重量和失败!".FormatWith(wayBillNumber));
                        return(false);
                    }
                    var sb = new StringBuilder();
                    priceResult.PackageDetails.ForEach(p =>
                    {
                        sb.Append("<PackageDetails>");
                        sb.Append("<Length>{0}</Length>".FormatWith(p.Length));
                        sb.Append("<SettleWeight>{0}</SettleWeight>".FormatWith(p.SettleWeight));
                        sb.Append("<Width>{0}</Width>".FormatWith(p.Width));
                        sb.Append("<Height>{0}</Height>".FormatWith(p.Height));
                        sb.Append("<Weight>{0}</Weight>".FormatWith(p.Weight));
                        sb.Append("<LengthFee>{0}</LengthFee>".FormatWith(p.OverGirthFee));
                        sb.Append("<WeightFee>{0}</WeightFee>".FormatWith(p.OverWeightOrLengthFee));
                        sb.Append("</PackageDetails>");
                    });
                    string obj = dbUtility.ExecuteScalar(
                        "exec P_UpdateReceivingFreight {0},{1},{2},{3},{4},{5},{6},{7},{8},{9}",
                        wayBillNumber, receivingExpenseId, priceResult.Weight, priceResult.ShippingFee,
                        priceResult.RemoteAreaFee, priceResult.RegistrationFee, priceResult.FuelFee,
                        priceResult.Value - priceResult.ShippingFee - priceResult.RemoteAreaFee - priceResult.RegistrationFee - priceResult.FuelFee - priceResult.TariffPrepayFee,//其他费用把总费用减去已知费用
                        priceResult.TariffPrepayFee, sb.ToString()).ToString();
                    result = obj == "1";
                    if (obj == "2")
                    {
                        Log.Error("运单号:{0}运费已经更新!".FormatWith(wayBillNumber));
                    }
                    if (result)
                    {
                        UpdateJobErrorLog(wayBillNumber, null);
                    }
                    Log.Info(string.Format("完成更新运单号为:{0}的运费!", wayBillNumber));
                }
                else
                {
                    UpdateJobErrorLog(wayBillNumber, priceResult.Message + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + Environment.NewLine);
                    Log.Error("运单号:{0}获取运费失败,错误:{1}".FormatWith(wayBillNumber, priceResult.Message));
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
            return(result);
        }