盲盒转盘优化调整

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

View File

@@ -335,29 +335,26 @@ 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)){
if ($selectedGift) { $randomKey = array_rand($remaining_available_gifts);
$gift = $giftInfoMap[$selectedGift['foreign_id']]; $selectedGift = $remaining_available_gifts[$randomKey];
$precomputedResults[] = [ unset($remaining_available_gifts[$randomKey]);
'gift_user_id' => $giftUserId, if ($selectedGift) {
'gift_bag_detail' => $selectedGift, $gift = $giftInfoMap[$selectedGift['foreign_id']];
'gift' => $gift, $precomputedResults[] = [
'draw_times' => $totalDrawTimes, 'gift_user_id' => $giftUserId,
'periods' => $periods, 'gift_bag_detail' => $selectedGift,
]; 'gift' => $gift,
$precomputedResultss[] = [ 'draw_times' => $totalDrawTimes,
'gift_user_id' => $giftUserId, 'periods' => $periods,
'gift_bag_detail' => $selectedGift, ];
'gift' => $gift, $totalDrawTimes++;
'draw_times' => $totalDrawTimes, $currentXlhPeriodsNum++;
'periods' => $periods, $addcurrentXlhPeriodsNum++;
];
$totalDrawTimes++;
$currentXlhPeriodsNum++;
$addcurrentXlhPeriodsNum++;
// 更新Alias表 // 更新Alias表
$this->updateAliasTable($aliasTableForRemaining, $selectedGift['id']); $this->updateAliasTable($aliasTableForRemaining, $selectedGift['id']);
}
} }
} }
} }
@@ -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')
$this_xlh_periods = $this->getCachedXlhPeriods('get'); ->where(['send_time' => 0])
$pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([ ->order('id', 'desc')
'room_id' => $room_id, ->find();
'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'], if (empty($pan_xlh)) {
'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'], // 巡乐会正式开始
'periods' => $this_xlh_periods+1, $this_xlh_periods = $this->getCachedXlhPeriods('get');
'num' => 0, $pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([
'end_time' => time() + $xlh_ext['locking_time']['end_time'] * 60, 'room_id' => $room_id,
'createtime' => time() 'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'],
]); 'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'],
if(!$pan_xlh_id){ 'periods' => $this_xlh_periods + 1,
return ['code' => 0, 'msg' => '创建巡乐会失败!', 'data' => []]; '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){ 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']);
} // }
} // }
} }
/* /*