三个广告平台更换账号表222

This commit is contained in:
huangguancheng 2025-02-15 18:00:22 +08:00
parent 212cbbead0
commit 973df3866e

View File

@ -206,8 +206,8 @@ class AdsInsightService
COALESCE(SUM(d.revenue / 1000000), 0) as revenue,
COALESCE(SUM(d.total_cost / 1000000), 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('c.campaign_id, c.status, c.account_id, c.name,c.platform_type')
->where('c.account_id', 'in', $customerIds); // 添加 customerIds 条件
->group('c.campaign_id, c.status, c.account_id, c.name,c.platform_type');
// ->where('c.account_id', 'in', $customerIds); // 添加 customerIds 条件
// 根据 $requireSpend 参数决定是否添加 SUM(d.spend) > 0 的条件
if ($requireSpend) {
$query->having('SUM(d.spend) > 0');
@ -910,8 +910,8 @@ class AdsInsightService
COALESCE(SUM(d.revenue / 1000000), 0) as revenue,
COALESCE(SUM(d.total_cost / 1000000), 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('s.ad_set_id, s.status, s.account_id, s.name,s.platform_type,c.name')
->where('s.account_id', 'in', $customerIds); // 添加 customerIds 条件
->group('s.ad_set_id, s.status, s.account_id, s.name,s.platform_type,c.name');
// ->where('s.account_id', 'in', $customerIds); // 添加 customerIds 条件
// 根据 $requireSpend 参数决定是否添加 SUM(d.spend) > 0 的条件
if ($requireSpend) {
$query->having('SUM(d.spend) > 0');
@ -1214,8 +1214,8 @@ class AdsInsightService
COALESCE(SUM(d.revenue) / 1000000, 0) as revenue,
COALESCE(SUM(d.total_cost) / 1000000, 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('bamr.account_id, bamr.account_name,bamr.platform')
->where('bamr.account_id', 'in', $customerIds); // 添加 customerIds 条件
->group('bamr.account_id, bamr.account_name,bamr.platform');
// ->where('bamr.account_id', 'in', $customerIds); // 添加 customerIds 条件
// 如果传入了 status 参数,按状态筛选
// if ($status !== 0) {
// $query->where('a.status', '=', $status);
@ -1240,7 +1240,9 @@ class AdsInsightService
// 获取所有符合条件的数据(不分页)
$allAccounts = $query->select()->toArray();
// 打印调试 SQL 查询
$sql = $query->getLastSql();
dump($sql);
// 汇总统计数据
$total_spend = array_sum(array_column($allAccounts, 'spend'));
$total_cost = array_sum(array_column($allAccounts, 'total_cost'));
@ -1389,8 +1391,8 @@ class AdsInsightService
COALESCE(SUM(d.revenue) / 1000000, 0) as revenue,
COALESCE(SUM(d.total_cost) / 1000000, 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, s.name')
->where('a.account_id', 'in', $customerIds); // 添加 customerIds 条件
->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) {
$query->where('a.status', '=', $status);