fix 10分钟通知发送2次
This commit is contained in:
parent
a9fc49b0f9
commit
c9667cf136
@ -11,6 +11,7 @@ use app\common\model\SubjectHomework;
|
|||||||
use app\common\model\Teacher;
|
use app\common\model\Teacher;
|
||||||
use app\common\model\TeacherScheduleTime;
|
use app\common\model\TeacherScheduleTime;
|
||||||
use app\constant\ResponseCode;
|
use app\constant\ResponseCode;
|
||||||
|
use support\Redis;
|
||||||
use think\Exception;
|
use think\Exception;
|
||||||
|
|
||||||
class SendMsgCronJobService
|
class SendMsgCronJobService
|
||||||
@ -366,7 +367,7 @@ class SendMsgCronJobService
|
|||||||
]);
|
]);
|
||||||
// throw new Exception('未找到课程分配的学生');
|
// throw new Exception('未找到课程分配的学生');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$student_info = [];
|
$student_info = [];
|
||||||
foreach ($studentSchedule as $student) {
|
foreach ($studentSchedule as $student) {
|
||||||
@ -582,8 +583,7 @@ class SendMsgCronJobService
|
|||||||
->select();
|
->select();
|
||||||
|
|
||||||
foreach ($teacher_schedule_time as $item) {
|
foreach ($teacher_schedule_time as $item) {
|
||||||
|
|
||||||
|
|
||||||
$studentSchedule = $item->studentSchedule->toArray();
|
$studentSchedule = $item->studentSchedule->toArray();
|
||||||
if (empty($studentSchedule)) {
|
if (empty($studentSchedule)) {
|
||||||
CronJob::create([
|
CronJob::create([
|
||||||
@ -668,27 +668,32 @@ class SendMsgCronJobService
|
|||||||
"lang" => "zh_CN",
|
"lang" => "zh_CN",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$class_begin_notify_teacher_key = md5(serialize($send_teacher_data));
|
||||||
|
if(!Redis::get($class_begin_notify_teacher_key)){
|
||||||
|
Redis::setEx($class_begin_notify_teacher_key, 65, 1);
|
||||||
|
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
||||||
|
|
||||||
$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' => 'teacher',
|
||||||
|
'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'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
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' => 'teacher',
|
|
||||||
'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'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($student_info as $student) {
|
foreach ($student_info as $student) {
|
||||||
@ -720,27 +725,32 @@ class SendMsgCronJobService
|
|||||||
"lang" => "zh_CN",
|
"lang" => "zh_CN",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$class_begin_notify_student_key = md5(serialize($send_teacher_data));
|
||||||
|
if(!Redis::get($class_begin_notify_student_key)){
|
||||||
|
Redis::setEx($class_begin_notify_student_key, 65, 1);
|
||||||
|
|
||||||
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
||||||
|
|
||||||
CronJob::create([
|
CronJob::create([
|
||||||
'msg_type' => self::CLASS_BEGIN_NOTIFY_STUDENT,
|
'msg_type' => self::CLASS_BEGIN_NOTIFY_STUDENT,
|
||||||
'teacher_id' => $item->teacher_id,
|
'teacher_id' => $item->teacher_id,
|
||||||
'subject_id' => $item->subject_id,
|
'subject_id' => $item->subject_id,
|
||||||
'student_id' => '',
|
'student_id' => '',
|
||||||
'teacher_schedule_time_id' => $item->id,
|
'teacher_schedule_time_id' => $item->id,
|
||||||
'time' => $item->time,
|
'time' => $item->time,
|
||||||
'en_time' => $item->en_time,
|
'en_time' => $item->en_time,
|
||||||
'start_time' => $item->start_time,
|
'start_time' => $item->start_time,
|
||||||
'end_time' => $item->end_time,
|
'end_time' => $item->end_time,
|
||||||
'en_start_time' => $item->en_start_time,
|
'en_start_time' => $item->en_start_time,
|
||||||
'en_end_time' => $item->en_end_time,
|
'en_end_time' => $item->en_end_time,
|
||||||
'send_role' => 'student',
|
'send_role' => 'student',
|
||||||
'send_data' => json_encode($send_teacher_data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
'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),
|
'msg_info' => json_encode($item->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||||
'send_result' => $result['code'] == ResponseCode::SUCCESS ? 1 : 0,
|
'send_result' => $result['code'] == ResponseCode::SUCCESS ? 1 : 0,
|
||||||
'send_result_msg' => $result['msg'],
|
'send_result_msg' => $result['msg'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//查找学生家长,同步发送消息给家长
|
//查找学生家长,同步发送消息给家长
|
||||||
@ -773,27 +783,32 @@ class SendMsgCronJobService
|
|||||||
"lang" => "zh_CN",
|
"lang" => "zh_CN",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$class_begin_notify_parent_key = md5(serialize($send_teacher_data));
|
||||||
|
|
||||||
|
if (!Redis::get($class_begin_notify_parent_key)){
|
||||||
|
Redis::setEx($class_begin_notify_parent_key, 65, 1);
|
||||||
|
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
||||||
|
CronJob::create([
|
||||||
|
'msg_type' => self::CLASS_BEGIN_NOTIFY_PARENT,
|
||||||
|
'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' => 'parent',
|
||||||
|
'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'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
|
|
||||||
|
|
||||||
CronJob::create([
|
|
||||||
'msg_type' => self::CLASS_BEGIN_NOTIFY_PARENT,
|
|
||||||
'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' => 'parent',
|
|
||||||
'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'],
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user