From 41e00e570213e828a54b3fa59e213cc56e20a466 Mon Sep 17 00:00:00 2001
From: huangguancheng <huangguancheng@bestfulfill>
Date: Fri, 10 Jan 2025 10:56:44 +0800
Subject: [PATCH] fixed2

---
 app/service/AdsInsightService.php | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/app/service/AdsInsightService.php b/app/service/AdsInsightService.php
index dc64cdf..b334da7 100644
--- a/app/service/AdsInsightService.php
+++ b/app/service/AdsInsightService.php
@@ -98,7 +98,7 @@ class AdsInsightService
         $statistics = [
             'assisted_purchases' => array_sum(array_column($allCampaigns, 'assisted_purchases')),
             'last_clicked_purchases' => array_sum(array_column($allCampaigns, 'last_clicked_purchases')),
-            'roas' => $total_spend === 0 ? '-' : round($total_purchases_value / $total_spend, 2),
+            'roas' => $total_spend == 0 ? '-' : round($total_purchases_value / $total_spend, 2),
             'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出
             'clicks' => $total_clicks,
             'impressions' => $total_impressions,
@@ -236,7 +236,7 @@ class AdsInsightService
         $statistics = [
             'assisted_purchases' => array_sum(array_column($allAdsets, 'assisted_purchases')),
             'last_clicked_purchases' => array_sum(array_column($allAdsets, 'last_clicked_purchases')),
-            'roas' => $total_spend === 0 ? '-' : round($total_purchases_value / $total_spend, 2),
+            'roas' => $total_spend == 0 ? '-' : round($total_purchases_value / $total_spend, 2),
             'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出
             'clicks' => $total_clicks,
             'impressions' => array_sum(array_column($allAdsets, 'impressions')),
@@ -370,7 +370,7 @@ class AdsInsightService
         $statistics = [
             'assisted_purchases' => array_sum(array_column($allAds, 'assisted_purchases')),
             'last_clicked_purchases' => array_sum(array_column($allAds, 'last_clicked_purchases')),
-            'roas' => $total_spend === 0 ? '-' : round($total_purchases_value / $total_spend, 2),
+            'roas' => $total_spend == 0 ? '-' : round($total_purchases_value / $total_spend, 2),
             'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出
             'clicks' => $total_clicks,
             'impressions' => array_sum(array_column($allAds, 'impressions')),
@@ -516,7 +516,7 @@ class AdsInsightService
         $total_cost            = array_sum(array_column($allUsers, 'total_cost'));
 
         // 计算 ROAS
-        $roas = $total_spend === 0 ? '-' : round($total_purchases_value / $total_spend, 2);
+        $roas = $total_spend == 0 ? '-' : round($total_purchases_value / $total_spend, 2);
 
         // 计算 CTR
         $ctr = $total_impressions > 0 ? number_format(($total_clicks / $total_impressions) * 100, 2) . '%' : '-';
@@ -525,7 +525,7 @@ class AdsInsightService
         $statistics = [
             'assisted_purchases' => 0,
             'last_clicked_purchases' => 0,
-            'roas' => $total_spend === 0 ? '-' : round($total_purchases_value / $total_spend, 2),
+            'roas' => $total_spend == 0 ? '-' : round($total_purchases_value / $total_spend, 2),
             'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出
             'clicks' => $total_clicks,
             'impressions' => $total_impressions,
@@ -605,13 +605,13 @@ class AdsInsightService
 //            $total_last_clicked_purchases = $data['last_clicked_purchases'];
 
             // 计算 ROAS, CTR 和其他需要的字段
-            $aggregatedUsers[$userId]['roas']            = $total_spend === 0 ? '-' : round($total_purchases_value / $total_spend, 2);
+            $aggregatedUsers[$userId]['roas']            = $total_spend == 0 ? '-' : round($total_purchases_value / $total_spend, 2);
             $aggregatedUsers[$userId]['amount_spend']    = '$' . number_format($total_spend, 2) ?: '$0.00';
             $aggregatedUsers[$userId]['purchases_value'] = '$' . number_format($total_purchases_value, 2) ?: '$0.00';
             $aggregatedUsers[$userId]['revenue']         = '$' . number_format($total_revenue, 2) ?: '$0.00';
             $aggregatedUsers[$userId]['total_cost']      = '$' . number_format($total_cost, 2) ?: '$0.00';
-            $aggregatedUsers[$userId]['conversion_rate'] = $total_impressions === 0 ? '-' : round(($total_clicks / $total_impressions) * 100, 2) . '%';
-            $aggregatedUsers[$userId]['ctr']             = $total_impressions === 0 ? '-' : round(($total_clicks / $total_impressions) * 100, 2) . '%';
+            $aggregatedUsers[$userId]['conversion_rate'] = $total_impressions == 0 ? '-' : round(($total_clicks / $total_impressions) * 100, 2) . '%';
+            $aggregatedUsers[$userId]['ctr']             = $total_impressions == 0 ? '-' : round(($total_clicks / $total_impressions) * 100, 2) . '%';
         }
 
         // 最终分页信息