From 656f0692cf13979c874b3fc6f45ebf9d58815c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=92=8A?= Date: Thu, 16 Oct 2025 20:22:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E9=9C=80=E6=B1=82-=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E9=9C=80=E6=B1=82-=E7=9B=B2=E7=9B=92=E8=BD=AC=E7=9B=98?= =?UTF-8?q?=E8=B0=83=E9=80=9A=E7=9B=98-=E5=B7=A1=E4=B9=90=E4=BC=9A-?= =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/BlindBoxTurntableGiftDrawWorld.php | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/application/api/model/BlindBoxTurntableGiftDrawWorld.php b/application/api/model/BlindBoxTurntableGiftDrawWorld.php index 8586423..53527a5 100644 --- a/application/api/model/BlindBoxTurntableGiftDrawWorld.php +++ b/application/api/model/BlindBoxTurntableGiftDrawWorld.php @@ -39,7 +39,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model // 最大重试次数 $maxRetries = 3; for ($attempt = 0; $attempt < $maxRetries; $attempt++) { - try { +// try { // 1. 验证参数并提前处理错误 $validationResult = $this->validateDrawParameters($gift_bag_id, $user_id, $gift_user_ids); if ($validationResult !== true) { @@ -107,28 +107,28 @@ class BlindBoxTurntableGiftDrawWorld extends Model // 6. 构建并返回结果 return $this->buildDrawResult($boxTurntableLog, $giftCounts); - } catch (\Exception $e) { - $key = 'blind_box_draw_errors_' . date('Y-m-d-H-i-s'); - $errorData = [ - 'gift_bag_id' => $gift_bag_id, - 'user_id' => $user_id, - 'gift_user_ids' => $gift_user_ids, - 'num' => $num, - 'room_id' => $room_id, - 'heart_id' => $heart_id, - 'auction_id' => $auction_id, - ]; - if ($this->redis) { - $this->redis->setex($key, 86400 * 7, $e->getMessage() . ' ' . json_encode($errorData)); - } - // 如果是死锁且还有重试机会 - if (strpos($e->getMessage(), 'Deadlock') !== false && $attempt < $maxRetries - 1) { - // 随机延迟后重试 - usleep(rand(50000, 200000)); // 50-200ms - continue; - } - return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null]; - } +// } catch (\Exception $e) { +// $key = 'blind_box_draw_errors_' . date('Y-m-d-H-i-s'); +// $errorData = [ +// 'gift_bag_id' => $gift_bag_id, +// 'user_id' => $user_id, +// 'gift_user_ids' => $gift_user_ids, +// 'num' => $num, +// 'room_id' => $room_id, +// 'heart_id' => $heart_id, +// 'auction_id' => $auction_id, +// ]; +// if ($this->redis) { +// $this->redis->setex($key, 86400 * 7, $e->getMessage() . ' ' . json_encode($errorData)); +// } +// // 如果是死锁且还有重试机会 +// if (strpos($e->getMessage(), 'Deadlock') !== false && $attempt < $maxRetries - 1) { +// // 随机延迟后重试 +// usleep(rand(50000, 200000)); // 50-200ms +// continue; +// } +// return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null]; +// } } } /**