盲盒转盘代码优化
This commit is contained in:
@@ -69,7 +69,7 @@ class BlindBoxTurntableGiftDraw extends Model
|
|||||||
if(count($precomputedResults) != $expectedCount){
|
if(count($precomputedResults) != $expectedCount){
|
||||||
// 记录错误到Redis
|
// 记录错误到Redis
|
||||||
$this->recordDrawErrorToRedis($expectedCount, count($precomputedResults), $room_id, $user_id, $gift_bag_id, $num, $gift_user_ids, $precomputedResults);
|
$this->recordDrawErrorToRedis($expectedCount, count($precomputedResults), $room_id, $user_id, $gift_bag_id, $num, $gift_user_ids, $precomputedResults);
|
||||||
return ['code' => 0, 'msg' => '抽奖结果数量与预期数量不一致,请重试! ', 'data' => null];
|
return ['code' => 0, 'msg' => '网络加载失败,请重试!', 'data' => null];
|
||||||
}
|
}
|
||||||
// 4. 执行抽奖事务(核心操作)
|
// 4. 执行抽奖事务(核心操作)
|
||||||
$transactionResult = $this->executeDrawTransaction(
|
$transactionResult = $this->executeDrawTransaction(
|
||||||
@@ -103,6 +103,8 @@ class BlindBoxTurntableGiftDraw extends Model
|
|||||||
return $this->buildDrawResult($boxTurntableLog, $giftCounts);
|
return $this->buildDrawResult($boxTurntableLog, $giftCounts);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
$key = 'blind_box_draw_errors_' . date('Y-m-d-H-i-s');
|
||||||
|
$this->redis->setex($key, 86400 * 7, $e->getMessage());
|
||||||
return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null];
|
return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user