From 5c421224436aede6c3e22693b8ee100696488aaf Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Fri, 18 Aug 2023 11:45:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BA=93=E5=AD=98=E5=88=A4?= =?UTF-8?q?=E6=96=ADbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/repositories/community/CommunityRepository.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/common/repositories/community/CommunityRepository.php b/app/common/repositories/community/CommunityRepository.php index f25565e1..2c074e33 100644 --- a/app/common/repositories/community/CommunityRepository.php +++ b/app/common/repositories/community/CommunityRepository.php @@ -610,11 +610,13 @@ class CommunityRepository extends BaseRepository // if ($exist) { // throw new ValidateException('已发起转售'); // } - if (empty($purchaseRecord) || ($purchaseRecord['number'] - $purchaseRecord['sales_volume']) <= 0) { + $totalNumber = PurchaseRecord::where('unique', $value['product_attr_unique'])->sum('number'); + $totalSalesVolume = PurchaseRecord::where('unique', $value['product_attr_unique'])->sum('sales_volume'); + if (empty($purchaseRecord) || ($totalNumber - $totalSalesVolume) <= 0) { throw new ValidateException('进货记录不存在或已售罄'); } - if (($purchaseRecord['number'] - $purchaseRecord['sales_volume']) < $value['number']) { - throw new ValidateException('库存不足123'); + if (($totalNumber - $totalSalesVolume) < $value['number']) { + throw new ValidateException('库存不足'); } if ($value) {