From 8b7377de63498873f09b9f800441f4a9461d6916 Mon Sep 17 00:00:00 2001 From: jianweie code Date: Mon, 3 Apr 2023 02:30:16 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E8=BF=90=E8=B4=B9=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=B8=BA=E5=BC=82=E6=AD=A5=E5=A4=84=E7=90=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cart/ICoreCmsCartServices.cs | 2 +- .../Shop/ICoreCmsShipServices.cs | 4 ++-- .../Cart/CoreCmsCartServices.cs | 8 +++++--- .../Order/CoreCmsOrderServices.cs | 2 +- .../Shop/CoreCmsShipServices.cs | 20 +++++++++---------- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/CoreCms.Net.IServices/Cart/ICoreCmsCartServices.cs b/CoreCms.Net.IServices/Cart/ICoreCmsCartServices.cs index 0bcae6a7..03020622 100644 --- a/CoreCms.Net.IServices/Cart/ICoreCmsCartServices.cs +++ b/CoreCms.Net.IServices/Cart/ICoreCmsCartServices.cs @@ -99,7 +99,7 @@ namespace CoreCms.Net.IServices /// 购物车信息 /// 收货地址id /// - bool CartFreight(CartDto cartDto, int areaId); + Task CartFreight(CartDto cartDto, int areaId); /// diff --git a/CoreCms.Net.IServices/Shop/ICoreCmsShipServices.cs b/CoreCms.Net.IServices/Shop/ICoreCmsShipServices.cs index ae53be69..a273303a 100644 --- a/CoreCms.Net.IServices/Shop/ICoreCmsShipServices.cs +++ b/CoreCms.Net.IServices/Shop/ICoreCmsShipServices.cs @@ -59,7 +59,7 @@ namespace CoreCms.Net.IServices /// 重量,单位g /// 商品总价 /// - decimal GetShipCost(int areaId = 0, decimal weight = 0, decimal totalmoney = 0); + Task GetShipCost(int areaId = 0, decimal weight = 0, decimal totalmoney = 0); /// @@ -75,7 +75,7 @@ namespace CoreCms.Net.IServices /// /// 根据地区获取配送方式 /// - CoreCmsShip GetShip(int areaId = 0); + Task GetShip(int areaId = 0); #region 重写增删改查操作=========================================================== diff --git a/CoreCms.Net.Services/Cart/CoreCmsCartServices.cs b/CoreCms.Net.Services/Cart/CoreCmsCartServices.cs index 32872763..d01ad429 100644 --- a/CoreCms.Net.Services/Cart/CoreCmsCartServices.cs +++ b/CoreCms.Net.Services/Cart/CoreCmsCartServices.cs @@ -600,7 +600,8 @@ namespace CoreCms.Net.Services else if (deliveryType == (int)GlobalEnumVars.OrderReceiptType.Logistics) { // 运费判断 - if (CartFreight(cartDto, areaId) == false) + var blFreight = await CartFreight(cartDto, areaId); + if (blFreight == false) { jm.data = cartDto; jm.msg = "运费判断"; @@ -665,17 +666,18 @@ namespace CoreCms.Net.Services #endregion #region 算运费 + /// /// 算运费 /// /// 购物车信息 /// 收货地址id /// - public bool CartFreight(CartDto cartDto, int areaId) + public async Task CartFreight(CartDto cartDto, int areaId) { if (areaId > 0) { - cartDto.costFreight = _shipServices.GetShipCost(areaId, cartDto.weight, cartDto.goodsAmount); + cartDto.costFreight =await _shipServices.GetShipCost(areaId, cartDto.weight, cartDto.goodsAmount); cartDto.amount = Math.Round(cartDto.amount + cartDto.costFreight, 2); } return true; diff --git a/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs b/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs index 32d5569d..0360ac87 100644 --- a/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs +++ b/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs @@ -583,7 +583,7 @@ namespace CoreCms.Net.Services order.shipName = userShipInfo.name; order.shipMobile = userShipInfo.mobile; - var ship = _shipServices.GetShip(userShipInfo.areaId); + var ship = await _shipServices.GetShip(userShipInfo.areaId); if (ship != null) { order.logisticsId = ship.id; diff --git a/CoreCms.Net.Services/Shop/CoreCmsShipServices.cs b/CoreCms.Net.Services/Shop/CoreCmsShipServices.cs index 8604f67c..47bc27ba 100644 --- a/CoreCms.Net.Services/Shop/CoreCmsShipServices.cs +++ b/CoreCms.Net.Services/Shop/CoreCmsShipServices.cs @@ -116,24 +116,24 @@ namespace CoreCms.Net.Services /// 重量,单位g /// 商品总价 /// - public decimal GetShipCost(int areaId = 0, decimal weight = 0, decimal totalmoney = 0) + public async Task GetShipCost(int areaId = 0, decimal weight = 0, decimal totalmoney = 0) { decimal postfee = 0; var idStr = areaId.ToString(); //先判断是否子地区满足条件 - var def = base.QueryByClause(p => - p.status == (int)GlobalEnumVars.ShipStatus.Yes && - p.areaType == (int)GlobalEnumVars.ShipAreaType.Part && p.areaFee.Contains(idStr)); + var def = await _dal.QueryByClauseAsync(p => + p.status == (int)GlobalEnumVars.ShipStatus.Yes && + p.areaType == (int)GlobalEnumVars.ShipAreaType.Part && p.areaFee.Contains(idStr)); //没有子地区取默认 if (def == null) { - def = base.QueryByClause(p => p.isDefault == true && p.status == (int)GlobalEnumVars.ShipStatus.Yes); + def = await _dal.QueryByClauseAsync(p => p.isDefault == true && p.status == (int)GlobalEnumVars.ShipStatus.Yes); } //没有默认取启用状态 if (def == null) { - def = base.QueryByClause(p => p.status == (int)GlobalEnumVars.ShipStatus.Yes); + def = await _dal.QueryByClauseAsync(p => p.status == (int)GlobalEnumVars.ShipStatus.Yes); if (def == null) {//没有配送方式,返回0 return postfee; @@ -226,22 +226,22 @@ namespace CoreCms.Net.Services /// /// 根据地区获取配送方式 /// - public CoreCmsShip GetShip(int areaId = 0) + public async Task GetShip(int areaId = 0) { var idStr = areaId.ToString(); //先判断是否子地区满足条件 - var def = base.QueryByClause(p => + var def = await _dal.QueryByClauseAsync(p => p.status == (int)GlobalEnumVars.ShipStatus.Yes && p.areaType == (int)GlobalEnumVars.ShipAreaType.Part && p.areaFee.Contains(idStr)); //没有子地区取默认 if (def == null) { - def = base.QueryByClause(p => p.isDefault == true && p.status == (int)GlobalEnumVars.ShipStatus.Yes); + def = await _dal.QueryByClauseAsync(p => p.isDefault == true && p.status == (int)GlobalEnumVars.ShipStatus.Yes); } //没有默认取启用状态 if (def == null) { - def = base.QueryByClause(p => p.status == (int)GlobalEnumVars.ShipStatus.Yes); + def = await _dal.QueryByClauseAsync(p => p.status == (int)GlobalEnumVars.ShipStatus.Yes); return def; } return def;