新需求-活动需求-盲盒转盘调通盘-巡乐会-调试-优化错误
This commit is contained in:
@@ -840,6 +840,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
$text_list_new = [
|
$text_list_new = [
|
||||||
'xlh_data' => $xlh,
|
'xlh_data' => $xlh,
|
||||||
'text' => "",
|
'text' => "",
|
||||||
|
'room_id' => $room_id,
|
||||||
'from_type' => 100
|
'from_type' => 100
|
||||||
];
|
];
|
||||||
$push->xunlehui($text_list_new);
|
$push->xunlehui($text_list_new);
|
||||||
@@ -1101,9 +1102,6 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
|
|
||||||
while ($total_processed < $num) {
|
while ($total_processed < $num) {
|
||||||
$current_batch = min($batch_size, $num - $total_processed); // 当前批次处理数量
|
$current_batch = min($batch_size, $num - $total_processed); // 当前批次处理数量
|
||||||
|
|
||||||
$maxRetries = 3;
|
|
||||||
for ($retry = 0; $retry < $maxRetries; $retry++) {
|
|
||||||
try {
|
try {
|
||||||
db::startTrans();
|
db::startTrans();
|
||||||
// 批量扣除金币(只在第一次事务中处理)
|
// 批量扣除金币(只在第一次事务中处理)
|
||||||
@@ -1238,12 +1236,6 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
$total_processed += $current_batch;
|
$total_processed += $current_batch;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
db::rollback();
|
db::rollback();
|
||||||
// 检查是否是死锁错误
|
|
||||||
if (strpos($e->getMessage(), 'Deadlock') !== false && $retry < $maxRetries - 1) {
|
|
||||||
// 等待随机时间后重试
|
|
||||||
usleep(rand(10000, 100000)); // 10-100ms
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$key = 'xlh_draw_gift_errors_' . date('Y-m-d-H-i-s');
|
$key = 'xlh_draw_gift_errors_' . date('Y-m-d-H-i-s');
|
||||||
$errorData = [
|
$errorData = [
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
@@ -1254,7 +1246,6 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
return ['code' => 0, 'msg' => "抽奖中,请稍等...", 'data' => null];
|
return ['code' => 0, 'msg' => "抽奖中,请稍等...", 'data' => null];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 7. 批量处理结果记录
|
// 7. 批量处理结果记录
|
||||||
try {
|
try {
|
||||||
@@ -1319,6 +1310,13 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
db::commit();
|
db::commit();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
db::rollback();
|
db::rollback();
|
||||||
|
$key = 'xlh_draw_gift_errors_' . date('Y-m-d-H-i-s');
|
||||||
|
$errorData = [
|
||||||
|
'user_id' => $user_id,
|
||||||
|
'gift_bag_id' => $gift_bag_id,
|
||||||
|
'room_id' => $room_id,
|
||||||
|
];
|
||||||
|
$this->redis->setex($key, 86400 * 7, "巡乐会抽奖记录失败-异常:".$e->getMessage(). ' ' .json_encode($errorData));
|
||||||
return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null];
|
return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user