| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\command;
- use app\extra\dyMini\PlanLive;
- use app\model\saas\SaasLivePlan;
- use Symfony\Component\Console\Command\Command;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Output\OutputInterface;
- class SyncPlan extends Command
- {
- protected static string $defaultName = 'sync:plan';
- protected static string $defaultDescription = '查询定向佣金计划带货汇总数据';
- protected function execute(InputInterface $input, OutputInterface $output): int
- {
- try {
- $output->writeln("开始更计划带货数据信息====>" . getDateFull());
- $nextPage = 1;
- while (is_numeric($nextPage)) {
- $resp = (new SaasLivePlan)->where(["status" => 1])->page($nextPage, 10)->select();
- if ($resp->isEmpty()) {
- $output->writeln("没有任务啦==".getDateFull());
- $nextPage = null;
- return true;
- }
- foreach ($resp as $item) {
- $output->writeln("计划ID=={$item['plan_id']}==".getDateFull());
- $planData = (new PlanLive)->config([
- "appid" => sConf("wechat.mini_appid"),
- "secret" => sConf("wechat.mini_secret"),
- ])->token()->getPlanData([intval($item['plan_id'])]);
- if (isset($planData['data'][$item['plan_id']])) {
- echo getDateFull()."更新数据成功\n";
- (new SaasLivePlan)->where("id",$item['id'])->save([
- "order_money" => $planData['data'][$item['plan_id']]['gmv']??0,
- "done_money" => $planData['data'][$item['plan_id']]['used_gmv']??0
- ]);
- } else {
- echo getDateFull()."没有查询到数据\n";
- }
- }
- $nextPage = $nextPage+1;
- $output->writeln("进入下一页=={$nextPage}==".getDateFull());
- }
- } catch (\Throwable $throwable) {
- echo getDateFull()."===查询计划数据报错\n";
- echo $throwable->getFile()."\n";
- echo $throwable->getLine()."\n";
- }
- return self::SUCCESS;
- }
- }
|