增加自媒体渠道
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\command;
|
||||
|
||||
use app\common\service\qywx\MediaChannelService;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
|
||||
class QywxScanMediaChannel extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('qywx:scan-media-channel')
|
||||
->addOption('batch', 'b', \think\console\input\Option::VALUE_OPTIONAL, '每批扫描客户数', 200)
|
||||
->setDescription('扫描企微客户 follow_users 并记录渠道标签源');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$batchSize = max(1, (int) $input->getOption('batch'));
|
||||
$output->writeln('开始扫描企微客户渠道标签...');
|
||||
|
||||
$result = MediaChannelService::scanFromContacts($batchSize);
|
||||
|
||||
$output->writeln(sprintf(
|
||||
'扫描完成:客户 %d,发现渠道标签 %d,写入/更新 %d。',
|
||||
(int) ($result['scanned_contacts'] ?? 0),
|
||||
(int) ($result['discovered_tags'] ?? 0),
|
||||
(int) ($result['inserted_or_updated'] ?? 0)
|
||||
));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user