private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string           oid = this.tbOrderId.Text.Trim();
                DeliveryTemplate dt  = this.cbbDeliveryCompanies.SelectedItem as DeliveryTemplate;

                if (string.IsNullOrWhiteSpace(oid) || dt == null)
                {
                    throw new Exception("订单编号或者模板为空");
                }

                var order = ServiceContainer.GetService <OrderService>().GetById(long.Parse(oid));

                if (order == null)
                {
                    throw new Exception("订单不存在");
                }
                float money = ServiceContainer.GetService <DeliveryTemplateService>().ComputeDeliveryMoney(order.DeliveryCompany,
                                                                                                           order.ReceiverAddress, order.Type == OrderType.SHUA, order.PopPayType,
                                                                                                           order.Weight).data;
                MessageBox.Show(money.ToString("F2"));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        /// <summary>
        /// 添加运费模版
        /// </summary>
        /// <param name="template">模版</param>
        public static DeliveryIDEntity AddTemplate(DeliveryTemplate template, string accessToken)
        {
            var url = string.Format("https://api.weixin.qq.com/merchant/express/add?access_token={0}", accessToken);
            var obj = new { delivery_template = template };

            return(Utils.PostResult <DeliveryIDEntity>(obj, url));
        }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Button           btn = sender as Button;
                DeliveryTemplate vm  = btn.DataContext as DeliveryTemplate;

                if (MessageBox.Show("是否删除:" + vm.Name, "警告", MessageBoxButton.YesNo, MessageBoxImage.Warning) !=
                    MessageBoxResult.Yes)
                {
                    return;
                }

                if (MessageBox.Show("是否删除:" + vm.Name, "警告", MessageBoxButton.YesNo, MessageBoxImage.Warning) !=
                    MessageBoxResult.Yes)
                {
                    return;
                }
                ServiceContainer.GetService <DeliveryTemplateService>().Delete(vm.Id);
                var list = this.lstDeliveryTemplates.ItemsSource.OfType <DeliveryTemplate>().ToList();
                list.RemoveAll(obj => obj.Id == vm.Id);
                this.lstDeliveryTemplates.ItemsSource = null;
                this.lstDeliveryTemplates.ItemsSource = list;
                MessageBox.Show("删除成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public ActionResult AddTemplate(string id)
 {
     var ps = new DeliveryTemplateFreight();
     ps.kuaidi = new List<PostfareDetail>();
     ps.ziti=new List<PostfareDetail>();
     ps.shangjia = new List<PostfareDetail>();
     ps.FareFreeConditions = new List<FareFreeCondition>();
     ViewBag.Title = "新增运费模板";
     int templateid = 0;
     var model = new DeliveryTemplate();
     if (int.TryParse(id, out templateid))
     {
         ViewBag.Title = "修改运费模板";
         var r =
             YunClient.Instance.Execute(new GetExpressTemplateRequest
             {
                 Id = templateid
             }, Member.Token);
         model = r.Result;
         if (model.Freight.Any(e => e.DeliveryId == 4 && (e.Cities==null ||!e.Cities.Any())))
         {
             var m = model.Freight.First(e => e.DeliveryId == 4 && (e.Cities==null ||!e.Cities.Any()));
             ps.kuaidi1 = m.BaseQuantity.ToString();
             ps.kuaidi2 = m.BasePrice.ToString();
             ps.kuaidi3 = m.AddQuantity.ToString();
             ps.kuaidi4 = m.AddPrice.ToString();
         }
         foreach (var a in model.Freight.Where(e => e.DeliveryId == 4 && (e.Cities!=null &&e.Cities.Any())))
         {
             ps.kuaidi.Add(a);
         }
         if (model.Freight.Any(e => e.DeliveryId == 419 && (e.Cities == null || !e.Cities.Any())))
         {
             var m = model.Freight.First(e => e.DeliveryId == 419 && (e.Cities==null ||!e.Cities.Any()));
             ps.ziti1 = m.BaseQuantity.ToString();
             ps.ziti2 = m.BasePrice.ToString();
             ps.ziti3 = m.AddQuantity.ToString();
             ps.ziti4 = m.AddPrice.ToString();
         }
         foreach (var a in model.Freight.Where(e => e.DeliveryId == 419 && (e.Cities != null && e.Cities.Any())))
         {
             ps.ziti.Add(a);
         }
         if (model.Freight.Any(e => e.DeliveryId == 2 && (e.Cities == null || !e.Cities.Any()) ))
         {
             var m = model.Freight.First(e => e.DeliveryId == 2 && (e.Cities==null ||!e.Cities.Any()));
             ps.shangjia1 = m.BaseQuantity.ToString();
             ps.shangjia2 = m.BasePrice.ToString();
             ps.shangjia3 = m.AddQuantity.ToString();
             ps.shangjia4 = m.AddPrice.ToString();
         }
         foreach (var a in model.Freight.Where(e => e.DeliveryId == 2 && (e.Cities != null && e.Cities.Any())))
         {
             ps.shangjia.Add(a);
         }
     }
     ViewBag.Prices = ps;
     return View(model);
 }
Example #5
0
        /// <summary>
        /// 添加邮费模板
        /// </summary>
        /// <param name="delivery_template"></param>
        /// <param name="access_token"></param>

        /// <returns></returns>
        public static AddDeliveryTemplateResult AddDeliveryTemplate(DeliveryTemplate delivery_template, string access_token)
        {
            var url = "https://api.weixin.qq.com/merchant/express/add?access_token=";

            url = url + access_token;
            var json = Util.HttpPost2(url, Util.ToJson(new { delivery_template = delivery_template }));

            return(Util.JsonTo <AddDeliveryTemplateResult>(json));
        }
Example #6
0
        /// <summary>
        /// CountFeeByRegion
        /// </summary>
        /// <param name="express"></param>
        /// <param name="regionId"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        private decimal CountFeeByRegion(DeliveryTemplate express, long regionId, decimal value)
        {
            var regionTemplateFee = GetTemplateFeeByRegionId(express, regionId);

            if (regionTemplateFee != null)
            {
                return(CountFeeByWeight(regionTemplateFee, value));
            }
            return(-1);
        }
Example #7
0
        /// <summary>
        /// 删除邮费模板
        /// </summary>
        /// <param name="delivery_template"></param>
        /// <param name="access_token"></param>

        /// <returns></returns>
        public static ReturnCode UpdateDeliveryTemplate(DeliveryTemplate delivery_template, string access_token)
        {
            var template_id = delivery_template.Id;
            var url         = "https://api.weixin.qq.com/merchant/express/update?access_token=";

            url = url + access_token;
            var json = Util.HttpPost2(url, Util.ToJson(new { template_id = template_id, delivery_template = delivery_template }));

            return(Util.JsonTo <ReturnCode>(json));
        }
Example #8
0
        /// <summary>
        ///     通过模版名得到模版ID,如果通过模版名没有找到,者返回第一个模版ID
        ///     如果用户没有设置运费模版者返回NULL
        /// </summary>
        /// <param name="tempName"></param>
        /// <returns></returns>
        public string GetDeliveryTemplateId(string tempName)
        {
            List <DeliveryTemplate> deliveryTemplateList = GetDeliveryTemplates();

            if (deliveryTemplateList.IsNullOrEmpty())
            {
                return(null);
            }

            DeliveryTemplate dTmp = deliveryTemplateList.Find(f => f.Name == Resource.SysConfig_DeliveryTemplateName);

            return(dTmp.IsNotNull()
                       ? dTmp.TemplateId.ToString(CultureInfo.InvariantCulture)
                       : deliveryTemplateList[0].TemplateId.ToString(CultureInfo.InvariantCulture));
        }
Example #9
0
        /// <summary>
        ///     Gets the template fee by region identifier.
        ///     根据区域Id,返回快递模板
        /// </summary>
        /// <param name="expressTemplate"></param>
        /// <param name="regionId">The region identifier.</param>
        private RegionTemplateFee GetTemplateFeeByRegionId(DeliveryTemplate expressTemplate, long regionId)
        {
            // 遍历所有的物流模板,从第一个开始
            foreach (var feeItem in expressTemplate.TemplateFees) // 遍历所有的区域
            {
                foreach (var id in feeItem.RegionList)
                {
                    if (id == regionId)
                    {
                        return(feeItem);
                    }
                }
            }

            return(null);
        }
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var              window   = new DeliveryTemplateEditWindow();
         bool?            ret      = window.ShowDialog();
         DeliveryTemplate template = window.DeliveryTemplate;
         if (window.NeedUpdate && template.Id > 0)
         {
             var list = this.lstDeliveryTemplates.ItemsSource.OfType <DeliveryTemplate>().ToList();
             list.Add(template);
             this.lstDeliveryTemplates.ItemsSource = null;
             this.lstDeliveryTemplates.ItemsSource = list;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #11
0
        /// <summary>
        /// 运费模板
        /// </summary>
        internal List <DeliveryTemplate> DeliveryTemplates(string sessionKey)
        {
            ITopClient client = new DefaultTopClient(StaticSystemConfig.soft.ApiURL, StaticSystemConfig.soft.AppKey, StaticSystemConfig.soft.AppSecret, "json");
            DeliveryTemplatesGetRequest req = new DeliveryTemplatesGetRequest();

            req.Fields = "template_id,template_name,created,modified,supports,assumer,valuation,query_express,query_ems,query_cod,query_post";
            DeliveryTemplatesGetResponse           response = client.Execute(req, sessionKey);
            List <Top.Api.Domain.DeliveryTemplate> list     = new List <Top.Api.Domain.DeliveryTemplate>();

            list = response.DeliveryTemplates;
            List <DeliveryTemplate> result = new List <DeliveryTemplate>();

            foreach (Top.Api.Domain.DeliveryTemplate item in list)
            {
                DeliveryTemplate dt = new DeliveryTemplate();
                dt.Address       = item.Address;
                dt.Assumer       = item.Assumer;
                dt.ConsignAreaId = item.ConsignAreaId;
                dt.Created       = item.Created;
                dt.FeeList       = new List <TopFee>();
                foreach (Top.Api.Domain.TopFee child in item.FeeList)
                {
                    TopFee ft = new TopFee();
                    ft.AddFee        = child.AddFee;
                    ft.AddStandard   = child.AddStandard;
                    ft.Destination   = child.Destination;
                    ft.ServiceType   = child.ServiceType;
                    ft.StartFee      = child.ServiceType;
                    ft.StartStandard = child.StartStandard;
                    dt.FeeList.Add(ft);
                }
                dt.Modified   = item.Modified;
                dt.Name       = item.Name;
                dt.Supports   = item.Supports;
                dt.TemplateId = item.TemplateId;
                dt.Valuation  = item.Valuation;
                result.Add(dt);
            }
            return(result);
        }
 private void btnEdit_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Button           btn = sender as Button;
         DeliveryTemplate vm  = btn.DataContext as DeliveryTemplate;
         var window           = new DeliveryTemplateEditWindow {
             DeliveryTemplate = vm
         };
         bool?ret = window.ShowDialog();
         if (window.NeedUpdate)
         {
             var list = this.lstDeliveryTemplates.ItemsSource;
             this.lstDeliveryTemplates.ItemsSource = null;
             this.lstDeliveryTemplates.ItemsSource = list;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         if (this.DeliveryTemplate == null)
         {
             this.Title            = "新增运费模板";
             this.DeliveryTemplate = new DeliveryTemplate()
             {
                 Areas = new List <DeliveryTemplateArea>(), UpdateOperator = "", UpdateTime = DateTime.Now, CreateTime = DateTime.Now
             };
         }
         else
         {
             this.Title = "编辑运费模板";
         }
         this.DataContext = this.DeliveryTemplate;
         this.cbbDeliveryCompanies.DataContext = this.DeliveryTemplate;
         this.cbbDeliveryCompanies.ItemsSource = ServiceContainer.GetService <DeliveryCompanyService>().GetByAll().Datas.Select(obj => obj.Name).ToList();
         if (string.IsNullOrWhiteSpace(this.DeliveryTemplate.DeliveryCompany))
         {
             this.cbbDeliveryCompanies.SelectedIndex = 0;
         }
         else
         {
             this.cbbDeliveryCompanies.SelectedItem = this.DeliveryTemplate.DeliveryCompany;
         }
         foreach (var item in this.DeliveryTemplate.Areas)
         {
             this.templateAreas.Add(item);
         }
         this.dgvAreas.ItemsSource = this.templateAreas;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #14
0
        public ActionResult AddTemplate(string id)
        {
            ViewData["AllCitys"] = SystemCity.GetAdminClientCities();

            var ps = new DeliveryTemplateFreight
            {
                kuaidi             = new List <PostfareDetail>(),
                ziti               = new List <PostfareDetail>(),
                shangjia           = new List <PostfareDetail>(),
                FareFreeConditions = new List <FareFreeCondition>()
            };

            int templateid;
            var model = new DeliveryTemplate();

            if (int.TryParse(id, out templateid))
            {
                var r =
                    YunClient.Instance.Execute(new GetExpressTemplateRequest
                {
                    Id = templateid
                }, Token);

                model = r.Result;

                if (model.Freight.Any(e => e.DeliveryId == 4 && (e.Cities == null || !e.Cities.Any())))
                {
                    var m = model.Freight.First(e => e.DeliveryId == 4 && (e.Cities == null || !e.Cities.Any()));
                    ps.kuaidi1 = m.BaseQuantity.ToString();
                    ps.kuaidi2 = m.BasePrice.ToString();
                    ps.kuaidi3 = m.AddQuantity.ToString();
                    ps.kuaidi4 = m.AddPrice.ToString();
                }

                foreach (var a in model.Freight.Where(e => e.DeliveryId == 4 && (e.Cities != null && e.Cities.Any())))
                {
                    ps.kuaidi.Add(a);
                }

                if (model.Freight.Any(e => e.DeliveryId == 419 && (e.Cities == null || !e.Cities.Any())))
                {
                    var m = model.Freight.First(e => e.DeliveryId == 419 && (e.Cities == null || !e.Cities.Any()));
                    ps.ziti1 = m.BaseQuantity.ToString();
                    ps.ziti2 = m.BasePrice.ToString();
                    ps.ziti3 = m.AddQuantity.ToString();
                    ps.ziti4 = m.AddPrice.ToString();
                }

                foreach (var a in model.Freight.Where(e => e.DeliveryId == 419 && (e.Cities != null && e.Cities.Any())))
                {
                    ps.ziti.Add(a);
                }

                if (model.Freight.Any(e => e.DeliveryId == 2 && (e.Cities == null || !e.Cities.Any())))
                {
                    var m = model.Freight.First(e => e.DeliveryId == 2 && (e.Cities == null || !e.Cities.Any()));
                    ps.shangjia1 = m.BaseQuantity.ToString();
                    ps.shangjia2 = m.BasePrice.ToString();
                    ps.shangjia3 = m.AddQuantity.ToString();
                    ps.shangjia4 = m.AddPrice.ToString();
                }
                foreach (var a in model.Freight.Where(e => e.DeliveryId == 2 && (e.Cities != null && e.Cities.Any())))
                {
                    ps.shangjia.Add(a);
                }
            }

            ViewBag.Prices = ps;

            return(View(model));
        }
        /// <summary>
        /// 计算快递价格
        /// </summary>
        /// <param name="expressId"></param>
        /// <param name="quantity"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        public static double GetExpressPrice(int expressId, int quantity, string address,
            double totalPrice, double totalWeight, double totalVolume, DeliveryTemplate fareDetail)
        {
            if (fareDetail == null || expressId <= 0) return 0;

            //_log.Trace("物流模板已匹配");

            //直接包邮
            if (fareDetail.FareFree < 0)
            {
                return 0;
            }

            //如果有包邮政策,首先计算包邮条件
            if (fareDetail.FareFreeConditions != null && fareDetail.FareFreeConditions.Any())
            {
                //筛选出匹配的递送方式
                var suitFareFree = fareDetail.FareFreeConditions.Where(e => e.DeliveryId == expressId).ToList();

                //如果没有,则不需要进行包邮处理
                if (suitFareFree.Any())
                {
                    //筛选出合适的城市
                    FareFreeCondition suit = null;

                    foreach (var condition in suitFareFree)
                    {
                        if (suit != null)
                        {
                            break;
                        }

                        if (condition.Cities == null)
                        {
                            continue;
                        }

                        foreach (var c in condition.Cities)
                        {
                            //直辖市,直辖区的变更,特殊处理

                            if (
                                address.IndexOf(GetSuitCityName((int) c.Key, c.Value), System.StringComparison.Ordinal) >=
                                0)
                            {
                                suit = condition;
                                break;
                            }
                        }
                    }

                    //如果有的话,则进行价格和数量的核实
                    if (suit != null)
                    {
                        //满多少件包邮
                        if (suit.FreeType == 0)
                        {
                            //按重量或按体积,按件计费
                            if ((fareDetail.PriceType == 1 && suit.Preferential >= totalWeight) ||
                                (fareDetail.PriceType == 2 && suit.Preferential >= totalVolume) || (
                                    fareDetail.PriceType == 0 && suit.Preferential <= quantity))
                            {
                                return 0;
                            }
                        }

                        //满多少元包邮
                        if (suit.FreeType == 1 && suit.Price <= totalPrice)
                        {
                            return 0;
                        }

                        //满多少件并且多少元才包邮
                        if (suit.FreeType == 2 && suit.Price <= totalPrice &&
                            ((fareDetail.PriceType == 1 && suit.Preferential >= totalWeight) ||
                             (fareDetail.PriceType == 2 && suit.Preferential >= totalVolume) || (
                                 fareDetail.PriceType == 0 && suit.Preferential <= quantity)))
                        {
                            return 0;
                        }
                    }
                }
            }

            PostfareDetail suitExpress = null;

            //判断适配哪个城市
            foreach (
                var postfareDetail in
                    fareDetail.Freight.Where(e => e.DeliveryId == expressId && e.Cities != null && e.Cities.Any()))
            {
                if (suitExpress != null)
                {
                    break;
                }

                if (postfareDetail.Cities == null)
                {
                    continue;
                }

                foreach (var c in postfareDetail.Cities)
                {
                    if (address.IndexOf(GetSuitCityName((int) c.Key, c.Value), System.StringComparison.Ordinal) >= 0)
                    {
                        suitExpress = postfareDetail;
                        break;
                    }
                }
            }

            //如果没有匹配到合适的价格,则取默认价格
            if (suitExpress == null)
            {
                suitExpress = fareDetail.Freight.FirstOrDefault(e => e.Cities == null || !e.Cities.Any());
                if (suitExpress == null)
                {
                    return 0;
                }
            }


            //选择计价单位
            var lastQuantity = 0.0;
            switch (fareDetail.PriceType)
            {
                case 0:
                    lastQuantity = quantity;
                    break;
                case 1:
                    lastQuantity = totalWeight;
                    break;
                case 2:
                    lastQuantity = totalVolume;
                    break;
            }

            //根据数量和运费条件直接计算价格
            if (lastQuantity <= suitExpress.BaseQuantity)
            {
                return suitExpress.BasePrice;
            }

            //超过初始数量
            var canDivisible = Math.Abs((lastQuantity - suitExpress.BaseQuantity)%suitExpress.AddQuantity) < 0.01;

            return ((int) ((lastQuantity - suitExpress.BaseQuantity)/suitExpress.AddQuantity) +
                    (canDivisible ? 0 : 1))*
                   suitExpress.AddPrice +
                   suitExpress.BasePrice;
        }
Example #16
0
 /// <summary>
 /// 删除邮费模板
 /// </summary>
 /// <param name="delivery_template"></param>
 /// <returns></returns>
 public static ReturnCode UpdateDeliveryTemplate(DeliveryTemplate delivery_template)
 {
     WeiXin.CheckGlobalCredential();
     return(UpdateDeliveryTemplate(delivery_template, WeiXin.AppID, WeiXin.AppSecret));
 }
Example #17
0
 /// <summary>
 /// 添加邮费模板
 /// </summary>
 /// <param name="delivery_template"></param>
 /// <returns></returns>
 public static AddDeliveryTemplateResult AddDeliveryTemplate(DeliveryTemplate delivery_template)
 {
     WeiXin.CheckGlobalCredential();
     return(AddDeliveryTemplate(delivery_template, WeiXin.AppID, WeiXin.AppSecret));
 }
Example #18
0
        /// <summary>
        /// 计算快递价格
        /// </summary>
        /// <param name="expressId"></param>
        /// <param name="quantity"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        public static double GetExpressPrice(int expressId, int quantity, string address,
                                             double totalPrice, double totalWeight, double totalVolume, DeliveryTemplate fareDetail)
        {
            if (fareDetail == null || expressId <= 0)
            {
                return(0);
            }

            //_log.Trace("物流模板已匹配");

            //直接包邮
            if (fareDetail.FareFree < 0)
            {
                return(0);
            }

            //如果有包邮政策,首先计算包邮条件
            if (fareDetail.FareFreeConditions != null && fareDetail.FareFreeConditions.Any())
            {
                //筛选出匹配的递送方式
                var suitFareFree = fareDetail.FareFreeConditions.Where(e => e.DeliveryId == expressId).ToList();

                //如果没有,则不需要进行包邮处理
                if (suitFareFree.Any())
                {
                    //筛选出合适的城市
                    FareFreeCondition suit = null;

                    foreach (var condition in suitFareFree)
                    {
                        if (suit != null)
                        {
                            break;
                        }

                        if (condition.Cities == null)
                        {
                            continue;
                        }

                        foreach (var c in condition.Cities)
                        {
                            //直辖市,直辖区的变更,特殊处理

                            if (
                                address.IndexOf(GetSuitCityName((int)c.Key, c.Value), System.StringComparison.Ordinal) >=
                                0)
                            {
                                suit = condition;
                                break;
                            }
                        }
                    }

                    //如果有的话,则进行价格和数量的核实
                    if (suit != null)
                    {
                        //满多少件包邮
                        if (suit.FreeType == 0)
                        {
                            //按重量或按体积,按件计费
                            if ((fareDetail.PriceType == 1 && suit.Preferential >= totalWeight) ||
                                (fareDetail.PriceType == 2 && suit.Preferential >= totalVolume) || (
                                    fareDetail.PriceType == 0 && suit.Preferential <= quantity))
                            {
                                return(0);
                            }
                        }

                        //满多少元包邮
                        if (suit.FreeType == 1 && suit.Price <= totalPrice)
                        {
                            return(0);
                        }

                        //满多少件并且多少元才包邮
                        if (suit.FreeType == 2 && suit.Price <= totalPrice &&
                            ((fareDetail.PriceType == 1 && suit.Preferential >= totalWeight) ||
                             (fareDetail.PriceType == 2 && suit.Preferential >= totalVolume) || (
                                 fareDetail.PriceType == 0 && suit.Preferential <= quantity)))
                        {
                            return(0);
                        }
                    }
                }
            }

            PostfareDetail suitExpress = null;

            //判断适配哪个城市
            foreach (
                var postfareDetail in
                fareDetail.Freight.Where(e => e.DeliveryId == expressId && e.Cities != null && e.Cities.Any()))
            {
                if (suitExpress != null)
                {
                    break;
                }

                if (postfareDetail.Cities == null)
                {
                    continue;
                }

                foreach (var c in postfareDetail.Cities)
                {
                    if (address.IndexOf(GetSuitCityName((int)c.Key, c.Value), System.StringComparison.Ordinal) >= 0)
                    {
                        suitExpress = postfareDetail;
                        break;
                    }
                }
            }

            //如果没有匹配到合适的价格,则取默认价格
            if (suitExpress == null)
            {
                suitExpress = fareDetail.Freight.FirstOrDefault(e => e.Cities == null || !e.Cities.Any());
                if (suitExpress == null)
                {
                    return(0);
                }
            }


            //选择计价单位
            var lastQuantity = 0.0;

            switch (fareDetail.PriceType)
            {
            case 0:
                lastQuantity = quantity;
                break;

            case 1:
                lastQuantity = totalWeight;
                break;

            case 2:
                lastQuantity = totalVolume;
                break;
            }

            //根据数量和运费条件直接计算价格
            if (lastQuantity <= suitExpress.BaseQuantity)
            {
                return(suitExpress.BasePrice);
            }

            //超过初始数量
            var canDivisible = Math.Abs((lastQuantity - suitExpress.BaseQuantity) % suitExpress.AddQuantity) < 0.01;

            return(((int)((lastQuantity - suitExpress.BaseQuantity) / suitExpress.AddQuantity) +
                    (canDivisible ? 0 : 1)) *
                   suitExpress.AddPrice +
                   suitExpress.BasePrice);
        }