作者 lyh

变更数据

@@ -54,7 +54,7 @@ class LyhImportTest extends Command @@ -54,7 +54,7 @@ class LyhImportTest extends Command
54 echo date('Y-m-d H:i:s') . 'start->1517' . PHP_EOL; 54 echo date('Y-m-d H:i:s') . 'start->1517' . PHP_EOL;
55 $url1 = 'https://ecdn6.globalso.com/upload/p/1517/file/2025-10/horse-racing-tkd-modification-1.xlsx';//改tdk 55 $url1 = 'https://ecdn6.globalso.com/upload/p/1517/file/2025-10/horse-racing-tkd-modification-1.xlsx';//改tdk
56 $url2 = 'https://v6-file.globalso.com/upload/p/1517/file/2025-10/horse-racing-url-modification.xlsx';//改url路由+tdk 56 $url2 = 'https://v6-file.globalso.com/upload/p/1517/file/2025-10/horse-racing-url-modification.xlsx';//改url路由+tdk
57 - $this->download_1517_action($url1); 57 + $this->download_1517_action($url2);
58 DB::disconnect('custom_mysql'); 58 DB::disconnect('custom_mysql');
59 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 59 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
60 } 60 }
@@ -100,12 +100,28 @@ class LyhImportTest extends Command @@ -100,12 +100,28 @@ class LyhImportTest extends Command
100 if (file_exists($tempPath)) { 100 if (file_exists($tempPath)) {
101 unlink($tempPath); 101 unlink($tempPath);
102 } 102 }
  103 + $d = [];
103 //todo::处理数据 104 //todo::处理数据
104 $productModel = new Product(); 105 $productModel = new Product();
105 - foreach ($rows as $row) {  
106 - dd($row);  
107 - $info = $productModel->read(['title'=>$row[0]]);  
108 - dd($row); 106 + foreach ($rows as $key => $row) {
  107 + if($key == 0){
  108 + continue;
  109 + }
  110 + $path = parse_url($row[1], PHP_URL_PATH);
  111 + $path = ltrim(parse_url($path, PHP_URL_PATH), '/');
  112 + $info = $productModel->read(['route'=>$path],['id','title','route','seo_mate']);
  113 + if($info === false){
  114 + echo '未找到数据->'.$row[0].PHP_EOL;
  115 + $d[] = $row[0];
  116 + continue;
  117 + }
  118 + $seo_mate = $info['seo_mate'];
  119 + $seo_mate['title'] = $row[2] ?? '';
  120 + $seo_mate['keyword'] = $row[3] ?? '';
  121 + //todo::重新生成路由
  122 + $route = RouteMap::setRoute($row[2],RouteMap::SOURCE_PRODUCT,$info['id'],$info['project_id']);
  123 + $productModel->edit(['route'=>$route,'old_route'=>$path,'seo_mate'=>json_encode($seo_mate,true),'title'=>$row[2]],['id'=>$info['id']]);
  124 + echo '执行的ID:'.$info['id'].PHP_EOL;
109 } 125 }
110 } catch (\Exception $e) { 126 } catch (\Exception $e) {
111 // 输出更清晰的错误信息 127 // 输出更清晰的错误信息