From e3e623c5e14a1c7a25d9b7c0669bab1e1445e42a Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 26 Jan 2022 16:41:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=85=E8=BF=87=E8=AE=A2=E5=8D=95=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/sam/views_sale.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hb_server/apps/sam/views_sale.py b/hb_server/apps/sam/views_sale.py index 63381f1..c67c5ca 100644 --- a/hb_server/apps/sam/views_sale.py +++ b/hb_server/apps/sam/views_sale.py @@ -42,6 +42,8 @@ class SaleViewSet(CreateUpdateModelAMixin, ListModelMixin, RetrieveModelMixin, C with transaction.atomic(): iproducts = vdata.pop('iproducts') vdata['count'] = len(iproducts) + if vdata['count'] + vdata['order'].delivered_count > vdata['order'].count: + raise exceptions.APIException('超过订单所需数量') sale = Sale.objects.create(**vdata) i_l = [] for i in iproducts: