master
cody 5 months ago
parent 64675e5319
commit c5f8608f64

@ -17,7 +17,7 @@ class PushCourses extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'push_courses {--course_id=}'; protected $signature = 'push_courses';
/** /**
* The console command description. * The console command description.
@ -43,12 +43,8 @@ class PushCourses extends Command
*/ */
public function handle() public function handle()
{ {
$course_id = $this->option('course_id'); $today = date('Y-m-d');
$courses = Course::where(function ($query) use ($course_id) { $courses = Course::where('sign_end_date', $today)->whereHas('typeDetail', function ($query) {
if ($course_id) {
$query->where('id', $course_id);
}
})->whereHas('typeDetail', function ($query) {
$query->where('is_push', 1); $query->where('is_push', 1);
})->get(); })->get();
if ($courses->isEmpty()) { if ($courses->isEmpty()) {

@ -24,6 +24,8 @@ class Kernel extends ConsoleKernel
$schedule->command('check_birthday')->dailyAt('09:00'); $schedule->command('check_birthday')->dailyAt('09:00');
// 邮件群发 // 邮件群发
$schedule->command('send_email')->everyMinute(); $schedule->command('send_email')->everyMinute();
// 推送课程人员信息
$schedule->command('push_courses')->dailyAt('23:00');
} }
/** /**

@ -239,11 +239,6 @@ class CourseController extends BaseController
if ($model->status == 1 && $model->start_date) { if ($model->status == 1 && $model->start_date) {
CourseAppointmentTotal::addByCourse($model->id); CourseAppointmentTotal::addByCourse($model->id);
} }
// 如果添加了开课时间,就推送数据
if ($model->start_date) {
// 调用命令行更新
Artisan::call("push_courses --course_id={$model->id}");
}
// 记录日志 // 记录日志
$this->saveLogs($original, $model); $this->saveLogs($original, $model);
return $this->success($model); return $this->success($model);

Loading…
Cancel
Save