diff --git a/app/service/AdsInsightService.php b/app/service/AdsInsightService.php index 72f6cad..f854155 100644 --- a/app/service/AdsInsightService.php +++ b/app/service/AdsInsightService.php @@ -209,7 +209,7 @@ class AdsInsightService COALESCE(SUM(d.platform_purchase), 0) as platform_purchase, COALESCE(SUM(d.pixel_purchase), 0) as pixel_purchase, COALESCE(SUM(d.purchases_value / 1000000), 0) as purchases_value, - COALESCE(SUM(d.revenue / 1000000), 0) as revenue, + COALESCE(SUM(d.platform_purchase_value / 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'); @@ -921,7 +921,7 @@ class AdsInsightService COALESCE(SUM(d.platform_purchase), 0) as platform_purchase, COALESCE(SUM(d.pixel_purchase), 0) as pixel_purchase, COALESCE(SUM(d.purchases_value / 1000000), 0) as purchases_value, - COALESCE(SUM(d.revenue / 1000000), 0) as revenue, + COALESCE(SUM(d.platform_purchase_value / 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'); @@ -1010,7 +1010,7 @@ class AdsInsightService 'status' => $item['status'], 'platform_purchase' => number_format($item['platform_purchase']), 'pixel_purchase' => number_format($item['pixel_purchase']), - 'roas' => $item['spend'] == 0 ? '-' : round($item['purchases_value'] / $item['spend'], 2) . 'x', + 'roas' => $item['spend'] == 0 ? '-' : round($item['revenue'] / $item['spend'], 2) . 'x', 'spend' => '$' . number_format($item['spend'], 2), // 格式化支出 'impressions' => number_format($item['impressions']), 'clicks' => number_format($item['clicks']), @@ -1228,7 +1228,7 @@ class AdsInsightService COALESCE(SUM(d.platform_purchase), 0) as platform_purchase, COALESCE(SUM(d.pixel_purchase), 0) as pixel_purchase, COALESCE(SUM(d.purchases_value) / 1000000, 0) as purchases_value, - COALESCE(SUM(d.revenue) / 1000000, 0) as revenue, + COALESCE(SUM(d.platform_purchase_value) / 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'); @@ -1274,7 +1274,7 @@ class AdsInsightService $statistics = [ 'platform_purchase' => number_format(array_sum(array_column($allAccounts, 'platform_purchase'))), 'pixel_purchase' => number_format(array_sum(array_column($allAccounts, 'pixel_purchase'))), - 'roas' => $total_spend == 0 ? '-' : round($total_purchases_value / $total_spend, 2) . 'x', + 'roas' => $total_spend == 0 ? '-' : round($total_revenue / $total_spend, 2) . 'x', 'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出 'clicks' => number_format($total_clicks), 'impressions' => number_format($total_impressions), @@ -1321,7 +1321,7 @@ class AdsInsightService // 'status' => $item['status'], 'platform_purchase' => number_format($item['platform_purchase']), 'pixel_purchase' => number_format($item['pixel_purchase']), - 'roas' => $item['spend'] == 0 ? '-' : round($item['purchases_value'] / $item['spend'], 2) . 'x', + 'roas' => $item['spend'] == 0 ? '-' : round($item['revenue'] / $item['spend'], 2) . 'x', 'spend' => '$' . number_format($item['spend'], 2), // 格式化支出 'amount_spend' => '$' . number_format($item['spend'], 2), // 格式化支出 'impressions' => number_format($item['impressions']), @@ -1405,7 +1405,7 @@ class AdsInsightService COALESCE(SUM(d.platform_purchase), 0) as platform_purchase, COALESCE(SUM(d.pixel_purchase), 0) as pixel_purchase, COALESCE(SUM(d.purchases_value) / 1000000, 0) as purchases_value, - COALESCE(SUM(d.revenue) / 1000000, 0) as revenue, + COALESCE(SUM(d.platform_purchase_value / 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'); @@ -1463,7 +1463,7 @@ class AdsInsightService $statistics = [ 'platform_purchase' => number_format(array_sum(array_column($allAds, 'platform_purchase'))), 'pixel_purchase' => number_format(array_sum(array_column($allAds, 'pixel_purchase'))), - 'roas' => $total_spend == 0 ? '-' : round($total_purchases_value / $total_spend, 2) . 'x', + 'roas' => $total_spend == 0 ? '-' : round($total_revenue / $total_spend, 2) . 'x', 'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出 'clicks' => number_format($total_clicks), 'impressions' => number_format($total_impressions), @@ -1514,7 +1514,7 @@ class AdsInsightService 'status' => $item['status'], 'platform_purchase' => number_format($item['platform_purchase']), 'pixel_purchase' => number_format($item['pixel_purchase']), - 'roas' => $item['spend'] == 0 ? '-' : round($item['purchases_value'] / $item['spend'], 2) . 'x', + 'roas' => $item['spend'] == 0 ? '-' : round($item['revenue'] / $item['spend'], 2) . 'x', 'spend' => '$' . number_format($item['spend'], 2), // 格式化支出 'impressions' => number_format($item['impressions']), 'clicks' => number_format($item['clicks']),