作者 李宇航

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

gx数据



查看合并请求 !1456
... ... @@ -52,10 +52,9 @@ class LyhImportTest extends Command
* @time :2023/11/20 15:13
*/
public function handle(){
ProjectServer::useProject(3283);
ProjectServer::useProject(2837);
echo date('Y-m-d H:i:s') . 'start' . PHP_EOL;
// $this->importProductCategory('https://ecdn6.globalso.com/upload/p/3283/file/2025-03/zy_boss_pricelistcat_202503131025.csv','3283');
$this->importProduct('https://ecdn6.globalso.com/upload/p/3283/file/2025-03/zy_boss_price_copy1.csv',3283);
$this->importCustomModule('https://ecdn6.globalso.com/upload/p/2837/file/2025-03/xindaxing-s-product-screening.csv',2837);
DB::disconnect('custom_mysql');
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
... ... @@ -332,12 +331,27 @@ class LyhImportTest extends Command
* @method :post
* @time :2025/2/24 14:54
*/
public function importCustomModule($text,$project_id = 2837){
public function importCustomModule($url,$project_id){
$line_of_text = [];
$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($url, 'r', null, stream_context_create($opts));
while (!feof($file_handle)) {
$line_of_text[] = fgetcsv($file_handle, 0, ',');
}
fclose($file_handle);
$customContentModel = new CustomModuleContent();
$customCategoryModel = new CustomModuleCategory();;
$customExtendContentTModel = new CustomModuleExtentContent();
$data = explode("\n", $text);
foreach ($data as $k => $item){
foreach ($line_of_text as $k => $item){
$item = trim($item,',');
//按照逗号转为数组
$array = explode(",", $item);
... ...