ImportInquiry.php
2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
namespace App\Console\Commands\Inquiry;
use App\Models\Inquiry\InquiryForm;
use App\Models\Inquiry\InquiryFormData;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
/**
* 询盘导入
* Class InquiryList
* @package App\Console\Commands
* @author Akun
* @date 2024/10/24
*/
class ImportInquiry extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'import_inquiry';
/**
* The console command description.
*
* @var string
*/
protected $description = '询盘导入';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
public function handle()
{
// $csv_url = 'https://ecdn6.globalso.com/upload/p/2408/image_product/2024-10/rf-miso.csv';
// $project_id = 2408;
// $domain = 'www.rf-miso.com';
//
// //读取文件
// $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($csv_url, 'r', null, stream_context_create($opts));
// while (!feof($file_handle)) {
// $line_of_text[] = fgetcsv($file_handle, 0, ',');
// }
// fclose($file_handle);
// } catch (\Exception $e) {
// $this->output($e->getMessage());
// }
//
// ProjectServer::useProject($project_id);
//
// foreach ($line_of_text as $k => $v) {
// if ($k > 0) {
// $data = [
// 'project_id' => $project_id,
// 'domain' => $domain,
// 'ip' => $v[4],
// 'country' => $v[6],
// 'referer' => $v[5],
// 'user_agent' => '',
// 'submit_at' => $v[0],
// 'data' => [
// 'name' => $v[1],
// 'email' => $v[2],
// 'phone' => $v[3],
// ]
// ];
// $form_id = InquiryForm::getFromId($data['data'], $data['project_id']);
//
// InquiryFormData::saveData($form_id, $data['domain'], $data['ip'], $data['country'], $data['referer'], $data['user_agent'], $data['submit_at'], $data['data']);
//
// $this->output($k . ',success');
// }
// }
}
public function output($message)
{
echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL;
}
}