webman_ad/app/queue/redis/GoogleAdsCustomerInitQueue.php

57 lines
2.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\queue\redis;
use app\event\GoogleAdsCustomers;
use app\event\GoogleAdsCampaigns;
use app\event\GoogleAdsGroups;
use app\event\GoogleAdsAds;
use app\event\GoogleAdsAssets;
use app\event\GoogleAdsDateDatas;
use app\event\GoogleAdsAssetRelations;
use app\event\GoogleAdsCreatives;
use Webman\Event\Event;
use Webman\RedisQueue\Consumer;
class GoogleAdsCustomerInitQueue implements Consumer
{
// 要消费的队列名
public $queue = GoogleAdsCustomers::init_queue;
// 连接名,对应 plugin/webman/redis-queue/redis.php 里的连接`
public $connection = 'default';
// 消费
public function consume($data)
{
dump($this->queue . ' consumed', $data);
//新绑定的客户,立即同步广告系列
//$data包含merchant_id,account_id
Event::emit(GoogleAdsCampaigns::event, $data);
//新绑定的客户,立即同步广告组
Event::emit(GoogleAdsGroups::event, $data);
//新绑定的客户,立即同步广告
Event::emit(GoogleAdsAds::event, $data);
//新绑定的客户,立即同步素材库
Event::emit(GoogleAdsAssets::event, $data);
//新绑定的客户,立即同步素材关系绑定
Event::emit(GoogleAdsCreatives::event, $data);
//新绑定的客户立即同步最近7天的广告报表
// $data['date'] = date('Y-m-d', strtotime('-2 day'));
// Event::emit(GoogleAdsDateDatas::event, $data);
// $data['date'] = date('Y-m-d', strtotime('-1 day'));
// Event::emit(GoogleAdsDateDatas::event, $data);
// $data['date'] = date('Y-m-d', strtotime('0 day'));
// Event::emit(GoogleAdsDateDatas::event, $data);
$data['endDate'] = date('Y-m-d'); // 获取今天的日期
$data['startDate'] = date('Y-m-d', strtotime('-7 days')); // 获取7天前的日期
Event::emit(GoogleAdsDateDatas::event, $data);
//新绑定的客户立即同步最近7天素材-广告关系绑定
Event::emit(GoogleAdsAssetRelations::event, $data);
Event::emit(GoogleAdsCustomers::last_sync, $data);
}
}