From 69aed0abbebeaaf0dd9c1dbe407f77b42d82a7b1 Mon Sep 17 00:00:00 2001 From: Terry <2358269014@qq.com> Date: Sun, 19 Nov 2017 13:45:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=80=E5=B0=8F=E8=B4=AD=E4=B9=B0=E4=B8=AA?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E5=9C=A8=E8=B4=AD=E7=89=A9=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E9=99=90=E5=88=B6=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/Checkout/controllers/CartController.php | 1 + services/cart/QuoteItem.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/appfront/modules/Checkout/controllers/CartController.php b/app/appfront/modules/Checkout/controllers/CartController.php index 046ecb457..65f3eb07c 100644 --- a/app/appfront/modules/Checkout/controllers/CartController.php +++ b/app/appfront/modules/Checkout/controllers/CartController.php @@ -208,6 +208,7 @@ public function actionUpdateinfo() } else { echo json_encode([ 'status' => 'fail', + 'content' => Yii::$service->helper->errors->get(',') ]); $innerTransaction->rollBack(); } diff --git a/services/cart/QuoteItem.php b/services/cart/QuoteItem.php index 358c8ffbd..41c6c2f0d 100644 --- a/services/cart/QuoteItem.php +++ b/services/cart/QuoteItem.php @@ -284,9 +284,19 @@ public function lessOneItem($item_id) 'cart_id' => $cart_id, 'item_id' => $item_id, ])->one(); + $lessedQty = $one['qty'] - 1; + + $product = Yii::$service->product->getByPrimaryKey($one['product_id']); + if(isset($product['min_sales_qty']) && $product['min_sales_qty'] > 1){ + if($lessedQty < $product['min_sales_qty']){ + Yii::$service->helper->errors->add('product less buy qty is '.$product['min_sales_qty']); + + return false; + } + } if ($one['item_id']) { if ($one['qty'] > 1) { - $one['qty'] = $one['qty'] - 1; + $one['qty'] = $lessedQty; $one->save(); // 重新计算购物车的数量 Yii::$service->cart->quote->computeCartInfo();