From 9db3e29aec3ee3be0a204a48a0d30ad18d150f7c Mon Sep 17 00:00:00 2001 From: jianweie code Date: Thu, 13 Jun 2024 14:20:49 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=95=86=E5=93=81=E4=BF=AE=E5=A4=8D=E8=B4=AD=E4=B9=B0?= =?UTF-8?q?=E6=80=BB=E6=95=B0=E9=87=8F=E9=99=90=E5=88=B6=EF=BC=8C=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E8=B4=AD=E4=B9=B0=E6=95=B0=E9=87=8F=E9=99=90=E5=88=B6?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ServiceController.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CoreCms.Net.Web.WebApi/Controllers/ServiceController.cs b/CoreCms.Net.Web.WebApi/Controllers/ServiceController.cs index 7fb6e093..c1ff2666 100644 --- a/CoreCms.Net.Web.WebApi/Controllers/ServiceController.cs +++ b/CoreCms.Net.Web.WebApi/Controllers/ServiceController.cs @@ -251,6 +251,23 @@ namespace CoreCms.Net.Web.WebApi.Controllers return jm; } + //判断当前数量是否超过限制数量 + var orderCount = await _userServicesOrderServices.GetCountAsync(p => p.status == (int)GlobalEnumVars.ServicesOrderStatus.正常 && p.servicesId == entity.id); + + if (orderCount >= data.amount) + { + jm.msg = "当前项目已售罄。"; + return jm; + } + + //获取自己的购买数量 + var userOrderCount = await _userServicesOrderServices.GetCountAsync(p => p.status == (int)GlobalEnumVars.ServicesOrderStatus.正常 && p.servicesId == entity.id && p.userId == _user.ID); + if (data.maxBuyNumber >= 0 && userOrderCount > data.maxBuyNumber) + { + jm.msg = "已超出购买数量限制。"; + return jm; + } + var order = new CoreCmsUserServicesOrder(); order.serviceOrderId = CommonHelper.GetSerialNumberType((int)GlobalEnumVars.SerialNumberType.服务订单编号); order.userId = _user.ID;