where('is_push', 1); }) //->where('sign_end_date', $today) ->where('is_push', 1) ->get(); if ($courses->isEmpty()) { $this->info('没有可推送的课程'); return; } $YuanheRepository = new YuanheRepository(); foreach ($courses as $course) { // 所有报名审核成功的用户id $userIds = $course->courseSigns()->where('status', 1)->pluck('user_id'); $users = User::whereIn('id', $userIds)->whereNotNull('company_id')->groupBy('company_id')->get(); foreach ($users as $user) { $result = $YuanheRepository->pushCourses($course, $user,$out); if ($result) { $this->info("推送成功:{$course->name}-{$user->name}"); } else { $this->info("推送失败:{$course->name}-{$user->name}-{$out}"); } } } return $this->info('全部更新完成'); } }