统计字段 优化格式
This commit is contained in:
		
							parent
							
								
									5d6467f75f
								
							
						
					
					
						commit
						549ac512ec
					
				| @ -133,7 +133,7 @@ class AdsDashboardService | |||||||
|                 'meta_conversion_value' => 'platform_purchase_value', |                 'meta_conversion_value' => 'platform_purchase_value', | ||||||
|                 'web_conversion_value' => 'purchases_value', |                 'web_conversion_value' => 'purchases_value', | ||||||
|                 'conversion_value' => 'purchases_value', |                 'conversion_value' => 'purchases_value', | ||||||
|                 'cpoc' => '', |                 'cpoc' => 'cpoc', | ||||||
|                 'ctr' => 'ctr', |                 'ctr' => 'ctr', | ||||||
|                 'revenue_per_link_click' => 'revenue_per_link_click', |                 'revenue_per_link_click' => 'revenue_per_link_click', | ||||||
|                 'cpa' => 'cpa', |                 'cpa' => 'cpa', | ||||||
| @ -234,13 +234,13 @@ class AdsDashboardService | |||||||
|                             $value = '$' . number_format($platform_purchase_value, 2); |                             $value = '$' . number_format($platform_purchase_value, 2); | ||||||
|                             break; |                             break; | ||||||
|                         case 'roas': |                         case 'roas': | ||||||
|                             $value = round($roas, 2) . 'X'; |                             $value = round($roas, 2) . 'x'; | ||||||
|                             break; |                             break; | ||||||
|                         case 'google_roas': |                         case 'google_roas': | ||||||
|                             $value = round($google_roas, 2) . 'X'; |                             $value = round($google_roas, 2) . 'x'; | ||||||
|                             break; |                             break; | ||||||
|                         case 'cpoc': |                         case 'cpoc': | ||||||
|                             $value = '$' . number_format($cpoc, 2) . '%'; |                             $value = '$' . number_format($cpoc, 2); | ||||||
|                             break; |                             break; | ||||||
|                         case 'ctr': |                         case 'ctr': | ||||||
|                             $value = number_format($ctr * 100, 2) . '%'; |                             $value = number_format($ctr * 100, 2) . '%'; | ||||||
|  | |||||||
| @ -239,7 +239,7 @@ class AdsInsightService | |||||||
|         $statistics = [ |         $statistics = [ | ||||||
|             'platform_purchase' => array_sum(array_column($allCampaigns, 'platform_purchase')), |             'platform_purchase' => array_sum(array_column($allCampaigns, 'platform_purchase')), | ||||||
|             'pixel_purchase' => array_sum(array_column($allCampaigns, 'pixel_purchase')), |             'pixel_purchase' => array_sum(array_column($allCampaigns, 'pixel_purchase')), | ||||||
|             'roas' => $total_spend == 0 ? '-' : round($total_revenue / $total_spend, 2) . 'X', |             'roas' => $total_spend == 0 ? '-' : round($total_revenue / $total_spend, 2) . 'x', | ||||||
|             'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出
 |             'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出
 | ||||||
|             'clicks' => $total_clicks, |             'clicks' => $total_clicks, | ||||||
|             'impressions' => $total_impressions, |             'impressions' => $total_impressions, | ||||||
| @ -285,7 +285,7 @@ class AdsInsightService | |||||||
|                 'status' => $item['status'], |                 'status' => $item['status'], | ||||||
|                 'platform_purchase' => $item['platform_purchase'], |                 'platform_purchase' => $item['platform_purchase'], | ||||||
|                 'pixel_purchase' => $item['pixel_purchase'], |                 'pixel_purchase' => $item['pixel_purchase'], | ||||||
|                 'roas' => $item['spend'] == 0 ? '-' : round($item['revenue'] / $item['spend'], 2) . 'X', |                 'roas' => $item['spend'] == 0 ? '-' : round($item['revenue'] / $item['spend'], 2) . 'x', | ||||||
|                 'spend' => '$' . number_format($item['spend'], 2),  // 格式化支出
 |                 'spend' => '$' . number_format($item['spend'], 2),  // 格式化支出
 | ||||||
|                 'impressions' => $item['impressions'], |                 'impressions' => $item['impressions'], | ||||||
|                 'clicks' => $item['clicks'], |                 'clicks' => $item['clicks'], | ||||||
| @ -940,7 +940,7 @@ class AdsInsightService | |||||||
|         $statistics = [ |         $statistics = [ | ||||||
|             'platform_purchase' => array_sum(array_column($allAdsets, 'platform_purchase')), |             'platform_purchase' => array_sum(array_column($allAdsets, 'platform_purchase')), | ||||||
|             'pixel_purchase' => array_sum(array_column($allAdsets, 'pixel_purchase')), |             'pixel_purchase' => array_sum(array_column($allAdsets, 'pixel_purchase')), | ||||||
|             'roas' => $total_spend == 0 ? '-' : round($total_revenue / $total_spend, 2) . 'X', |             'roas' => $total_spend == 0 ? '-' : round($total_revenue / $total_spend, 2) . 'x', | ||||||
|             'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出
 |             'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出
 | ||||||
|             'clicks' => $total_clicks, |             'clicks' => $total_clicks, | ||||||
|             'impressions' => array_sum(array_column($allAdsets, 'impressions')), |             'impressions' => array_sum(array_column($allAdsets, 'impressions')), | ||||||
| @ -985,7 +985,7 @@ class AdsInsightService | |||||||
|                 'status' => $item['status'], |                 'status' => $item['status'], | ||||||
|                 'platform_purchase' => $item['platform_purchase'], |                 'platform_purchase' => $item['platform_purchase'], | ||||||
|                 'pixel_purchase' => $item['pixel_purchase'], |                 'pixel_purchase' => $item['pixel_purchase'], | ||||||
|                 'roas' => $item['spend'] == 0 ? '-' : round($item['purchases_value'] / $item['spend'], 2) . 'X', |                 'roas' => $item['spend'] == 0 ? '-' : round($item['purchases_value'] / $item['spend'], 2) . 'x', | ||||||
|                 'spend' => '$' . number_format($item['spend'], 2),  // 格式化支出
 |                 'spend' => '$' . number_format($item['spend'], 2),  // 格式化支出
 | ||||||
|                 'impressions' => $item['impressions'], |                 'impressions' => $item['impressions'], | ||||||
|                 'clicks' => $item['clicks'], |                 'clicks' => $item['clicks'], | ||||||
| @ -1947,7 +1947,7 @@ class AdsInsightService | |||||||
|         $statistics = [ |         $statistics = [ | ||||||
|             'spend' => '$' . number_format($statisticsData['spend'], 2),  // 格式化金额
 |             'spend' => '$' . number_format($statisticsData['spend'], 2),  // 格式化金额
 | ||||||
|             'purchases_value' => '$' . number_format($statisticsData['purchases_value'], 2),  // 格式化金额
 |             'purchases_value' => '$' . number_format($statisticsData['purchases_value'], 2),  // 格式化金额
 | ||||||
|             'roas' => $statisticsData['spend'] == 0 ? '-' : round($statisticsData['purchases_value'] / $statisticsData['spend'], 2) . 'X', |             'roas' => $statisticsData['spend'] == 0 ? '-' : round($statisticsData['purchases_value'] / $statisticsData['spend'], 2) . 'x', | ||||||
|             'cpa' => $statisticsData['purchases'] == 0 ? '-' : '$' . number_format($statisticsData['spend'] / $statisticsData['purchases'], 2), |             'cpa' => $statisticsData['purchases'] == 0 ? '-' : '$' . number_format($statisticsData['spend'] / $statisticsData['purchases'], 2), | ||||||
|             'cpc_link_click' => $statisticsData['link_clicks'] == 0 ? '-' : '$' . number_format($statisticsData['spend'] / $statisticsData['link_clicks'], 2), |             'cpc_link_click' => $statisticsData['link_clicks'] == 0 ? '-' : '$' . number_format($statisticsData['spend'] / $statisticsData['link_clicks'], 2), | ||||||
|             'cpm' => $statisticsData['impressions'] == 0 ? '-' : '$' . number_format($statisticsData['spend'] * 1000 / $statisticsData['impressions'], 2), // sum(spend) * 1000 / sum(Impression)
 |             'cpm' => $statisticsData['impressions'] == 0 ? '-' : '$' . number_format($statisticsData['spend'] * 1000 / $statisticsData['impressions'], 2), // sum(spend) * 1000 / sum(Impression)
 | ||||||
| @ -2017,7 +2017,7 @@ class AdsInsightService | |||||||
|                 'thumbnail_url' => $item['thumbnail_url'], |                 'thumbnail_url' => $item['thumbnail_url'], | ||||||
|                 'spend' => '$' . number_format($item['spend'], 2), |                 'spend' => '$' . number_format($item['spend'], 2), | ||||||
|                 'purchases_value' => '$' . number_format($item['purchases_value'], 2), |                 'purchases_value' => '$' . number_format($item['purchases_value'], 2), | ||||||
|                 'roas' => $item['spend'] == 0 ? '-' : round($item['purchases_value'] / $item['spend'], 2) . 'X', |                 'roas' => $item['spend'] == 0 ? '-' : round($item['purchases_value'] / $item['spend'], 2) . 'x', | ||||||
|                 'cpa' => $item['purchases'] == 0 ? '-' : '$' . number_format($item['spend'] / $item['purchases'], 2), |                 'cpa' => $item['purchases'] == 0 ? '-' : '$' . number_format($item['spend'] / $item['purchases'], 2), | ||||||
|                 'cpc_link_click' => $item['link_clicks'] == 0 ? '-' : '$' . number_format($item['spend'] / $item['link_clicks'], 2), |                 'cpc_link_click' => $item['link_clicks'] == 0 ? '-' : '$' . number_format($item['spend'] / $item['link_clicks'], 2), | ||||||
|                 'cpm' => $item['impressions'] == 0 ? '-' : '$' . number_format($item['spend'] * 1000 / $item['impressions'], 2), |                 'cpm' => $item['impressions'] == 0 ? '-' : '$' . number_format($item['spend'] * 1000 / $item['impressions'], 2), | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 huangguancheng
						huangguancheng