优化 creative 导出表格

This commit is contained in:
huangguancheng 2025-01-23 15:16:10 +08:00
parent 982ecc2401
commit 5b38944261

View File

@ -738,30 +738,31 @@ class AdsInsightService
// 设置表头 // 设置表头
$headers = [ $headers = [
'A1' => 'Creative', 'A1' => 'Creative',
'B1' => 'Thumbnail/Creative URL', 'B1' => 'Ad Platform',
'C1' => 'Creative Type', 'C1' => 'Thumbnail/Creative URL',
'D1' => 'Ad Count', 'D1' => 'Creative Type',
'E1' => 'Spend', 'E1' => 'Ad Count',
'F1' => 'Purchase value', 'F1' => 'Spend',
'G1' => 'ROAS', 'G1' => 'Purchase value',
'H1' => 'CPA', 'H1' => 'ROAS',
'I1' => 'CPC (link click)', 'I1' => 'CPA',
'J1' => 'CPM', 'J1' => 'CPC (link click)',
'K1' => 'CPC (all)', 'K1' => 'CPM',
'L1' => 'AOV', 'L1' => 'CPC (all)',
'M1' => 'Click to ATC ratio', 'M1' => 'AOV',
'N1' => 'ATC to purchase ratio', 'N1' => 'Click to ATC ratio',
'O1' => 'Purchases', 'O1' => 'ATC to purchase ratio',
'P1' => '1st frame retention', 'P1' => 'Purchases',
'Q1' => 'Thumbstop', 'Q1' => '1st frame retention',
'R1' => 'CTR (outbound)', 'R1' => 'Thumbstop',
'S1' => 'Click to purchase', 'S1' => 'CTR (outbound)',
'T1' => 'CTR (all)', 'T1' => 'Click to purchase',
'U1' => '25% video plays (rate)', 'U1' => 'CTR (all)',
'V1' => '50% video plays (rate)', 'V1' => '25% video plays (rate)',
'W1' => '75% video plays (rate)', 'W1' => '50% video plays (rate)',
'X1' => '100% video plays (rate)', 'X1' => '75% video plays (rate)',
'Y1' => 'Hold rate' 'Y1' => '100% video plays (rate)',
'Z1' => 'Hold rate'
]; ];
// 填充表头 // 填充表头
@ -773,58 +774,59 @@ class AdsInsightService
$row = 2; $row = 2;
foreach ($creativeList['data'] as $creative) { foreach ($creativeList['data'] as $creative) {
$sheet->setCellValue('A' . $row, $creative['creative']); // Creative $sheet->setCellValue('A' . $row, $creative['creative']); // Creative
$sheet->setCellValue('B' . $row, $creative['thumbnail_url'] ?: $creative['creative_url']); // Thumbnail/Creative URL $sheet->setCellValue('B' . $row, self::$platformMapping[$creative['platform']]); // Ad Platform
$sheet->setCellValue('C' . $row, self::$creativeTypeMapping[$creative['creative_type']]); // Creative Type $sheet->setCellValue('C' . $row, $creative['thumbnail_url'] ?: $creative['creative_url']); // Thumbnail/Creative URL
$sheet->setCellValue('D' . $row, $creative['ad_count']); // Ad Count $sheet->setCellValue('D' . $row, self::$creativeTypeMapping[$creative['creative_type']]); // Creative Type
$sheet->setCellValue('E' . $row, $creative['spend']); // Spend $sheet->setCellValue('E' . $row, $creative['ad_count']); // Ad Count
$sheet->setCellValue('F' . $row, $creative['purchases_value']); // Purchase value $sheet->setCellValue('F' . $row, $creative['spend']); // Spend
$sheet->setCellValue('G' . $row, $creative['roas']); // ROAS $sheet->setCellValue('G' . $row, $creative['purchases_value']); // Purchase value
$sheet->setCellValue('H' . $row, $creative['cpa']); // CPA $sheet->setCellValue('H' . $row, $creative['roas']); // ROAS
$sheet->setCellValue('I' . $row, $creative['cpc_link_click']); // CPC (link click) $sheet->setCellValue('I' . $row, $creative['cpa']); // CPA
$sheet->setCellValue('J' . $row, $creative['cpm']); // CPM $sheet->setCellValue('J' . $row, $creative['cpc_link_click']); // CPC (link click)
$sheet->setCellValue('K' . $row, $creative['cpc_all']); // CPC (all) $sheet->setCellValue('K' . $row, $creative['cpm']); // CPM
$sheet->setCellValue('L' . $row, $creative['aov']); // AOV $sheet->setCellValue('L' . $row, $creative['cpc_all']); // CPC (all)
$sheet->setCellValue('M' . $row, $creative['click_to_atc_ratio']); // Click to ATC ratio $sheet->setCellValue('M' . $row, $creative['aov']); // AOV
$sheet->setCellValue('N' . $row, $creative['atc_to_purchase_ratio']); // ATC to purchase ratio $sheet->setCellValue('N' . $row, $creative['click_to_atc_ratio']); // Click to ATC ratio
$sheet->setCellValue('O' . $row, $creative['purchases']); // Purchases $sheet->setCellValue('O' . $row, $creative['atc_to_purchase_ratio']); // ATC to purchase ratio
$sheet->setCellValue('P' . $row, $creative['first_frame_retention']); // 1st frame retention $sheet->setCellValue('P' . $row, $creative['purchases']); // Purchases
$sheet->setCellValue('Q' . $row, $creative['thumbstop']); // Thumbstop $sheet->setCellValue('Q' . $row, $creative['first_frame_retention']); // 1st frame retention
$sheet->setCellValue('R' . $row, $creative['ctr_outbound']); // CTR (outbound) $sheet->setCellValue('R' . $row, $creative['thumbstop']); // Thumbstop
$sheet->setCellValue('S' . $row, $creative['click_to_purchase']); // Click to purchase $sheet->setCellValue('S' . $row, $creative['ctr_outbound']); // CTR (outbound)
$sheet->setCellValue('T' . $row, $creative['ctr_all']); // CTR (all) $sheet->setCellValue('T' . $row, $creative['click_to_purchase']); // Click to purchase
$sheet->setCellValue('U' . $row, $creative['video_plays_25_rate']); // 25% video plays (rate) $sheet->setCellValue('U' . $row, $creative['ctr_all']); // CTR (all)
$sheet->setCellValue('V' . $row, $creative['video_plays_50_rate']); // 50% video plays (rate) $sheet->setCellValue('V' . $row, $creative['video_plays_25_rate']); // 25% video plays (rate)
$sheet->setCellValue('W' . $row, $creative['video_plays_75_rate']); // 75% video plays (rate) $sheet->setCellValue('W' . $row, $creative['video_plays_50_rate']); // 50% video plays (rate)
$sheet->setCellValue('X' . $row, $creative['video_plays_100_rate']); // 100% video plays (rate) $sheet->setCellValue('X' . $row, $creative['video_plays_75_rate']); // 75% video plays (rate)
$sheet->setCellValue('Y' . $row, $creative['hold_rate']); // Hold rate $sheet->setCellValue('Y' . $row, $creative['video_plays_100_rate']); // 100% video plays (rate)
$sheet->setCellValue('Z' . $row, $creative['hold_rate']); // Hold rate
$row++; $row++;
} }
// 填充统计信息到表格的最后一行 // 填充统计信息到表格的最后一行
$statistics = $creativeList['statistics']; $statistics = $creativeList['statistics'];
$statisticsRow = $row; // 统计信息从当前行开始 $statisticsRow = $row; // 统计信息从当前行开始
$sheet->setCellValue('D' . $statisticsRow, 'Totals'); // 统计信息标题 $sheet->setCellValue('E' . $statisticsRow, 'Totals'); // 统计信息标题
$sheet->setCellValue('E' . $statisticsRow, $statistics['spend']); // Spend $sheet->setCellValue('F' . $statisticsRow, $statistics['spend']); // Spend
$sheet->setCellValue('F' . $statisticsRow, $statistics['purchases_value']); // Purchase value $sheet->setCellValue('G' . $statisticsRow, $statistics['purchases_value']); // Purchase value
$sheet->setCellValue('G' . $statisticsRow, $statistics['roas']); // ROAS $sheet->setCellValue('H' . $statisticsRow, $statistics['roas']); // ROAS
$sheet->setCellValue('H' . $statisticsRow, $statistics['cpa']); // CPA $sheet->setCellValue('I' . $statisticsRow, $statistics['cpa']); // CPA
$sheet->setCellValue('I' . $statisticsRow, $statistics['cpc_link_click']); // CPC (link click) $sheet->setCellValue('J' . $statisticsRow, $statistics['cpc_link_click']); // CPC (link click)
$sheet->setCellValue('J' . $statisticsRow, $statistics['cpm']); // CPM $sheet->setCellValue('K' . $statisticsRow, $statistics['cpm']); // CPM
$sheet->setCellValue('K' . $statisticsRow, $statistics['cpc_all']); // CPC (all) $sheet->setCellValue('L' . $statisticsRow, $statistics['cpc_all']); // CPC (all)
$sheet->setCellValue('L' . $statisticsRow, $statistics['aov']); // AOV $sheet->setCellValue('M' . $statisticsRow, $statistics['aov']); // AOV
$sheet->setCellValue('M' . $statisticsRow, $statistics['click_to_atc_ratio']); // Click to ATC ratio $sheet->setCellValue('N' . $statisticsRow, $statistics['click_to_atc_ratio']); // Click to ATC ratio
$sheet->setCellValue('N' . $statisticsRow, $statistics['atc_to_purchase_ratio']); // ATC to purchase ratio $sheet->setCellValue('O' . $statisticsRow, $statistics['atc_to_purchase_ratio']); // ATC to purchase ratio
$sheet->setCellValue('O' . $statisticsRow, $statistics['purchases']); // Purchases $sheet->setCellValue('P' . $statisticsRow, $statistics['purchases']); // Purchases
$sheet->setCellValue('P' . $statisticsRow, $statistics['first_frame_retention']); // 1st frame retention $sheet->setCellValue('Q' . $statisticsRow, $statistics['first_frame_retention']); // 1st frame retention
$sheet->setCellValue('Q' . $statisticsRow, $statistics['thumbstop']); // Thumbstop $sheet->setCellValue('R' . $statisticsRow, $statistics['thumbstop']); // Thumbstop
$sheet->setCellValue('R' . $statisticsRow, $statistics['ctr_outbound']); // CTR (outbound) $sheet->setCellValue('S' . $statisticsRow, $statistics['ctr_outbound']); // CTR (outbound)
$sheet->setCellValue('S' . $statisticsRow, $statistics['click_to_purchase']); // Click to purchase $sheet->setCellValue('T' . $statisticsRow, $statistics['click_to_purchase']); // Click to purchase
$sheet->setCellValue('T' . $statisticsRow, $statistics['ctr_all']); // CTR (all) $sheet->setCellValue('U' . $statisticsRow, $statistics['ctr_all']); // CTR (all)
$sheet->setCellValue('U' . $statisticsRow, $statistics['video_plays_25_rate']); // 25% video plays (rate) $sheet->setCellValue('V' . $statisticsRow, $statistics['video_plays_25_rate']); // 25% video plays (rate)
$sheet->setCellValue('V' . $statisticsRow, $statistics['video_plays_50_rate']); // 50% video plays (rate) $sheet->setCellValue('W' . $statisticsRow, $statistics['video_plays_50_rate']); // 50% video plays (rate)
$sheet->setCellValue('W' . $statisticsRow, $statistics['video_plays_75_rate']); // 75% video plays (rate) $sheet->setCellValue('X' . $statisticsRow, $statistics['video_plays_75_rate']); // 75% video plays (rate)
$sheet->setCellValue('X' . $statisticsRow, $statistics['video_plays_100_rate']); // 100% video plays (rate) $sheet->setCellValue('Y' . $statisticsRow, $statistics['video_plays_100_rate']); // 100% video plays (rate)
$sheet->setCellValue('Y' . $statisticsRow, $statistics['hold_rate']); // Hold rate $sheet->setCellValue('Z' . $statisticsRow, $statistics['hold_rate']); // Hold rate
// 释放内存 // 释放内存
unset($statistics); unset($statistics);