采集广告成效后同步通知到"collector"."task"
This commit is contained in:
parent
3b2d59420b
commit
80c1630c09
@ -8,6 +8,7 @@ use Google\ApiCore\ApiException;
|
||||
use support\Response;
|
||||
use DI\Annotation\Inject;
|
||||
use Webman\RedisQueue\Redis;
|
||||
use Webman\RedisQueue\Client;
|
||||
|
||||
//use QL\QueryList;
|
||||
|
||||
@ -24,6 +25,7 @@ class GoogleAdsDateDatas
|
||||
|
||||
const event = 'googleads:datedatas:event';
|
||||
const queue = 'googleads:datedatas:queue';
|
||||
const task = 'googleads:datedatas:task';
|
||||
|
||||
public function syncDateDatas($options = [])
|
||||
{
|
||||
@ -32,10 +34,21 @@ class GoogleAdsDateDatas
|
||||
foreach ($customers as $customer) {
|
||||
if ($customer['login_customer_id'] > 0) {
|
||||
$customer['date'] = $options['date'];
|
||||
Redis::send($queue, $customer,rand(1,10));
|
||||
Redis::send($queue, $customer, rand(1, 10));
|
||||
}
|
||||
}
|
||||
return self::event.' send queue ok';
|
||||
//同步消息到同步任务表
|
||||
// $queueTask = self::task;
|
||||
// $taskInfo = [
|
||||
// 'ecommerce' => 1001,
|
||||
// 'ecommerce_shop_id' => $options['date'],
|
||||
// 'task_type' => 'InsightsMerge',
|
||||
// 'remain' => 1
|
||||
// ];
|
||||
// Client::send($queueTask, $taskInfo, 30);
|
||||
|
||||
|
||||
return self::event . ' send queue ok';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,6 +69,16 @@ class GoogleAdsDateDatas
|
||||
// return $this->successResponse(['data' => $resourceName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知到同步task
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function noticeDateDatas($taskInfo)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 可以加入一些公共方法
|
||||
protected function successResponse($data): Response
|
||||
|
23
app/queue/redis/GoogleAdsDateDataTaskQueue.php
Normal file
23
app/queue/redis/GoogleAdsDateDataTaskQueue.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace app\queue\redis;
|
||||
|
||||
use app\event\GoogleAdsDateDatas;
|
||||
use Webman\Event\Event;
|
||||
use Webman\RedisQueue\Consumer;
|
||||
|
||||
class GoogleAdsDateDataTaskQueue implements Consumer
|
||||
{
|
||||
// 要消费的队列名
|
||||
public $queue = GoogleAdsDateDatas::task;
|
||||
|
||||
// 连接名,对应 plugin/webman/redis-queue/redis.php 里的连接`
|
||||
public $connection = 'default';
|
||||
|
||||
// 消费
|
||||
public function consume($data)
|
||||
{
|
||||
// Event::emit(GoogleAdsDateDatas::task, $data);
|
||||
}
|
||||
|
||||
}
|
@ -69,6 +69,9 @@ return [
|
||||
GoogleAdsDateDatas::queue => [
|
||||
[GoogleAdsDateDatas::class, 'getDateDatas'],
|
||||
],
|
||||
// GoogleAdsDateDatas::task => [
|
||||
// [GoogleAdsDateDatas::class, 'noticeDateDatas'],
|
||||
// ],
|
||||
GoogleAdsCustomers::event => [
|
||||
[GoogleAdsCustomers::class, 'addCustomers'],
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user