From e691241ac9b99a5a30e3d9ce7b313c8eb996e62c Mon Sep 17 00:00:00 2001 From: toom1996 Date: Tue, 24 Jun 2025 17:27:28 +0800 Subject: [PATCH] update --- .../admin/api/KeywordsController.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/app/Controller/admin/api/KeywordsController.php b/app/Controller/admin/api/KeywordsController.php index a82e9db..f3c50cd 100644 --- a/app/Controller/admin/api/KeywordsController.php +++ b/app/Controller/admin/api/KeywordsController.php @@ -225,18 +225,37 @@ class KeywordsController extends AbstractController $v['created_at'] = date('Y-m-d H:i:s', $v['created_at']); } + $toutiaoPC = AppKeywordsMonitorResult::query() + ->where('is_delete', 0) + ->where('platform', 3) + ->where('created_at', '>', strtotime('today')) + ->orderBy('aid', 'desc') + ->get() + ->toArray(); + + foreach ($toutiaoPC as &$v) { + $v['keyword'] = AppKeywordsMonitorTask::find($v['aid'])->keyword; + $v['screen_path'] = Config::getDomain() . $v['screen_path']; + $v['created_at'] = date('Y-m-d H:i:s', $v['created_at']); + } + $fileName = date('Y-m-d') . '关键词监控结果'; $exportList = []; - // 百度PC非负率 + // 百度PC负面率 $total = AppKeywordsMonitorTask::query()->where('is_delete', 0)->where('platform', 1)->sum('length') ?: 1; $percent = round(count($baiduPCRes) / $total, 2) * 100; $exportList["百度PC端_$percent%"] = $baiduPCRes; - // 百度WAP非负率 + // 百度WAP负面率 $total = AppKeywordsMonitorTask::query()->where('is_delete', 0)->where('platform', 2)->sum('length') ?: 1; $percent = round(count($baiduWAPRes) / $total, 2) * 100; $exportList["百度WAP端_$percent%"] = $baiduWAPRes; + // 头条PC端负面率 + $total = AppKeywordsMonitorTask::query()->where('is_delete', 0)->where('platform', 3)->sum('length') ?: 1; + $percent = round(count($toutiaoPC) / $total, 2) * 100; + $exportList["头条PC端_$percent%"] = $toutiaoPC; + return ExcelHelper::exportData($this->response, list: $exportList, header: [ ['关键词', 'keyword', 'text'], ['标题', 'title', 'text'],