修改7
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user