userRecipes()->where('user_id', $userId)->first(); if (!$userRecipe || !$userRecipe->is_unlocked) { return [ 'can_craft' => false, 'reason' => '配方未解锁', ]; } // 检查冷却时间 if ($recipe->cooldown_seconds > 0) { $lastCraft = $recipe->craftLogs() ->where('user_id', $userId) ->where('created_at', '>', now()->subSeconds($recipe->cooldown_seconds)) ->first(); if ($lastCraft) { $remainingSeconds = $recipe->cooldown_seconds - now()->diffInSeconds($lastCraft->created_at); return [ 'can_craft' => false, 'reason' => '冷却中', 'remaining_seconds' => $remainingSeconds, ]; } } return [ 'can_craft' => true, 'reason' => '', ]; } }