解决超出发放礼物问题-巡乐会-加清除缓存方法
This commit is contained in:
@@ -1576,43 +1576,11 @@ class BlindBoxTurntableGiftDraw extends Model
|
|||||||
'num' => $num,
|
'num' => $num,
|
||||||
'gift_user_ids' => $gift_user_ids,
|
'gift_user_ids' => $gift_user_ids,
|
||||||
'precomputed_results_count' => count($precomputedResults),
|
'precomputed_results_count' => count($precomputedResults),
|
||||||
|
'precomputed_results' => $precomputedResults,
|
||||||
'error_type' => 'draw_count_mismatch'
|
'error_type' => 'draw_count_mismatch'
|
||||||
];
|
];
|
||||||
|
|
||||||
// 将错误信息推送到Redis列表中
|
// 将错误信息推送到Redis列表中
|
||||||
$this->redis->lpush('blind_box_draw_errors', json_encode($errorData));
|
$this->redis->set('blind_box_draw_errors', json_encode($errorData),86400 * 7);
|
||||||
|
|
||||||
// 同时记录到哈希结构,便于按房间ID或用户ID查询
|
|
||||||
$errorKey = 'blind_box_error:' . $room_id . ':' . time() . ':' . uniqid();
|
|
||||||
$this->redis->hmset($errorKey, $errorData);
|
|
||||||
$this->redis->expire($errorKey, 86400 * 7); // 设置1天过期时间
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取抽奖错误统计信息
|
|
||||||
*/
|
|
||||||
public function getDrawErrorStats()
|
|
||||||
{
|
|
||||||
$errors = $this->redis->lrange('blind_box_draw_errors', 0, 99); // 获取最近100条错误记录
|
|
||||||
$stats = [
|
|
||||||
'total_errors' => $this->redis->llen('blind_box_draw_errors'),
|
|
||||||
'recent_errors' => [],
|
|
||||||
'error_distribution' => []
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($errors as $error) {
|
|
||||||
$errorData = json_decode($error, true);
|
|
||||||
$stats['recent_errors'][] = $errorData;
|
|
||||||
|
|
||||||
// 统计错误分布
|
|
||||||
$errorType = $errorData['error_type'] ?? 'unknown';
|
|
||||||
if (!isset($stats['error_distribution'][$errorType])) {
|
|
||||||
$stats['error_distribution'][$errorType] = 0;
|
|
||||||
}
|
|
||||||
$stats['error_distribution'][$errorType]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user