|
...
|
...
|
@@ -3,12 +3,14 @@ |
|
|
|
namespace App\Console\Commands\Test;
|
|
|
|
|
|
|
|
use App\Helper\Arr;
|
|
|
|
use App\Http\Logic\Bside\Product\CategoryLogic;
|
|
|
|
use App\Models\Com\Notify;
|
|
|
|
use App\Models\Devops\ServerConfig;
|
|
|
|
use App\Models\Devops\ServersIp;
|
|
|
|
use App\Models\Domain\DomainCreateTask;
|
|
|
|
use App\Models\Domain\DomainInfo;
|
|
|
|
use App\Models\Product\Category;
|
|
|
|
use App\Models\Product\CategoryRelated;
|
|
|
|
use App\Models\Product\Keyword;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\Project\DeployBuild;
|
|
...
|
...
|
@@ -38,9 +40,111 @@ class Temp extends Command |
|
|
|
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$this->importTdk();
|
|
|
|
$this->importPdf();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 3424项目导入pdf
|
|
|
|
* @return bool
|
|
|
|
* @throws \Exception
|
|
|
|
* @author Akun
|
|
|
|
* @date 2025/04/01 16:26
|
|
|
|
*/
|
|
|
|
public function importPdf()
|
|
|
|
{
|
|
|
|
$file_url = 'https://ecdn6.globalso.com/upload/p/3424/file/2025-04/tmp_2.jsonl';
|
|
|
|
$project_id = 3424;
|
|
|
|
|
|
|
|
$line_of_text = [];
|
|
|
|
try {
|
|
|
|
$opts = [
|
|
|
|
'http' => [
|
|
|
|
'method' => 'GET',
|
|
|
|
'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'
|
|
|
|
],
|
|
|
|
'ssl' => [
|
|
|
|
'verify_peer' => false,
|
|
|
|
'verify_peer_name' => false
|
|
|
|
]
|
|
|
|
];
|
|
|
|
$file_handle = fopen($file_url, 'r', null, stream_context_create($opts));
|
|
|
|
while (!feof($file_handle)) {
|
|
|
|
$line_of_text[] = fgets($file_handle);
|
|
|
|
}
|
|
|
|
fclose($file_handle);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
$this->output($e->getMessage());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count($line_of_text) > 1) {
|
|
|
|
$project = ProjectServer::useProject($project_id);
|
|
|
|
if ($project) {
|
|
|
|
$product_model = new Product();
|
|
|
|
foreach ($line_of_text as $line) {
|
|
|
|
if (!$line) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$item = Arr::s2a($line);
|
|
|
|
if (!$item) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$title = $item['name'] ?? '';
|
|
|
|
if (!$title) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//根据标题查询产品
|
|
|
|
$product = $product_model->read(['title' => $title], ['id']);
|
|
|
|
if (!$product) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//处理分类
|
|
|
|
$cate = $item['cate'] ?? '';
|
|
|
|
$category_id = '';
|
|
|
|
$category_arr = [];
|
|
|
|
if ($cate) {
|
|
|
|
$cate_array = explode('/', $cate);
|
|
|
|
$category = implode($cate_array, '^v6sp$');
|
|
|
|
//处理分类
|
|
|
|
$categoryLogic = new CategoryLogic();
|
|
|
|
$category_info = $categoryLogic->importProductCategory($project_id, $category);
|
|
|
|
$category_id = $category_info['category_id'];
|
|
|
|
$category_arr = $category_info['category_arr'];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//处理pdf
|
|
|
|
$pdf = $item['pdf'] ?? '';
|
|
|
|
$files = null;
|
|
|
|
if ($pdf) {
|
|
|
|
$files = Arr::a2s(['url' => $pdf, 'text' => 'Download']);
|
|
|
|
}
|
|
|
|
|
|
|
|
//保存分类及pdf数据
|
|
|
|
$product_model->edit(['category_id' => $category_id, 'files' => $files], ['id' => $product['id']]);
|
|
|
|
|
|
|
|
//关联分类
|
|
|
|
if ($category_arr) {
|
|
|
|
CategoryRelated::saveRelated($product['id'], $category_arr);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->output($title . ' | success');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//关闭数据库
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 2379项目导入tdk
|
|
|
|
*/
|
|
|
|
public function importTdk()
|
|
|
|
{
|
|
|
|
$project_id = 2379;
|
...
|
...
|
|