fix Creative 2
This commit is contained in:
parent
568df50454
commit
2577f5df58
@ -96,7 +96,7 @@ class AdsInsightService
|
|||||||
$total_impressions = array_sum(array_column($allCampaigns, 'impressions'));
|
$total_impressions = array_sum(array_column($allCampaigns, 'impressions'));
|
||||||
$total_clicks = array_sum(array_column($allCampaigns, 'clicks'));
|
$total_clicks = array_sum(array_column($allCampaigns, 'clicks'));
|
||||||
$total_purchases_value = array_sum(array_column($allCampaigns, 'purchases_value'));
|
$total_purchases_value = array_sum(array_column($allCampaigns, 'purchases_value'));
|
||||||
$total_revenue = array_sum(array_column($allCampaigns, 'revenue'));
|
$total_revenue = array_sum(array_column($allCampaigns, 'revenue'));
|
||||||
$total_purchases = array_sum(array_column($allCampaigns, 'purchases'));
|
$total_purchases = array_sum(array_column($allCampaigns, 'purchases'));
|
||||||
$cost_per_purchase = $total_purchases == 0 ? 0 : round($total_spend / $total_purchases, 2);
|
$cost_per_purchase = $total_purchases == 0 ? 0 : round($total_spend / $total_purchases, 2);
|
||||||
// 汇总统计数据
|
// 汇总统计数据
|
||||||
@ -831,8 +831,10 @@ class AdsInsightService
|
|||||||
{
|
{
|
||||||
// 1. 创建查询对象,初始化 BpsAdCreativeInsight 查询
|
// 1. 创建查询对象,初始化 BpsAdCreativeInsight 查询
|
||||||
$creativeDataQuery = BpsAdCreativeInsight::alias('i')
|
$creativeDataQuery = BpsAdCreativeInsight::alias('i')
|
||||||
->join('bps.bps_ads_creative c', 'i.creative_id = c.creative_id', 'LEFT') // 联接 bps_ads_creative 表
|
->join('bps.bps_ads_creative c', 'i.creative_id = c.creative_id', 'LEFT'); // 联接 bps_ads_creative 表
|
||||||
->where('i.platform', $platformType); // 根据 platform 筛选
|
if ($platformType != 0) {
|
||||||
|
$creativeDataQuery->where('i.platform', $platformType); // 只有 platformType 不为 0 时才添加筛选
|
||||||
|
}
|
||||||
|
|
||||||
// 2. 日期范围筛选
|
// 2. 日期范围筛选
|
||||||
if ($startDate && $endDate) {
|
if ($startDate && $endDate) {
|
||||||
@ -937,7 +939,7 @@ class AdsInsightService
|
|||||||
// 汇总总体统计数据
|
// 汇总总体统计数据
|
||||||
$statisticsData['spend'] += $creativeData->total_spend;
|
$statisticsData['spend'] += $creativeData->total_spend;
|
||||||
$statisticsData['conversions_value'] += $creativeData->total_conversions_value;
|
$statisticsData['conversions_value'] += $creativeData->total_conversions_value;
|
||||||
$statisticsData['impressions'] += $creativeData->total_impressions;
|
$statisticsData['impressions'] += $creativeData->total_impressions;
|
||||||
|
|
||||||
// 计算 ROAS
|
// 计算 ROAS
|
||||||
$roas = $creativeSummaryData[$creativeData->creative_id]['spend'] > 0
|
$roas = $creativeSummaryData[$creativeData->creative_id]['spend'] > 0
|
||||||
|
Loading…
Reference in New Issue
Block a user