修复cost_per_purchase计算Bug
This commit is contained in:
		
							parent
							
								
									71470ca94c
								
							
						
					
					
						commit
						c395cf5c60
					
				@ -1268,8 +1268,9 @@ class AdsInsightService
 | 
			
		||||
        $total_purchases_value = array_sum(array_column($allAccounts, 'purchases_value'));
 | 
			
		||||
        $total_revenue         = array_sum(array_column($allAccounts, 'revenue'));
 | 
			
		||||
        $total_purchases       = array_sum(array_column($allAccounts, 'purchases'));
 | 
			
		||||
        $total_platform_purchase    = array_sum(array_column($allAccounts, 'platform_purchase'));
 | 
			
		||||
        $adds_to_cart          = array_sum(array_column($allAccounts, 'adds_to_cart'));
 | 
			
		||||
        $cost_per_purchase     = $total_purchases == 0 ? 0 : round($total_spend / $total_purchases, 2);
 | 
			
		||||
        $cost_per_purchase     = $total_platform_purchase == 0 ? 0 : round($total_cost / $total_platform_purchase, 2);
 | 
			
		||||
 | 
			
		||||
        $statistics = [
 | 
			
		||||
            'platform_purchase' => number_format(array_sum(array_column($allAccounts, 'platform_purchase'))),
 | 
			
		||||
@ -1331,7 +1332,7 @@ class AdsInsightService
 | 
			
		||||
                'cost_per_atc' => $item['adds_to_cart'] > 0 ? '$' . number_format(($item['spend'] / $item['adds_to_cart']), 2) : '-',
 | 
			
		||||
                '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) : '-',
 | 
			
		||||
                'cost_per_purchase' => $item['platform_purchase'] > 0 ? '$' . number_format(($item['spend'] / $item['platform_purchase']), 2) : '-',
 | 
			
		||||
                'revenue' => '$' . number_format($item['revenue'], 2),  // 格式化收入
 | 
			
		||||
                'total_cost' => '$' . number_format($item['total_cost'], 2),  // 格式化总成本
 | 
			
		||||
                'conversion_rate' => $conversion_rate,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user