盲盒转盘优化调整

This commit is contained in:
2025-10-23 18:32:05 +08:00
parent a6ae1d8c01
commit 0d734d092b

View File

@@ -335,7 +335,10 @@ class BlindBoxTurntableGiftDrawWorld extends Model
} }
for ($i = 0; $i < $userRemainingAllocation; $i++) { for ($i = 0; $i < $userRemainingAllocation; $i++) {
$selectedGift = $this->selectGiftWithAliasMethod($aliasTableForRemaining); if(!empty($remaining_available_gifts)){
$randomKey = array_rand($remaining_available_gifts);
$selectedGift = $remaining_available_gifts[$randomKey];
unset($remaining_available_gifts[$randomKey]);
if ($selectedGift) { if ($selectedGift) {
$gift = $giftInfoMap[$selectedGift['foreign_id']]; $gift = $giftInfoMap[$selectedGift['foreign_id']];
$precomputedResults[] = [ $precomputedResults[] = [
@@ -345,13 +348,6 @@ class BlindBoxTurntableGiftDrawWorld extends Model
'draw_times' => $totalDrawTimes, 'draw_times' => $totalDrawTimes,
'periods' => $periods, 'periods' => $periods,
]; ];
$precomputedResultss[] = [
'gift_user_id' => $giftUserId,
'gift_bag_detail' => $selectedGift,
'gift' => $gift,
'draw_times' => $totalDrawTimes,
'periods' => $periods,
];
$totalDrawTimes++; $totalDrawTimes++;
$currentXlhPeriodsNum++; $currentXlhPeriodsNum++;
$addcurrentXlhPeriodsNum++; $addcurrentXlhPeriodsNum++;
@@ -362,6 +358,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
} }
} }
} }
}
// 再从新奖池中分配剩余所需礼物 // 再从新奖池中分配剩余所需礼物
if ($newGiftsNeeded > 0 && !empty($availableGifts)) { if ($newGiftsNeeded > 0 && !empty($availableGifts)) {
@@ -822,21 +819,27 @@ class BlindBoxTurntableGiftDrawWorld extends Model
'from_type' => 102 'from_type' => 102
]; ];
$push->xunlehui($text_list_new); $push->xunlehui($text_list_new);
$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'); $this_xlh_periods = $this->getCachedXlhPeriods('get');
$pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([ $pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([
'room_id' => $room_id, 'room_id' => $room_id,
'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'], 'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'],
'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'], 'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'],
'periods' => $this_xlh_periods+1, 'periods' => $this_xlh_periods + 1,
'num' => 0, 'num' => 0,
'end_time' => time() + $xlh_ext['locking_time']['end_time'] * 60, 'end_time' => time() + $xlh_ext['locking_time']['end_time'] * 60,
'createtime' => time() 'createtime' => time()
]); ]);
if(!$pan_xlh_id){ if (!$pan_xlh_id) {
return ['code' => 0, 'msg' => '创建巡乐会失败!', 'data' => []]; 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){ 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")->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')]);//重置奖池 db::name("vs_gift_bag_detail")->where('gift_bag_id',$gift_bag_id)->update(['remaining_number'=>db::raw('quantity')]);//重置奖池
//防止并发上把如果件数小于0则加上 //防止并发上把如果件数小于0则加上
foreach ($bag_detail as $pan) { // foreach ($bag_detail as $pan) {
if($pan['remaining_number']<0){ // if($pan['remaining_number']<0){
db::name("vs_gift_bag_detail")->where('id', $pan['id'])->setInc('remaining_number', $pan['remaining_number']); // db::name("vs_gift_bag_detail")->where('id', $pan['id'])->setInc('remaining_number', $pan['remaining_number']);
} // }
} // }
//补充上把礼物有剩余 //补充上把礼物有剩余
if(!empty($remaining_available_gifts)){ // if(!empty($remaining_available_gifts)){
foreach ($remaining_available_gifts as $gift) { // foreach ($remaining_available_gifts as $gift) {
db::name("vs_gift_bag_detail")->where('id', $gift['id'])->setInc('remaining_number',$gift['remaining_number']); // db::name("vs_gift_bag_detail")->where('id', $gift['id'])->setInc('remaining_number',$gift['remaining_number']);
} // }
} // }
} }
/* /*