getArgsDate(); // 指派调度统计某1天的所有新增用户. dispatch(new NewUsersChannelJob($date)); $this->comment('['. Carbon::now()->toDateTimeString() .'][statistics:new_users]['. $date .']所有每日新增用户统计,丢入队列'); // 指派调度统计某1天的官方新增用户. dispatch(new NewUsersChannelJob($date, '')); $this->comment('['. Carbon::now()->toDateTimeString() .'][statistics:new_users]['. $date .']官方每日新增用户统计,丢入队列'); // 分片处理. $chunkPer = 1000; ChannelModel::orderBy('id', 'ASC')->chunk($chunkPer, function ($res) use ($date) { foreach ($res as $item) { if (!empty($item->uid)) { dispatch(new NewUsersChannelJob($date, $item->uid)); } } }); $this->comment('['. Carbon::now()->toDateTimeString() .'][statistics:new_users]['. $date .']单独渠道代理每日新增用户统计,全部丢入队列'); } /** * 获取日期参数. * @return string */ private function getArgsDate() { $date = $this->option('date'); if (empty($date)) { // 没有传参数,则默认使用执行脚本服务器环境昨天日期为准. $date = Carbon::now()->subDays(1)->toDateString(); } return $date; } }