fix: 批量发布学生课程消息通知
This commit is contained in:
parent
978cae06b9
commit
008ed9c58a
@ -118,12 +118,23 @@ class StudentScheduleController extends Crud
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
|
||||
$student_schedule = \app\common\model\StudentSchedule::where(['id' => $data['ids']])->select()->toArray();
|
||||
|
||||
$res = \app\common\model\StudentSchedule::where(['id' => $data['ids']])->save([
|
||||
'is_publish' => $data['status']
|
||||
]);
|
||||
if (!$res) {
|
||||
throw new Exception('操作失败');
|
||||
}
|
||||
|
||||
foreach ($student_schedule as $item) {
|
||||
if (!$item['is_publish'] && $data['status']) {
|
||||
(new SendMsgCronJobService())->teacherScheduleTimePublishMsgToStudent($item['teacher_schedule_time_id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||
'msg' => 'success'
|
||||
@ -160,17 +171,17 @@ class StudentScheduleController extends Crud
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
$data = $request->post();
|
||||
if(isset($data['is_publish']) && $data['is_publish'] == 1){
|
||||
if (isset($data['is_publish']) && $data['is_publish'] == 1) {
|
||||
$student_schedule = \app\common\model\StudentSchedule::where(['id' => $data['id']])->find();
|
||||
//查找教师课程是否发布,未发布提示先发布教师课程
|
||||
$teacher_schedule_time = TeacherScheduleTime::where(['id'=>$student_schedule['teacher_schedule_time_id']])->findOrEmpty();
|
||||
if($teacher_schedule_time->isEmpty()){
|
||||
$teacher_schedule_time = TeacherScheduleTime::where(['id' => $student_schedule['teacher_schedule_time_id']])->findOrEmpty();
|
||||
if ($teacher_schedule_time->isEmpty()) {
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_FAIL,
|
||||
'msg' => '教师排课不存在'
|
||||
]);
|
||||
}
|
||||
if($teacher_schedule_time->is_publish != 1){
|
||||
if ($teacher_schedule_time->is_publish != 1) {
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_FAIL,
|
||||
'msg' => '请先发布教师排课'
|
||||
@ -427,9 +438,9 @@ class StudentScheduleController extends Crud
|
||||
$publish_status = 'all';
|
||||
|
||||
if (isset($data['is_publish']) && !empty($data['is_publish'])) {
|
||||
if($data['is_publish'] == 1){
|
||||
if ($data['is_publish'] == 1) {
|
||||
$publish_status = 'published';
|
||||
}else{
|
||||
} else {
|
||||
$publish_status = 'unpublished';
|
||||
}
|
||||
$student_schedule->where(['is_publish' => $data['is_publish']]);
|
||||
@ -442,7 +453,6 @@ class StudentScheduleController extends Crud
|
||||
}
|
||||
|
||||
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
//设置工作表标题名称
|
||||
@ -495,7 +505,7 @@ class StudentScheduleController extends Crud
|
||||
$teacher_name = $schedule_time['teacher_name'];
|
||||
$student_name = $schedule_time['student_name'];
|
||||
$global_student_name = $student_name;
|
||||
$row_publish_status = $schedule_time['is_publish']? 'published' : 'unpublished';
|
||||
$row_publish_status = $schedule_time['is_publish'] ? 'published' : 'unpublished';
|
||||
$hour = $schedule_time['hour'];
|
||||
}
|
||||
|
||||
@ -522,7 +532,7 @@ class StudentScheduleController extends Crud
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
|
||||
|
||||
$file_name = $data['month'] . '-' . $global_student_name .'-' . $publish_status .'-' . time() . '.xlsx';
|
||||
$file_name = $data['month'] . '-' . $global_student_name . '-' . $publish_status . '-' . time() . '.xlsx';
|
||||
|
||||
$file_path = '/export_file/';
|
||||
$save_path = public_path($file_path);
|
||||
|
Loading…
x
Reference in New Issue
Block a user