From 60e2cde5e7c4fc5868995ee477226be50808b747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=92=8A?= Date: Sat, 25 Oct 2025 18:14:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B2=E7=9B=92=E8=BD=AC=E7=9B=98=E4=BC=98?= =?UTF-8?q?=E5=8C=96-=E8=B0=83=E8=AF=95-=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/model/BlindBoxTurntableGiftDrawWorld.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/application/api/model/BlindBoxTurntableGiftDrawWorld.php b/application/api/model/BlindBoxTurntableGiftDrawWorld.php index 173ba7f..ed0e9ba 100644 --- a/application/api/model/BlindBoxTurntableGiftDrawWorld.php +++ b/application/api/model/BlindBoxTurntableGiftDrawWorld.php @@ -582,6 +582,16 @@ class BlindBoxTurntableGiftDrawWorld extends Model // 批量更新 foreach ($inventoryUpdates as $giftId => $count) { + $giftBagDetail = Db::name("vs_gift_bag_detail") + ->where('id', $giftId) + ->find(); + if (!$giftBagDetail) { + throw new \Exception("礼物详情不存在,ID: " . $giftId); + } + // 检查库存是否足够 + if ($giftBagDetail['remaining_number'] < $count) { + throw new \Exception("礼物库存不足,ID: " . $giftId); + } $ret = db::name("vs_gift_bag_detail")->where('id',$giftId) ->setDec('remaining_number', $count); if (!$ret) {