master
cody 2 months ago
parent 1f50ac9bd2
commit 2f8ff5db66

@ -43,7 +43,7 @@ class UpdateCompany extends Command
public function handle()
{
// $YuanheRepository = new YuanheRepository();
// $result = $YuanheRepository->companyInfo(['keyword' => '苏州元瞰科技有限公司']);
// $result = $YuanheRepository->companyInfo(['keyword' => '苏州元瞰科技有限公司','enterpriseName'=>'博世工程技术']);
// dd($result);
$user_id = $this->option('user_id');

@ -135,11 +135,11 @@ class UpdateCourseUrls extends Command
$this->info("处理行 {$row}: 课程='{$courseName}', 跳转链接='{$jumpLink}'");
// 从phome_ecms_news表获取titleurl
$titleUrl = $this->getTitleUrlFromNews($jumpLink);
list($title, $titleUrl) = $this->getTitleUrlFromNews($jumpLink);
if ($titleUrl) {
// 更新courses表
$updateCount = $this->updateCourseUrl($courseName, $titleUrl);
$updateCount = $this->updateCourseUrl($courseName, $titleUrl, $title);
$updated += $updateCount;
if ($updateCount > 0) {
@ -176,7 +176,7 @@ class UpdateCourseUrls extends Command
->first();
if ($news && !empty($news->titleurl)) {
return $news->titleurl;
return [$news->title, $news->titleurl];
}
// 模糊匹配
@ -186,7 +186,7 @@ class UpdateCourseUrls extends Command
if ($news && !empty($news->titleurl)) {
$this->info("通过模糊匹配找到: '{$news->title}' -> '{$news->titleurl}'");
return $news->titleurl;
return [$news->title, $news->titleurl];
}
// 使用相似度匹配
@ -210,7 +210,7 @@ class UpdateCourseUrls extends Command
if ($bestMatch && $highestSimilarity > 0) {
$this->info("通过相似度匹配找到 (相似度: " . round($highestSimilarity * 100, 2) . "%): '{$bestMatch->title}' -> '{$bestMatch->titleurl}'");
return $bestMatch->titleurl;
return [$bestMatch->title, $bestMatch->titleurl];
}
} catch (\Exception $e) {
@ -223,13 +223,13 @@ class UpdateCourseUrls extends Command
/**
* 更新courses表的url字段
*/
private function updateCourseUrl($courseName, $titleUrl)
private function updateCourseUrl($courseName, $titleUrl, $title)
{
try {
// 直接匹配
$updateCount = Course::where('name', $courseName)
->whereNull('deleted_at')
->update(['url' => $titleUrl]);
->update(['url' => $titleUrl, 'url_title' => $title]);
if ($updateCount > 0) {
return $updateCount;
@ -238,7 +238,7 @@ class UpdateCourseUrls extends Command
// 模糊匹配
$updateCount = Course::where('name', 'like', "%{$courseName}%")
->whereNull('deleted_at')
->update(['url' => $titleUrl]);
->update(['url' => $titleUrl, 'url_title' => $title]);
if ($updateCount > 0) {
$this->info("通过模糊匹配更新了课程");
@ -264,6 +264,7 @@ class UpdateCourseUrls extends Command
if ($bestMatch && $highestSimilarity > 0) {
$bestMatch->url = $titleUrl;
$bestMatch->url_title = $title;
$bestMatch->save();
$this->info("通过相似度匹配更新了课程 (相似度: " . round($highestSimilarity * 100, 2) . "%): '{$bestMatch->name}'");
return 1;

Loading…
Cancel
Save