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