公众号消息提醒
This commit is contained in:
parent
fadb49352a
commit
8024023280
@ -38,7 +38,9 @@ class SendMsgCronJobController extends BaseController
|
||||
try {
|
||||
// $teacher_schedule_time = TeacherScheduleTime::where('id', $teacher_schedule_time_id)->with(['teacherAttr', 'subject', 'studentSchedule'])->findOrEmpty();
|
||||
|
||||
$res = (new SendMsgCronJobService())->teacherScheduleTimePublishMsg(75);
|
||||
// $res = (new SendMsgCronJobService())->teacherScheduleTimePublishMsgToTeacher(75);
|
||||
|
||||
$res = (new SendMsgCronJobService())->teacherScheduleTimePublishMsgToStudent(75);
|
||||
|
||||
return $this->json($res);
|
||||
}catch (Exception $e){
|
||||
@ -54,8 +56,29 @@ class SendMsgCronJobController extends BaseController
|
||||
*/
|
||||
public function classBeginMsgToTeacher()
|
||||
{
|
||||
//@todo: 定时脚本
|
||||
$res = (new SendMsgCronJobService())->classBeginMsgToTeacher();
|
||||
|
||||
print '<pre>';
|
||||
print_r($res);
|
||||
die;
|
||||
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 上课提前通知老师
|
||||
* @return void
|
||||
*/
|
||||
public function classBeginSingleMsgToTeacher()
|
||||
{
|
||||
//@todo: 定时脚本
|
||||
$res = (new SendMsgCronJobService())->classBeginSingleMsgToTeacher(79);
|
||||
|
||||
print '<pre>';
|
||||
print_r($res);
|
||||
die;
|
||||
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ 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';
|
||||
const TEACHER_SCHEDULE_TIME_PUBLISH_STUDENT = 'teacher_schedule_time_publish_to_student';
|
||||
|
||||
|
||||
/**
|
||||
@ -47,7 +47,7 @@ class SendMsgCronJobService
|
||||
* @return void
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function teacherScheduleTimePublishMsg($teacher_schedule_time_id)
|
||||
public function teacherScheduleTimePublishMsgToTeacher($teacher_schedule_time_id)
|
||||
{
|
||||
try {
|
||||
$teacher_schedule_time = TeacherScheduleTime::where(['id' => $teacher_schedule_time_id])->with(['teacherAttr', 'subject', 'studentSchedule'])
|
||||
@ -71,7 +71,6 @@ class SendMsgCronJobService
|
||||
array_push($student_info, ['id' => $student['id'], 'student_name' => $student['student_name'], 'openid' => $student['openid']]);
|
||||
}
|
||||
|
||||
|
||||
//给教师发送消息
|
||||
$msgInfo = $teacher_schedule_time->toArray();
|
||||
$student_name = implode(',', array_column($student_info, 'student_name'));
|
||||
@ -122,6 +121,43 @@ class SendMsgCronJobService
|
||||
'send_result_msg' => $result['msg'],
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 排课成功通知
|
||||
* @param $teacher_schedule_time_id
|
||||
* @return void
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function teacherScheduleTimePublishMsgToStudent($teacher_schedule_time_id)
|
||||
{
|
||||
try {
|
||||
$teacher_schedule_time = TeacherScheduleTime::where(['id' => $teacher_schedule_time_id])->with(['teacherAttr', 'subject', 'studentSchedule'])
|
||||
->findOrEmpty();
|
||||
|
||||
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']]);
|
||||
}
|
||||
|
||||
$student_name = implode(',', array_column($student_info, 'student_name'));
|
||||
|
||||
foreach ($student_info as $student) {
|
||||
|
||||
$send_teacher_data = [
|
||||
@ -153,7 +189,7 @@ class SendMsgCronJobService
|
||||
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
||||
|
||||
CronJob::create([
|
||||
'msg_type' => self::TEACHER_SCHEDULE_TIME_PUBLISH_TEACHER,
|
||||
'msg_type' => self::TEACHER_SCHEDULE_TIME_PUBLISH_STUDENT,
|
||||
'teacher_id' => $teacher_schedule_time->teacher_id,
|
||||
'subject_id' => $teacher_schedule_time->subject_id,
|
||||
'student_id' => '',
|
||||
@ -166,7 +202,7 @@ class SendMsgCronJobService
|
||||
'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),
|
||||
'msg_info' => json_encode($msgInfo, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
'msg_info' => json_encode($teacher_schedule_time->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
'send_result' => $result['code'] == ResponseCode::SUCCESS ? 1 : 0,
|
||||
'send_result_msg' => $result['msg'],
|
||||
]);
|
||||
@ -187,15 +223,32 @@ class SendMsgCronJobService
|
||||
{
|
||||
try {
|
||||
$teacher_schedule_time = TeacherScheduleTime::where(['is_publish' => 1])
|
||||
->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')))
|
||||
->whereTime('start_time', '>=', date('Y-m-d 00:00:00', strtotime('+1 day')))
|
||||
->whereTime('start_time', '<=', date('Y-m-d 23:59:59', strtotime('+1 day')))
|
||||
->with(['teacherAttr', 'subject', 'studentSchedule'])
|
||||
->select();
|
||||
|
||||
foreach ($teacher_schedule_time as $item) {
|
||||
|
||||
$studentSchedule = $item->studentSchedule->toArray();
|
||||
if (empty($studentSchedule)) {
|
||||
CronJob::create([
|
||||
'msg_type' => self::CLASS_BEGIN_NOTIFY_TEACHER,
|
||||
'teacher_id' => $item->teacher_id,
|
||||
'subject_id' => $item->subject_id,
|
||||
'student_id' => '',
|
||||
'teacher_schedule_time_id' => $item->id,
|
||||
'time' => $item->time,
|
||||
'en_time' => $item->en_time,
|
||||
'start_time' => $item->start_time,
|
||||
'end_time' => $item->end_time,
|
||||
'en_start_time' => $item->en_start_time,
|
||||
'en_end_time' => $item->en_end_time,
|
||||
'send_role' => 'student',
|
||||
'send_data' => json_encode([], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
'msg_info' => json_encode($item->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
'send_result' => 0,
|
||||
'send_result_msg' => '未找到课程分配的学生',
|
||||
]);
|
||||
throw new Exception('未找到课程分配的学生');
|
||||
}
|
||||
|
||||
@ -209,6 +262,29 @@ class SendMsgCronJobService
|
||||
array_push($student_info, ['id' => $student['id'], 'student_name' => $student['student_name'], 'openid' => $student['openid']]);
|
||||
}
|
||||
$student_name = implode(',', array_column($student_info, 'student_name'));
|
||||
|
||||
if (empty($student_name)) {
|
||||
CronJob::create([
|
||||
'msg_type' => self::CLASS_BEGIN_NOTIFY_TEACHER,
|
||||
'teacher_id' => $item->teacher_id,
|
||||
'subject_id' => $item->subject_id,
|
||||
'student_id' => '',
|
||||
'teacher_schedule_time_id' => $item->id,
|
||||
'time' => $item->time,
|
||||
'en_time' => $item->en_time,
|
||||
'start_time' => $item->start_time,
|
||||
'end_time' => $item->end_time,
|
||||
'en_start_time' => $item->en_start_time,
|
||||
'en_end_time' => $item->en_end_time,
|
||||
'send_role' => 'student',
|
||||
'send_data' => json_encode([], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
'msg_info' => json_encode($item->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
'send_result' => 0,
|
||||
'send_result_msg' => '未找到课程分配的学生',
|
||||
]);
|
||||
throw new Exception('未找到课程分配的学生');
|
||||
}
|
||||
|
||||
$send_teacher_data = [
|
||||
'touser' => 'olfLh6o4CG9xb6_tA3y29shOj_Bo',//@todo:发送人
|
||||
'template_id' => 'yYw0jnlhjnq4AJ_CAlAghgGyV0bvbVHG-eV8TNC3REI',
|
||||
@ -236,10 +312,157 @@ class SendMsgCronJobService
|
||||
"lang" => "zh_CN",
|
||||
];
|
||||
|
||||
|
||||
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
||||
|
||||
CronJob::create([
|
||||
'msg_type' => self::CLASS_BEGIN_NOTIFY_TEACHER,
|
||||
'teacher_id' => $item->teacher_id,
|
||||
'subject_id' => $item->subject_id,
|
||||
'student_id' => '',
|
||||
'teacher_schedule_time_id' => $item->id,
|
||||
'time' => $item->time,
|
||||
'en_time' => $item->en_time,
|
||||
'start_time' => $item->start_time,
|
||||
'end_time' => $item->end_time,
|
||||
'en_start_time' => $item->en_start_time,
|
||||
'en_end_time' => $item->en_end_time,
|
||||
'send_role' => 'student',
|
||||
'send_data' => json_encode($send_teacher_data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
'msg_info' => json_encode($item->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()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上课时间 提前一天通知老师
|
||||
* @return void
|
||||
*/
|
||||
public function classBeginSingleMsgToTeacher($teacher_schedule_time_id)
|
||||
{
|
||||
try {
|
||||
$teacher_schedule_time = TeacherScheduleTime::where(['is_publish' => 1, 'id' => $teacher_schedule_time_id])
|
||||
->with(['teacherAttr', 'subject', 'studentSchedule'])
|
||||
->findOrEmpty();
|
||||
|
||||
$studentSchedule = $teacher_schedule_time->studentSchedule->toArray();
|
||||
if (empty($studentSchedule)) {
|
||||
CronJob::create([
|
||||
'msg_type' => self::CLASS_BEGIN_NOTIFY_TEACHER,
|
||||
'teacher_id' => $teacher_schedule_time->teacher_id,
|
||||
'subject_id' => $teacher_schedule_time->subject_id,
|
||||
'student_id' => '',
|
||||
'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([], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
'msg_info' => json_encode($teacher_schedule_time->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
'send_result' => 0,
|
||||
'send_result_msg' => '未找到课程分配的学生',
|
||||
]);
|
||||
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']]);
|
||||
}
|
||||
$student_name = implode(',', array_column($student_info, 'student_name'));
|
||||
|
||||
if (empty($student_name)) {
|
||||
CronJob::create([
|
||||
'msg_type' => self::CLASS_BEGIN_NOTIFY_TEACHER,
|
||||
'teacher_id' => $teacher_schedule_time->teacher_id,
|
||||
'subject_id' => $teacher_schedule_time->subject_id,
|
||||
'student_id' => '',
|
||||
'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([], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
'msg_info' => json_encode($teacher_schedule_time->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
'send_result' => 0,
|
||||
'send_result_msg' => '未找到课程分配的学生',
|
||||
]);
|
||||
throw new Exception('未找到课程分配的学生');
|
||||
}
|
||||
|
||||
$send_teacher_data = [
|
||||
'touser' => 'olfLh6o4CG9xb6_tA3y29shOj_Bo',//@todo:发送人
|
||||
'template_id' => 'yYw0jnlhjnq4AJ_CAlAghgGyV0bvbVHG-eV8TNC3REI',
|
||||
'data' => [
|
||||
'thing8' => [//课程名称
|
||||
'value' => $teacher_schedule_time->english_name,
|
||||
'color' => '#000000'
|
||||
],
|
||||
'time5' => [//上课时间
|
||||
'value' => $teacher_schedule_time->end_time,
|
||||
'color' => '#000000'
|
||||
],
|
||||
'thing4' => [//任课教师
|
||||
'value' => $teacher_schedule_time->teacherAttr->teacher_name,
|
||||
'color' => '#000000'
|
||||
],
|
||||
'thing7' => [//学员姓名
|
||||
'value' => $student_name,
|
||||
'color' => '#000000'
|
||||
]
|
||||
],
|
||||
'miniprogram' => [
|
||||
|
||||
],
|
||||
"lang" => "zh_CN",
|
||||
];
|
||||
|
||||
|
||||
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
||||
|
||||
CronJob::create([
|
||||
'msg_type' => self::CLASS_BEGIN_NOTIFY_TEACHER,
|
||||
'teacher_id' => $teacher_schedule_time->teacher_id,
|
||||
'subject_id' => $teacher_schedule_time->subject_id,
|
||||
'student_id' => '',
|
||||
'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),
|
||||
'msg_info' => json_encode($teacher_schedule_time->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()
|
||||
@ -264,7 +487,7 @@ class SendMsgCronJobService
|
||||
'template_id' => 'OKLtn1L12ZrKsJczk1IRn_8kcQ4aKBmMsYsnjgAkkfE',
|
||||
'data' => [
|
||||
'thing1' => [//作业名称
|
||||
'value' => $subject_homework->english_name . '/' . date('m-d H:i', strtotime($subject_homework->start_time)),
|
||||
'value' => substr($subject_homework->english_name . '/' . date('m-d H:i', strtotime($subject_homework->start_time)), 0, 18) . '..',
|
||||
'color' => '#000000'
|
||||
],
|
||||
'thing2' => [//教师姓名
|
||||
@ -278,9 +501,26 @@ class SendMsgCronJobService
|
||||
"lang" => "zh_CN",
|
||||
];
|
||||
|
||||
|
||||
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
||||
|
||||
CronJob::create([
|
||||
'msg_type' => self::SUBJECT_UPLOAD_NOTIFY_ADMIN,
|
||||
'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' => 'admin',
|
||||
'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 [
|
||||
@ -297,28 +537,25 @@ class SendMsgCronJobService
|
||||
* @return array|void
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function uploadVersionSubjectHomeworkNotifyStudent($subject_homework_id)
|
||||
public function uploadVersionSubjectHomeworkNotifyStudent($student_homework_id)
|
||||
{
|
||||
try {
|
||||
$subject_homework = SubjectHomework::where(['id' => $subject_homework_id])->with(['teacher', 'subject'])->findOrEmpty();
|
||||
|
||||
$student_homework = StudentHomework::where(['id' => $student_homework_id])->with(['teacher', 'subject'])->findOrEmpty();
|
||||
// $subject_homework = SubjectHomework::where(['id' => $subject_homework_id])->with(['teacher', 'subject'])->findOrEmpty();
|
||||
|
||||
//查找相同老师、相同课程、相同学生的下一节课
|
||||
$teacher_schedule_time = TeacherScheduleTime::where(['id' => $subject_homework->teacher_schedule_time_id])->with(['studentSchedule'])->findOrEmpty();
|
||||
|
||||
//查找下次课程开始时间
|
||||
$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)
|
||||
$next_student_schedule_time = StudentSchedule::where([
|
||||
'student_id' => $student_homework->student_id,
|
||||
'teacher_id' => $student_homework->teacher_id,
|
||||
'subject_id' => $student_homework->subject_id
|
||||
])->whereTime('start_time', '>', $student_homework->start_time)
|
||||
->order('id asc')
|
||||
->limit(1)
|
||||
->findOrEmpty();
|
||||
|
||||
if (!$next_teacher_schedule_time->isEmpty()) {
|
||||
$next_time = $next_teacher_schedule_time->start_time;
|
||||
|
||||
if (!$next_student_schedule_time->isEmpty()) {
|
||||
$next_time = $next_student_schedule_time->start_time;
|
||||
} else {
|
||||
$next_time = '';//不能没有值
|
||||
}
|
||||
@ -329,11 +566,11 @@ class SendMsgCronJobService
|
||||
'template_id' => 'ng-vuuY_hHM3N2fR3VCGdjGldOrwmzVVQzebRgkW4uY',
|
||||
'data' => [
|
||||
'thing6' => [//课程名称
|
||||
'value' => $subject_homework->english_name . '/' . date('m-d H:i', strtotime($subject_homework->start_time)),
|
||||
'value' => substr($subject_homework->english_name . '/' . date('m-d H:i', strtotime($subject_homework->start_time)), 0, 18) . '..',
|
||||
'color' => '#000000'
|
||||
],
|
||||
'thing2' => [//作业名称
|
||||
'value' => $subject_homework->english_name . '/' . date('m-d H:i', strtotime($subject_homework->start_time)),
|
||||
'value' => substr($subject_homework->english_name . '/' . date('m-d H:i', strtotime($subject_homework->start_time)), 0, 18) . '..',
|
||||
'color' => '#000000'
|
||||
],
|
||||
'thing5' => [//批改老师
|
||||
@ -355,6 +592,25 @@ class SendMsgCronJobService
|
||||
$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'],
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -414,6 +670,24 @@ class SendMsgCronJobService
|
||||
|
||||
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
||||
|
||||
CronJob::create([
|
||||
'msg_type' => self::STUDENT_UPLOAD_HOMEWORK_NOTIFY_TEACHER,
|
||||
'teacher_id' => $student_homework->teacher_id,
|
||||
'subject_id' => $student_homework->subject_id,
|
||||
'student_id' => '',
|
||||
'teacher_schedule_time_id' => $student_homework->teacher_schedule_time_id,
|
||||
'time' => $student_homework->time,
|
||||
'en_time' => $student_homework->en_time,
|
||||
'start_time' => $student_homework->start_time,
|
||||
'end_time' => $student_homework->end_time,
|
||||
'en_start_time' => $student_homework->en_start_time,
|
||||
'en_end_time' => $student_homework->en_end_time,
|
||||
'send_role' => 'student',
|
||||
'send_data' => json_encode($send_teacher_data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
'msg_info' => json_encode($student_homework->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
'send_result' => $result['code'] == ResponseCode::SUCCESS ? 1 : 0,
|
||||
'send_result_msg' => $result['msg'],
|
||||
]);
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
|
@ -21,8 +21,8 @@ class WechatUtil
|
||||
public static function getAccessToken()
|
||||
{
|
||||
try {
|
||||
// $str = '83_s2360Qbo3QwQgLRYvmeRjBWkLxkP2gbhfc6D-oT31f2oQ5S47rXfTc52dyxBNZ9ZMuVTnEWBxyuAZ-OVZolz5_PDu7wTmzuPT3n8_g6TyeZv__ZliUG5GX3U9LsGQIcAJAVFX';
|
||||
// Cache::set(self::GENERAL_ACCESS_TOKEN, $str, 3500);
|
||||
$str = '83_j5DK2vFkFW10x-ch2B224nQg8ham92nWB84lQ2g9H3mpnGNOt3y222t2bB1sYmHeTGg2rolyPFQ0VKeinV4vBJYiWbaxkZLHuntlpilWNDgVOR8zkr4wXev54ZoQVXeAFAHMO';
|
||||
Cache::set(self::GENERAL_ACCESS_TOKEN, $str, 3500);
|
||||
if (Cache::has(self::GENERAL_ACCESS_TOKEN)) {
|
||||
return Cache::get(self::GENERAL_ACCESS_TOKEN);
|
||||
} else {
|
||||
|
@ -5,6 +5,7 @@ namespace plugin\admin\app\controller;
|
||||
use app\common\model\Student;
|
||||
use app\common\model\Subject;
|
||||
use app\common\model\Teacher;
|
||||
use app\common\service\SendMsgCronJobService;
|
||||
use app\constant\ResponseCode;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
@ -153,6 +154,11 @@ class StudentHomeworkController extends Crud
|
||||
'feedback_version_file_url' => empty($feedback_version_file_url) ? '' : json_encode($feedback_version_file_url, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
]);
|
||||
|
||||
if($homework->is_publish){
|
||||
//后台发布学生作业之后通知教师
|
||||
(new SendMsgCronJobService())->studentUploadSubjectHomeworkNotifyTeacher($homework->id);
|
||||
}
|
||||
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||
'msg' => 'success'
|
||||
|
@ -6,6 +6,7 @@ use app\common\model\Student;
|
||||
use app\common\model\Subject;
|
||||
use app\common\model\Teacher;
|
||||
use app\common\model\TeacherScheduleTime;
|
||||
use app\common\service\SendMsgCronJobService;
|
||||
use app\constant\ResponseCode;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
@ -323,16 +324,19 @@ class StudentScheduleController extends Crud
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$teacher_schedule_time = \app\common\model\StudentSchedule::where(['id' => $data['schedule_time_id']])->findOrEmpty();
|
||||
if ($teacher_schedule_time->isEmpty()) {
|
||||
$student_schedule_time = \app\common\model\StudentSchedule::where(['id' => $data['schedule_time_id']])->findOrEmpty();
|
||||
if ($student_schedule_time->isEmpty()) {
|
||||
throw new Exception('未找到排课时间');
|
||||
}
|
||||
$changeData = [];
|
||||
if(isset($data['is_publish'])){
|
||||
$teacher_schedule_time->is_publish = $data['is_publish'];
|
||||
$student_schedule_time->is_publish = $data['is_publish'];
|
||||
if($data['is_publish']){
|
||||
(new SendMsgCronJobService())->teacherScheduleTimePublishMsgToStudent($student_schedule_time->teacher_schedule_time_id);
|
||||
}
|
||||
}
|
||||
|
||||
$teacher_schedule_time->save();
|
||||
$student_schedule_time->save();
|
||||
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace plugin\admin\app\controller;
|
||||
|
||||
use app\common\service\SendMsgCronJobService;
|
||||
use app\constant\ResponseCode;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
@ -180,6 +181,7 @@ class SubjectHomeworkController extends Crud
|
||||
|
||||
$subject_homework = \app\common\model\SubjectHomework::where(['id' => $data['id']])->findOrEmpty();
|
||||
$subject_homework->save([
|
||||
'homework_file_is_publish' => $data['homework_file_is_publish'],
|
||||
'homework_version_is_publish' => $data['homework_version_is_publish'],
|
||||
'last_homework_feedback_is_publish' => $data['last_homework_feedback_is_publish'],
|
||||
'subject_report_version_is_publish' => $data['subject_report_version_is_publish'],
|
||||
@ -195,6 +197,12 @@ 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->homework_file_is_publish){
|
||||
//课程作业发布之后通知学生
|
||||
(new SendMsgCronJobService())->uploadVersionSubjectHomeworkNotifyStudent($subject_homework->id);
|
||||
}
|
||||
|
||||
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||
'msg' => 'success'
|
||||
|
@ -7,6 +7,7 @@ use app\common\model\StudentSchedule;
|
||||
use app\common\model\Subject;
|
||||
use app\common\model\Teacher;
|
||||
use app\common\model\TeacherFreeTime;
|
||||
use app\common\service\SendMsgCronJobService;
|
||||
use app\constant\ResponseCode;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
@ -316,6 +317,10 @@ class TeacherScheduleTimeController extends Crud
|
||||
}
|
||||
if (isset($data['is_publish'])) {
|
||||
$teacher_schedule_time->is_publish = $data['is_publish'];
|
||||
|
||||
if($data['is_publish']){
|
||||
(new SendMsgCronJobService())->teacherScheduleTimePublishMsgToTeacher($teacher_schedule_time->id);
|
||||
}
|
||||
}
|
||||
|
||||
$teacher_schedule_time->save();
|
||||
|
@ -139,10 +139,10 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否发布</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" id="homework_version_is_publish" lay-filter="homework_version_is_publish"
|
||||
<input type="checkbox" id="homework_file_is_publish" lay-filter="homework_file_is_publish"
|
||||
lay-skin="switch"/>
|
||||
<input type="text" style="display:none" name="homework_version_is_publish"
|
||||
value="{$subject_homework['homework_version_is_publish']}"/>
|
||||
<input type="text" style="display:none" name="homework_file_is_publish"
|
||||
value="{$subject_homework['homework_file_is_publish']}"/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
@ -683,6 +683,15 @@
|
||||
$(this).parent().parent().remove();
|
||||
})
|
||||
|
||||
// 字段 是否发布 is_publish
|
||||
layui.use(["form"], function () {
|
||||
layui.$("#homework_file_is_publish").attr("checked", layui.$('input[name="homework_file_is_publish"]').val() != 0);
|
||||
layui.form.render();
|
||||
layui.form.on("switch(homework_file_is_publish)", function (data) {
|
||||
layui.$('input[name="homework_file_is_publish"]').val(this.checked ? 1 : 0);
|
||||
});
|
||||
})
|
||||
|
||||
// 字段 是否发布 is_publish
|
||||
layui.use(["form"], function () {
|
||||
layui.$("#homework_version_is_publish").attr("checked", layui.$('input[name="homework_version_is_publish"]').val() != 0);
|
||||
|
@ -10,44 +10,7 @@
|
||||
<body class="pear-container">
|
||||
|
||||
<!-- 顶部查询表单 -->
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form top-search-from">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">主键</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="id" value="" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">创建时间</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-block" id="created_at">
|
||||
<input type="text" autocomplete="off" name="created_at[]" id="created_at-date-start" class="layui-input inline-block" placeholder="开始时间">
|
||||
-
|
||||
<input type="text" autocomplete="off" name="created_at[]" id="created_at-date-end" class="layui-input inline-block" placeholder="结束时间">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-inline">
|
||||
<label class="layui-form-label"></label>
|
||||
<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="table-query">
|
||||
<i class="layui-icon layui-icon-search"></i>查询
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-md" lay-submit lay-filter="table-reset">
|
||||
<i class="layui-icon layui-icon-refresh"></i>重置
|
||||
</button>
|
||||
</div>
|
||||
<div class="toggle-btn">
|
||||
<a class="layui-hide">展开<i class="layui-icon layui-icon-down"></i></a>
|
||||
<a class="layui-hide">收起<i class="layui-icon layui-icon-up"></i></a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<div class="layui-card">
|
||||
@ -87,15 +50,6 @@
|
||||
const INSERT_URL = "/app/admin/test/insert";
|
||||
const UPDATE_URL = "/app/admin/test/update";
|
||||
|
||||
// 字段 创建时间 created_at
|
||||
layui.use(["laydate"], function() {
|
||||
layui.laydate.render({
|
||||
elem: "#created_at",
|
||||
range: ["#created_at-date-start", "#created_at-date-end"],
|
||||
type: "datetime",
|
||||
});
|
||||
})
|
||||
|
||||
// 表格渲染
|
||||
layui.use(["table", "form", "common", "popup", "util"], function() {
|
||||
let table = layui.table;
|
||||
@ -110,43 +64,15 @@
|
||||
type: "checkbox",
|
||||
align: "center"
|
||||
},{
|
||||
title: "主键",align: "center",
|
||||
title: "id",align: "center",
|
||||
field: "id",
|
||||
},{
|
||||
title: "用户",align: "center",
|
||||
field: "user_id",
|
||||
sort: true,
|
||||
},{
|
||||
title: "服务类型",align: "center",
|
||||
field: "service_type",
|
||||
templet: function (d) {
|
||||
let field = "service_type";
|
||||
if (typeof d[field] == "undefined") return "";
|
||||
let items = [];
|
||||
layui.each((d[field] + "").split(","), function (k , v) {
|
||||
items.push(apiResults[field][v] || v);
|
||||
});
|
||||
return util.escape(items.join(","));
|
||||
}
|
||||
},{
|
||||
title: "创建时间",align: "center",
|
||||
field: "created_at",
|
||||
sort: true,
|
||||
},{
|
||||
title: "更新时间",align: "center",
|
||||
field: "updated_at",
|
||||
},{
|
||||
title: "deleted_at",align: "center",
|
||||
field: "deleted_at",
|
||||
},{
|
||||
title: "用户类型",align: "center",
|
||||
field: "user_type",
|
||||
templet: function (d) {
|
||||
let field = "user_type";
|
||||
if (typeof d[field] == "undefined") return "";
|
||||
let items = [];
|
||||
layui.each((d[field] + "").split(","), function (k , v) {
|
||||
items.push(apiResults[field][v] || v);
|
||||
});
|
||||
return util.escape(items.join(","));
|
||||
}
|
||||
title: "角色",align: "center",
|
||||
field: "role_id",
|
||||
},{
|
||||
title: "操作",
|
||||
toolbar: "#table-bar",
|
||||
@ -157,8 +83,6 @@
|
||||
];
|
||||
|
||||
// 渲染表格
|
||||
function render()
|
||||
{
|
||||
table.render({
|
||||
elem: "#data-table",
|
||||
url: SELECT_API,
|
||||
@ -177,45 +101,7 @@
|
||||
layer.photos({photos: 'div[lay-id="data-table"]', anim: 5});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 获取表格中下拉或树形组件数据
|
||||
let apis = [];
|
||||
apis.push(["user_type", "/app/admin/device/getDevice?format=select"]);
|
||||
let apiResults = {};
|
||||
apiResults["service_type"] = {"1":"选项1","2":"选项2","3":"选项3"};
|
||||
apiResults["user_type"] = [];
|
||||
let count = apis.length;
|
||||
layui.each(apis, function (k, item) {
|
||||
let [field, url] = item;
|
||||
$.ajax({
|
||||
url: url,
|
||||
dateType: "json",
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
function travel(items) {
|
||||
for (let k in items) {
|
||||
let item = items[k];
|
||||
apiResults[field][item.value] = item.name;
|
||||
if (item.children) {
|
||||
travel(item.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
travel(res.data);
|
||||
},
|
||||
complete: function () {
|
||||
if (--count === 0) {
|
||||
render();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
if (!count) {
|
||||
render();
|
||||
}
|
||||
|
||||
// 编辑或删除行事件
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
|
@ -15,23 +15,16 @@
|
||||
<div class="main-container mr-5">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">服务类型</label>
|
||||
<label class="layui-form-label required">用户</label>
|
||||
<div class="layui-input-block">
|
||||
<div name="service_type" id="service_type" value="" ></div>
|
||||
<input type="number" name="user_id" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">deleted_at</label>
|
||||
<label class="layui-form-label required">角色</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="deleted_at" id="deleted_at" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">用户类型</label>
|
||||
<div class="layui-input-block">
|
||||
<div name="user_type" id="user_type" value="" ></div>
|
||||
<input type="number" name="role_id" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -62,51 +55,6 @@
|
||||
// 相关接口
|
||||
const INSERT_API = "/app/admin/test/insert";
|
||||
|
||||
// 字段 服务类型 service_type
|
||||
layui.use(["jquery", "xmSelect"], function() {
|
||||
let value = layui.$("#service_type").attr("value");
|
||||
let initValue = value ? value.split(",") : [];
|
||||
layui.xmSelect.render({
|
||||
el: "#service_type",
|
||||
name: "service_type",
|
||||
filterable: true,
|
||||
initValue: initValue,
|
||||
data: [{"value":"1","name":"选项1"},{"value":"2","name":"选项2"},{"value":"3","name":"选项3"}],
|
||||
toolbar: {"show":true,"list":["ALL","CLEAR","REVERSE"]},
|
||||
})
|
||||
});
|
||||
|
||||
// 字段 deleted_at deleted_at
|
||||
layui.use(["laydate"], function() {
|
||||
layui.laydate.render({
|
||||
elem: "#deleted_at",
|
||||
type: "datetime",
|
||||
});
|
||||
})
|
||||
|
||||
// 字段 用户类型 user_type
|
||||
layui.use(["jquery", "xmSelect", "popup"], function() {
|
||||
layui.$.ajax({
|
||||
url: "/app/admin/device/getDevice?format=select",
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
let value = layui.$("#user_type").attr("value");
|
||||
let initValue = value ? value.split(",") : [];
|
||||
layui.xmSelect.render({
|
||||
el: "#user_type",
|
||||
name: "user_type",
|
||||
initValue: initValue,
|
||||
filterable: true,
|
||||
data: res.data,
|
||||
toolbar: {"show":true,"list":["ALL","CLEAR","REVERSE"]},
|
||||
});
|
||||
if (res.code) {
|
||||
layui.popup.failure(res.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//提交事件
|
||||
layui.use(["form", "popup"], function () {
|
||||
// 字段验证允许为空
|
||||
|
@ -16,23 +16,16 @@
|
||||
<div class="main-container mr-5">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">服务类型</label>
|
||||
<label class="layui-form-label required">用户</label>
|
||||
<div class="layui-input-block">
|
||||
<div name="service_type" id="service_type" value="" ></div>
|
||||
<input type="number" name="user_id" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">deleted_at</label>
|
||||
<label class="layui-form-label required">角色</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="deleted_at" id="deleted_at" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">用户类型</label>
|
||||
<div class="layui-input-block">
|
||||
<div name="user_type" id="user_type" value="" ></div>
|
||||
<input type="number" name="role_id" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -88,51 +81,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
// 字段 服务类型 service_type
|
||||
layui.use(["jquery", "xmSelect"], function() {
|
||||
let value = layui.$("#service_type").attr("value");
|
||||
let initValue = value ? value.split(",") : [];
|
||||
layui.xmSelect.render({
|
||||
el: "#service_type",
|
||||
name: "service_type",
|
||||
filterable: true,
|
||||
initValue: initValue,
|
||||
data: [{"value":"1","name":"选项1"},{"value":"2","name":"选项2"},{"value":"3","name":"选项3"}],
|
||||
toolbar: {"show":true,"list":["ALL","CLEAR","REVERSE"]},
|
||||
})
|
||||
});
|
||||
|
||||
// 字段 deleted_at deleted_at
|
||||
layui.use(["laydate"], function() {
|
||||
layui.laydate.render({
|
||||
elem: "#deleted_at",
|
||||
type: "datetime",
|
||||
});
|
||||
})
|
||||
|
||||
// 字段 用户类型 user_type
|
||||
layui.use(["jquery", "xmSelect", "popup"], function() {
|
||||
layui.$.ajax({
|
||||
url: "/app/admin/device/getDevice?format=select",
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
let value = layui.$("#user_type").attr("value");
|
||||
let initValue = value ? value.split(",") : [];
|
||||
layui.xmSelect.render({
|
||||
el: "#user_type",
|
||||
name: "user_type",
|
||||
initValue: initValue,
|
||||
filterable: true,
|
||||
data: res.data,
|
||||
toolbar: {"show":true,"list":["ALL","CLEAR","REVERSE"]},
|
||||
});
|
||||
if (res.code) {
|
||||
layui.popup.failure(res.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// ajax返回失败
|
||||
if (res.code) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace process;
|
||||
|
||||
use app\common\service\SendMsgCronJobService;
|
||||
use Workerman\Crontab\Crontab;
|
||||
|
||||
class Task
|
||||
@ -11,7 +12,8 @@ class Task
|
||||
|
||||
// 每天的7点50执行,注意这里省略了秒位
|
||||
new Crontab('50 7 * * *', function(){
|
||||
echo date('Y-m-d H:i:s')."\n";
|
||||
//上课前一天提醒教师
|
||||
(new SendMsgCronJobService())->classBeginMsgToTeacher();
|
||||
});
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user