| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- declare(strict_types=1);
- namespace App\Command;
- use App\Model\CollectionsModel;
- use App\Model\Mongo\RegisterModel;
- use App\Model\Mongo\StatisticsModel;
- use App\Model\VipOrderModel;
- use App\Repositories\StatisticsRepository;
- use App\Repositories\Utils\TelegramRepository;
- use Carbon\Carbon;
- use Hyperf\Command\Command as HyperfCommand;
- use Hyperf\Command\Annotation\Command;
- use Hyperf\Redis\Redis;
- use Symfony\Component\Console\Input\InputArgument;
- /**
- * @Command
- */
- class PushStatisticsInfoCommand extends HyperfCommand
- {
- public function __construct()
- {
- parent::__construct('push:statistics_info');
- }
- public function configure()
- {
- parent::configure();
- $this->setDescription('推送统计数据到tg群');
- $this->addArgument('date', InputArgument::OPTIONAL, '日期', '');
- }
- public function handle()
- {
- $date = $this->input->getArgument('date');
- if (empty($date)) {
- // 定义昨天
- $date = Carbon::now()->subDays(1)->toDateString();
- } else {
- $date = Carbon::parse($date)->toDateString();
- }
- /**
- * @var StatisticsRepository $repo
- */
- $repo = make(StatisticsRepository::class);
- $data = $repo->oneDayInfo($date);
- $vipMoney = $data['all_money'] - $data['coins_money'];
- /**
- * @var TelegramRepository $tgRepo
- */
- $tgRepo = make(TelegramRepository::class);
- $taskName = 'data_report';
- $nowDate = Carbon::now()->toDateTimeString();
- $appFlag = env('APP_NAME', '');
- $msgContent = <<<EOT
- 【主题】每日单个项目数据汇总({$date})
- 【项目标识】{$appFlag}
- 【统计日期】{$date}
- 【报告时间】{$nowDate}
- 【清单如下】
- 今日总充值:{$data['all_money']}
- 今日VIP充值:{$vipMoney}
- 今日金币充值:{$data['coins_money']}
- 今日新增:{$data['inc']}
- 今日日活:{$data['dua']}
- ------------------
- EOT;
- $tgRepo->sendCommonText($msgContent, $taskName);
- $this->info('success');
- }
- }
|