作者 lyh

gx脚本导出产品

<?php
/**
* @remark :
* @name :Demo.php
* @author :lyh
* @method :post
* @time :2025/2/20 9:19
*/
namespace App\Console\Commands\Test;
use Illuminate\Console\Command;
class Demo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'demo';
/**
* The console command description.
*
* @var string
*/
protected $description = '';
public function handle(){
return $this->getExtendProjects();
}
public function getExtendProjects($api_no = null)
{
$key = 'extend_projects_list';
$data = Cache::get($key);
if (!$data) {
$api_url = 'http://api.quanqiusou.cn/google-rank/api/extend_projects.php';
try {
$data = HttpUtils::get($api_url, []);
if ($data) {
$data = Arr::s2a($data);
Cache::put($key, $data, 4 * 3600);
}
} catch (\Exception | GuzzleException $e) {
errorLog('复制站点项目获取失败', [], $e);
return false;
}
}
if ($api_no !== null) {
$data = collect($data)->where('apino', $api_no)->first();
return $data ?: [];
}
echo date('Y-m-d H:i:s') . 'end'.json_encode($data) . PHP_EOL;
return $data;
}
}
... ... @@ -23,7 +23,10 @@ use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
use App\Models\Template\Setting;
use App\Services\ProjectServer;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
... ... @@ -58,22 +61,36 @@ class UpdateRoute extends Command
* @time :2023/11/20 15:13
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>['=',0],'id'=>1462]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->ceshi();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
$data = $this->ceshi();
echo date('Y-m-d H:i:s') . 'end'.json_encode($data) . PHP_EOL;
}
public function ceshi()
public function ceshi($api_no = null)
{
return true;
$key = 'extend_projects_list';
$data = Cache::get($key);
if (!$data) {
$api_url = 'http://api.quanqiusou.cn/google-rank/api/extend_projects.php';
try {
$data = HttpUtils::get($api_url, []);
if ($data) {
$data = Arr::s2a($data);
Cache::put($key, $data, 4 * 3600);
}
} catch (\Exception | GuzzleException $e) {
errorLog('复制站点项目获取失败', [], $e);
return false;
}
}
if ($api_no !== null) {
$data = collect($data)->where('apino', $api_no)->first();
return $data ?: [];
}
return $data;
}
/**
* @remark :更新产品
* @name :updateProduct
... ...