From 4029a20e3c05a7131da352ac3ebf229e2a18ab92 Mon Sep 17 00:00:00 2001 From: huangguancheng Date: Fri, 10 Jan 2025 15:19:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=9B=E9=80=89=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/BpsAdController.php | 12 +++++++++--- app/service/AdsInsightService.php | 18 +++++++++++++----- app/service/BpsAdAccountService.php | 10 +++++++--- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/app/controller/BpsAdController.php b/app/controller/BpsAdController.php index 9c2b8b3..e2710e5 100644 --- a/app/controller/BpsAdController.php +++ b/app/controller/BpsAdController.php @@ -116,6 +116,7 @@ class BpsAdController $pageSize = $options['pageSize'] ?? 1000; // 每页数量 $keyword = $options['conditions']['keyword'] ?? ''; // 关键字搜索 $platformType = $options['conditions']['platformType'] ?? 0; // 平台类型 + $status = $options['conditions']['status'] ?? 0; // 平台类型 $startDate = $options['conditions']['startDate'] ?? null; // 开始日期 $endDate = $options['conditions']['endDate'] ?? null; // 结束日期 // $dateRange = 'Last Week'; // 默认日期范围 @@ -147,7 +148,8 @@ class BpsAdController $pageSize, // 每页数量 $keyword, // 关键字 $startDate, // 开始日期 - $endDate // 结束日期 + $endDate, // 结束日期 + $status ); // 返回结果 @@ -199,6 +201,7 @@ class BpsAdController $pageSize = $options['pageSize'] ?? 1000; // 每页数量 $keyword = $options['conditions']['keyword'] ?? ''; // 关键字搜索 $platformType = $options['conditions']['platformType'] ?? 0; // 关键字搜索 + $status = $options['conditions']['status'] ?? 0; // 平台类型 $startDate = $options['conditions']['startDate'] ?? null; // 开始日期 $endDate = $options['conditions']['endDate'] ?? null; // 结束日期 // $dateRange = 'Last Week'; // 默认日期范围 @@ -228,7 +231,8 @@ class BpsAdController $pageSize, // 每页数量 $keyword, // 关键字 $startDate, // 开始日期 - $endDate // 结束日期 + $endDate, // 结束日期 + $status ); return $this->successResponse($result, $request); // return $this->errorResponse(300,'授权失败'); @@ -244,6 +248,7 @@ class BpsAdController $pageSize = $options['pageSize'] ?? 1000; // 每页数量 $keyword = $options['conditions']['keyword'] ?? ''; // 关键字搜索 $platformType = $options['conditions']['platformType'] ?? 0; // 平台类型 + $status = $options['conditions']['status'] ?? 0; // 平台类型 $startDate = $options['conditions']['startDate'] ?? null; // 开始日期 $endDate = $options['conditions']['endDate'] ?? null; // 结束日期 // $dateRange = 'Last Week'; // 默认日期范围 @@ -275,7 +280,8 @@ class BpsAdController $pageSize, // 每页数量 $keyword, // 关键字 $startDate, // 开始日期 - $endDate // 结束日期 + $endDate, // 结束日期 + $status ); // 返回结果 diff --git a/app/service/AdsInsightService.php b/app/service/AdsInsightService.php index ab5a324..c8dedfc 100644 --- a/app/service/AdsInsightService.php +++ b/app/service/AdsInsightService.php @@ -30,7 +30,7 @@ class AdsInsightService /** * 获取广告系列列表 */ - public static function getCampaignList($platformType, $customerIds, $page, $pageSize, $keyword, $startDate = null, $endDate = null) + public static function getCampaignList($platformType, $customerIds, $page, $pageSize, $keyword, $startDate = null, $endDate = null,$status =0) { // 检查 customerIds 是否为空,直接返回空结构 if (empty($customerIds)) { @@ -74,7 +74,9 @@ class AdsInsightService -1 as conversion_rate, -1 as roas, -1 as ctr,-1 as net_profit,-1 as net_profit_margin,-1 as net_profit_on_ad_spend') ->group('c.campaign_id, c.status, c.account_id, c.name') ->where('c.account_id', 'in', $customerIds); // 添加 customerIds 条件 - + if ($status !== 0) { + $query->where('c.status', '=', $status); + } // 添加关键字过滤条件 $query->where(function ($query) use ($keyword, $platformType) { if ($keyword) { @@ -167,7 +169,7 @@ class AdsInsightService /** * 获取广告组列表 */ - public static function getAdsetList($platformType, $customerIds, $page, $pageSize, $keyword, $startDate = null, $endDate = null) + public static function getAdsetList($platformType, $customerIds, $page, $pageSize, $keyword, $startDate = null, $endDate = null, $status = 0) { // 检查 customerIds 是否为空,直接返回空结构 if (empty($customerIds)) { @@ -211,6 +213,9 @@ class AdsInsightService -1 as conversion_rate, -1 as roas, -1 as ctr,-1 as net_profit,-1 as net_profit_margin,-1 as net_profit_on_ad_spend') ->group('s.ad_set_id, s.status, s.account_id, s.name') ->where('s.account_id', 'in', $customerIds); // 添加 customerIds 条件 + if ($status !== 0) { + $query->where('s.status', '=', $status); + } // 添加关键字过滤条件 $query->where(function ($query) use ($keyword, $platformType) { @@ -302,7 +307,7 @@ class AdsInsightService ]; } - public static function getAdList($platformType, $customerIds, $page, $pageSize, $keyword, $startDate = null, $endDate = null) + public static function getAdList($platformType, $customerIds, $page, $pageSize, $keyword, $startDate = null, $endDate = null, $status = 0) { // 检查 customerIds 是否为空,直接返回空结构 if (empty($customerIds)) { @@ -345,7 +350,10 @@ class AdsInsightService -1 as conversion_rate, -1 as roas, -1 as ctr, -1 as net_profit, -1 as net_profit_margin, -1 as net_profit_on_ad_spend') ->group('a.ad_id, a.status, a.account_id, a.name') ->where('a.account_id', 'in', $customerIds); // 添加 customerIds 条件 - + // 如果传入了 status 参数,按状态筛选 + if ($status !== 0) { + $query->where('a.status', '=', $status); + } // 添加关键字过滤条件 $query->where(function ($query) use ($keyword, $platformType) { if ($keyword) { diff --git a/app/service/BpsAdAccountService.php b/app/service/BpsAdAccountService.php index 67fcbc4..3641027 100644 --- a/app/service/BpsAdAccountService.php +++ b/app/service/BpsAdAccountService.php @@ -168,7 +168,8 @@ class BpsAdAccountService $users = ThirdUserAdvertiser::alias('tua') ->join('bps.bps_third_user tu', 'tua.doc_ = tu.id') // 连接 bps_third_user 表 ->where('tu.third_type', 'facebook') // 筛选 third_type 为 facebook 的记录 - ->where('tu.user_id', $uid) // 使用 UID 筛选用户 + ->where('tu.user_id', $uid) // 筛选 user_id 的记录 + ->where('tu.access_token', '<>', '') // 筛选 access_token 不为空的记录 ->field('tu.id, tu.access_token as refresh_token') // 获取相关字段 ->select(); } else { @@ -199,7 +200,8 @@ class BpsAdAccountService $users = ThirdUserAdvertiser::alias('tua') ->join('bps.bps_third_user tu', 'tua.doc_ = tu.id') // 连接 bps_third_user 表 ->where('tu.third_type', 'google') // 筛选 third_type 为 google 的记录 - ->where('tu.user_id', $uid) // 筛选 third_type 为 google 的记录 + ->where('tu.user_id', $uid) // 筛选 user_id 的记录 + ->where('tu.access_token', '<>', '') // 筛选 access_token 不为空的记录 ->field('tu.id, tu.access_token as refresh_token') // 获取相关字段 ->select(); } else { @@ -230,7 +232,8 @@ class BpsAdAccountService $users = ThirdUserAdvertiser::alias('tua') ->join('bps.bps_third_user tu', 'tua.doc_ = tu.id') // 连接 bps_third_user 表 ->where('tu.third_type', 'tiktok') // 筛选 third_type 为 tiktok 的记录 - ->where('tu.access_token', $uid) // 筛选 third_type 为 tiktok 的记录 + ->where('tu.user_id', $uid) // 筛选 user_id 的记录 + ->where('tu.access_token', '<>', '') // 筛选 access_token 不为空的记录 ->field('tu.id, tu.access_token as refresh_token') // 获取相关字段 ->select(); } else { @@ -259,6 +262,7 @@ class BpsAdAccountService $users = ThirdUserAdvertiser::alias('tua') ->join('bps.bps_third_user tu', 'tua.doc_ = tu.id') // 连接 bps_third_user 表 ->where('tu.user_id', $userId) // 筛选 user_id 的记录 + ->where('tu.access_token', '<>', '') // 筛选 access_token 不为空的记录 ->field('tu.id, tu.access_token as refresh_token') // 获取相关字段 ->select();