This commit is contained in:
toom1996
2025-06-24 17:27:28 +08:00
parent bcb27c49f0
commit e691241ac9

View File

@ -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'],