From 67bd3a07908e7a77921694bf30dca5bcec03641c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=BF=97?= Date: Tue, 6 Jan 2026 15:31:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/MatchService.php | 53 ++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/app/service/MatchService.php b/app/service/MatchService.php index 6cd4b5c..2af5797 100644 --- a/app/service/MatchService.php +++ b/app/service/MatchService.php @@ -88,12 +88,38 @@ class MatchService // 3. 计算匹配度 $results = []; $zeroScoreCount = 0; + $firstZeroScoreReason = null; // 记录第一个0分岗位的拒绝原因 foreach ($filteredPositions as $position) { try { - $score = $this->calculateMatchScore($position, $resume); + // 检查硬性条件,获取详细的拒绝原因 + $hardCheck = $this->checkHardRequirements($position, $resume); + $score = 0; + $rejectionInfo = null; + + if ($hardCheck['passed']) { + // 硬性条件通过,计算软性条件分数 + $softCheck = $this->calculateSoftRequirements($position, $resume); + $score = $softCheck['score']; + } else { + // 硬性条件不通过,记录拒绝原因 + $score = 0; + $rejectionInfo = [ + 'rejection_reasons' => $hardCheck['rejection_reasons'], + 'details' => $hardCheck['details'] + ]; + } if ($score == 0) { $zeroScoreCount++; + // 记录第一个0分岗位的拒绝原因 + if ($firstZeroScoreReason === null && $rejectionInfo !== null) { + $firstZeroScoreReason = [ + 'position_id' => $position['id'] ?? 0, + 'position_name' => $position['position_name'] ?? $position['name'] ?? '', + 'rejection_reasons' => $rejectionInfo['rejection_reasons'], + 'details' => $rejectionInfo['details'] + ]; + } } if ($filterZero && $score == 0) { @@ -139,7 +165,15 @@ class MatchService 'total_positions' => count($filteredPositions), 'zero_score_count' => $zeroScoreCount, 'filter_zero' => $filterZero, - 'result_count' => $total + 'result_count' => $total, + 'resume_info' => [ + 'user_id' => $resume['user_id'] ?? 0, + 'has_education' => !empty($resume['education']), + 'education_count' => count($resume['education'] ?? []), + 'birth_date' => $resume['birth_date'] ?? '', + 'gender' => $resume['gender'] ?? '', + ], + 'first_zero_reason' => $firstZeroScoreReason ] ]; } @@ -157,7 +191,10 @@ class MatchService try { $user = Db::name('t_user')->where('uid', $userId)->find(); } catch (\Exception $e) { - // 如果uid字段不存在,尝试id字段 + // ignore and fallback below + } + // 如果按 uid 没有查到,再按 id 尝试(即使没有异常也尝试,以防字段是 id) + if (empty($user)) { try { $user = Db::name('t_user')->where('id', $userId)->find(); } catch (\Exception $e2) { @@ -183,7 +220,10 @@ class MatchService ->where('uid', $userId) ->find(); } catch (\Exception $e) { - // 如果uid字段不存在,尝试user_id字段 + // ignore and fallback below + } + // 如果按 uid 没查到,再按 user_id 查一次 + if (empty($curriculumVitae)) { try { $curriculumVitae = Db::name('t_user_curriculum_vitae') ->where('user_id', $userId) @@ -210,7 +250,10 @@ class MatchService ->select() ->toArray(); } catch (\Exception $e) { - // 如果uid字段不存在,尝试user_id字段 + // ignore and fallback below + } + // 如果按 uid 没查到,再按 user_id 查一次(即使没有异常也尝试,以防字段是 user_id) + if (empty($educations)) { try { $educations = Db::name('t_user_education') ->where('user_id', $userId)