正在显示
1 个修改的文件
包含
36 行增加
和
1 行删除
| @@ -10,6 +10,7 @@ | @@ -10,6 +10,7 @@ | ||
| 10 | namespace App\Console\Commands\Geo; | 10 | namespace App\Console\Commands\Geo; |
| 11 | 11 | ||
| 12 | use App\Models\Geo\GeoQuestionLog; | 12 | use App\Models\Geo\GeoQuestionLog; |
| 13 | +use App\Models\Geo\GeoQuestionResult; | ||
| 13 | use Illuminate\Console\Command; | 14 | use Illuminate\Console\Command; |
| 14 | use Illuminate\Support\Carbon; | 15 | use Illuminate\Support\Carbon; |
| 15 | 16 | ||
| @@ -51,6 +52,40 @@ class GeoCount extends Command | @@ -51,6 +52,40 @@ class GeoCount extends Command | ||
| 51 | $start = $date.' 00:00:00'; | 52 | $start = $date.' 00:00:00'; |
| 52 | $end = $date.' 23:59:59'; | 53 | $end = $date.' 23:59:59'; |
| 53 | $geoLogModel = new GeoQuestionLog(); | 54 | $geoLogModel = new GeoQuestionLog(); |
| 54 | - $geoLogModel->formatQuery(['created_at' => ['between',[$start,$end]]])->distinct()->pluck('project_id'); | 55 | + $project_id = $geoLogModel->formatQuery(['created_at' => ['between',[$start,$end]]])->distinct()->pluck('project_id'); |
| 56 | + if(empty($project_id)){ | ||
| 57 | + return true; | ||
| 58 | + } | ||
| 59 | + $geoQuestionResModel = new GeoQuestionResult(); | ||
| 60 | + $platforms = ['gemini','openai','deepseek','poe','perplexity','google_ai_overview','openai-not-network','claude']; | ||
| 61 | + foreach ($project_id as $item){ | ||
| 62 | + $this->output('执行的项目ID----'.$item); | ||
| 63 | + //收录总数 | ||
| 64 | + $total = $geoQuestionResModel->counts(['project_id' => $item,'hit'=>['!=',0],'created_at' => ['between',[$start,$end]]]); | ||
| 65 | + $data = [ | ||
| 66 | + 'project_id' => $item, | ||
| 67 | + 'date' => $date, | ||
| 68 | + 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), | ||
| 69 | + 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), | ||
| 70 | + 'total'=>$total,//收录总数 | ||
| 71 | + ]; | ||
| 72 | + foreach ($platforms as $platform){ | ||
| 73 | + $data[$platform] = $geoQuestionResModel->counts(['project_id' => $item,'hit'=>['!=',0],'platform'=>$platform,'created_at' => ['between',[$start,$end]]]); | ||
| 74 | + } | ||
| 75 | + //新增一条数据 | ||
| 76 | + $geoQuestionResModel->addReturnId($data); | ||
| 77 | + } | ||
| 78 | + return true; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * 输出日志 | ||
| 83 | + * @param $message | ||
| 84 | + * @return bool | ||
| 85 | + */ | ||
| 86 | + public function output($message) | ||
| 87 | + { | ||
| 88 | + echo date('Y-m-d H:i:s') . ' ' . $message . PHP_EOL; | ||
| 89 | + return true; | ||
| 55 | } | 90 | } |
| 56 | } | 91 | } |
-
请 注册 或 登录 后发表评论