Esempio n. 1
0
        /// <summary>
        /// 获取出服务商价格(成本价)
        /// </summary>
        /// <param name="package"></param>
        /// <returns></returns>
        private PriceProviderResult PostVenderPrice(VenderPackageModel package)
        {
            var result = new PriceProviderResult();

            try
            {
                var list = HttpHelper.DoRequest <PriceProviderResult>(MyConfig.PostVenderPriceUrl, EnumHttpMethod.POST, EnumContentType.Json, package);
                result = list.Value;
                Log.Info(list.RawValue);
            }
            catch (Exception ex)
            {
                result.CanShipping = false;
                result.Message     = ex.Message;
            }
            return(result);
        }
        public static PriceProviderResult GetFreightPrice(WayBillImportModel model)
        {
            var result = new PriceProviderResult();

            try
            {
                var list = HttpHelper.DoRequest <PriceProviderResult>(_baseLISUrl + "API/LIS/PostCustomerPriceAuto",
                                                                      EnumHttpMethod.POST, EnumContentType.Json, model);
                result = list.Value;
                Log.Info(list.RawValue);
            }
            catch (Exception ex)
            {
                Log.Error("错误地址:" + _baseLISUrl + "API/LIS/PostCustomerPriceAuto");
                Log.Exception(ex);
                result.CanShipping = false;
                result.Message     = "";
            }
            return(result);
        }
        /// <summary>
        /// 获取成本价
        /// </summary>
        /// <param name="package"></param>
        /// <returns></returns>
        public static PriceProviderResult PostVenderPrice(VenderInfoPackageRequest package)
        {
            var result = new PriceProviderResult();

            try
            {
                var list = HttpHelper.DoRequest <PriceProviderResult>(_baseLISUrl + "API/LIS/PostVenderPriceAuto",
                                                                      EnumHttpMethod.POST, EnumContentType.Json, package);
                result = list.Value;
                Log.Info(list.RawValue);
            }
            catch (Exception ex)
            {
                Log.Error("错误地址:" + _baseLISUrl + "API/LIS/PostVenderPriceAuto");
                Log.Exception(ex);
                result.CanShipping = false;
                result.Message     = "";
            }
            return(result);
        }
Esempio n. 4
0
        private PriceProviderResult PostVenderPrice(VenderPackageModel package)
        {
            var result = new PriceProviderResult();

            try
            {
                var list = HttpHelper.DoRequest <PriceProviderResult>(sysConfig.LISAPIPath + "API/LIS/PostVenderPrice",
                                                                      EnumHttpMethod.POST, EnumContentType.Json, package);
                result = list.Value;
                Log.Info(list.RawValue);
            }
            catch (Exception ex)
            {
                Log.Error("错误地址:" + sysConfig.LISAPIPath + "API/LIS/PostVenderPrice");
                Log.Exception(ex);
                result.CanShipping = false;
                result.Message     = ex.Message;
            }
            return(result);
        }
Esempio n. 5
0
        public void UpdateVenderPrice(string wayBillNumber, PriceProviderResult result)
        {
            if (result == null || !result.CanShipping)
            {
                return;
            }
            var venderLog = _venderFeeLogRepository.First(p => p.WayBillNumber == wayBillNumber);

            if (venderLog == null)
            {
                return;
            }
            venderLog.Freight      = result.ShippingFee;                     //运费
            venderLog.FuelCharge   = result.FuelFee;                         //燃油费
            venderLog.Register     = result.RegistrationFee;                 //挂号费
            venderLog.SettleWeight = result.Weight;
            venderLog.Surcharge    = result.RemoteAreaFee + result.OtherFee; //附加费
            venderLog.Remark       = "";
            _venderFeeLogRepository.Modify(venderLog);
            _venderFeeLogRepository.UnitOfWork.Commit();
        }
        /// <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);
        }
        /// <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);
        }