|
...
|
...
|
@@ -10,6 +10,7 @@ |
|
|
|
namespace App\Console\Commands\Geo;
|
|
|
|
|
|
|
|
use App\Models\Geo\GeoQuestionLog;
|
|
|
|
use App\Models\Geo\GeoQuestionResult;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Carbon;
|
|
|
|
|
|
...
|
...
|
@@ -51,6 +52,40 @@ class GeoCount extends Command |
|
|
|
$start = $date.' 00:00:00';
|
|
|
|
$end = $date.' 23:59:59';
|
|
|
|
$geoLogModel = new GeoQuestionLog();
|
|
|
|
$geoLogModel->formatQuery(['created_at' => ['between',[$start,$end]]])->distinct()->pluck('project_id');
|
|
|
|
$project_id = $geoLogModel->formatQuery(['created_at' => ['between',[$start,$end]]])->distinct()->pluck('project_id');
|
|
|
|
if(empty($project_id)){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
$geoQuestionResModel = new GeoQuestionResult();
|
|
|
|
$platforms = ['gemini','openai','deepseek','poe','perplexity','google_ai_overview','openai-not-network','claude'];
|
|
|
|
foreach ($project_id as $item){
|
|
|
|
$this->output('执行的项目ID----'.$item);
|
|
|
|
//收录总数
|
|
|
|
$total = $geoQuestionResModel->counts(['project_id' => $item,'hit'=>['!=',0],'created_at' => ['between',[$start,$end]]]);
|
|
|
|
$data = [
|
|
|
|
'project_id' => $item,
|
|
|
|
'date' => $date,
|
|
|
|
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
|
|
|
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
|
|
|
'total'=>$total,//收录总数
|
|
|
|
];
|
|
|
|
foreach ($platforms as $platform){
|
|
|
|
$data[$platform] = $geoQuestionResModel->counts(['project_id' => $item,'hit'=>['!=',0],'platform'=>$platform,'created_at' => ['between',[$start,$end]]]);
|
|
|
|
}
|
|
|
|
//新增一条数据
|
|
|
|
$geoQuestionResModel->addReturnId($data);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 输出日志
|
|
|
|
* @param $message
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function output($message)
|
|
|
|
{
|
|
|
|
echo date('Y-m-d H:i:s') . ' ' . $message . PHP_EOL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|