From 526a096ca030b555fc16f681d66bf1af7c26d011 Mon Sep 17 00:00:00 2001 From: jianweie Date: Mon, 3 Apr 2023 17:34:16 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=B8=8D=E5=90=8C=E5=9C=B0=E5=8C=BA=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E4=BB=B7=E6=A0=BC=E9=85=8D=E9=80=81=E8=B4=B9?= =?UTF-8?q?=E7=94=A8=E5=A4=B1=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Shop/ICoreCmsShipServices.cs | 6 ++-- .../Shop/CoreCmsShipServices.cs | 32 ++++++++++--------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/CoreCms.Net.IServices/Shop/ICoreCmsShipServices.cs b/CoreCms.Net.IServices/Shop/ICoreCmsShipServices.cs index a273303a..987bbfda 100644 --- a/CoreCms.Net.IServices/Shop/ICoreCmsShipServices.cs +++ b/CoreCms.Net.IServices/Shop/ICoreCmsShipServices.cs @@ -68,9 +68,11 @@ namespace CoreCms.Net.IServices /// 配送方式内容 /// 订单总重 /// 商品总价 - /// + /// 单独地区首重 + /// 单独地区续重 + /// 是否在地区内 /// - decimal calculate_fee(CoreCmsShip ship, decimal weight, decimal totalmoney = 0, decimal firstunitAreaPrice = 0); + decimal calculate_fee(CoreCmsShip ship, decimal weight, decimal totalmoney = 0, decimal firstunitAreaPrice = 0, decimal continueunitAreaPrice = 0, bool isInChild = false); /// /// 根据地区获取配送方式 diff --git a/CoreCms.Net.Services/Shop/CoreCmsShipServices.cs b/CoreCms.Net.Services/Shop/CoreCmsShipServices.cs index 47bc27ba..11962bca 100644 --- a/CoreCms.Net.Services/Shop/CoreCmsShipServices.cs +++ b/CoreCms.Net.Services/Shop/CoreCmsShipServices.cs @@ -123,8 +123,8 @@ namespace CoreCms.Net.Services var idStr = areaId.ToString(); //先判断是否子地区满足条件 var def = await _dal.QueryByClauseAsync(p => - p.status == (int)GlobalEnumVars.ShipStatus.Yes && - p.areaType == (int)GlobalEnumVars.ShipAreaType.Part && p.areaFee.Contains(idStr)); + p.status == (int)GlobalEnumVars.ShipStatus.Yes && + p.areaType == (int)GlobalEnumVars.ShipAreaType.Part && p.areaFee.Contains(idStr)); //没有子地区取默认 if (def == null) { @@ -157,13 +157,14 @@ namespace CoreCms.Net.Services //if (item.Property("area") == null) continue; var area = item["area"].ObjectToString(); var firstunitAreaPrice = item["firstunitAreaPrice"].ObjectToInt(0); + var continueunitAreaPrice = item["continueunitAreaPrice"].ObjectToInt(0); if (!string.IsNullOrEmpty(area)) { var areaArr = CommonHelper.StringToIntArray(area); if (areaArr.Contains(areaId)) { isIn = true; - var total = calculate_fee(def, weight, totalmoney, firstunitAreaPrice); + var total = calculate_fee(def, weight, totalmoney, firstunitAreaPrice, continueunitAreaPrice, true); postfee = Math.Round(total, 2); break; } @@ -195,9 +196,11 @@ namespace CoreCms.Net.Services /// 配送方式内容 /// 订单总重 /// 商品总价 - /// + /// 单独地区首重 + /// 单独地区续重 + /// 是否在地区内 /// - public decimal calculate_fee(CoreCmsShip ship, decimal weight, decimal totalmoney = 0, decimal firstunitAreaPrice = 0) + public decimal calculate_fee(CoreCmsShip ship, decimal weight, decimal totalmoney = 0, decimal firstunitAreaPrice = 0, decimal continueunitAreaPrice = 0, bool isInChild = false) { //满多少免运费 if (ship.goodsMoney > 0 && totalmoney >= ship.goodsMoney) @@ -205,22 +208,21 @@ namespace CoreCms.Net.Services return 0; } - if (weight > 0 && weight > ship.firstUnit) + if (isInChild) { - decimal shipMoney = ship.firstunitPrice + (Math.Ceiling(Math.Abs(weight - ship.firstUnit) / ship.continueUnit) * ship.continueunitPrice); + if (weight <= 0 || weight <= ship.firstUnit) return firstunitAreaPrice; + var shipMoney = firstunitAreaPrice + (Math.Ceiling(Math.Abs(weight - ship.firstUnit) / ship.continueUnit) * continueunitAreaPrice); return shipMoney; + } else { - if (ship.firstunitPrice > 0) - { - return ship.firstunitPrice; - } - else - { - return firstunitAreaPrice; - } + if (weight <= 0 || weight <= ship.firstUnit) return ship.firstunitPrice; + var shipMoney = ship.firstunitPrice + (Math.Ceiling(Math.Abs(weight - ship.firstUnit) / ship.continueUnit) * ship.continueunitPrice); + return shipMoney; } + + } ///