This commit is contained in:
杨志
2026-01-06 15:31:56 +08:00
parent 0485bf47d4
commit 67bd3a0790

View File

@@ -88,12 +88,38 @@ class MatchService
// 3. 计算匹配度 // 3. 计算匹配度
$results = []; $results = [];
$zeroScoreCount = 0; $zeroScoreCount = 0;
$firstZeroScoreReason = null; // 记录第一个0分岗位的拒绝原因
foreach ($filteredPositions as $position) { foreach ($filteredPositions as $position) {
try { 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) { if ($score == 0) {
$zeroScoreCount++; $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) { if ($filterZero && $score == 0) {
@@ -139,7 +165,15 @@ class MatchService
'total_positions' => count($filteredPositions), 'total_positions' => count($filteredPositions),
'zero_score_count' => $zeroScoreCount, 'zero_score_count' => $zeroScoreCount,
'filter_zero' => $filterZero, '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 { try {
$user = Db::name('t_user')->where('uid', $userId)->find(); $user = Db::name('t_user')->where('uid', $userId)->find();
} catch (\Exception $e) { } catch (\Exception $e) {
// 如果uid字段不存在尝试id字段 // ignore and fallback below
}
// 如果按 uid 没有查到,再按 id 尝试(即使没有异常也尝试,以防字段是 id
if (empty($user)) {
try { try {
$user = Db::name('t_user')->where('id', $userId)->find(); $user = Db::name('t_user')->where('id', $userId)->find();
} catch (\Exception $e2) { } catch (\Exception $e2) {
@@ -183,7 +220,10 @@ class MatchService
->where('uid', $userId) ->where('uid', $userId)
->find(); ->find();
} catch (\Exception $e) { } catch (\Exception $e) {
// 如果uid字段不存在尝试user_id字段 // ignore and fallback below
}
// 如果按 uid 没查到,再按 user_id 查一次
if (empty($curriculumVitae)) {
try { try {
$curriculumVitae = Db::name('t_user_curriculum_vitae') $curriculumVitae = Db::name('t_user_curriculum_vitae')
->where('user_id', $userId) ->where('user_id', $userId)
@@ -210,7 +250,10 @@ class MatchService
->select() ->select()
->toArray(); ->toArray();
} catch (\Exception $e) { } catch (\Exception $e) {
// 如果uid字段不存在尝试user_id字段 // ignore and fallback below
}
// 如果按 uid 没查到,再按 user_id 查一次(即使没有异常也尝试,以防字段是 user_id
if (empty($educations)) {
try { try {
$educations = Db::name('t_user_education') $educations = Db::name('t_user_education')
->where('user_id', $userId) ->where('user_id', $userId)