公众号消息提醒

This commit is contained in:
Dai 2024-08-05 22:34:26 +08:00
parent 639f2aa380
commit e8c1b25443
2 changed files with 108 additions and 5 deletions

View File

@ -59,6 +59,17 @@ class SendMsgCronJobController extends BaseController
return $this->json($res);
}
/**
* @desc 老师上传作业,通知后台管理员人员翻译
* @return void
*/
public function teacherPublishSubjectHomework()
{
$res = (new SendMsgCronJobService())->teacherPublishSubjectHomework(10);
return $this->json($res);
}
}

View File

@ -4,6 +4,7 @@ namespace app\common\service;
use app\common\model\CronJob;
use app\common\model\Student;
use app\common\model\SubjectHomework;
use app\common\model\TeacherScheduleTime;
use app\constant\ResponseCode;
use think\Exception;
@ -184,21 +185,21 @@ class SendMsgCronJobService
$student_name = implode(',',array_column($student_info, 'student_name'));
$send_teacher_data = [
'touser' => 'olfLh6o4CG9xb6_tA3y29shOj_Bo',//@todo发送人
'template_id' => 'gTtXWz35mjbtbOZdq6uNBIqy2_W-gu7F4H6s5N-vNAI',
'template_id' => 'yYw0jnlhjnq4AJ_CAlAghgGyV0bvbVHG-eV8TNC3REI',
'data' => [
'thing8' => [//课程名称
'value' => $item->english_name,
'color' => '#000000'
],
'thing1' => [//上课时间
'time5' => $item->end_time,
'time5' => [//上课时间
'value' => $item->end_time,
'color' => '#000000'
],
'thing5' => [//任课教师
'thing4' => [//任课教师
'value' => $item->teacherAttr->teacher_name,
'color' => '#000000'
],
'thing4' => [//学员姓名
'thing7' => [//学员姓名
'value' => $student_name,
'color' => '#000000'
]
@ -208,6 +209,7 @@ class SendMsgCronJobService
],
"lang" => "zh_CN",
];
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
}
@ -220,4 +222,94 @@ class SendMsgCronJobService
}
/**
* @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);
}catch (Exception $e) {
return [
'code' => ResponseCode::FAIL,
'msg' => $e->getMessage()
];
}
}
public function uploadVersionSubjectHomeworkNotifyStudent($subject_homework_id)
{
try {
$subject_homework = SubjectHomework::where(['id' => $subject_homework_id])->with(['teacher', 'subject'])->findOrEmpty();
if(!empty($subject_homework->homework_version_file_url)){
$send_teacher_data = [
'touser' => 'olfLh6o4CG9xb6_tA3y29shOj_Bo',//@todo发送人
'template_id' => 'OKLtn1L12ZrKsJczk1IRn_8kcQ4aKBmMsYsnjgAkkfE',
'data' => [
'thing6' => [//课程名称
'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'
],
'thing5' => [//批改老师
'value' => $subject_homework->teacher_name,
'color' => '#000000'
],
'time3' => [//作业截止时间
'value' => $subject_homework->teacher_name,
'color' => '#000000'
]
],
'miniprogram' => [
],
"lang" => "zh_CN",
];
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
}
}catch (Exception $e) {
return [
'code' => ResponseCode::FAIL,
'msg' => $e->getMessage()
];
}
}
}