diff --git a/app/service/AdsInsightService.php b/app/service/AdsInsightService.php index 8e24687..a474bb9 100644 --- a/app/service/AdsInsightService.php +++ b/app/service/AdsInsightService.php @@ -194,13 +194,13 @@ class AdsInsightService } $query->leftJoin('bps.bps_ads_insights d', "c.campaign_id = d.ad_campaign_id AND c.platform_type = d.platform AND {$dateCondition}") ->field('c.campaign_id, c.status as status, c.name, c.account_id,c.platform_type, - COALESCE(SUM(d.assisted_purchases), 0) as assisted_purchases, - COALESCE(SUM(d.last_clicked_purchases), 0) as last_clicked_purchases, COALESCE(SUM(d.clicks), 0) as clicks, COALESCE(SUM(d.spend) / 1000000, 0) as spend, COALESCE(SUM(d.impressions), 0) as impressions, COALESCE(SUM(d.adds_to_cart), 0) as adds_to_cart, COALESCE(SUM(d.purchases), 0) as purchases, + COALESCE(SUM(d.platform_purchase), 0) as platform_purchase, + COALESCE(SUM(d.pixel_purchase), 0) as pixel_purchase, COALESCE(SUM(d.purchases_value / 1000000), 0) as purchases_value, COALESCE(SUM(d.revenue / 1000000), 0) as revenue, COALESCE(SUM(d.total_cost / 1000000), 0) as total_cost, @@ -224,19 +224,21 @@ class AdsInsightService // 获取所有符合条件的数据(不分页) $allCampaigns = $query->select()->toArray(); - $total_spend = array_sum(array_column($allCampaigns, 'spend')); - $total_cost = array_sum(array_column($allCampaigns, 'total_cost')); - $total_impressions = array_sum(array_column($allCampaigns, 'impressions')); - $total_clicks = array_sum(array_column($allCampaigns, 'clicks')); - $total_purchases_value = array_sum(array_column($allCampaigns, 'purchases_value')); - $total_revenue = array_sum(array_column($allCampaigns, 'revenue')); - $total_purchases = array_sum(array_column($allCampaigns, 'purchases')); - $adds_to_cart = array_sum(array_column($allCampaigns, 'adds_to_cart')); - $cost_per_purchase = $total_purchases == 0 ? 0 : round($total_spend / $total_purchases, 2); + $total_spend = array_sum(array_column($allCampaigns, 'spend')); + $total_cost = array_sum(array_column($allCampaigns, 'total_cost')); + $total_impressions = array_sum(array_column($allCampaigns, 'impressions')); + $total_clicks = array_sum(array_column($allCampaigns, 'clicks')); + $total_purchases_value = array_sum(array_column($allCampaigns, 'purchases_value')); + $total_revenue = array_sum(array_column($allCampaigns, 'revenue')); + $total_purchases = array_sum(array_column($allCampaigns, 'purchases')); +// $total_platform_purchase = array_sum(array_column($allCampaigns, 'platform_purchase')); +// $total_pixel_purchase = array_sum(array_column($allCampaigns, 'pixel_purchase')); + $adds_to_cart = array_sum(array_column($allCampaigns, 'adds_to_cart')); + $cost_per_purchase = $total_purchases == 0 ? 0 : round($total_spend / $total_purchases, 2); // 汇总统计数据 $statistics = [ - 'assisted_purchases' => array_sum(array_column($allCampaigns, 'assisted_purchases')), - 'last_clicked_purchases' => array_sum(array_column($allCampaigns, 'last_clicked_purchases')), + 'platform_purchase' => array_sum(array_column($allCampaigns, 'platform_purchase')), + 'pixel_purchase' => 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, @@ -281,8 +283,8 @@ class AdsInsightService 'account_id' => $item['account_id'], // 映射为 customer_id 'name' => $item['name'] ?: '-', // 若 name 为空则显示 '-' 'status' => $item['status'], - 'assisted_purchases' => $item['assisted_purchases'], - 'last_clicked_purchases' => $item['last_clicked_purchases'], + 'platform_purchase' => $item['platform_purchase'], + 'pixel_purchase' => $item['pixel_purchase'], 'roas' => $item['spend'] == 0 ? '-' : round($item['revenue'] / $item['spend'], 2) . 'X', 'spend' => '$' . number_format($item['spend'], 2), // 格式化支出 'impressions' => $item['impressions'], @@ -355,8 +357,8 @@ class AdsInsightService 'B1' => 'Status', 'C1' => 'Ad Platform', // 修正为 Ad Platform 'D1' => 'Ad Accounts', // 修正为 Ad Accounts - 'E1' => 'Assisted Purchases', - 'F1' => 'Last-clicked Purchases', + 'E1' => 'Platform Purchases', + 'F1' => 'Best Pixel Purchases', 'G1' => 'ROAS', 'H1' => 'Amount Spent', 'I1' => 'Impressions', @@ -386,8 +388,8 @@ class AdsInsightService $sheet->setCellValue('B' . $row, self::$statusMapping[$campaign['status']]); // Status $sheet->setCellValue('C' . $row, self::$platformMapping[$campaign['platform_type']]); // Platform Type $sheet->setCellValueExplicit('D' . $row, (string)$campaign['account_id'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); - $sheet->setCellValue('E' . $row, $campaign['assisted_purchases']); // Assisted Purchases - $sheet->setCellValue('F' . $row, $campaign['last_clicked_purchases']); // Last-clicked Purchases + $sheet->setCellValue('E' . $row, $campaign['platform_purchase']); // Assisted Purchases + $sheet->setCellValue('F' . $row, $campaign['pixel_purchase']); // Last-clicked Purchases $sheet->setCellValue('G' . $row, $campaign['roas']); // ROAS $sheet->setCellValue('H' . $row, $campaign['spend']); // Amount Spent $sheet->setCellValue('I' . $row, $campaign['impressions']); // Impressions @@ -410,8 +412,8 @@ class AdsInsightService $statistics = $campaignList['statistics']; $statisticsRow = $row; // 统计信息从当前行开始 $sheet->setCellValue('D' . $statisticsRow, 'Totals'); // 统计信息标题 - $sheet->setCellValue('E' . $statisticsRow, $statistics['assisted_purchases']); // Assisted Purchases - $sheet->setCellValue('F' . $statisticsRow, $statistics['last_clicked_purchases']); // Last-clicked Purchases + $sheet->setCellValue('E' . $statisticsRow, $statistics['platform_purchase']); // Platform Purchases + $sheet->setCellValue('F' . $statisticsRow, $statistics['pixel_purchase']); // Pixel Purchases $sheet->setCellValue('G' . $statisticsRow, $statistics['roas']); // ROAS $sheet->setCellValue('H' . $statisticsRow, $statistics['amount_spend']); // Amount Spent $sheet->setCellValue('I' . $statisticsRow, $statistics['impressions']); // Impressions @@ -487,8 +489,8 @@ class AdsInsightService 'B1' => 'Status', 'C1' => 'Ad Platform', // 修正为 Ad Platform 'D1' => 'Ad Accounts', // 修正为 Ad Accounts - 'E1' => 'Assisted Purchases', - 'F1' => 'Last-clicked Purchases', + 'E1' => 'Platform Purchases', + 'F1' => 'Best Pixel Purchases', 'G1' => 'ROAS', 'H1' => 'Amount Spent', 'I1' => 'Impressions', @@ -518,8 +520,8 @@ class AdsInsightService $sheet->setCellValue('B' . $row, self::$statusMapping[$adset['status']]); // Status $sheet->setCellValue('C' . $row, self::$platformMapping[$adset['platform_type']]); // Platform Type $sheet->setCellValueExplicit('D' . $row, (string)$adset['account_id'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); - $sheet->setCellValue('E' . $row, $adset['assisted_purchases']); // Assisted Purchases - $sheet->setCellValue('F' . $row, $adset['last_clicked_purchases']); // Last-clicked Purchases + $sheet->setCellValue('E' . $row, $adset['platform_purchase']); // Assisted Purchases + $sheet->setCellValue('F' . $row, $adset['pixel_purchase']); // Last-clicked Purchases $sheet->setCellValue('G' . $row, $adset['roas']); // ROAS $sheet->setCellValue('H' . $row, $adset['spend']); // Amount Spent $sheet->setCellValue('I' . $row, $adset['impressions']); // Impressions @@ -542,8 +544,8 @@ class AdsInsightService $statistics = $adsetList['statistics']; $statisticsRow = $row; // 统计信息从当前行开始 $sheet->setCellValue('D' . $statisticsRow, 'Totals'); // 统计信息标题 - $sheet->setCellValue('E' . $statisticsRow, $statistics['assisted_purchases']); // Assisted Purchases - $sheet->setCellValue('F' . $statisticsRow, $statistics['last_clicked_purchases']); // Last-clicked Purchases + $sheet->setCellValue('E' . $statisticsRow, $statistics['platform_purchase']); // Assisted Purchases + $sheet->setCellValue('F' . $statisticsRow, $statistics['pixel_purchase']); // Last-clicked Purchases $sheet->setCellValue('G' . $statisticsRow, $statistics['roas']); // ROAS $sheet->setCellValue('H' . $statisticsRow, $statistics['amount_spend']); // Amount Spent $sheet->setCellValue('I' . $statisticsRow, $statistics['impressions']); // Impressions @@ -619,8 +621,8 @@ class AdsInsightService 'B1' => 'Status', 'C1' => 'Ad Platform', // 修正为 Ad Platform 'D1' => 'Ad Accounts', // 修正为 Ad Accounts - 'E1' => 'Assisted Purchases', - 'F1' => 'Last-clicked Purchases', + 'E1' => 'Platform Purchases', + 'F1' => 'Best Pixel Purchases', 'G1' => 'ROAS', 'H1' => 'Amount Spent', 'I1' => 'Impressions', @@ -650,8 +652,8 @@ class AdsInsightService $sheet->setCellValue('B' . $row, self::$statusMapping[$ad['status']]); // Status $sheet->setCellValue('C' . $row, self::$platformMapping[$ad['platform_type']]); // Platform Type $sheet->setCellValueExplicit('D' . $row, (string)$ad['account_id'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); - $sheet->setCellValue('E' . $row, $ad['assisted_purchases']); // Assisted Purchases - $sheet->setCellValue('F' . $row, $ad['last_clicked_purchases']); // Last-clicked Purchases + $sheet->setCellValue('E' . $row, $ad['platform_purchase']); // Assisted Purchases + $sheet->setCellValue('F' . $row, $ad['pixel_purchase']); // Last-clicked Purchases $sheet->setCellValue('G' . $row, $ad['roas']); // ROAS $sheet->setCellValue('H' . $row, $ad['spend']); // Amount Spent $sheet->setCellValue('I' . $row, $ad['impressions']); // Impressions @@ -674,8 +676,8 @@ class AdsInsightService $statistics = $adList['statistics']; $statisticsRow = $row; // 统计信息从当前行开始 $sheet->setCellValue('D' . $statisticsRow, 'Totals'); // 统计信息标题 - $sheet->setCellValue('E' . $statisticsRow, $statistics['assisted_purchases']); // Assisted Purchases - $sheet->setCellValue('F' . $statisticsRow, $statistics['last_clicked_purchases']); // Last-clicked Purchases + $sheet->setCellValue('E' . $statisticsRow, $statistics['platform_purchase']); // Assisted Purchases + $sheet->setCellValue('F' . $statisticsRow, $statistics['pixel_purchase']); // Last-clicked Purchases $sheet->setCellValue('G' . $statisticsRow, $statistics['roas']); // ROAS $sheet->setCellValue('H' . $statisticsRow, $statistics['amount_spend']); // Amount Spent $sheet->setCellValue('I' . $statisticsRow, $statistics['impressions']); // Impressions @@ -890,13 +892,13 @@ class AdsInsightService $query->leftJoin('bps.bps_ads_insights d', "s.ad_set_id = d.ad_set_id AND s.platform_type = d.platform AND {$dateCondition}") ->leftJoin('bps.bps_ads_campaign c', 's.campaign_id = c.campaign_id') // 联接广告系列表 ->field('s.ad_set_id, s.status as status, s.name, s.account_id,s.platform_type,c.name as campaign_name, - COALESCE(SUM(d.assisted_purchases), 0) as assisted_purchases, - COALESCE(SUM(d.last_clicked_purchases), 0) as last_clicked_purchases, COALESCE(SUM(d.clicks), 0) as clicks, COALESCE(SUM(d.spend) / 1000000, 0) as spend, COALESCE(SUM(d.impressions), 0) as impressions, COALESCE(SUM(d.adds_to_cart), 0) as adds_to_cart, COALESCE(SUM(d.purchases), 0) as purchases, + COALESCE(SUM(d.platform_purchase), 0) as platform_purchase, + COALESCE(SUM(d.pixel_purchase), 0) as pixel_purchase, COALESCE(SUM(d.purchases_value / 1000000), 0) as purchases_value, COALESCE(SUM(d.revenue / 1000000), 0) as revenue, COALESCE(SUM(d.total_cost / 1000000), 0) as total_cost, @@ -929,13 +931,15 @@ class AdsInsightService $total_purchases_value = array_sum(array_column($allAdsets, 'purchases_value')); $total_revenue = array_sum(array_column($allAdsets, 'revenue')); $total_purchases = array_sum(array_column($allAdsets, 'purchases')); +// $total_platform_purchase = array_sum(array_column($allAdsets, 'platform_purchase')); +// $total_pixel_purchase = array_sum(array_column($allAdsets, 'pixel_purchase')); $adds_to_cart = array_sum(array_column($allAdsets, 'adds_to_cart')); $cost_per_purchase = $total_purchases == 0 ? 0 : round($total_spend / $total_purchases, 2); // 汇总统计数据 $statistics = [ - 'assisted_purchases' => array_sum(array_column($allAdsets, 'assisted_purchases')), - 'last_clicked_purchases' => array_sum(array_column($allAdsets, 'last_clicked_purchases')), + 'platform_purchase' => array_sum(array_column($allAdsets, 'platform_purchase')), + 'pixel_purchase' => 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, @@ -979,8 +983,8 @@ class AdsInsightService 'name' => $item['name'] ?: '-', // 若 name 为空则显示 '-' 'campaign_name' => $item['campaign_name'] ?: '-', // 若 name 为空则显示 '-' 'status' => $item['status'], - 'assisted_purchases' => $item['assisted_purchases'], - 'last_clicked_purchases' => $item['last_clicked_purchases'], + 'platform_purchase' => $item['platform_purchase'], + 'pixel_purchase' => $item['pixel_purchase'], 'roas' => $item['spend'] == 0 ? '-' : round($item['purchases_value'] / $item['spend'], 2) . 'X', 'spend' => '$' . number_format($item['spend'], 2), // 格式化支出 'impressions' => $item['impressions'], @@ -1083,8 +1087,8 @@ class AdsInsightService $sheet->setCellValueExplicit('A' . $row, (string)$account['user_id'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); // Ad Account Id $sheet->setCellValue('B' . $row, $account['advertiser_name']); // Advertiser Name $sheet->setCellValue('C' . $row, self::$platformMapping[$account['platform_type']]); // Ad Platform - $sheet->setCellValue('D' . $row, $account['assisted_purchases']); // Assisted Purchases(原 E 列) - $sheet->setCellValue('E' . $row, $account['last_clicked_purchases']); // Last-clicked Purchases(原 F 列) + $sheet->setCellValue('D' . $row, $account['platform_purchase']); // Assisted Purchases(原 E 列) + $sheet->setCellValue('E' . $row, $account['pixel_purchase']); // Last-clicked Purchases(原 F 列) $sheet->setCellValue('F' . $row, $account['roas']); // ROAS(原 G 列) $sheet->setCellValue('G' . $row, $account['spend']); // Amount Spent(原 H 列) $sheet->setCellValue('H' . $row, $account['impressions']); // Impressions(原 I 列) @@ -1107,8 +1111,8 @@ class AdsInsightService $statistics = $accountList['statistics']; $statisticsRow = $row; // 统计信息从当前行开始 $sheet->setCellValue('C' . $statisticsRow, 'Totals'); // 统计信息标题(调整到 A 列) - $sheet->setCellValue('D' . $statisticsRow, $statistics['assisted_purchases']); // Assisted Purchases(原 E 列) - $sheet->setCellValue('E' . $statisticsRow, $statistics['last_clicked_purchases']); // Last-clicked Purchases(原 F 列) + $sheet->setCellValue('D' . $statisticsRow, $statistics['platform_purchase']); + $sheet->setCellValue('E' . $statisticsRow, $statistics['pixel_purchase']); $sheet->setCellValue('F' . $statisticsRow, $statistics['roas']); // ROAS(原 G 列) $sheet->setCellValue('G' . $statisticsRow, $statistics['amount_spend']); // Amount Spent(原 H 列) $sheet->setCellValue('H' . $statisticsRow, $statistics['impressions']); // Impressions(原 I 列) @@ -1186,13 +1190,13 @@ class AdsInsightService $query->leftJoin('bps.bps_ads_insights d', "a.advertiser_id = d.account_id AND {$dateCondition}") ->leftJoin('bps.bps_third_user u', 'a.doc_ = u.id') ->field('a.advertiser_id, a.advertiser_name,u.third_type, - COALESCE(SUM(d.assisted_purchases), 0) as assisted_purchases, - COALESCE(SUM(d.last_clicked_purchases), 0) as last_clicked_purchases, COALESCE(SUM(d.clicks), 0) as clicks, COALESCE(SUM(d.spend) / 1000000, 0) as spend, COALESCE(SUM(d.impressions), 0) as impressions, COALESCE(SUM(d.adds_to_cart), 0) as adds_to_cart, COALESCE(SUM(d.purchases), 0) as purchases, + COALESCE(SUM(d.platform_purchase), 0) as platform_purchase, + COALESCE(SUM(d.pixel_purchase), 0) as pixel_purchase, COALESCE(SUM(d.purchases_value) / 1000000, 0) as purchases_value, COALESCE(SUM(d.revenue) / 1000000, 0) as revenue, COALESCE(SUM(d.total_cost) / 1000000, 0) as total_cost, @@ -1231,8 +1235,8 @@ class AdsInsightService $cost_per_purchase = $total_purchases == 0 ? 0 : round($total_spend / $total_purchases, 2); $statistics = [ - 'assisted_purchases' => array_sum(array_column($allAccounts, 'assisted_purchases')), - 'last_clicked_purchases' => array_sum(array_column($allAccounts, 'last_clicked_purchases')), + '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), 'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出 'clicks' => $total_clicks, @@ -1277,8 +1281,8 @@ class AdsInsightService 'advertiser_name' => $item['advertiser_name'] ?: '-', // 若 name 为空则显示 '-' // 'ad_set_name' => $item['ad_set_name'] ?: '-', // 若 name 为空则显示 '-' // 'status' => $item['status'], - 'assisted_purchases' => $item['assisted_purchases'], - 'last_clicked_purchases' => $item['last_clicked_purchases'], + 'platform_purchase' => $item['platform_purchase'], + 'pixel_purchase' => $item['pixel_purchase'], 'roas' => $item['spend'] == 0 ? '-' : round($item['purchases_value'] / $item['spend'], 2), 'spend' => '$' . number_format($item['spend'], 2), // 格式化支出 'amount_spend' => '$' . number_format($item['spend'], 2), // 格式化支出 @@ -1355,13 +1359,13 @@ class AdsInsightService $query->leftJoin('bps.bps_ads_insights d', "a.ad_id = d.ad_id AND a.platform_type = d.platform AND {$dateCondition}") ->leftJoin('bps.bps_ads_set s', 'a.ad_set_id = s.ad_set_id') // 联接广告组表,获取 ad_set_name ->field('a.ad_id, a.status as status, a.name, a.account_id,a.platform_type,s.name as ad_set_name, - COALESCE(SUM(d.assisted_purchases), 0) as assisted_purchases, - COALESCE(SUM(d.last_clicked_purchases), 0) as last_clicked_purchases, COALESCE(SUM(d.clicks), 0) as clicks, COALESCE(SUM(d.spend) / 1000000, 0) as spend, COALESCE(SUM(d.impressions), 0) as impressions, COALESCE(SUM(d.adds_to_cart), 0) as adds_to_cart, COALESCE(SUM(d.purchases), 0) as purchases, + COALESCE(SUM(d.platform_purchase), 0) as platform_purchase, + COALESCE(SUM(d.pixel_purchase), 0) as pixel_purchase, COALESCE(SUM(d.purchases_value) / 1000000, 0) as purchases_value, COALESCE(SUM(d.revenue) / 1000000, 0) as revenue, COALESCE(SUM(d.total_cost) / 1000000, 0) as total_cost, @@ -1399,8 +1403,8 @@ class AdsInsightService $cost_per_purchase = $total_purchases == 0 ? 0 : round($total_spend / $total_purchases, 2); $statistics = [ - 'assisted_purchases' => array_sum(array_column($allAds, 'assisted_purchases')), - 'last_clicked_purchases' => array_sum(array_column($allAds, 'last_clicked_purchases')), + '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), 'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出 'clicks' => $total_clicks, @@ -1446,8 +1450,8 @@ class AdsInsightService 'name' => $item['name'] ?: '-', // 若 name 为空则显示 '-' 'ad_set_name' => $item['ad_set_name'] ?: '-', // 若 name 为空则显示 '-' 'status' => $item['status'], - 'assisted_purchases' => $item['assisted_purchases'], - 'last_clicked_purchases' => $item['last_clicked_purchases'], + 'platform_purchase' => $item['platform_purchase'], + 'pixel_purchase' => $item['pixel_purchase'], 'roas' => $item['spend'] == 0 ? '-' : round($item['purchases_value'] / $item['spend'], 2), 'spend' => '$' . number_format($item['spend'], 2), // 格式化支出 'impressions' => $item['impressions'], @@ -1516,8 +1520,8 @@ class AdsInsightService ->leftJoin('bps.bps_third_user_advertiser a', "u.id = a.doc_") ->field('u.id as user_id,u.third_type,a.advertiser_name, - COALESCE(SUM(d.assisted_purchases), 0) as assisted_purchases, - COALESCE(SUM(d.last_clicked_purchases), 0) as last_clicked_purchases, + COALESCE(SUM(d.platform_purchase), 0) as platform_purchase, + COALESCE(SUM(d.pixel_purchase), 0) as pixel_purchase, COALESCE(SUM(d.spend) / 1000000, 0) as spend, COALESCE(SUM(d.impressions), 0) as impressions, COALESCE(SUM(d.clicks), 0) as clicks, @@ -1573,8 +1577,8 @@ class AdsInsightService // 汇总统计字段初始化 $statistics = [ - 'assisted_purchases' => 0, - 'last_clicked_purchases' => 0, + 'platform_purchase' => 0, + 'pixel_purchase' => 0, 'roas' => $total_spend == 0 ? '-' : round($total_purchases_value / $total_spend, 2), 'amount_spend' => '$' . number_format($total_spend, 2) ?: '$0.00', // 格式化支出 'clicks' => $total_clicks, @@ -1608,8 +1612,8 @@ class AdsInsightService 'user_id' => $item['user_id'], 'platform_type' => self::getPlatformType($item['third_type']), 'advertiser_name' => $item['advertiser_name'], - 'assisted_purchases' => 0, - 'last_clicked_purchases' => 0, + 'platform_purchase' => 0, + 'pixel_purchase' => 0, 'roas' => 0, 'spend' => 0, 'impressions' => 0, @@ -1638,8 +1642,8 @@ class AdsInsightService $aggregatedUsers[$thirdUserId]['purchases_value'] += $item['purchases_value']; $aggregatedUsers[$thirdUserId]['revenue'] += $item['revenue']; $aggregatedUsers[$thirdUserId]['total_cost'] += $item['total_cost']; - $aggregatedUsers[$thirdUserId]['assisted_purchases'] += $item['assisted_purchases']; - $aggregatedUsers[$thirdUserId]['last_clicked_purchases'] += $item['last_clicked_purchases']; + $aggregatedUsers[$thirdUserId]['platform_purchase'] += $item['platform_purchase']; + $aggregatedUsers[$thirdUserId]['pixel_purchase'] += $item['pixel_purchase']; } // 计算统计口径字段:ROAS, CTR等 @@ -1702,8 +1706,8 @@ class AdsInsightService 'user_id' => $user['user_id'], 'platform_type' => (int)$platformType, 'advertiser_name' => $user['advertiser_name'], - 'assisted_purchases' => 0, - 'last_clicked_purchases' => 0, + 'platform_purchase' => 0, + 'pixel_purchase' => 0, 'spend' => 0, 'impressions' => 0, 'clicks' => 0, @@ -2029,9 +2033,9 @@ class AdsInsightService 'ctr_all' => ($item['impressions'] > 0) ? number_format(($item['clicks'] / $item['impressions']) * 100, 2) . '%' : '-', 'total_conversions_value' => '$' . number_format($item['purchases_value'], 2), //准备删除 'impressions' => $item['impressions'], - 'video_plays_25_rate' => ($item['video_plays'] > 0) ? number_format($item['video_25'] / $item['video_plays'], 2). '%' : '-', - 'video_plays_50_rate' => ($item['video_plays'] > 0) ? number_format($item['video_50'] / $item['video_plays'], 2). '%' : '-', - 'video_plays_75_rate' => ($item['video_plays'] > 0) ? number_format($item['video_75'] / $item['video_plays'], 2). '%' : '-', + 'video_plays_25_rate' => ($item['video_plays'] > 0) ? number_format($item['video_25'] / $item['video_plays'], 2) . '%' : '-', + 'video_plays_50_rate' => ($item['video_plays'] > 0) ? number_format($item['video_50'] / $item['video_plays'], 2) . '%' : '-', + 'video_plays_75_rate' => ($item['video_plays'] > 0) ? number_format($item['video_75'] / $item['video_plays'], 2) . '%' : '-', 'hold_rate' => self::calculateHoldRate($item['video_25'], $item['video_50'], $item['video_75'], $item['video_100']), 'ad_count' => $item['ad_count'], // 添加更多的格式化字段