| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace app\command;
- use app\v1\logic\tool\advertCost\GdtCostVideoLogic;
- 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:gdt_video', 'cost gdt_video')]
- class CostGdtVideo extends Command
- {
- /**
- * 自定义脚本示例
- * @return void
- */
- protected function configure()
- {
- // 用法示例 php webman cost:gdt_video date api_id advertiser_ids
- // php webman cost:gdt_video 2025-07-30,2025-07-31 0 54970254,60853999
- $this->addArgument('date', InputArgument::OPTIONAL, '日期范围');
- $this->addArgument('api_id', 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;
- $apiId = (int)$input->getArgument('api_id');
- $advertiserIds = $input->getArgument('advertiser_ids');
- $params = [];
- if($date){
- $params['date'] = explode(',', $date);
- }
- if($apiId){
- $params['api_id'] = $apiId;
- }
- if($advertiserIds){
- $params['advertiser_ids'] = explode(',', $advertiserIds);
- }
- $output->writeln("\ngdt cost sta:" . json_encode($params, JSON_UNESCAPED_UNICODE));
- $res = (new GdtCostVideoLogic)->run($params);
- $output->writeln("\ngdt cost end:" . $res);
- return self::SUCCESS;
- }
- }
|