新需求-活动需求-盲盒转盘调通盘-巡乐会-调试

This commit is contained in:
2025-10-15 15:54:53 +08:00
parent faba9d6d2b
commit a04a75d7d9

View File

@@ -489,7 +489,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
// 增加重试机制
$maxRetries = 3;
for ($retry = 0; $retry < $maxRetries; $retry++) {
try {
// try {
db::startTrans();
// 按照固定顺序处理事务步骤
// 1. 扣除用户金币(优先处理)
@@ -534,16 +534,16 @@ class BlindBoxTurntableGiftDrawWorld extends Model
'gift_counts' => $giftCounts
]
];
} catch (\Exception $e) {
db::rollback();
// 检查是否是死锁错误
if (strpos($e->getMessage(), 'Deadlock') !== false && $retry < $maxRetries - 1) {
// 等待随机时间后重试
usleep(rand(10000, 100000)); // 10-100ms
continue;
}
return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null];
}
// } catch (\Exception $e) {
// db::rollback();
// // 检查是否是死锁错误
// if (strpos($e->getMessage(), 'Deadlock') !== false && $retry < $maxRetries - 1) {
// // 等待随机时间后重试
// usleep(rand(10000, 100000)); // 10-100ms
// continue;
// }
// return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null];
// }
}
return ['code' => 0, 'msg' => '操作超时,请重试', 'data' => null];
}