From 80c1630c09de2cc0e03075a9dea90d011f4bae66 Mon Sep 17 00:00:00 2001 From: huangguancheng Date: Tue, 14 Jan 2025 11:35:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E9=9B=86=E5=B9=BF=E5=91=8A=E6=88=90?= =?UTF-8?q?=E6=95=88=E5=90=8E=E5=90=8C=E6=AD=A5=E9=80=9A=E7=9F=A5=E5=88=B0?= =?UTF-8?q?"collector"."task"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/event/GoogleAdsDateDatas.php | 27 +++++++++++++++++-- .../redis/GoogleAdsDateDataTaskQueue.php | 23 ++++++++++++++++ config/event.php | 3 +++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 app/queue/redis/GoogleAdsDateDataTaskQueue.php diff --git a/app/event/GoogleAdsDateDatas.php b/app/event/GoogleAdsDateDatas.php index 35a7e54..84fa5f9 100644 --- a/app/event/GoogleAdsDateDatas.php +++ b/app/event/GoogleAdsDateDatas.php @@ -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 diff --git a/app/queue/redis/GoogleAdsDateDataTaskQueue.php b/app/queue/redis/GoogleAdsDateDataTaskQueue.php new file mode 100644 index 0000000..2d73d30 --- /dev/null +++ b/app/queue/redis/GoogleAdsDateDataTaskQueue.php @@ -0,0 +1,23 @@ + [ [GoogleAdsDateDatas::class, 'getDateDatas'], ], +// GoogleAdsDateDatas::task => [ +// [GoogleAdsDateDatas::class, 'noticeDateDatas'], +// ], GoogleAdsCustomers::event => [ [GoogleAdsCustomers::class, 'addCustomers'], ],