作者 李宇航

合并分支 'master-server' 到 'master'

gx复制项目脚本



查看合并请求 !1312
@@ -37,7 +37,7 @@ class LyhImportTest extends Command @@ -37,7 +37,7 @@ class LyhImportTest extends Command
37 */ 37 */
38 protected $description = '导入数据'; 38 protected $description = '导入数据';
39 39
40 - public $data = ''; 40 +
41 41
42 /** 42 /**
43 * @remark :统一更新路由 43 * @remark :统一更新路由
@@ -49,9 +49,7 @@ class LyhImportTest extends Command @@ -49,9 +49,7 @@ class LyhImportTest extends Command
49 public function handle(){ 49 public function handle(){
50 ProjectServer::useProject(3283); 50 ProjectServer::useProject(3283);
51 echo date('Y-m-d H:i:s') . 'start' . PHP_EOL; 51 echo date('Y-m-d H:i:s') . 'start' . PHP_EOL;
52 -// $this->importCustomModule($this->data);  
53 -// $this->importProductCategory($this->data,3283);  
54 - $this->handleCatePid(); 52 + $this->importProduct('https://ecdn6.globalso.com/upload/p/1/file/2025-03/zy_boss_price_copy1.csv',3283);
55 DB::disconnect('custom_mysql'); 53 DB::disconnect('custom_mysql');
56 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 54 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
57 } 55 }
@@ -63,25 +61,24 @@ class LyhImportTest extends Command @@ -63,25 +61,24 @@ class LyhImportTest extends Command
63 * @method :post 61 * @method :post
64 * @time :2025/3/3 15:59 62 * @time :2025/3/3 15:59
65 */ 63 */
66 - public function importProductCategory($text,$project_id){  
67 - //设置对应管理数组  
68 - $key_val = [];  
69 - $arr = explode("\n", $text);  
70 - foreach ($arr as $val){  
71 - $cate_arr = explode(",", $val);  
72 - $key_val[$cate_arr[1]] = $cate_arr[1];  
73 - $saveData = [  
74 - 'project_id'=>$project_id,  
75 - 'title'=>$cate_arr[1],  
76 - 'seo_title'=>$cate_arr[0],  
77 - 'seo_des'=>$cate_arr[2]  
78 - ];  
79 - $cateModel = new Category();  
80 - $id = $cateModel->addReturnId($saveData);  
81 - $route = RouteMap::setRoute($cate_arr[1],RouteMap::SOURCE_PRODUCT_CATE,$id,$project_id);  
82 - $cateModel->edit(['route'=>$route],['id'=>$id]); 64 + public function importProduct($url,$project_id){
  65 + $line_of_text = [];
  66 + $opts = [
  67 + 'http' => [
  68 + 'method' => 'GET',
  69 + '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'
  70 + ],
  71 + 'ssl' => [
  72 + 'verify_peer' => false,
  73 + 'verify_peer_name' => false
  74 + ]
  75 + ];
  76 + $file_handle = fopen($url, 'r', null, stream_context_create($opts));
  77 + while (!feof($file_handle)) {
  78 + $line_of_text[] = fgetcsv($file_handle, 0, ',');
83 } 79 }
84 - return true; 80 + fclose($file_handle);
  81 + dd($line_of_text);
85 } 82 }
86 83
87 public function handleCatePid(){ 84 public function handleCatePid(){