From 0d734d092b1ac5a02f1a683aa013d77ed73be694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=92=8A?= Date: Thu, 23 Oct 2025 18:32:05 +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=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/BlindBoxTurntableGiftDrawWorld.php | 95 ++++++++++--------- 1 file changed, 49 insertions(+), 46 deletions(-) diff --git a/application/api/model/BlindBoxTurntableGiftDrawWorld.php b/application/api/model/BlindBoxTurntableGiftDrawWorld.php index b205a7f..7eb939d 100644 --- a/application/api/model/BlindBoxTurntableGiftDrawWorld.php +++ b/application/api/model/BlindBoxTurntableGiftDrawWorld.php @@ -335,29 +335,26 @@ class BlindBoxTurntableGiftDrawWorld extends Model } for ($i = 0; $i < $userRemainingAllocation; $i++) { - $selectedGift = $this->selectGiftWithAliasMethod($aliasTableForRemaining); - if ($selectedGift) { - $gift = $giftInfoMap[$selectedGift['foreign_id']]; - $precomputedResults[] = [ - 'gift_user_id' => $giftUserId, - 'gift_bag_detail' => $selectedGift, - 'gift' => $gift, - 'draw_times' => $totalDrawTimes, - 'periods' => $periods, - ]; - $precomputedResultss[] = [ - 'gift_user_id' => $giftUserId, - 'gift_bag_detail' => $selectedGift, - 'gift' => $gift, - 'draw_times' => $totalDrawTimes, - 'periods' => $periods, - ]; - $totalDrawTimes++; - $currentXlhPeriodsNum++; - $addcurrentXlhPeriodsNum++; + if(!empty($remaining_available_gifts)){ + $randomKey = array_rand($remaining_available_gifts); + $selectedGift = $remaining_available_gifts[$randomKey]; + unset($remaining_available_gifts[$randomKey]); + if ($selectedGift) { + $gift = $giftInfoMap[$selectedGift['foreign_id']]; + $precomputedResults[] = [ + 'gift_user_id' => $giftUserId, + 'gift_bag_detail' => $selectedGift, + 'gift' => $gift, + 'draw_times' => $totalDrawTimes, + 'periods' => $periods, + ]; + $totalDrawTimes++; + $currentXlhPeriodsNum++; + $addcurrentXlhPeriodsNum++; - // 更新Alias表 - $this->updateAliasTable($aliasTableForRemaining, $selectedGift['id']); + // 更新Alias表 + $this->updateAliasTable($aliasTableForRemaining, $selectedGift['id']); + } } } } @@ -822,21 +819,27 @@ class BlindBoxTurntableGiftDrawWorld extends Model 'from_type' => 102 ]; $push->xunlehui($text_list_new); - // 巡乐会正式开始 - $this_xlh_periods = $this->getCachedXlhPeriods('get'); - $pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([ - 'room_id' => $room_id, - 'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'], - 'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'], - 'periods' => $this_xlh_periods+1, - 'num' => 0, - 'end_time' => time() + $xlh_ext['locking_time']['end_time'] * 60, - 'createtime' => time() - ]); - if(!$pan_xlh_id){ - return ['code' => 0, 'msg' => '创建巡乐会失败!', 'data' => []]; + $pan_xlh = db::name('vs_room_pan_xlh') + ->where(['send_time' => 0]) + ->order('id', 'desc') + ->find(); + if (empty($pan_xlh)) { + // 巡乐会正式开始 + $this_xlh_periods = $this->getCachedXlhPeriods('get'); + $pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([ + 'room_id' => $room_id, + 'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'], + 'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'], + 'periods' => $this_xlh_periods + 1, + 'num' => 0, + 'end_time' => time() + $xlh_ext['locking_time']['end_time'] * 60, + 'createtime' => time() + ]); + if (!$pan_xlh_id) { + return ['code' => 0, 'msg' => '创建巡乐会失败!', 'data' => []]; + } + $this->getCachedXlhPeriods('set', $this_xlh_periods + 1);//修改巡乐会期数 } - $this->getCachedXlhPeriods('set', $this_xlh_periods+1);//修改巡乐会期数 } } private function updateAndPushXlhStatus($room_id, $xlh_ext, $currentXlhPeriodsNum){ @@ -1045,17 +1048,17 @@ class BlindBoxTurntableGiftDrawWorld extends Model db::name("vs_gift_bag")->where('id',$gift_bag_id)->setInc('periods'); //更新期数 db::name("vs_gift_bag_detail")->where('gift_bag_id',$gift_bag_id)->update(['remaining_number'=>db::raw('quantity')]);//重置奖池 //防止并发,上把如果件数小于0,则加上 - foreach ($bag_detail as $pan) { - if($pan['remaining_number']<0){ - db::name("vs_gift_bag_detail")->where('id', $pan['id'])->setInc('remaining_number', $pan['remaining_number']); - } - } +// foreach ($bag_detail as $pan) { +// if($pan['remaining_number']<0){ +// db::name("vs_gift_bag_detail")->where('id', $pan['id'])->setInc('remaining_number', $pan['remaining_number']); +// } +// } //补充上把礼物有剩余 - if(!empty($remaining_available_gifts)){ - foreach ($remaining_available_gifts as $gift) { - db::name("vs_gift_bag_detail")->where('id', $gift['id'])->setInc('remaining_number',$gift['remaining_number']); - } - } +// if(!empty($remaining_available_gifts)){ +// foreach ($remaining_available_gifts as $gift) { +// db::name("vs_gift_bag_detail")->where('id', $gift['id'])->setInc('remaining_number',$gift['remaining_number']); +// } +// } } /*