盲盒转盘优化调整

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++) {
$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']);
// }
// }
}
/*