新需求-活动需求-盲盒转盘调通盘-巡乐会-调试
This commit is contained in:
@@ -493,9 +493,9 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
$bagGiftPrice = $bag_data['gift_price'] * $num * $gift_user_num;
|
$bagGiftPrice = $bag_data['gift_price'] * $num * $gift_user_num;
|
||||||
|
|
||||||
// 增加重试机制
|
// 增加重试机制
|
||||||
$maxRetries = 3;
|
// $maxRetries = 3;
|
||||||
for ($retry = 0; $retry < $maxRetries; $retry++) {
|
// for ($retry = 0; $retry < $maxRetries; $retry++) {
|
||||||
try {
|
// try {
|
||||||
db::startTrans();
|
db::startTrans();
|
||||||
// 按照固定顺序处理事务步骤
|
// 按照固定顺序处理事务步骤
|
||||||
// 1. 扣除用户金币(优先处理)
|
// 1. 扣除用户金币(优先处理)
|
||||||
@@ -540,17 +540,17 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
|||||||
'gift_counts' => $giftCounts
|
'gift_counts' => $giftCounts
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
} catch (\Exception $e) {
|
// } catch (\Exception $e) {
|
||||||
db::rollback();
|
// db::rollback();
|
||||||
// 检查是否是死锁错误
|
// // 检查是否是死锁错误
|
||||||
if (strpos($e->getMessage(), 'Deadlock') !== false && $retry < $maxRetries - 1) {
|
// if (strpos($e->getMessage(), 'Deadlock') !== false && $retry < $maxRetries - 1) {
|
||||||
// 等待随机时间后重试
|
// // 等待随机时间后重试
|
||||||
usleep(rand(10000, 100000)); // 10-100ms
|
// usleep(rand(10000, 100000)); // 10-100ms
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null];
|
// return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null];
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return ['code' => 0, 'msg' => '操作超时,请重试', 'data' => null];
|
return ['code' => 0, 'msg' => '操作超时,请重试', 'data' => null];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user