新需求-活动需求-盲盒转盘调通盘-调试-优化错误
This commit is contained in:
@@ -64,7 +64,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
$precomputedResults = $precomputeResult['data']['results'];
|
$precomputedResults = $precomputeResult['data']['results'];
|
||||||
$availableGiftss = $precomputeResult['data']['availableGifts'];
|
$availableGiftss = $precomputeResult['data']['availableGifts'];
|
||||||
$currentXlhPeriodsNum = $precomputeResult['data']['current_xlh_periods_num'];
|
$currentXlhPeriodsNum = $precomputeResult['data']['current_xlh_periods_num'];
|
||||||
$xlhIsPiaoPing = $precomputeResult['data']['xlh_is_piao_ping'];
|
$addcurrentXlhPeriodsNum = $precomputeResult['data']['addcurrentXlhPeriodsNum'];
|
||||||
$expectedCount = count(explode(',', $gift_user_ids)) * $num;
|
$expectedCount = count(explode(',', $gift_user_ids)) * $num;
|
||||||
if (count($precomputedResults) != $expectedCount) {
|
if (count($precomputedResults) != $expectedCount) {
|
||||||
// 记录错误到Redis
|
// 记录错误到Redis
|
||||||
@@ -95,8 +95,8 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
$boxTurntableLog,
|
$boxTurntableLog,
|
||||||
$room_id,
|
$room_id,
|
||||||
$xlh_ext,
|
$xlh_ext,
|
||||||
$xlhIsPiaoPing,
|
|
||||||
$currentXlhPeriodsNum,
|
$currentXlhPeriodsNum,
|
||||||
|
$addcurrentXlhPeriodsNum,
|
||||||
$room
|
$room
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -203,9 +203,6 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
private function precomputeDrawResults($bag_data, $gift_user_ids, $num)
|
private function precomputeDrawResults($bag_data, $gift_user_ids, $num)
|
||||||
{
|
{
|
||||||
$toarray = explode(',', $gift_user_ids);
|
$toarray = explode(',', $gift_user_ids);
|
||||||
$xlh_is_piao_ping = 0;
|
|
||||||
$current_xlh_periods_num = $this->getCachedXlhPeriodsNum("get");
|
|
||||||
|
|
||||||
// 1. 计算奖池信息
|
// 1. 计算奖池信息
|
||||||
$poolInfo = $this->calculatePoolInfo($bag_data['id']);
|
$poolInfo = $this->calculatePoolInfo($bag_data['id']);
|
||||||
if ($poolInfo['code'] !== 1) {
|
if ($poolInfo['code'] !== 1) {
|
||||||
@@ -245,7 +242,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
}
|
}
|
||||||
$totalDrawTimes = 0; // 总抽奖次数重置
|
$totalDrawTimes = 0; // 总抽奖次数重置
|
||||||
}
|
}
|
||||||
|
$current_xlh_periods_num = $this->getCachedXlhPeriodsNum("get");
|
||||||
// 5. 使用Alias Method预计算抽奖结果(O(1)复杂度)
|
// 5. 使用Alias Method预计算抽奖结果(O(1)复杂度)
|
||||||
$precomputedResults = $this->precomputeResultsWithAliasMethod(
|
$precomputedResults = $this->precomputeResultsWithAliasMethod(
|
||||||
$toarray,
|
$toarray,
|
||||||
@@ -267,8 +264,8 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
'data' => [
|
'data' => [
|
||||||
'results' => $precomputedResults['precomputedResults'],
|
'results' => $precomputedResults['precomputedResults'],
|
||||||
'current_xlh_periods_num' => $current_xlh_periods_num,
|
'current_xlh_periods_num' => $current_xlh_periods_num,
|
||||||
'xlh_is_piao_ping' => $xlh_is_piao_ping,
|
|
||||||
'availableGifts' => $precomputedResults['precomputedResultss'],
|
'availableGifts' => $precomputedResults['precomputedResultss'],
|
||||||
|
'addcurrentXlhPeriodsNum' => $precomputedResults['addcurrentXlhPeriodsNum'],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -288,6 +285,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
) {
|
) {
|
||||||
$precomputedResults = [];
|
$precomputedResults = [];
|
||||||
$precomputedResultss = [];
|
$precomputedResultss = [];
|
||||||
|
$addcurrentXlhPeriodsNum = 0;
|
||||||
|
|
||||||
// 计算上期剩余礼物总数
|
// 计算上期剩余礼物总数
|
||||||
$remainingGiftCount = array_sum(array_column($remaining_available_gifts, 'remaining_number'));
|
$remainingGiftCount = array_sum(array_column($remaining_available_gifts, 'remaining_number'));
|
||||||
@@ -328,6 +326,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
];
|
];
|
||||||
$totalDrawTimes++;
|
$totalDrawTimes++;
|
||||||
$currentXlhPeriodsNum++;
|
$currentXlhPeriodsNum++;
|
||||||
|
$addcurrentXlhPeriodsNum++;
|
||||||
|
|
||||||
// 更新Alias表
|
// 更新Alias表
|
||||||
$this->updateAliasTable($aliasTableForRemaining, $selectedGift['id']);
|
$this->updateAliasTable($aliasTableForRemaining, $selectedGift['id']);
|
||||||
@@ -370,6 +369,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
];
|
];
|
||||||
$totalDrawTimes++;
|
$totalDrawTimes++;
|
||||||
$currentXlhPeriodsNum++;
|
$currentXlhPeriodsNum++;
|
||||||
|
$addcurrentXlhPeriodsNum++;
|
||||||
|
|
||||||
// 更新Alias表
|
// 更新Alias表
|
||||||
$this->updateAliasTable($aliasTableForNew, $selectedGift['id']);
|
$this->updateAliasTable($aliasTableForNew, $selectedGift['id']);
|
||||||
@@ -378,7 +378,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['precomputedResults' => $precomputedResults, 'precomputedResultss' => $precomputedResultss];
|
return ['precomputedResults' => $precomputedResults, 'precomputedResultss' => $precomputedResultss, 'addcurrentXlhPeriodsNum' => $addcurrentXlhPeriodsNum];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -644,8 +644,8 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
$boxTurntableLog,
|
$boxTurntableLog,
|
||||||
$room_id,
|
$room_id,
|
||||||
$xlh_ext,
|
$xlh_ext,
|
||||||
$xlhIsPiaoPing,
|
|
||||||
$currentXlhPeriodsNum,
|
$currentXlhPeriodsNum,
|
||||||
|
$addcurrentXlhPeriodsNum,
|
||||||
$room
|
$room
|
||||||
) {
|
) {
|
||||||
// 1. 批量插入盲盒转盘结果记录
|
// 1. 批量插入盲盒转盘结果记录
|
||||||
@@ -653,7 +653,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
|
|
||||||
// 3. 处理巡乐会相关操作
|
// 3. 处理巡乐会相关操作
|
||||||
if (!empty($xlh_ext) && $xlh_ext['inlet_bag_id'] == $precomputedResults[0]['gift_bag_detail']['gift_bag_id']) {
|
if (!empty($xlh_ext) && $xlh_ext['inlet_bag_id'] == $precomputedResults[0]['gift_bag_detail']['gift_bag_id']) {
|
||||||
$this->handleXlhOperations($room_id, $xlh_ext, $xlhIsPiaoPing, $currentXlhPeriodsNum,$room);
|
$this->handleXlhOperations($room_id, $xlh_ext, $currentXlhPeriodsNum,$addcurrentXlhPeriodsNum,$room);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -755,8 +755,9 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
/**
|
/**
|
||||||
* 处理巡乐会相关操作
|
* 处理巡乐会相关操作
|
||||||
*/
|
*/
|
||||||
private function handleXlhOperations($room_id, $xlh_ext, $xlhIsPiaoPing, $currentXlhPeriodsNum,$room)
|
private function handleXlhOperations($room_id, $xlh_ext, $currentXlhPeriodsNum,$addcurrentXlhPeriodsNum,$room)
|
||||||
{
|
{
|
||||||
|
$xlhIsPiaoPing = 0;
|
||||||
$xlhPeriodsNum = $this->getCachedXlhPeriodsNum("get");
|
$xlhPeriodsNum = $this->getCachedXlhPeriodsNum("get");
|
||||||
if($xlhPeriodsNum < $xlh_ext['open_condition']['waiting_start_num'] && $currentXlhPeriodsNum >= $xlh_ext['open_condition']['waiting_start_num']){
|
if($xlhPeriodsNum < $xlh_ext['open_condition']['waiting_start_num'] && $currentXlhPeriodsNum >= $xlh_ext['open_condition']['waiting_start_num']){
|
||||||
$xlhIsPiaoPing = 1;
|
$xlhIsPiaoPing = 1;
|
||||||
@@ -765,7 +766,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
$xlhIsPiaoPing = 2;
|
$xlhIsPiaoPing = 2;
|
||||||
}
|
}
|
||||||
// 更新房间巡乐会次数
|
// 更新房间巡乐会次数
|
||||||
$this->getCachedXlhPeriodsNum("set",$currentXlhPeriodsNum);
|
$this->getCachedXlhPeriodsNum("set",$addcurrentXlhPeriodsNum);
|
||||||
|
|
||||||
// 处理飘屏
|
// 处理飘屏
|
||||||
if ($xlhIsPiaoPing == 1 || $xlhIsPiaoPing == 2) {
|
if ($xlhIsPiaoPing == 1 || $xlhIsPiaoPing == 2) {
|
||||||
@@ -989,7 +990,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
$cacheKey = "xlh_periods_num";
|
$cacheKey = "xlh_periods_num";
|
||||||
$xlh_periods_num = Cache::get($cacheKey) ?? 0;
|
$xlh_periods_num = Cache::get($cacheKey) ?? 0;
|
||||||
if($type=="set"){
|
if($type=="set"){
|
||||||
$xlh_periods_num = $num;
|
$xlh_periods_num = $xlh_periods_num + $num;
|
||||||
Cache::set($cacheKey, $xlh_periods_num, 0);
|
Cache::set($cacheKey, $xlh_periods_num, 0);
|
||||||
}
|
}
|
||||||
return $xlh_periods_num;
|
return $xlh_periods_num;
|
||||||
|
|||||||
Reference in New Issue
Block a user