This commit is contained in:
Dai 2024-09-22 21:46:18 +08:00
parent 7b471851e0
commit 1388426e54
3 changed files with 108 additions and 1 deletions

View File

@ -84,7 +84,7 @@ class TeacherScheduleTimeController extends BaseController
'time_on' => $v['time'],
'subject' => $v['english_name'],
'teacher_name' => $v['teacher_name'],
'student_name' => implode(',', array_unique($student)),
'student_name' => implode(',', array_unique(array_filter($student))),
'time_num' => $v['hour'] . '/h',
];
$stu_nmae = $v['teacher_name'];

View File

@ -532,6 +532,109 @@ class SendMsgCronJobService
}
/**
* @desc 课程报告发布之后通知学生家长
* @param $subject_homework_id
* @return array|void
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function uploadSubjectReportVersionNotifyStudentParents($subject_homework_id)
{
try {
return [
'code' => ResponseCode::FAIL,
'msg' => $e->getMessage()
];
$subject_homework = SubjectHomework::where(['id'=>$subject_homework_id])->findOrEmpty();
//查找该课程作业的课程的学生
$student_schedule = StudentSchedule::where(['teacher_schedule_time_id'=>$subject_homework->teacher_schedule_time_id])->with(['student', 'subject', 'teacher'])->findOrEmpty();
//
// $student_homework = StudentHomework::where(['id' => $student_homework_id])->with(['teacher', 'subject'])->findOrEmpty();
//查找相同老师、相同课程、相同学生的下一节课
$next_student_schedule_time = StudentSchedule::where([
'student_id' => $student_schedule->student_id,
'teacher_id' => $student_schedule->teacher_id,
'subject_id' => $student_schedule->subject_id
])->whereTime('start_time', '>', $student_schedule->start_time)
->order('id asc')
->limit(1)
->findOrEmpty();
if (!$next_student_schedule_time->isEmpty()) {
$next_time = $next_student_schedule_time->start_time;
} else {
// $next_time = date('Y-m-d H:i:s', strtotime('+7 day',$next_student_schedule_time->start_time ));//不能没有值
$next_time = '作业提交时间为下次上课前';//不能没有值
}
if (!empty($subject_homework->subject_file_url)) {
$send_teacher_data = [
'touser' => $student_schedule->student_openid,
'template_id' => 'IYIMurENbyxkQ_axIsrkjMJNb8i1AIX4qRgVUEzQX6I',
'data' => [
'thing1' => [//所属课程
'value' => substr($student_schedule->english_name . '/' . date('m-d H:i', strtotime($student_schedule->start_time)), 0, 18) . '..',
'color' => '#000000'
],
'thing2' => [//作业名称
'value' => substr($student_schedule->english_name . '/' . date('m-d H:i', strtotime($student_schedule->start_time)), 0, 18) . '..',
'color' => '#000000'
],
'thing3' => [//批改老师
'value' => $student_schedule->teacher_name,
'color' => '#000000'
],
'time8' => [//机构名称
'value' => $next_time,
'color' => '#000000'
]
],
'miniprogram' => [
],
"lang" => "zh_CN",
];
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
//@todo:写入日志中
CronJob::create([
'msg_type' => self::SUBJECT_VERSION_UPLOAD_NOTIFY_STUDENT,
'teacher_id' => $subject_homework->teacher_id,
'subject_id' => $subject_homework->subject_id,
'student_id' => '',
'teacher_schedule_time_id' => $subject_homework->teacher_schedule_time_id,
'time' => $subject_homework->time,
'en_time' => $subject_homework->en_time,
'start_time' => $subject_homework->start_time,
'end_time' => $subject_homework->end_time,
'en_start_time' => $subject_homework->en_start_time,
'en_end_time' => $subject_homework->en_end_time,
'send_role' => 'student',
'send_data' => json_encode($send_teacher_data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
'msg_info' => json_encode($subject_homework->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
'send_result' => $result['code'] == ResponseCode::SUCCESS ? 1 : 0,
'send_result_msg' => $result['msg'],
]);
}
}catch (Exception $e) {
return [
'code' => ResponseCode::FAIL,
'msg' => $e->getMessage()
];
}
}
/**
* @desc 老师上传作业后台管理员人员翻译过,重新上传通知学生,课程作业通知
* @param $subject_homework_id

View File

@ -227,6 +227,10 @@ class SubjectHomeworkController extends Crud
'subject_file_version_url' => empty($subject_file_version_url) ? '' : json_encode($subject_file_version_url, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
]);
if($subject_homework->subject_report_version_is_publish){
//课程报告发布之后通知学生
(new SendMsgCronJobService())->uploadSubjectReportVersionNotifyStudentParents($subject_homework->id);
}
if($subject_homework->subject_file_version_is_publish){
//课程作业发布之后通知学生
(new SendMsgCronJobService())->uploadVersionSubjectHomeworkNotifyStudent($subject_homework->id);