getArgsDate(); $nowDateObj = Carbon::now(); if ($nowDateObj->hour == 0 && $nowDateObj->isToday()) { // 凌晨00点,就跑昨日的. 解决昨日23~24点数据没统计. $date = $nowDateObj->subDays(1)->toDateString(); } $repo = new StatisticsAgentAttrsRepository(); $repo->initTodayMongo($date); // 清空今天的日志. // 指派调度统计某1天的所有用户数据. dispatch(new AgentAttrsTodayJob($date)); logger('StatisticsAgentAttrsToday', ['comment' => '['. Carbon::now()->toDateTimeString() .'][statistics:users_attrs_today]['. $date .']官方今日数据统计,丢入队列']); $this->comment('['. Carbon::now()->toDateTimeString() .'][statistics:users_attrs_today]['. $date .']官方今日数据统计,丢入队列'); $channelUids = $this->getCommonRepo()->getValidChannelUidsByDate($date); if (!empty($channelUids)) { foreach ($channelUids as $channelUid) { // 调度异步任务. dispatch(new AgentAttrsTodayJob($date, $channelUid)); } } else { logger('StatisticsAgentAttrsToday', ['msg' => 'channelUids empty', 'channelUids' => $channelUids]); } logger('StatisticsAgentAttrsToday', ['comment' => '['. Carbon::now()->toDateTimeString() .'][statistics:users_attrs_today]['. $date .']单独渠道代理今日数据统计,全部丢入队列']); $this->comment('['. Carbon::now()->toDateTimeString() .'][statistics:users_attrs_today]['. $date .']单独渠道代理今日数据统计,全部丢入队列'); } /** * 获取日期参数. * @return string */ private function getArgsDate() { $date = $this->option('date'); if (empty($date)) { // 没有传参数, 拿今天的 $date = Carbon::now()->toDateString(); } return $date; } /** * @return StatisticsCommonRepository|\Illuminate\Contracts\Foundation\Application|mixed|null */ private function getCommonRepo() { if (!$this->commonRepo instanceof StatisticsCommonRepository) { $this->commonRepo = app(StatisticsCommonRepository::class); } return $this->commonRepo; } }