getArgsDate(); // 指派调度统计某1天的所有日活. dispatch(new ActiveChannelJob($date)); $this->comment('['. Carbon::now()->toDateTimeString() .'][statistics:active]['. $date .']所有每日日活统计,丢入队列'); // 指派调度统计某1天的官方日活. dispatch(new ActiveChannelJob($date, '')); $this->comment('['. Carbon::now()->toDateTimeString() .'][statistics:active]['. $date .']官方每日日活统计,丢入队列'); // 分片处理. $chunkPer = 1000; ChannelModel::orderBy('id', 'ASC')->chunk($chunkPer, function ($res) use ($date) { foreach ($res as $item) { if (!empty($item->uid)) { dispatch(new ActiveChannelJob($date, $item->uid)); } } }); $this->comment('['. Carbon::now()->toDateTimeString() .'][statistics:active]['. $date .']单独渠道代理每日日活统计,全部丢入队列'); } /** * 获取日期参数. * @return string */ private function getArgsDate() { $date = $this->option('date'); if (empty($date)) { // 没有传参数,则默认使用执行脚本服务器环境昨天日期为准. $date = Carbon::now()->subDays(1)->toDateString(); } return $date; } /** * 获取所有渠道. * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Query\Builder[]|ChannelModel[] */ private function getAllChannel() { $columns = ['id', 'uid']; $items = ChannelModel::orderBy('id', 'DESC')->all($columns); return $items; } /** * 获取仓库. * @return StatisticsActiveRepository */ private function getRepo() { if (!$this->repo instanceof StatisticsActiveRepository) { $this->repo = new StatisticsActiveRepository(); } return $this->repo; } }