fix 定时任务发送通知学生和教师
This commit is contained in:
parent
446178d213
commit
0b22f96c4a
@ -345,7 +345,7 @@ class SendMsgCronJobService
|
||||
|
||||
foreach ($teacher_schedule_time as $item) {
|
||||
$studentSchedule = $item->studentSchedule->toArray();
|
||||
if (empty($studentSchedule)) {
|
||||
if (!empty($studentSchedule)) {
|
||||
CronJob::create([
|
||||
'msg_type' => self::CLASS_BEGIN_NOTIFY_TEACHER,
|
||||
'teacher_id' => $item->teacher_id,
|
||||
@ -364,7 +364,7 @@ class SendMsgCronJobService
|
||||
'send_result' => 0,
|
||||
'send_result_msg' => '未找到课程分配的学生',
|
||||
]);
|
||||
throw new Exception('未找到课程分配的学生');
|
||||
// throw new Exception('未找到课程分配的学生');
|
||||
}
|
||||
|
||||
$student_info = [];
|
||||
@ -378,7 +378,7 @@ class SendMsgCronJobService
|
||||
}
|
||||
$student_name = implode(',', array_column($student_info, 'student_name'));
|
||||
|
||||
if (empty($student_name)) {
|
||||
if (!empty($student_name)) {
|
||||
CronJob::create([
|
||||
'msg_type' => self::CLASS_BEGIN_NOTIFY_TEACHER,
|
||||
'teacher_id' => $item->teacher_id,
|
||||
@ -397,7 +397,7 @@ class SendMsgCronJobService
|
||||
'send_result' => 0,
|
||||
'send_result_msg' => '未找到课程分配的学生',
|
||||
]);
|
||||
throw new Exception('未找到课程分配的学生');
|
||||
// throw new Exception('未找到课程分配的学生');
|
||||
}
|
||||
|
||||
$send_teacher_data = [
|
||||
@ -575,16 +575,13 @@ class SendMsgCronJobService
|
||||
{
|
||||
try {
|
||||
$teacher_schedule_time = TeacherScheduleTime::where(['is_publish' => 1])
|
||||
->whereTime('start_time', '>=', date('Y-m-d H:i:s', strtotime('+10 minute')))
|
||||
->whereTime('start_time', '<=', date('Y-m-d H:i:s', strtotime('+11 minute')))
|
||||
->whereTime('start_time', '>=', date('Y-m-d 00:00:00', strtotime('+10 minute')))
|
||||
->whereTime('start_time', '<=', date('Y-m-d 00:00:00', strtotime('+11 minute')))
|
||||
->with(['teacherAttr', 'subject', 'studentSchedule'])
|
||||
->select();
|
||||
|
||||
foreach ($teacher_schedule_time as $item) {
|
||||
|
||||
if (strtotime($item['start_time']) - time() > 60) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$studentSchedule = $item->studentSchedule->toArray();
|
||||
if (empty($studentSchedule)) {
|
||||
@ -824,7 +821,7 @@ class SendMsgCronJobService
|
||||
->findOrEmpty();
|
||||
|
||||
$studentSchedule = $teacher_schedule_time->studentSchedule->toArray();
|
||||
if (empty($studentSchedule)) {
|
||||
if (!empty($studentSchedule)) {
|
||||
CronJob::create([
|
||||
'msg_type' => self::CLASS_BEGIN_NOTIFY_TEACHER,
|
||||
'teacher_id' => $teacher_schedule_time->teacher_id,
|
||||
@ -843,7 +840,7 @@ class SendMsgCronJobService
|
||||
'send_result' => 0,
|
||||
'send_result_msg' => '未找到课程分配的学生',
|
||||
]);
|
||||
throw new Exception('未找到课程分配的学生');
|
||||
// throw new Exception('未找到课程分配的学生');
|
||||
}
|
||||
|
||||
$student_info = [];
|
||||
@ -857,7 +854,7 @@ class SendMsgCronJobService
|
||||
}
|
||||
$student_name = implode(',', array_column($student_info, 'student_name'));
|
||||
|
||||
if (empty($student_name)) {
|
||||
if (!empty($student_name)) {
|
||||
CronJob::create([
|
||||
'msg_type' => self::CLASS_BEGIN_NOTIFY_TEACHER,
|
||||
'teacher_id' => $teacher_schedule_time->teacher_id,
|
||||
@ -876,7 +873,7 @@ class SendMsgCronJobService
|
||||
'send_result' => 0,
|
||||
'send_result_msg' => '未找到课程分配的学生',
|
||||
]);
|
||||
throw new Exception('未找到课程分配的学生');
|
||||
// throw new Exception('未找到课程分配的学生');
|
||||
}
|
||||
|
||||
$send_teacher_data = [
|
||||
@ -930,6 +927,7 @@ class SendMsgCronJobService
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
raw_log('cron_job/send_to_teacher_before_day_field', ['msg'=>$e->getMessage()]);
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
|
@ -13,7 +13,7 @@ class Task
|
||||
// 每天的7点50执行,注意这里省略了秒位
|
||||
new Crontab('50 7 * * *', function(){
|
||||
//上课前一天提醒教师、学生、家长
|
||||
(new SendMsgCronJobService())->classBeginSingleMsgToTeacher();
|
||||
(new SendMsgCronJobService())->classBeginMsgToTeacherBeforeDay();
|
||||
});
|
||||
|
||||
// 每分钟执行一次
|
||||
|
Loading…
x
Reference in New Issue
Block a user