update
This commit is contained in:
@ -60,8 +60,8 @@ class KeywordsController extends AbstractController
|
||||
$query = new AppKeywordsMonitor();
|
||||
|
||||
$query->keyword = $keyword;
|
||||
$ignoreUrl = array_filter(array_unique(explode(PHP_EOL, $ignoreUrl)));
|
||||
|
||||
$ignoreUrl = array_filter(array_unique(explode(PHP_EOL, $ignoreUrl)));
|
||||
$query->ignore_url = json_encode($ignoreUrl);
|
||||
$query->save();
|
||||
|
||||
@ -131,7 +131,9 @@ class KeywordsController extends AbstractController
|
||||
// 先全部删掉
|
||||
AppKeywordsMonitorTask::query()->where(['aid' => $id])->update(['is_delete' => 1]);
|
||||
foreach ($platform as $platformItem) {
|
||||
$query = AppKeywordsMonitorTask::query()->where('aid', $id)->first();
|
||||
$query = AppKeywordsMonitorTask::query()->where([
|
||||
['aid', $id], ['platform', $platformItem]
|
||||
])->first();
|
||||
if ($query) {
|
||||
$query->is_delete = 0;
|
||||
$query->save();
|
||||
@ -140,6 +142,7 @@ class KeywordsController extends AbstractController
|
||||
$query->platform = $platformItem;
|
||||
$query->aid = $id;
|
||||
$query->keyword = $keyword;
|
||||
$query->page = 2; // 写死的只查前两页
|
||||
$query->save();
|
||||
}
|
||||
}
|
||||
@ -147,6 +150,23 @@ class KeywordsController extends AbstractController
|
||||
return $this->response->json(['code' => 0, 'msg' => 'ok', 'data' => $query]);
|
||||
}
|
||||
|
||||
// /admin/api/keywords/monitor/research
|
||||
|
||||
/**
|
||||
* 重查关键词
|
||||
* @url /admin/api/keywords/monitor/research
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'monitor/research', methods: 'post')]
|
||||
public function monitorResearch(): \Psr\Http\Message\ResponseInterface
|
||||
{
|
||||
$id = $this->request->input('id');
|
||||
|
||||
$query = AppKeywordsMonitorTask::query()->where('aid', $id)->update(['queried_at' => 0]);
|
||||
|
||||
return $this->response->json(['code' => 0, 'msg' => 'ok', 'data' => $query]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除关键词
|
||||
* @url /admin/api/keywords/monitor/delete
|
||||
@ -177,27 +197,45 @@ class KeywordsController extends AbstractController
|
||||
#[RequestMapping(path: 'monitor/export-all', methods: 'get')]
|
||||
public function monitorExportAll()
|
||||
{
|
||||
$res = AppKeywordsMonitorResult::query()
|
||||
$baiduPCRes = AppKeywordsMonitorResult::query()
|
||||
->where('is_delete', 0)
|
||||
->where('platform', 1)
|
||||
->where('created_at', '>', date('Y-m-d H:i:s', strtotime('today')))
|
||||
->orderBy('aid', 'desc')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
foreach ($res as &$v) {
|
||||
foreach ($baiduPCRes as &$v) {
|
||||
$v['keyword'] = AppKeywordsMonitorTask::find($v['aid'])->keyword;
|
||||
$v['screen_path'] = Config::getDomain() . $v['screen_path'];
|
||||
}
|
||||
|
||||
// 百度PC非负率
|
||||
$total = 20 * AppKeywordsMonitorTask::query()->where('platform', 1)->count();
|
||||
$baiduRes = $res;
|
||||
$percent = round(($total - count($baiduRes)) / $total, 2) * 100;
|
||||
$fileName = date('Y-m-d') . '关键词监控结果';
|
||||
$baiduWAPRes = AppKeywordsMonitorResult::query()
|
||||
->where('is_delete', 0)
|
||||
->where('platform', 2)
|
||||
->where('created_at', '>', date('Y-m-d H:i:s', strtotime('today')))
|
||||
->orderBy('aid', 'desc')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
return ExcelHelper::exportData($this->response, list: [
|
||||
"百度PC端_$percent%" => $baiduRes
|
||||
], header: [
|
||||
foreach ($baiduWAPRes as &$v) {
|
||||
$v['keyword'] = AppKeywordsMonitorTask::find($v['aid'])->keyword;
|
||||
$v['screen_path'] = Config::getDomain() . $v['screen_path'];
|
||||
}
|
||||
|
||||
$fileName = date('Y-m-d') . '关键词监控结果';
|
||||
$exportList = [];
|
||||
// 百度PC非负率
|
||||
$total = AppKeywordsMonitorTask::query()->where('is_delete', 0)->where('platform', 1)->sum('length') ?: 1;
|
||||
$percent = round(($total - count($baiduPCRes)) / $total, 2) * 100;
|
||||
$exportList["百度PC端_$percent%"] = $baiduPCRes;
|
||||
|
||||
// 百度WAP非负率
|
||||
$total = AppKeywordsMonitorTask::query()->where('is_delete', 0)->where('platform', 2)->sum('length');
|
||||
$percent = round(($total - count($baiduWAPRes)) / $total, 2) * 100;
|
||||
$exportList["百度WAP端_$percent%"] = $baiduWAPRes;
|
||||
|
||||
return ExcelHelper::exportData($this->response, list: $exportList, header: [
|
||||
['关键词', 'keyword', 'text'],
|
||||
['标题', 'title', 'text'],
|
||||
['排名', 'order', 'text'],
|
||||
|
Reference in New Issue
Block a user