From bcabbcd40ac71b90ebebc6b2c40f83a8f59df8b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=BF=97?= Date: Tue, 6 Jan 2026 15:02:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/MatchService.php | 51 +++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/app/service/MatchService.php b/app/service/MatchService.php index d8f3b9b..1b00014 100644 --- a/app/service/MatchService.php +++ b/app/service/MatchService.php @@ -62,17 +62,23 @@ class MatchService // 3. 计算匹配度 $results = []; foreach ($filteredPositions as $position) { - $score = $this->calculateMatchScore($position, $resume); - - if ($filterZero && $score == 0) { - continue; // 过滤0分岗位 + try { + $score = $this->calculateMatchScore($position, $resume); + + if ($filterZero && $score == 0) { + continue; // 过滤0分岗位 + } + + $results[] = [ + 'position_id' => $position['id'], + 'match_score' => $score, + 'position' => $position + ]; + } catch (\Exception $e) { + // 如果计算出错,记录错误但继续处理其他岗位 + error_log("计算匹配度失败 - 岗位ID: {$position['id']}, 错误: " . $e->getMessage()); + continue; } - - $results[] = [ - 'position_id' => $position['id'], - 'match_score' => $score, - 'position' => $position - ]; } // 4. 按匹配度降序排序 @@ -291,8 +297,9 @@ class MatchService } // 3. 年龄要求(硬性) - if (!empty($positionRequire['年龄要求'])) { - $ageCheck = $this->checkAge($positionRequire['年龄要求'], $resume); + $ageRequire = $positionRequire['年龄要求'] ?? ''; + if (!empty($ageRequire) && trim($ageRequire) !== '' && trim($ageRequire) !== '无' && trim($ageRequire) !== '不限制') { + $ageCheck = $this->checkAge($ageRequire, $resume); $result['details']['年龄要求'] = $ageCheck; if (!$ageCheck['passed']) { $result['passed'] = false; @@ -313,9 +320,10 @@ class MatchService } // 5. 性别要求(硬性,如果明确要求) - $otherConditions = $positionRequire['其他资格条件'] ?? ''; - if (preg_match('/适合(男|女)性/u', $otherConditions, $matches)) { - $genderCheck = $this->checkGender($matches[1], $resume); + // 优先检查 sex_require 字段 + $sexRequire = $positionRequire['性别要求'] ?? ''; + if (!empty($sexRequire) && $sexRequire !== '不限制' && $sexRequire !== '无') { + $genderCheck = $this->checkGender($sexRequire, $resume); $result['details']['性别要求'] = $genderCheck; if (!$genderCheck['passed']) { $result['passed'] = false; @@ -323,6 +331,19 @@ class MatchService } } + // 如果 sex_require 字段没有明确要求,再检查其他资格条件 + if (empty($sexRequire) || $sexRequire === '不限制' || $sexRequire === '无') { + $otherConditions = $positionRequire['其他资格条件'] ?? ''; + if (preg_match('/适合(男|女)性/u', $otherConditions, $matches)) { + $genderCheck = $this->checkGender($matches[1], $resume); + $result['details']['性别要求'] = $genderCheck; + if (!$genderCheck['passed']) { + $result['passed'] = false; + $result['rejection_reasons'][] = $genderCheck['reason']; + } + } + } + return $result; }