From 0a36726ca48359cb2e26f1a2cae348b47d5b48c8 Mon Sep 17 00:00:00 2001 From: huangguancheng Date: Fri, 10 Jan 2025 18:58:21 +0800 Subject: [PATCH] ad_set_name --- app/service/AdsInsightService.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/service/AdsInsightService.php b/app/service/AdsInsightService.php index d2c7809..881a3bd 100644 --- a/app/service/AdsInsightService.php +++ b/app/service/AdsInsightService.php @@ -347,7 +347,8 @@ class AdsInsightService $query = BpsAdAd::alias('a') ->cache(false) // 强制不使用缓存 ->leftJoin('bps.bps_ads_insights d', "a.ad_id = d.ad_id AND a.platform_type = d.platform AND {$dateCondition}") - ->field('a.ad_id, a.status as status, a.name, a.account_id,a.platform_type, + ->leftJoin('bps.bps_ads_set s', 'a.ad_set_id = s.ad_set_id') // 联接广告组表,获取 ad_set_name + ->field('a.ad_id, a.status as status, a.name, a.account_id,a.platform_type,s.name as ad_set_name, COALESCE(SUM(d.assisted_purchases), 0) as assisted_purchases, COALESCE(SUM(d.last_clicked_purchases), 0) as last_clicked_purchases, COALESCE(SUM(d.clicks), 0) as clicks, @@ -360,7 +361,7 @@ class AdsInsightService COALESCE(SUM(d.revenue), 0) as revenue, COALESCE(SUM(d.total_cost), 0) as total_cost, -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,a.platform_type') + ->group('a.ad_id, a.status, a.account_id, a.name,a.platform_type, s.name') ->where('a.account_id', 'in', $customerIds); // 添加 customerIds 条件 // 如果传入了 status 参数,按状态筛选 if ($status !== 0) { @@ -421,6 +422,7 @@ class AdsInsightService 'platform_type' => $item['platform_type'], 'account_id' => $item['account_id'], // 映射为 customer_id 'name' => $item['name'] ?: '-', // 若 name 为空则显示 '-' + 'ad_set_name' => $item['ad_set_name'] ?: '-', // 若 name 为空则显示 '-' 'status' => $item['status'], 'assisted_purchases' => $item['assisted_purchases'], 'last_clicked_purchases' => $item['last_clicked_purchases'],