作者 lyh

gx数据

@@ -52,10 +52,9 @@ class LyhImportTest extends Command @@ -52,10 +52,9 @@ class LyhImportTest extends Command
52 * @time :2023/11/20 15:13 52 * @time :2023/11/20 15:13
53 */ 53 */
54 public function handle(){ 54 public function handle(){
55 - ProjectServer::useProject(3283); 55 + ProjectServer::useProject(2837);
56 echo date('Y-m-d H:i:s') . 'start' . PHP_EOL; 56 echo date('Y-m-d H:i:s') . 'start' . PHP_EOL;
57 -// $this->importProductCategory('https://ecdn6.globalso.com/upload/p/3283/file/2025-03/zy_boss_pricelistcat_202503131025.csv','3283');  
58 - $this->importProduct('https://ecdn6.globalso.com/upload/p/3283/file/2025-03/zy_boss_price_copy1.csv',3283); 57 + $this->importCustomModule('https://ecdn6.globalso.com/upload/p/2837/file/2025-03/xindaxing-s-product-screening.csv',2837);
59 DB::disconnect('custom_mysql'); 58 DB::disconnect('custom_mysql');
60 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 59 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
61 } 60 }
@@ -332,12 +331,27 @@ class LyhImportTest extends Command @@ -332,12 +331,27 @@ class LyhImportTest extends Command
332 * @method :post 331 * @method :post
333 * @time :2025/2/24 14:54 332 * @time :2025/2/24 14:54
334 */ 333 */
335 - public function importCustomModule($text,$project_id = 2837){ 334 + public function importCustomModule($url,$project_id){
  335 + $line_of_text = [];
  336 + $opts = [
  337 + 'http' => [
  338 + 'method' => 'GET',
  339 + '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'
  340 + ],
  341 + 'ssl' => [
  342 + 'verify_peer' => false,
  343 + 'verify_peer_name' => false
  344 + ]
  345 + ];
  346 + $file_handle = fopen($url, 'r', null, stream_context_create($opts));
  347 + while (!feof($file_handle)) {
  348 + $line_of_text[] = fgetcsv($file_handle, 0, ',');
  349 + }
  350 + fclose($file_handle);
336 $customContentModel = new CustomModuleContent(); 351 $customContentModel = new CustomModuleContent();
337 $customCategoryModel = new CustomModuleCategory();; 352 $customCategoryModel = new CustomModuleCategory();;
338 $customExtendContentTModel = new CustomModuleExtentContent(); 353 $customExtendContentTModel = new CustomModuleExtentContent();
339 - $data = explode("\n", $text);  
340 - foreach ($data as $k => $item){ 354 + foreach ($line_of_text as $k => $item){
341 $item = trim($item,','); 355 $item = trim($item,',');
342 //按照逗号转为数组 356 //按照逗号转为数组
343 $array = explode(",", $item); 357 $array = explode(",", $item);