From c395cf5c60585fcb6254d7352798ab7e99566745 Mon Sep 17 00:00:00 2001 From: hansen Date: Mon, 1 Sep 2025 17:41:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcost=5Fper=5Fpurchase?= =?UTF-8?q?=E8=AE=A1=E7=AE=97Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/AdsInsightService.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/service/AdsInsightService.php b/app/service/AdsInsightService.php index f854155..b4e77dd 100644 --- a/app/service/AdsInsightService.php +++ b/app/service/AdsInsightService.php @@ -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,