新增广告账户同步时间更新 GoogleAdsCustomers::last_sync
This commit is contained in:
parent
3361ee374d
commit
f82da5e25b
@ -34,6 +34,7 @@ class GoogleAdsCustomers
|
|||||||
private $googleAdsAccountService;
|
private $googleAdsAccountService;
|
||||||
|
|
||||||
const event = 'googleads:customers:event';
|
const event = 'googleads:customers:event';
|
||||||
|
const last_sync = 'googleads:customers:last_sync';
|
||||||
const newbind_event = 'googleads:customers:newbind:event';
|
const newbind_event = 'googleads:customers:newbind:event';
|
||||||
const add_queue = 'googleads:customers:add:queue';
|
const add_queue = 'googleads:customers:add:queue';
|
||||||
const init_queue = 'googleads:customers:init:queue';
|
const init_queue = 'googleads:customers:init:queue';
|
||||||
@ -147,6 +148,27 @@ class GoogleAdsCustomers
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//更新某个广告账号的最后同步时间
|
||||||
|
public function updateLastSyncTime($options)
|
||||||
|
{
|
||||||
|
if (!$options) {
|
||||||
|
dump('not found new third user');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$merchant_id = $options['merchant_id'];
|
||||||
|
$account_id = $options['account_id'];
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 更新某个广告账号的最后同步时间
|
||||||
|
$this->googleOAuthService->updateAccountLastSyncTime($merchant_id, $account_id);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 记录错误日志并跳过当前循环
|
||||||
|
Log::error("updateLastSyncTime Error processing account_id {$account_id}: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//每分钟定时轮询缓存是否有新的广告账号需要绑定-荣洁set缓存
|
//每分钟定时轮询缓存是否有新的广告账号需要绑定-荣洁set缓存
|
||||||
public function newBindAccount()
|
public function newBindAccount()
|
||||||
{
|
{
|
||||||
|
@ -49,6 +49,8 @@ class GoogleAdsCustomerInitQueue implements Consumer
|
|||||||
//新绑定的客户,立即同步最近7天素材-广告关系绑定
|
//新绑定的客户,立即同步最近7天素材-广告关系绑定
|
||||||
Event::emit(GoogleAdsAssetRelations::event, $data);
|
Event::emit(GoogleAdsAssetRelations::event, $data);
|
||||||
|
|
||||||
|
Event::emit(GoogleAdsCustomers::last_sync, $data);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace app\queue\redis;
|
namespace app\queue\redis;
|
||||||
|
|
||||||
|
use app\event\GoogleAdsCustomers;
|
||||||
use app\event\GoogleAdsDateDatas;
|
use app\event\GoogleAdsDateDatas;
|
||||||
use Webman\Event\Event;
|
use Webman\Event\Event;
|
||||||
use Webman\RedisQueue\Consumer;
|
use Webman\RedisQueue\Consumer;
|
||||||
@ -19,6 +20,7 @@ class GoogleAdsDateDataQueue implements Consumer
|
|||||||
{
|
{
|
||||||
// dump($this->queue.' consumed',$data);
|
// dump($this->queue.' consumed',$data);
|
||||||
Event::emit(GoogleAdsDateDatas::queue, $data);
|
Event::emit(GoogleAdsDateDatas::queue, $data);
|
||||||
|
Event::emit(GoogleAdsCustomers::last_sync, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -60,7 +60,7 @@ class BpsAdAccountService
|
|||||||
$query->where('bamr.account_id', $account_id);
|
$query->where('bamr.account_id', $account_id);
|
||||||
}
|
}
|
||||||
// 选择需要的字段
|
// 选择需要的字段
|
||||||
$customers = $query->field('bamr.account_id, bamr.refresh_token, bamr.ext_info->>\'login_customer_id\' as login_customer_id')
|
$customers = $query->field('bamr.merchant_id,bamr.account_id, bamr.refresh_token, bamr.ext_info->>\'login_customer_id\' as login_customer_id')
|
||||||
->select(); // 执行查询
|
->select(); // 执行查询
|
||||||
} else {
|
} else {
|
||||||
// 获取符合条件的客户ID数组
|
// 获取符合条件的客户ID数组
|
||||||
|
@ -283,6 +283,27 @@ class GoogleOAuthService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function updateAccountLastSyncTime($merchantId, $accountId): void
|
||||||
|
{
|
||||||
|
$tableName = 'bps_ads_merchant_relation';
|
||||||
|
$tableName = getenv('DB_PG_SCHEMA') ? getenv('DB_PG_SCHEMA') . '.' . $tableName : 'bps' . $tableName;
|
||||||
|
|
||||||
|
//更新last_sync_time 赋值当前时间戳
|
||||||
|
$data = [
|
||||||
|
'merchant_id' => $merchantId,
|
||||||
|
'account_id' => $accountId,
|
||||||
|
'last_sync_time' => time()
|
||||||
|
];
|
||||||
|
$sql = "
|
||||||
|
UPDATE {$tableName}
|
||||||
|
SET last_sync_time = :last_sync_time
|
||||||
|
where paltform = 2 and merchant_id = :merchant_id and account_id = :account_id
|
||||||
|
";
|
||||||
|
ThinkDb::execute($sql, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function updateThirdUserDefault($third_user_id, $is_default = 't'): void
|
public function updateThirdUserDefault($third_user_id, $is_default = 't'): void
|
||||||
{
|
{
|
||||||
$tableName = 'bps_third_user';
|
$tableName = 'bps_third_user';
|
||||||
|
@ -81,6 +81,9 @@ return [
|
|||||||
GoogleAdsCustomers::newbind_event => [
|
GoogleAdsCustomers::newbind_event => [
|
||||||
[GoogleAdsCustomers::class, 'newBindAccount'],
|
[GoogleAdsCustomers::class, 'newBindAccount'],
|
||||||
],
|
],
|
||||||
|
GoogleAdsCustomers::last_sync => [
|
||||||
|
[GoogleAdsCustomers::class, 'updateLastSyncTime'],
|
||||||
|
],
|
||||||
GoogleAdsCustomers::add_queue => [
|
GoogleAdsCustomers::add_queue => [
|
||||||
[GoogleAdsCustomers::class, 'addRootCustomersNew'],
|
[GoogleAdsCustomers::class, 'addRootCustomersNew'],
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user