SyncPlan.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace app\command;
  3. use app\extra\dyMini\PlanLive;
  4. use app\model\saas\SaasLivePlan;
  5. use Symfony\Component\Console\Command\Command;
  6. use Symfony\Component\Console\Input\InputInterface;
  7. use Symfony\Component\Console\Output\OutputInterface;
  8. class SyncPlan extends Command
  9. {
  10. protected static string $defaultName = 'sync:plan';
  11. protected static string $defaultDescription = '查询定向佣金计划带货汇总数据';
  12. protected function execute(InputInterface $input, OutputInterface $output): int
  13. {
  14. try {
  15. $output->writeln("开始更新快递信息====>" . getDateFull());
  16. $nextPage = 1;
  17. while (is_numeric($nextPage)) {
  18. $resp = (new SaasLivePlan)->where(["status" => 1])->page($nextPage, 10)->select();
  19. if ($resp->isEmpty()) {
  20. $output->writeln("没有任务啦==".getDateFull());
  21. $nextPage = null;
  22. return true;
  23. }
  24. foreach ($resp as $item) {
  25. $output->writeln("计划ID=={$item['plan_id']}==".getDateFull());
  26. $planData = (new PlanLive)->config([
  27. "appid" => sConf("wechat.mini_appid"),
  28. "secret" => sConf("wechat.mini_secret"),
  29. ])->token()->getPlanData([intval($item['plan_id'])]);
  30. print_r($planData);
  31. }
  32. $nextPage = $nextPage+1;
  33. $output->writeln("进入下一页=={$nextPage}==".getDateFull());
  34. }
  35. } catch (\Throwable $throwable) {
  36. echo getDateFull()."===查询计划数据报错\n";
  37. echo $throwable->getFile()."\n";
  38. echo $throwable->getLine()."\n";
  39. }
  40. return self::SUCCESS;
  41. }
  42. }