作者 lyh

Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into lyh-server

@@ -3,12 +3,14 @@ @@ -3,12 +3,14 @@
3 namespace App\Console\Commands\Test; 3 namespace App\Console\Commands\Test;
4 4
5 use App\Helper\Arr; 5 use App\Helper\Arr;
  6 +use App\Http\Logic\Bside\Product\CategoryLogic;
6 use App\Models\Com\Notify; 7 use App\Models\Com\Notify;
7 use App\Models\Devops\ServerConfig; 8 use App\Models\Devops\ServerConfig;
8 use App\Models\Devops\ServersIp; 9 use App\Models\Devops\ServersIp;
9 use App\Models\Domain\DomainCreateTask; 10 use App\Models\Domain\DomainCreateTask;
10 use App\Models\Domain\DomainInfo; 11 use App\Models\Domain\DomainInfo;
11 use App\Models\Product\Category; 12 use App\Models\Product\Category;
  13 +use App\Models\Product\CategoryRelated;
12 use App\Models\Product\Keyword; 14 use App\Models\Product\Keyword;
13 use App\Models\Product\Product; 15 use App\Models\Product\Product;
14 use App\Models\Project\DeployBuild; 16 use App\Models\Project\DeployBuild;
@@ -38,9 +40,111 @@ class Temp extends Command @@ -38,9 +40,111 @@ class Temp extends Command
38 40
39 public function handle() 41 public function handle()
40 { 42 {
41 - $this->importTdk(); 43 + $this->importPdf();
42 } 44 }
43 45
  46 + /**
  47 + * 3424项目导入pdf
  48 + * @return bool
  49 + * @throws \Exception
  50 + * @author Akun
  51 + * @date 2025/04/01 16:26
  52 + */
  53 + public function importPdf()
  54 + {
  55 + $file_url = 'https://ecdn6.globalso.com/upload/p/3424/file/2025-04/tmp_2.jsonl';
  56 + $project_id = 3424;
  57 +
  58 + $line_of_text = [];
  59 + try {
  60 + $opts = [
  61 + 'http' => [
  62 + 'method' => 'GET',
  63 + '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'
  64 + ],
  65 + 'ssl' => [
  66 + 'verify_peer' => false,
  67 + 'verify_peer_name' => false
  68 + ]
  69 + ];
  70 + $file_handle = fopen($file_url, 'r', null, stream_context_create($opts));
  71 + while (!feof($file_handle)) {
  72 + $line_of_text[] = fgets($file_handle);
  73 + }
  74 + fclose($file_handle);
  75 + } catch (\Exception $e) {
  76 + $this->output($e->getMessage());
  77 + return true;
  78 + }
  79 +
  80 + if (count($line_of_text) > 1) {
  81 + $project = ProjectServer::useProject($project_id);
  82 + if ($project) {
  83 + $product_model = new Product();
  84 + foreach ($line_of_text as $line) {
  85 + if (!$line) {
  86 + continue;
  87 + }
  88 +
  89 + $item = Arr::s2a($line);
  90 + if (!$item) {
  91 + continue;
  92 + }
  93 +
  94 + $title = $item['name'] ?? '';
  95 + if (!$title) {
  96 + continue;
  97 + }
  98 +
  99 + //根据标题查询产品
  100 + $product = $product_model->read(['title' => $title], ['id']);
  101 + if (!$product) {
  102 + continue;
  103 + }
  104 +
  105 + //处理分类
  106 + $cate = $item['cate'] ?? '';
  107 + $category_id = '';
  108 + $category_arr = [];
  109 + if ($cate) {
  110 + $cate_array = explode('/', $cate);
  111 + $category = implode($cate_array, '^v6sp$');
  112 + //处理分类
  113 + $categoryLogic = new CategoryLogic();
  114 + $category_info = $categoryLogic->importProductCategory($project_id, $category);
  115 + $category_id = $category_info['category_id'];
  116 + $category_arr = $category_info['category_arr'];
  117 + }
  118 +
  119 +
  120 + //处理pdf
  121 + $pdf = $item['pdf'] ?? '';
  122 + $files = null;
  123 + if ($pdf) {
  124 + $files = Arr::a2s(['url' => $pdf, 'text' => 'Download']);
  125 + }
  126 +
  127 + //保存分类及pdf数据
  128 + $product_model->edit(['category_id' => $category_id, 'files' => $files], ['id' => $product['id']]);
  129 +
  130 + //关联分类
  131 + if ($category_arr) {
  132 + CategoryRelated::saveRelated($product['id'], $category_arr);
  133 + }
  134 +
  135 + $this->output($title . ' | success');
  136 + }
  137 + }
  138 + //关闭数据库
  139 + DB::disconnect('custom_mysql');
  140 + }
  141 +
  142 + return true;
  143 + }
  144 +
  145 + /*
  146 + * 2379项目导入tdk
  147 + */
44 public function importTdk() 148 public function importTdk()
45 { 149 {
46 $project_id = 2379; 150 $project_id = 2379;