作者 lyh
... ... @@ -8,6 +8,7 @@ use App\Helper\OaGlobalsoApi;
use App\Models\Channel\Channel;
use App\Models\Com\NoticeLog;
use App\Models\Com\UpdateLog;
use App\Models\Com\UpdateVisit;
use App\Models\Project\After;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
... ... @@ -244,6 +245,7 @@ class SyncProject extends Command
foreach ($task_list as $task){
UpdateLog::createLog($id,$task,$param['get_data_url']);
}
UpdateVisit::createLog($id,$param['get_data_url']);
}
DB::commit();
}catch (\Exception $e){
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Console\Commands\Test;
use App\Helper\Arr;
use App\Models\Collect\CollectTask;
use App\Models\Com\UpdateLog;
use App\Models\Com\UpdateVisit;
use App\Models\Product\Product;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
... ... @@ -29,31 +30,12 @@ class Temp extends Command
public function handle()
{
$data_project = [162];
foreach ($data_project as $project_id) {
$project = ProjectServer::useProject($project_id);
if ($project) {
$list = Product::get();
foreach ($list as $item) {
$seo = $item->seo_mate;
if ($seo) {
$seo['title'] = substr(strip_tags($seo['title']??''), 0, 70);
$seo['keyword'] = substr(strip_tags($seo['keyword']??''), 0, 255);
$seo['description'] = substr(strip_tags($seo['description']??''), 0, 200);
$item->seo_mate = Arr::a2s($seo);
try {
$item->save();
}catch (\Exception $e){
continue;
}
}
}
}
//关闭数据库
DB::disconnect('custom_mysql');
$data = UpdateLog::where('api_type','website_info')->get();
foreach ($data as $item) {
UpdateVisit::createLog($item->project_id,$item->api_url);
echo $project_id . '成功, product' . PHP_EOL;
echo $item->project_id . '成功' . PHP_EOL;
}
}
}
... ...
... ... @@ -94,6 +94,10 @@ class ProjectVisit extends Command
if (isset($item['id']) && $item['id']) {
if ($item['id'] > $task->max_id) {
$url_arr = parse_url($item['request'] ?? '');
$domain = $url_arr['host'] ?? '';
if(strlen($domain) > 50){
continue;
}
$insert[] = [
'url' => $item['request'] ?? '',
'referrer_url' => $item['referrer'] ?? '',
... ... @@ -101,7 +105,7 @@ class ProjectVisit extends Command
'country' => $item['ip_area'] ?? '',
'ip' => $item['ip'] ?? '',
'depth' => $item['pv'],
'domain' => $url_arr['host'] ?? '',
'domain' => $domain,
'is_inquiry' => $item['is_cf'] ?? 0,
'created_at' => date('Y-m-d H:i:s', isset($item['update']) && $item['update'] ? $item['update'] : time()),
'updated_at' => date('Y-m-d H:i:s', isset($item['update']) && $item['update'] ? $item['update'] : time()),
... ...
... ... @@ -12,4 +12,39 @@ class UpdateVisit extends Model
const STATUS_UN = 0;//未开始
const STATUS_ING = 1;//导入中
const STATUS_COM = 2;//导入完成
/**
* 创建更新日志
* @param $project_id
* @param $url
* @return mixed
*/
public static function createLog($project_id, $url)
{
$count = self::where('project_id', $project_id)->count('id');
if (!$count) {
$time = date('Y-m-d H:i:s');
$data = [
[
'project_id' => $project_id,
'api_type' => 'visit_list',
'api_url' => str_replace('update_v6.php?w=website_info&page=1&pagesize=20', 'extend_api.php', $url),
'sort' => 0,
'created_at' => $time,
'updated_at' => $time
],
[
'project_id' => $project_id,
'api_type' => 'visit_detail_list',
'api_url' => str_replace('update_v6.php?w=website_info&page=1&pagesize=20', 'extend_api.php', $url),
'sort' => 1,
'created_at' => $time,
'updated_at' => $time
]
];
return self::insert($data);
}
return true;
}
}
... ...