统计字段 优化格式3
This commit is contained in:
parent
be584f926a
commit
ee5e3b7bbd
@ -237,15 +237,15 @@ class AdsInsightService
|
||||
$cost_per_purchase = $total_purchases == 0 ? 0 : round($total_spend / $total_purchases, 2);
|
||||
// 汇总统计数据
|
||||
$statistics = [
|
||||
'platform_purchase' => array_sum(array_column($allCampaigns, 'platform_purchase')),
|
||||
'pixel_purchase' => array_sum(array_column($allCampaigns, 'pixel_purchase')),
|
||||
'platform_purchase' => number_format(array_sum(array_column($allCampaigns, 'platform_purchase'))),
|
||||
'pixel_purchase' => number_format(array_sum(array_column($allCampaigns, 'pixel_purchase'))),
|
||||
'roas' => $total_spend == 0 ? '-' : round($total_revenue / $total_spend, 2) . 'x',
|
||||
'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出
|
||||
'clicks' => $total_clicks,
|
||||
'impressions' => $total_impressions,
|
||||
'adds_to_cart' => array_sum(array_column($allCampaigns, 'adds_to_cart')),
|
||||
'clicks' => number_format($total_clicks),
|
||||
'impressions' => number_format($total_impressions),
|
||||
'adds_to_cart' => number_format($adds_to_cart),
|
||||
'cost_per_atc' => $adds_to_cart == 0 ? '-' : '$' . number_format(($total_spend / $adds_to_cart), 2),
|
||||
'purchases' => array_sum(array_column($allCampaigns, 'purchases')),
|
||||
'purchases' => number_format($total_purchases),
|
||||
'purchases_value' => array_sum(array_column($allCampaigns, 'purchases_value')),
|
||||
'cost_per_purchase' => '$' . number_format($cost_per_purchase, 2) ?: '$0.00',
|
||||
'revenue' => '$' . number_format(array_sum(array_column($allCampaigns, 'revenue')), 2) ?: '$0.00', // 格式化收入
|
||||
@ -283,16 +283,16 @@ class AdsInsightService
|
||||
'account_id' => $item['account_id'], // 映射为 customer_id
|
||||
'name' => $item['name'] ?: '-', // 若 name 为空则显示 '-'
|
||||
'status' => $item['status'],
|
||||
'platform_purchase' => $item['platform_purchase'],
|
||||
'pixel_purchase' => $item['pixel_purchase'],
|
||||
'platform_purchase' => number_format($item['platform_purchase']),
|
||||
'pixel_purchase' => number_format($item['pixel_purchase']),
|
||||
'roas' => $item['spend'] == 0 ? '-' : round($item['revenue'] / $item['spend'], 2) . 'x',
|
||||
'spend' => '$' . number_format($item['spend'], 2), // 格式化支出
|
||||
'impressions' => $item['impressions'],
|
||||
'clicks' => $item['clicks'],
|
||||
'impressions' => number_format($item['impressions']),
|
||||
'clicks' => number_format($item['clicks']),
|
||||
'ctr' => $ctr, // CTR 字段
|
||||
'adds_to_cart' => $item['adds_to_cart'],
|
||||
'adds_to_cart' => number_format($item['adds_to_cart']),
|
||||
'cost_per_atc' => $item['adds_to_cart'] > 0 ? '$' . number_format(($item['spend'] / $item['adds_to_cart']), 2) : '-',
|
||||
'purchases' => $item['purchases'],
|
||||
'purchases' => number_format($item['purchases']),
|
||||
'purchases_value' => '$' . number_format($item['purchases_value'], 2), // 格式化购买金额
|
||||
'cost_per_purchase' => $item['purchases'] > 0 ? '$' . number_format(($item['spend'] / $item['purchases']), 2) : '-',
|
||||
'revenue' => '$' . number_format($item['revenue'], 2), // 格式化收入
|
||||
@ -940,15 +940,15 @@ class AdsInsightService
|
||||
|
||||
// 汇总统计数据
|
||||
$statistics = [
|
||||
'platform_purchase' => array_sum(array_column($allAdsets, 'platform_purchase')),
|
||||
'pixel_purchase' => array_sum(array_column($allAdsets, 'pixel_purchase')),
|
||||
'platform_purchase' => number_format(array_sum(array_column($allAdsets, 'platform_purchase'))),
|
||||
'pixel_purchase' => number_format(array_sum(array_column($allAdsets, 'pixel_purchase'))),
|
||||
'roas' => $total_spend == 0 ? '-' : round($total_revenue / $total_spend, 2) . 'x',
|
||||
'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出
|
||||
'clicks' => $total_clicks,
|
||||
'impressions' => array_sum(array_column($allAdsets, 'impressions')),
|
||||
'adds_to_cart' => array_sum(array_column($allAdsets, 'adds_to_cart')),
|
||||
'clicks' => number_format($total_clicks),
|
||||
'impressions' => number_format($total_impressions),
|
||||
'adds_to_cart' => number_format($adds_to_cart),
|
||||
'cost_per_atc' => $adds_to_cart == 0 ? '-' : '$' . number_format(($total_spend / $adds_to_cart), 2),
|
||||
'purchases' => array_sum(array_column($allAdsets, 'purchases')),
|
||||
'purchases' => number_format($total_purchases),
|
||||
'purchases_value' => array_sum(array_column($allAdsets, 'purchases_value')),
|
||||
'cost_per_purchase' => '$' . number_format($cost_per_purchase, 2) ?: '$0.00',
|
||||
'revenue' => '$' . number_format(array_sum(array_column($allAdsets, 'revenue')), 2) ?: '$0.00', // 格式化收入
|
||||
@ -985,16 +985,16 @@ class AdsInsightService
|
||||
'name' => $item['name'] ?: '-', // 若 name 为空则显示 '-'
|
||||
'campaign_name' => $item['campaign_name'] ?: '-', // 若 name 为空则显示 '-'
|
||||
'status' => $item['status'],
|
||||
'platform_purchase' => $item['platform_purchase'],
|
||||
'pixel_purchase' => $item['pixel_purchase'],
|
||||
'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',
|
||||
'spend' => '$' . number_format($item['spend'], 2), // 格式化支出
|
||||
'impressions' => $item['impressions'],
|
||||
'clicks' => $item['clicks'],
|
||||
'impressions' => number_format($item['impressions']),
|
||||
'clicks' => number_format($item['clicks']),
|
||||
'ctr' => $ctr, // CTR 字段
|
||||
'adds_to_cart' => $item['adds_to_cart'],
|
||||
'adds_to_cart' => number_format($item['adds_to_cart']),
|
||||
'cost_per_atc' => $item['adds_to_cart'] > 0 ? '$' . number_format(($item['spend'] / $item['adds_to_cart']), 2) : '-',
|
||||
'purchases' => $item['purchases'],
|
||||
'purchases' => number_format($item['purchases']),
|
||||
'purchases_value' => '$' . number_format($item['purchases_value'], 2), // 格式化购买金额
|
||||
'cost_per_purchase' => $item['purchases'] > 0 ? '$' . number_format(($item['spend'] / $item['purchases']), 2) : '-',
|
||||
'revenue' => '$' . number_format($item['revenue'], 2), // 格式化收入
|
||||
@ -1237,15 +1237,15 @@ class AdsInsightService
|
||||
$cost_per_purchase = $total_purchases == 0 ? 0 : round($total_spend / $total_purchases, 2);
|
||||
|
||||
$statistics = [
|
||||
'platform_purchase' => array_sum(array_column($allAccounts, 'platform_purchase')),
|
||||
'pixel_purchase' => array_sum(array_column($allAccounts, 'pixel_purchase')),
|
||||
'roas' => $total_spend == 0 ? '-' : round($total_purchases_value / $total_spend, 2),
|
||||
'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',
|
||||
'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出
|
||||
'clicks' => $total_clicks,
|
||||
'impressions' => array_sum(array_column($allAccounts, 'impressions')),
|
||||
'adds_to_cart' => array_sum(array_column($allAccounts, 'adds_to_cart')),
|
||||
'clicks' => number_format($total_clicks),
|
||||
'impressions' => number_format($total_impressions),
|
||||
'adds_to_cart' => number_format($adds_to_cart),
|
||||
'cost_per_atc' => $adds_to_cart == 0 ? '-' : '$' . number_format(($total_spend / $adds_to_cart), 2),
|
||||
'purchases' => array_sum(array_column($allAccounts, 'purchases')),
|
||||
'purchases' => number_format($total_purchases),
|
||||
'purchases_value' => array_sum(array_column($allAccounts, 'purchases_value')),
|
||||
'cost_per_purchase' => '$' . number_format($cost_per_purchase, 2) ?: '$0.00',
|
||||
'revenue' => '$' . number_format(array_sum(array_column($allAccounts, 'revenue')), 2) ?: '$0.00', // 格式化收入
|
||||
@ -1283,17 +1283,17 @@ class AdsInsightService
|
||||
'advertiser_name' => $item['advertiser_name'] ?: '-', // 若 name 为空则显示 '-'
|
||||
// 'ad_set_name' => $item['ad_set_name'] ?: '-', // 若 name 为空则显示 '-'
|
||||
// 'status' => $item['status'],
|
||||
'platform_purchase' => $item['platform_purchase'],
|
||||
'pixel_purchase' => $item['pixel_purchase'],
|
||||
'roas' => $item['spend'] == 0 ? '-' : round($item['purchases_value'] / $item['spend'], 2),
|
||||
'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',
|
||||
'spend' => '$' . number_format($item['spend'], 2), // 格式化支出
|
||||
'amount_spend' => '$' . number_format($item['spend'], 2), // 格式化支出
|
||||
'impressions' => $item['impressions'],
|
||||
'clicks' => $item['clicks'],
|
||||
'impressions' => number_format($item['impressions']),
|
||||
'clicks' => number_format($item['clicks']),
|
||||
'ctr' => $ctr, // CTR 字段
|
||||
'adds_to_cart' => $item['adds_to_cart'],
|
||||
'adds_to_cart' => number_format($item['adds_to_cart']),
|
||||
'cost_per_atc' => $item['adds_to_cart'] > 0 ? '$' . number_format(($item['spend'] / $item['adds_to_cart']), 2) : '-',
|
||||
'purchases' => $item['purchases'],
|
||||
'purchases' => number_format($item['purchases']),
|
||||
'purchases_value' => '$' . number_format($item['purchases_value'], 2), // 格式化购买金额
|
||||
'cost_per_purchase' => $item['purchases'] > 0 ? '$' . number_format(($item['spend'] / $item['purchases']), 2) : '-',
|
||||
'revenue' => '$' . number_format($item['revenue'], 2), // 格式化收入
|
||||
@ -1405,15 +1405,15 @@ class AdsInsightService
|
||||
$cost_per_purchase = $total_purchases == 0 ? 0 : round($total_spend / $total_purchases, 2);
|
||||
|
||||
$statistics = [
|
||||
'platform_purchase' => array_sum(array_column($allAds, 'platform_purchase')),
|
||||
'pixel_purchase' => array_sum(array_column($allAds, 'pixel_purchase')),
|
||||
'roas' => $total_spend == 0 ? '-' : round($total_purchases_value / $total_spend, 2),
|
||||
'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',
|
||||
'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出
|
||||
'clicks' => $total_clicks,
|
||||
'impressions' => array_sum(array_column($allAds, 'impressions')),
|
||||
'adds_to_cart' => array_sum(array_column($allAds, 'adds_to_cart')),
|
||||
'clicks' => number_format($total_clicks),
|
||||
'impressions' => number_format($total_impressions),
|
||||
'adds_to_cart' => number_format($adds_to_cart),
|
||||
'cost_per_atc' => $adds_to_cart == 0 ? '-' : '$' . number_format(($total_spend / $adds_to_cart), 2),
|
||||
'purchases' => array_sum(array_column($allAds, 'purchases')),
|
||||
'purchases' => number_format($total_purchases),
|
||||
'purchases_value' => array_sum(array_column($allAds, 'purchases_value')),
|
||||
'cost_per_purchase' => '$' . number_format($cost_per_purchase, 2) ?: '$0.00',
|
||||
'revenue' => '$' . number_format(array_sum(array_column($allAds, 'revenue')), 2) ?: '$0.00', // 格式化收入
|
||||
@ -1452,16 +1452,16 @@ class AdsInsightService
|
||||
'name' => $item['name'] ?: '-', // 若 name 为空则显示 '-'
|
||||
'ad_set_name' => $item['ad_set_name'] ?: '-', // 若 name 为空则显示 '-'
|
||||
'status' => $item['status'],
|
||||
'platform_purchase' => $item['platform_purchase'],
|
||||
'pixel_purchase' => $item['pixel_purchase'],
|
||||
'roas' => $item['spend'] == 0 ? '-' : round($item['purchases_value'] / $item['spend'], 2),
|
||||
'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',
|
||||
'spend' => '$' . number_format($item['spend'], 2), // 格式化支出
|
||||
'impressions' => $item['impressions'],
|
||||
'clicks' => $item['clicks'],
|
||||
'impressions' => number_format($item['impressions']),
|
||||
'clicks' => number_format($item['clicks']),
|
||||
'ctr' => $ctr, // CTR 字段
|
||||
'adds_to_cart' => $item['adds_to_cart'],
|
||||
'adds_to_cart' => number_format($item['adds_to_cart']),
|
||||
'cost_per_atc' => $item['adds_to_cart'] > 0 ? '$' . number_format(($item['spend'] / $item['adds_to_cart']), 2) : '-',
|
||||
'purchases' => $item['purchases'],
|
||||
'purchases' => number_format($item['purchases']),
|
||||
'purchases_value' => '$' . number_format($item['purchases_value'], 2), // 格式化购买金额
|
||||
'cost_per_purchase' => $item['purchases'] > 0 ? '$' . number_format(($item['spend'] / $item['purchases']), 2) : '-',
|
||||
'revenue' => '$' . number_format($item['revenue'], 2), // 格式化收入
|
||||
|
Loading…
Reference in New Issue
Block a user