作者 lyh

变更数据

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