2024-08-04 22:28:52 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\common\service;
|
|
|
|
|
|
2024-08-04 23:31:50 +08:00
|
|
|
|
use app\common\model\CronJob;
|
|
|
|
|
use app\common\model\Student;
|
2024-08-19 22:48:14 +08:00
|
|
|
|
use app\common\model\StudentHomework;
|
|
|
|
|
use app\common\model\StudentSchedule;
|
2024-08-05 22:34:26 +08:00
|
|
|
|
use app\common\model\SubjectHomework;
|
2024-08-04 22:28:52 +08:00
|
|
|
|
use app\common\model\TeacherScheduleTime;
|
2024-08-04 23:31:50 +08:00
|
|
|
|
use app\constant\ResponseCode;
|
2024-08-04 22:28:52 +08:00
|
|
|
|
use think\Exception;
|
|
|
|
|
|
|
|
|
|
class SendMsgCronJobService
|
|
|
|
|
{
|
|
|
|
|
const TEACHER_SCHEDULE_TIME_PUBLISH_TEACHER = 'teacher_schedule_time_publish_to_teacher';
|
|
|
|
|
const TEACHER_SCHEDULE_TIME_PUBLISH_STUDENT = 'teacher_schedule_time_publish_to_teacher';
|
|
|
|
|
|
2024-08-05 21:59:13 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 排课成功通知
|
|
|
|
|
* @param $teacher_schedule_time_id
|
|
|
|
|
* @return void
|
|
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
|
|
*/
|
2024-08-04 22:28:52 +08:00
|
|
|
|
public function teacherScheduleTimePublishMsg($teacher_schedule_time_id)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2024-08-04 23:31:50 +08:00
|
|
|
|
$teacher_schedule_time = TeacherScheduleTime::where(['id' => $teacher_schedule_time_id])->with(['teacherAttr', 'subject', 'studentSchedule'])
|
|
|
|
|
->findOrEmpty();
|
2024-08-04 22:28:52 +08:00
|
|
|
|
|
2024-08-04 23:31:50 +08:00
|
|
|
|
if ($teacher_schedule_time->isEmpty()) {
|
|
|
|
|
throw new Exception('教师排课不存在');
|
|
|
|
|
}
|
|
|
|
|
$studentSchedule = $teacher_schedule_time->studentSchedule->toArray();
|
|
|
|
|
if (empty($studentSchedule)) {
|
|
|
|
|
throw new Exception('未找到课程分配的学生');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$student_info = [];
|
|
|
|
|
foreach ($studentSchedule as $student) {
|
|
|
|
|
if (!$student['is_publish']) {
|
|
|
|
|
// throw new Exception($student['student_name'] . '的排课未发布');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$student = Student::where(['id' => $student['student_id']])->findOrEmpty();
|
|
|
|
|
array_push($student_info, ['id' => $student['id'], 'student_name' => $student['student_name'], 'openid' => $student['openid']]);
|
|
|
|
|
}
|
2024-08-04 22:28:52 +08:00
|
|
|
|
|
2024-08-04 23:31:50 +08:00
|
|
|
|
|
|
|
|
|
//给教师发送消息
|
|
|
|
|
$msgInfo = $teacher_schedule_time->toArray();
|
2024-08-06 17:15:31 +08:00
|
|
|
|
$student_name = implode(',', array_column($student_info, 'student_name'));
|
2024-08-04 23:31:50 +08:00
|
|
|
|
$send_teacher_data = [
|
|
|
|
|
'touser' => 'olfLh6o4CG9xb6_tA3y29shOj_Bo',
|
|
|
|
|
'template_id' => 'gTtXWz35mjbtbOZdq6uNBIqy2_W-gu7F4H6s5N-vNAI',
|
2024-08-04 22:28:52 +08:00
|
|
|
|
'data' => [
|
|
|
|
|
'time2' => [//上课时间
|
2024-08-04 23:31:50 +08:00
|
|
|
|
'value' => $teacher_schedule_time->en_start_time,
|
2024-08-04 22:28:52 +08:00
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing1' => [//课程名称
|
2024-08-04 23:31:50 +08:00
|
|
|
|
'value' => $teacher_schedule_time->english_name,
|
2024-08-04 22:28:52 +08:00
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing5' => [//上课老师
|
2024-08-04 23:31:50 +08:00
|
|
|
|
'value' => $teacher_schedule_time->teacherAttr->teacher_name,
|
2024-08-04 22:28:52 +08:00
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing4' => [//学员姓名
|
2024-08-04 23:31:50 +08:00
|
|
|
|
'value' => $student_name,
|
2024-08-04 22:28:52 +08:00
|
|
|
|
'color' => '#000000'
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'miniprogram' => [
|
2024-08-04 23:31:50 +08:00
|
|
|
|
|
2024-08-04 22:28:52 +08:00
|
|
|
|
],
|
|
|
|
|
"lang" => "zh_CN",
|
|
|
|
|
];
|
2024-08-04 23:31:50 +08:00
|
|
|
|
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
|
|
|
|
|
|
|
|
|
CronJob::create([
|
|
|
|
|
'msg_type' => self::TEACHER_SCHEDULE_TIME_PUBLISH_TEACHER,
|
|
|
|
|
'teacher_id' => $teacher_schedule_time->teacher_id,
|
|
|
|
|
'subject_id' => $teacher_schedule_time->subject_id,
|
|
|
|
|
'student_id' => '',
|
2024-08-06 17:15:31 +08:00
|
|
|
|
'teacher_schedule_time_id' => $teacher_schedule_time->id,
|
|
|
|
|
'time' => $teacher_schedule_time->time,
|
|
|
|
|
'en_time' => $teacher_schedule_time->en_time,
|
|
|
|
|
'start_time' => $teacher_schedule_time->start_time,
|
|
|
|
|
'end_time' => $teacher_schedule_time->end_time,
|
|
|
|
|
'en_start_time' => $teacher_schedule_time->en_start_time,
|
|
|
|
|
'en_end_time' => $teacher_schedule_time->en_end_time,
|
|
|
|
|
'send_role' => 'teacher',
|
|
|
|
|
'send_data' => json_encode($send_teacher_data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
2024-08-04 23:31:50 +08:00
|
|
|
|
'msg_info' => json_encode($msgInfo, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
2024-08-06 17:15:31 +08:00
|
|
|
|
'send_result' => $result['code'] == ResponseCode::SUCCESS ? 1 : 0,
|
|
|
|
|
'send_result_msg' => $result['msg'],
|
|
|
|
|
]);
|
2024-08-04 23:31:50 +08:00
|
|
|
|
|
|
|
|
|
foreach ($student_info as $student) {
|
|
|
|
|
|
|
|
|
|
$send_teacher_data = [
|
|
|
|
|
'touser' => 'olfLh6o4CG9xb6_tA3y29shOj_Bo',//@todo:发送人
|
|
|
|
|
'template_id' => 'gTtXWz35mjbtbOZdq6uNBIqy2_W-gu7F4H6s5N-vNAI',
|
|
|
|
|
'data' => [
|
|
|
|
|
'time2' => [//上课时间
|
|
|
|
|
'value' => $teacher_schedule_time->start_time,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing1' => [//课程名称
|
|
|
|
|
'value' => $teacher_schedule_time->subject_name,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing5' => [//上课老师
|
|
|
|
|
'value' => $teacher_schedule_time->teacherAttr->teacher_name,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing4' => [//学员姓名
|
|
|
|
|
'value' => $student_name,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'miniprogram' => [
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
"lang" => "zh_CN",
|
|
|
|
|
];
|
|
|
|
|
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
|
|
|
|
|
|
|
|
|
CronJob::create([
|
|
|
|
|
'msg_type' => self::TEACHER_SCHEDULE_TIME_PUBLISH_TEACHER,
|
|
|
|
|
'teacher_id' => $teacher_schedule_time->teacher_id,
|
|
|
|
|
'subject_id' => $teacher_schedule_time->subject_id,
|
|
|
|
|
'student_id' => '',
|
2024-08-06 17:15:31 +08:00
|
|
|
|
'teacher_schedule_time_id' => $teacher_schedule_time->id,
|
|
|
|
|
'time' => $teacher_schedule_time->time,
|
|
|
|
|
'en_time' => $teacher_schedule_time->en_time,
|
|
|
|
|
'start_time' => $teacher_schedule_time->start_time,
|
|
|
|
|
'end_time' => $teacher_schedule_time->end_time,
|
|
|
|
|
'en_start_time' => $teacher_schedule_time->en_start_time,
|
|
|
|
|
'en_end_time' => $teacher_schedule_time->en_end_time,
|
|
|
|
|
'send_role' => 'student',
|
|
|
|
|
'send_data' => json_encode($send_teacher_data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
2024-08-04 23:31:50 +08:00
|
|
|
|
'msg_info' => json_encode($msgInfo, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
2024-08-06 17:15:31 +08:00
|
|
|
|
'send_result' => $result['code'] == ResponseCode::SUCCESS ? 1 : 0,
|
|
|
|
|
'send_result_msg' => $result['msg'],
|
2024-08-04 23:31:50 +08:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
}
|
2024-08-04 22:28:52 +08:00
|
|
|
|
|
2024-08-04 23:31:50 +08:00
|
|
|
|
} catch (Exception $e) {
|
2024-08-04 22:28:52 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-05 21:59:13 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 上课时间 提前一天通知老师
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function classBeginMsgToTeacher()
|
|
|
|
|
{
|
|
|
|
|
try {
|
2024-08-06 17:15:31 +08:00
|
|
|
|
$teacher_schedule_time = TeacherScheduleTime::where(['is_publish' => 1])
|
2024-08-05 21:59:13 +08:00
|
|
|
|
->whereTime('start_time', '>=', date('Y-m-d 00:00:00', strtotime('+21 day')))
|
|
|
|
|
->whereTime('start_time', '<=', date('Y-m-d 23:59:59', strtotime('+21 day')))
|
|
|
|
|
->with(['teacherAttr', 'subject', 'studentSchedule'])
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
foreach ($teacher_schedule_time as $item) {
|
|
|
|
|
|
|
|
|
|
$studentSchedule = $item->studentSchedule->toArray();
|
|
|
|
|
if (empty($studentSchedule)) {
|
|
|
|
|
throw new Exception('未找到课程分配的学生');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$student_info = [];
|
|
|
|
|
foreach ($studentSchedule as $student) {
|
|
|
|
|
if (!$student['is_publish']) {
|
|
|
|
|
// throw new Exception($student['student_name'] . '的排课未发布');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$student = Student::where(['id' => $student['student_id']])->findOrEmpty();
|
|
|
|
|
array_push($student_info, ['id' => $student['id'], 'student_name' => $student['student_name'], 'openid' => $student['openid']]);
|
|
|
|
|
}
|
2024-08-06 17:15:31 +08:00
|
|
|
|
$student_name = implode(',', array_column($student_info, 'student_name'));
|
2024-08-05 21:59:13 +08:00
|
|
|
|
$send_teacher_data = [
|
|
|
|
|
'touser' => 'olfLh6o4CG9xb6_tA3y29shOj_Bo',//@todo:发送人
|
2024-08-05 22:34:26 +08:00
|
|
|
|
'template_id' => 'yYw0jnlhjnq4AJ_CAlAghgGyV0bvbVHG-eV8TNC3REI',
|
2024-08-05 21:59:13 +08:00
|
|
|
|
'data' => [
|
|
|
|
|
'thing8' => [//课程名称
|
|
|
|
|
'value' => $item->english_name,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
2024-08-05 22:34:26 +08:00
|
|
|
|
'time5' => [//上课时间
|
|
|
|
|
'value' => $item->end_time,
|
2024-08-05 21:59:13 +08:00
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
2024-08-05 22:34:26 +08:00
|
|
|
|
'thing4' => [//任课教师
|
2024-08-05 21:59:13 +08:00
|
|
|
|
'value' => $item->teacherAttr->teacher_name,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
2024-08-05 22:34:26 +08:00
|
|
|
|
'thing7' => [//学员姓名
|
2024-08-05 21:59:13 +08:00
|
|
|
|
'value' => $student_name,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'miniprogram' => [
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
"lang" => "zh_CN",
|
|
|
|
|
];
|
2024-08-05 22:34:26 +08:00
|
|
|
|
|
|
|
|
|
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-06 17:15:31 +08:00
|
|
|
|
} catch (Exception $e) {
|
2024-08-05 22:34:26 +08:00
|
|
|
|
return [
|
|
|
|
|
'code' => ResponseCode::FAIL,
|
|
|
|
|
'msg' => $e->getMessage()
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @desc 管理员人员作业审阅结果通知
|
|
|
|
|
* @param $subject_homework_id
|
|
|
|
|
* @return array|void
|
|
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
|
|
*/
|
|
|
|
|
public function teacherPublishSubjectHomework($subject_homework_id)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$subject_homework = SubjectHomework::where(['id' => $subject_homework_id])->with(['teacher', 'subject'])->findOrEmpty();
|
|
|
|
|
|
|
|
|
|
$send_teacher_data = [
|
|
|
|
|
'touser' => 'olfLh6o4CG9xb6_tA3y29shOj_Bo',//@todo:发送人
|
|
|
|
|
'template_id' => 'OKLtn1L12ZrKsJczk1IRn_8kcQ4aKBmMsYsnjgAkkfE',
|
|
|
|
|
'data' => [
|
|
|
|
|
'thing1' => [//作业名称
|
|
|
|
|
'value' => $subject_homework->english_name . '/' . date('m-d H:i', strtotime($subject_homework->start_time)),
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing2' => [//教师姓名
|
|
|
|
|
'value' => $subject_homework->teacher_name,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'miniprogram' => [
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
"lang" => "zh_CN",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
|
|
|
|
|
|
|
|
|
|
2024-08-06 17:15:31 +08:00
|
|
|
|
} catch (Exception $e) {
|
2024-08-05 22:34:26 +08:00
|
|
|
|
return [
|
|
|
|
|
'code' => ResponseCode::FAIL,
|
|
|
|
|
'msg' => $e->getMessage()
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-08-06 17:15:31 +08:00
|
|
|
|
/**
|
2024-08-19 22:48:14 +08:00
|
|
|
|
* @desc 老师上传作业后台管理员人员翻译过,重新上传通知学生,课程作业通知
|
2024-08-06 17:15:31 +08:00
|
|
|
|
* @param $subject_homework_id
|
|
|
|
|
* @return array|void
|
|
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
|
|
*/
|
2024-08-05 22:34:26 +08:00
|
|
|
|
public function uploadVersionSubjectHomeworkNotifyStudent($subject_homework_id)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$subject_homework = SubjectHomework::where(['id' => $subject_homework_id])->with(['teacher', 'subject'])->findOrEmpty();
|
2024-08-06 17:15:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查找相同老师、相同课程、相同学生的下一节课
|
|
|
|
|
$teacher_schedule_time = TeacherScheduleTime::where(['id' => $subject_homework->teacher_schedule_time_id])->with(['studentSchedule'])->findOrEmpty();
|
|
|
|
|
|
2024-08-19 22:48:14 +08:00
|
|
|
|
//查找下次课程开始时间
|
|
|
|
|
$next_teacher_schedule_time = TeacherScheduleTime::where([
|
|
|
|
|
'teacher_id' => $teacher_schedule_time->teacher_id,
|
|
|
|
|
'subject_id' => $teacher_schedule_time->subject_id,
|
|
|
|
|
'is_publish' => 1
|
|
|
|
|
])
|
|
|
|
|
->whereTime('start_time', '>', $teacher_schedule_time->start_time)
|
|
|
|
|
->order('id asc')
|
|
|
|
|
->limit(1)
|
|
|
|
|
->findOrEmpty();
|
2024-08-06 17:15:31 +08:00
|
|
|
|
|
2024-08-19 22:48:14 +08:00
|
|
|
|
if (!$next_teacher_schedule_time->isEmpty()) {
|
|
|
|
|
$next_time = $next_teacher_schedule_time->start_time;
|
|
|
|
|
} else {
|
|
|
|
|
$next_time = '';//不能没有值
|
|
|
|
|
}
|
2024-08-06 17:15:31 +08:00
|
|
|
|
if (!empty($subject_homework->homework_version_file_url)) {
|
2024-08-19 22:48:14 +08:00
|
|
|
|
|
2024-08-05 22:34:26 +08:00
|
|
|
|
$send_teacher_data = [
|
|
|
|
|
'touser' => 'olfLh6o4CG9xb6_tA3y29shOj_Bo',//@todo:发送人
|
2024-08-19 22:48:14 +08:00
|
|
|
|
'template_id' => 'ng-vuuY_hHM3N2fR3VCGdjGldOrwmzVVQzebRgkW4uY',
|
2024-08-05 22:34:26 +08:00
|
|
|
|
'data' => [
|
|
|
|
|
'thing6' => [//课程名称
|
|
|
|
|
'value' => $subject_homework->english_name . '/' . date('m-d H:i', strtotime($subject_homework->start_time)),
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing2' => [//作业名称
|
2024-08-19 22:48:14 +08:00
|
|
|
|
'value' => $subject_homework->english_name . '/' . date('m-d H:i', strtotime($subject_homework->start_time)),
|
2024-08-05 22:34:26 +08:00
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing5' => [//批改老师
|
|
|
|
|
'value' => $subject_homework->teacher_name,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'time3' => [//作业截止时间
|
2024-08-19 22:48:14 +08:00
|
|
|
|
'value' => $next_time,
|
2024-08-05 22:34:26 +08:00
|
|
|
|
'color' => '#000000'
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'miniprogram' => [
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
"lang" => "zh_CN",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
2024-08-05 21:59:13 +08:00
|
|
|
|
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
2024-08-19 22:48:14 +08:00
|
|
|
|
//@todo:写入日志中
|
|
|
|
|
|
2024-08-05 21:59:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-05 22:34:26 +08:00
|
|
|
|
|
2024-08-06 17:15:31 +08:00
|
|
|
|
} catch (Exception $e) {
|
2024-08-05 21:59:13 +08:00
|
|
|
|
return [
|
|
|
|
|
'code' => ResponseCode::FAIL,
|
|
|
|
|
'msg' => $e->getMessage()
|
|
|
|
|
];
|
|
|
|
|
}
|
2024-08-05 22:34:26 +08:00
|
|
|
|
|
2024-08-05 21:59:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-08-19 22:48:14 +08:00
|
|
|
|
/**
|
|
|
|
|
* @desc 学生完成上传作业,通知老师
|
|
|
|
|
* @param $request
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function studentUploadSubjectHomeworkNotifyTeacher($student_homework_id)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$student_homework = StudentHomework::where(['id' => $student_homework_id])->with(['teacher', 'subject', 'student'])->findOrEmpty();
|
|
|
|
|
|
|
|
|
|
//获取教师openid
|
|
|
|
|
|
|
|
|
|
$send_teacher_data = [
|
|
|
|
|
'touser' => 'olfLh6o4CG9xb6_tA3y29shOj_Bo',//@todo:发送人
|
|
|
|
|
'template_id' => 'IYIMurENbyxkQ_axIsrkjOnfoURe4jOVpHU6zcGyksU',
|
|
|
|
|
'data' => [
|
|
|
|
|
'thing1' => [//课程名称
|
|
|
|
|
'value' => substr($student_homework->english_name . '/' . date('m-d H:i', strtotime($student_homework->en_start_time)), 0, 18) . '..',
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing2' => [//作业名称
|
|
|
|
|
'value' => substr($student_homework->english_name . '/' . date('m-d H:i', strtotime($student_homework->en_start_time)), 0, 18) . '..',
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing3' => [//批改老师
|
|
|
|
|
'value' => $student_homework->teacher_name,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing5' => [//学生
|
|
|
|
|
'value' => $student_homework->student_name,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'time4' => [//提交时间
|
|
|
|
|
'value' => $student_homework->created_at,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'miniprogram' => [
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
"lang" => "zh_CN",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'code' => ResponseCode::SUCCESS,
|
|
|
|
|
'data' => [],
|
|
|
|
|
'msg' => 'success'
|
|
|
|
|
];
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
return [
|
|
|
|
|
'code' => ResponseCode::FAIL,
|
|
|
|
|
'msg' => $e->getMessage()
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function studentScheduleConfirmNotifyTeacher($student_schedule_id)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$student_schedule = StudentSchedule::where(['id'=>$student_schedule_id, 'is_publish'=>1])->with(['teacher', 'student', 'subject'])->findOrEmpty();
|
|
|
|
|
|
|
|
|
|
if($student_schedule->isEmpty()){
|
|
|
|
|
throw new Exception('未找到');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//@todo:日志
|
|
|
|
|
|
|
|
|
|
$send_teacher_data = [
|
|
|
|
|
'touser' => 'olfLh6o4CG9xb6_tA3y29shOj_Bo',//@todo:发送人
|
|
|
|
|
'template_id' => '9zKhl4mYHNcz2jW8MGEtfZXU2M3slaIers9-NCpY4Xc',
|
|
|
|
|
'data' => [
|
|
|
|
|
'time3' => [//上课时间
|
|
|
|
|
'value' => $student_schedule->en_start_time,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing2' => [//课程名称
|
|
|
|
|
'value' => $student_schedule->english_name,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing4' => [//上课老师
|
|
|
|
|
'value' => $student_schedule->teacher_name,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
],
|
|
|
|
|
'thing1' => [//学生名称
|
|
|
|
|
'value' => $student_schedule->student_name,
|
|
|
|
|
'color' => '#000000'
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'miniprogram' => [
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
"lang" => "zh_CN",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
|
|
|
|
|
|
|
|
|
//@todo:添加日志
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'code' => ResponseCode::SUCCESS,
|
|
|
|
|
'data' => [],
|
|
|
|
|
'msg' => 'success'
|
|
|
|
|
];
|
|
|
|
|
}catch (Exception $e){
|
|
|
|
|
return [
|
|
|
|
|
'code' => ResponseCode::FAIL,
|
|
|
|
|
'msg' => $e->getMessage()
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-08-04 22:28:52 +08:00
|
|
|
|
}
|