diff --git a/app/api/controller/SendMsgCronJobController.php b/app/api/controller/SendMsgCronJobController.php
index 4356dc7..e00a930 100644
--- a/app/api/controller/SendMsgCronJobController.php
+++ b/app/api/controller/SendMsgCronJobController.php
@@ -126,9 +126,9 @@ class SendMsgCronJobController extends BaseController
* @param Request $request
* @return \support\Response
*/
- public function studentScheduleConfirmNotifyTeacher(Request $request)
+ public function manualNotifyStudentScheduleAfterConfirm(Request $request)
{
- $res = (new SendMsgCronJobService())->studentScheduleConfirmNotifyTeacher(84);
+ $res = (new SendMsgCronJobService())->manualNotifyStudentScheduleAfterConfirm(84);
return $this->json($res);
}
@@ -141,7 +141,7 @@ class SendMsgCronJobController extends BaseController
*/
public function alertTeacherSubmitFreeTime(Request $request)
{
- $res = (new SendMsgCronJobService())->studentScheduleConfirmNotifyTeacher(84);
+ $res = (new SendMsgCronJobService())->alertTeacherSubmitFreeTime(1);
return $this->json($res);
}
diff --git a/app/common/service/SendMsgCronJobService.php b/app/common/service/SendMsgCronJobService.php
index 067bbac..7fb98f9 100644
--- a/app/common/service/SendMsgCronJobService.php
+++ b/app/common/service/SendMsgCronJobService.php
@@ -7,6 +7,7 @@ use app\common\model\Student;
use app\common\model\StudentHomework;
use app\common\model\StudentSchedule;
use app\common\model\SubjectHomework;
+use app\common\model\Teacher;
use app\common\model\TeacherScheduleTime;
use app\constant\ResponseCode;
use think\Exception;
@@ -563,9 +564,9 @@ class SendMsgCronJobService
$send_teacher_data = [
'touser' => 'olfLh6o4CG9xb6_tA3y29shOj_Bo',//@todo:发送人
- 'template_id' => 'ng-vuuY_hHM3N2fR3VCGdjGldOrwmzVVQzebRgkW4uY',
+ 'template_id' => 'IYIMurENbyxkQ_axIsrkjMJNb8i1AIX4qRgVUEzQX6I',
'data' => [
- 'thing6' => [//课程名称
+ 'thing1' => [//所属课程
'value' => substr($subject_homework->english_name . '/' . date('m-d H:i', strtotime($subject_homework->start_time)), 0, 18) . '..',
'color' => '#000000'
],
@@ -573,11 +574,11 @@ class SendMsgCronJobService
'value' => substr($subject_homework->english_name . '/' . date('m-d H:i', strtotime($subject_homework->start_time)), 0, 18) . '..',
'color' => '#000000'
],
- 'thing5' => [//批改老师
+ 'thing3' => [//批改老师
'value' => $subject_homework->teacher_name,
'color' => '#000000'
],
- 'time3' => [//作业截止时间
+ 'time8' => [//机构名称
'value' => $next_time,
'color' => '#000000'
]
@@ -703,7 +704,13 @@ class SendMsgCronJobService
}
- public function studentScheduleConfirmNotifyTeacher($student_schedule_id)
+ /**
+ * @desc 课程确定之后提醒学生上课
+ * @param $student_schedule_id
+ * @return array
+ * @throws \GuzzleHttp\Exception\GuzzleException
+ */
+ public function manualNotifyStudentScheduleAfterConfirm($student_schedule_id)
{
try {
$student_schedule = StudentSchedule::where(['id' => $student_schedule_id, 'is_publish' => 1])->with(['teacher', 'student', 'subject'])->findOrEmpty();
@@ -714,7 +721,6 @@ class SendMsgCronJobService
//@todo:日志
-
$send_teacher_data = [
'touser' => 'olfLh6o4CG9xb6_tA3y29shOj_Bo',//@todo:发送人
'template_id' => '9zKhl4mYHNcz2jW8MGEtfZXU2M3slaIers9-NCpY4Xc',
@@ -745,7 +751,6 @@ class SendMsgCronJobService
$result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
- //@todo:添加日志
return [
'code' => ResponseCode::SUCCESS,
@@ -761,4 +766,60 @@ class SendMsgCronJobService
}
+ /**
+ * @desc 提醒教师上传空闲时间
+ * @param $teacher
+ * @return array|void
+ * @throws \GuzzleHttp\Exception\GuzzleException
+ */
+ public function alertTeacherSubmitFreeTime($teacher_id)
+ {
+ try {
+ $teacher = Teacher::where(['id' => $teacher_id])->findOrEmpty();
+ if($teacher->isEmpty()){
+ throw new Exception('未找到教师信息');
+ }
+ $send_teacher_data = [
+ 'touser' => 'olfLh6o4CG9xb6_tA3y29shOj_Bo',//@todo:发送人
+ 'template_id' => 'MGAdXtRAJ7qE8hRxFu3fWZvj8bBR-oNxx-1lenpCSAI',
+ 'data' => [
+ 'thing2' => [//课程名称
+ 'value' => 'Submit free time',
+ 'color' => '#000000'
+ ],
+ 'thing3' => [//任课教师
+ 'value' => $teacher->teacher_name,
+ 'color' => '#000000'
+ ],
+ 'const11' => [//上课老师
+ 'value' => 'Submit class time!',
+ 'color' => '#000000'
+ ]
+ ],
+ 'miniprogram' => [
+
+ ],
+ "lang" => "zh_CN",
+ ];
+
+ $result = (new WechatSubscriptService())->sendMsg($send_teacher_data);
+ CronJob::create([
+ 'msg_type' => self::ADMIN_NOTIFY_TEACHER_SUBMIT_FREE_TIME,
+ 'teacher_id' => $teacher->id,
+ 'send_role' => 'teacher',
+ 'send_data' => json_encode($send_teacher_data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
+ 'msg_info' => json_encode($teacher->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
+ 'send_result' => $result['code'] == ResponseCode::SUCCESS ? 1 : 0,
+ 'send_result_msg' => $result['msg'],
+ ]);
+
+ return $result;
+ }catch (Exception $e) {
+ return [
+ 'code' => ResponseCode::FAIL,
+ 'msg' => $e->getMessage()
+ ];
+ }
+ }
+
}
\ No newline at end of file
diff --git a/app/utils/WechatUtil.php b/app/utils/WechatUtil.php
index edb49e7..05a613c 100644
--- a/app/utils/WechatUtil.php
+++ b/app/utils/WechatUtil.php
@@ -21,7 +21,7 @@ class WechatUtil
public static function getAccessToken()
{
try {
- $str = '83_j5DK2vFkFW10x-ch2B224nQg8ham92nWB84lQ2g9H3mpnGNOt3y222t2bB1sYmHeTGg2rolyPFQ0VKeinV4vBJYiWbaxkZLHuntlpilWNDgVOR8zkr4wXev54ZoQVXeAFAHMO';
+ $str = '83_0jVm82U7ri-UENTGoTTFh2jowRpAN379ahJvK_3HpLPbdIheIr-ahgYhc5kkHv6dDYyaHklwqffKRQYOxURrQ-H8xq8kYvjoajYZQBNFhMCaBJs0VOU4PE5_-bYPUXfAAAXCF';
Cache::set(self::GENERAL_ACCESS_TOKEN, $str, 3500);
if (Cache::has(self::GENERAL_ACCESS_TOKEN)) {
return Cache::get(self::GENERAL_ACCESS_TOKEN);
diff --git a/plugin/admin/app/controller/CronJobController.php b/plugin/admin/app/controller/CronJobController.php
index dfb91d6..fe470c5 100644
--- a/plugin/admin/app/controller/CronJobController.php
+++ b/plugin/admin/app/controller/CronJobController.php
@@ -2,11 +2,13 @@
namespace plugin\admin\app\controller;
+use app\constant\ResponseCode;
use support\Request;
use support\Response;
use plugin\admin\app\model\CronJob;
use plugin\admin\app\controller\Crud;
use support\exception\BusinessException;
+use think\Exception;
/**
* 消息任务结果
@@ -37,6 +39,47 @@ class CronJobController extends Crud
return view('cron-job/index');
}
+ public function select(Request $request): Response
+ {
+ try {
+ $cron_job = \app\common\model\CronJob::order('id desc');
+ $data = $request->get();
+ if (isset($data['teacher_id']) && !empty($data['teacher_id'])) {
+ $cron_job->where('teacher_id', $data['teacher_id']);
+ }
+ if (isset($data['month']) && !empty($data['month'])) {
+ $cron_job->where('month', $data['month']);
+ }
+ if (isset($data['date']) && !empty($data['date'])) {
+ $cron_job->where('date', $data['date']);
+ }
+
+ $limit = (int)$request->get('limit', 10);
+ $limit = $limit <= 0 ? 10 : $limit;
+ $page = (int)$request->get('page');
+ $page = $page > 0 ? $page : 1;
+ $total = $cron_job->count();
+ $list = $cron_job->page($page, $limit)->select();
+
+ foreach ($list as &$item) {
+ $item['msg_info'] = json_decode($item['msg_info'], true);
+ }
+
+ return json([
+ 'code' => ResponseCode::WEB_API_SUCCESS,
+ 'data' => $list,
+ 'count' => $total
+ ]);
+ }catch(Exception $e){
+ return json([
+ 'code' => ResponseCode::FAIL,
+ 'msg' => $e->getMessage()
+ ]);
+ }
+
+
+ }
+
/**
* 插入
* @param Request $request
diff --git a/plugin/admin/app/controller/StudentScheduleController.php b/plugin/admin/app/controller/StudentScheduleController.php
index 3c5a73c..fc7268d 100644
--- a/plugin/admin/app/controller/StudentScheduleController.php
+++ b/plugin/admin/app/controller/StudentScheduleController.php
@@ -152,7 +152,15 @@ class StudentScheduleController extends Crud
public function update(Request $request): Response
{
if ($request->method() === 'POST') {
- return parent::update($request);
+ $result = parent::update($request);
+
+ $data = $request->post();
+ if (isset($data['is_publish']) && $data['is_publish']) {
+ $student_schedule = \app\common\model\StudentSchedule::where(['id' => $data['id']])->find();
+ (new SendMsgCronJobService())->teacherScheduleTimePublishMsgToStudent($student_schedule->teacher_schedule_time_id);
+ }
+
+ return $result;
}
return view('student-schedule/update');
}
diff --git a/plugin/admin/app/controller/SubjectHomeworkController.php b/plugin/admin/app/controller/SubjectHomeworkController.php
index 7ab5de3..3140236 100644
--- a/plugin/admin/app/controller/SubjectHomeworkController.php
+++ b/plugin/admin/app/controller/SubjectHomeworkController.php
@@ -197,7 +197,7 @@ 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){
+ if($subject_homework->subject_file_version_is_publish){
//课程作业发布之后通知学生
(new SendMsgCronJobService())->uploadVersionSubjectHomeworkNotifyStudent($subject_homework->id);
}
diff --git a/plugin/admin/app/controller/TeacherController.php b/plugin/admin/app/controller/TeacherController.php
index 9855f35..2979c82 100644
--- a/plugin/admin/app/controller/TeacherController.php
+++ b/plugin/admin/app/controller/TeacherController.php
@@ -7,6 +7,7 @@ use app\common\model\StudentSchedule;
use app\common\model\Subject;
use app\common\model\TeacherScheduleTime;
use app\common\model\TimeZone;
+use app\common\service\SendMsgCronJobService;
use app\constant\ResponseCode;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\IOFactory;
@@ -476,4 +477,27 @@ class TeacherController extends Crud
}
}
+
+ public function alterSubmitFreeTime(Request $request)
+ {
+ try {
+
+ $res = (new SendMsgCronJobService())->alertTeacherSubmitFreeTime($request->post('id'));
+
+ if($res['code'] == ResponseCode::FAIL){
+ throw new Exception($res['msg']);
+ }
+
+ return json([
+ 'code' => ResponseCode::WEB_API_SUCCESS,
+ 'msg' => '提醒一发送,请到【消息任务结果】查看状态'
+ ]);
+ }catch (Exception $e){
+ return json([
+ 'code' => ResponseCode::WEB_API_FAIL,
+ 'msg' => $e->getMessage()
+ ]);
+ }
+ }
+
}
diff --git a/plugin/admin/app/view/cron-job/index.html b/plugin/admin/app/view/cron-job/index.html
index 3aabf7a..afbcf76 100644
--- a/plugin/admin/app/view/cron-job/index.html
+++ b/plugin/admin/app/view/cron-job/index.html
@@ -96,18 +96,116 @@
+
+
+
+
+
+
+
+
+
+
@@ -152,60 +250,77 @@
},{
title: "消息类型",align: "center",
field: "msg_type",
+ templet:'#msg_type'
},{
title: "教师",align: "center",
field: "teacher_id",
+ hide: true
},{
title: "课程",align: "center",
field: "subject_id",
+ hide: true
},{
title: "学生",align: "center",
field: "student_id",
+ hide: true
},{
title: "教师排课id",align: "center",
field: "teacher_schedule_time_id",
+ hide: true
},{
title: "时间段",align: "center",
field: "time",
+ hide: true
},{
title: "国外时间",align: "center",
field: "en_time",
+ hide: true
},{
title: "课程开始时间",align: "center",
field: "start_time",
+ hide: true
},{
title: "课程结束时间",align: "center",
field: "end_time",
+ hide: true
},{
title: "国外课程开始时间",align: "center",
field: "en_start_time",
+ hide: true
},{
title: "国外课程结束时间",align: "center",
field: "en_end_time",
+ hide: true
},{
title: "发送角色",align: "center",
field: "send_role",
+ templet: '#msg_role'
},{
title: "公众号发送数据",align: "center",
field: "send_data",
+ hide: true
},{
- title: "发送消息信息",align: "center",
+ title: "消息内容",align: "center",
field: "msg_info",
+ templet: '#msg_info'
},{
title: "结果",align: "center",
field: "send_result",
+ templet: '#send_result'
},{
title: "结果信息",align: "center",
field: "send_result_msg",
},{
- title: "created_at",align: "center",
+ title: "发送时间",align: "center",
field: "created_at",
},{
title: "updated_at",align: "center",
field: "updated_at",
+ hide: true
},{
title: "deleted_at",align: "center",
field: "deleted_at",
+ hide: true
},{
title: "操作",
toolbar: "#table-bar",
diff --git a/plugin/admin/app/view/teacher/index.html b/plugin/admin/app/view/teacher/index.html
index 3fd3650..5f3fa2b 100644
--- a/plugin/admin/app/view/teacher/index.html
+++ b/plugin/admin/app/view/teacher/index.html
@@ -94,8 +94,8 @@
@@ -190,7 +190,7 @@
toolbar: "#table-bar",
align: "center",
fixed: "right",
- width: 265,
+ width: 390,
}
];
@@ -223,6 +223,8 @@
edit(obj);
} else if (obj.event === "free_time_schedule") {
free_time_schedule(obj);
+ } else if (obj.event === "alert_notify") {
+ alert_notify(obj);
} else if (obj.event === "rest_password") {
rest_password(obj);
}
@@ -321,6 +323,32 @@
});
}
// 表格编辑数据
+ let alert_notify = function(obj) {
+ let value = obj.data[PRIMARY_KEY];
+ let data = {};
+ data[PRIMARY_KEY] = obj.data[PRIMARY_KEY];
+ layer.confirm("确定给教师发送空闲时间上传提醒吗?", {
+ icon: 3,
+ title: "提示"
+ }, function(index) {
+ layer.close(index);
+ let loading = layer.load();
+ $.ajax({
+ url: '/app/admin/teacher/alterSubmitFreeTime',
+ data: data,
+ dataType: "json",
+ type: "post",
+ success: function(res) {
+ layer.close(loading);
+ if (res.code) {
+ return layui.popup.failure(res.msg);
+ }
+ return layui.popup.success("操作成功", refreshTable);
+ }
+ })
+ });
+ }
+ // 表格编辑数据
let free_time_schedule = function(obj) {
let value = obj.data[PRIMARY_KEY];
let index = layer.open({