| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace app\command;
- use app\v1\logic\tool\advertCost\ToutiaoCostVideoLogic;
- use Symfony\Component\Console\Command\Command;
- use Symfony\Component\Console\Attribute\AsCommand;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Input\InputOption;
- use Symfony\Component\Console\Input\InputArgument;
- use Symfony\Component\Console\Output\OutputInterface;
- #[AsCommand('cost:tt_video', 'cost tt_video')]
- class CostToutiaoVideo extends Command
- {
- /**
- * 自定义脚本示例
- * @return void
- */
- protected function configure()
- {
- // 用法示例 php webman cost:tt_video date pmid advertiser_ids
- // php webman cost:tt_video 2025-07-30,2025-07-31 0 54970254,60853999
- $this->addArgument('date', InputArgument::OPTIONAL, '日期范围');
- $this->addArgument('pmid', InputArgument::OPTIONAL, '需要拉取的API配置ID');
- $this->addArgument('advertiser_ids', InputArgument::OPTIONAL, '需要拉取的广告账户');
- }
- /**
- * @param InputInterface $input
- * @param OutputInterface $output
- * @return int
- */
- protected function execute(InputInterface $input, OutputInterface $output): int
- {
- $ydate = date('Y-m-d', strtotime('-1 day'));
- $date = $input->getArgument('date');
- $date = $date ?: $ydate;
- $pmid = (int)$input->getArgument('pmid');
- $advertiserIds = $input->getArgument('advertiser_ids');
- $params = [];
- if($date){
- $params['date'] = explode(',', $date);
- }
- if($pmid){
- $params['pmid'] = $pmid;
- }
- if($advertiserIds){
- $params['advertiser_ids'] = explode(',', $advertiserIds);
- }
- $output->writeln("\ntt cost sta:" . json_encode($params, JSON_UNESCAPED_UNICODE));
- $res = (new ToutiaoCostVideoLogic())->run($params);
- $output->writeln("\ntt cost end:" . $res);
- return self::SUCCESS;
- }
- }
|