From 4dfdcf325dccfe63e51a340352dc8a437e274923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=92=8A?= Date: Wed, 29 Oct 2025 16:01:47 +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-=E9=87=8D=E6=9E=84-=E4=BF=AE=E6=94=B9=E8=B0=83?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/BlindBoxTurntableGiftDrawWorldNew.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/application/api/model/BlindBoxTurntableGiftDrawWorldNew.php b/application/api/model/BlindBoxTurntableGiftDrawWorldNew.php index 6ea911e..1a12362 100644 --- a/application/api/model/BlindBoxTurntableGiftDrawWorldNew.php +++ b/application/api/model/BlindBoxTurntableGiftDrawWorldNew.php @@ -214,6 +214,16 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model } for ($i = 0; $i < $userNewAllocation; $i++) { $selectedGift = $this->selectGiftWithAliasMethod($aliasTableForNew); + if(!$selectedGift){ + //重置奖池 + $availableGifts = $this->resetPoolAndReload($gift_bag_id); + if (empty($availableGifts)) { + throw new \Exception('重置奖池后仍无可用礼物'); + } + $this->getCachedPanDrawTimes($gift_bag_id,"clear");//总抽奖次数重置 + $aliasTableForNew = $this->buildAliasTable($availableGifts); + $selectedGift = $this->selectGiftWithAliasMethod($aliasTableForNew); + } if ($selectedGift) { $gift = $giftInfoMap[$selectedGift['foreign_id']]??[]; $precomputedResults[] = [ @@ -400,6 +410,12 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model } $attempt++; } + // 兜底方案:遍历查找第一个有库存的礼物 + foreach ($aliasTable['index_map'] as $gift) { + if ($gift['remaining_number'] > 0) { + return $gift; + } + } // 如果重试次数用完仍未抽中有效礼物,返回null return null; }