From 6c7f89463630060b92c9830dee4ad8650700da89 Mon Sep 17 00:00:00 2001 From: Dai Date: Wed, 24 Jul 2024 14:31:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=99=E5=B8=88=E6=8E=92=E8=AF=BE=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=97=A5=E6=9C=9F=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/StudentController.php | 2 +- .../service/TeacherScheduleTimeService.php | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/api/controller/StudentController.php b/app/api/controller/StudentController.php index 22934aa..c0a4f3c 100644 --- a/app/api/controller/StudentController.php +++ b/app/api/controller/StudentController.php @@ -33,7 +33,7 @@ class StudentController extends BaseController $appid = getenv('APP_ID'); $redirect_uri = urlencode(getenv('SERVER_DOMAIN') . "/h5#/pages/login/login");//重定向地址 // $redirect_uri = getenv('SERVER_DOMAIN') . "/h5#/pages/index/index";//重定向地址 - + $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=$appid&redirect_uri=$redirect_uri&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect"; // $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=$appid&redirect_uri=$redirect_uri&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"; diff --git a/app/common/service/TeacherScheduleTimeService.php b/app/common/service/TeacherScheduleTimeService.php index 8a52aca..2c32480 100644 --- a/app/common/service/TeacherScheduleTimeService.php +++ b/app/common/service/TeacherScheduleTimeService.php @@ -37,7 +37,7 @@ class TeacherScheduleTimeService foreach ($free_time as $free_date => $times) { if ($times) { foreach ($times as $time) { - $time_period = explode( ' - ' , $time); + $time_period = explode(' - ', $time); $firstDate = new DateTime($free_date . ' ' . $time_period[0]); $secondDate = new DateTime($free_date . ' ' . $time_period[1]); $diff = $secondDate->diff($firstDate); @@ -55,7 +55,7 @@ class TeacherScheduleTimeService ]; //@todo:判断是否已经存在 $res = TeacherScheduleTime::create($free_data); - if(!$res){ + if (!$res) { throw new Exception('保存失败'); } } @@ -92,8 +92,15 @@ class TeacherScheduleTimeService } $data = $request->get(); - $schedule = TeacherScheduleTime::where(['teacher_id'=>$teacher->id, 'month'=>$data['month']]) - ->field('id,teacher_id,date,time,hour,month,subject_id,is_publish') + $schedule = TeacherScheduleTime::order('id desc')->where(['teacher_id' => $teacher->id]); + if (isset($data['month']) && !empty($data['month'])) { + $schedule->where('month', $data['month']); + } + if (isset($data['date']) && !empty($data['date'])) { + $schedule->where('date', $data['date']); + } + + $list = $schedule->field('id,teacher_id,date,time,hour,month,subject_id,is_publish') ->with(['subject']) ->select(); @@ -106,10 +113,10 @@ class TeacherScheduleTimeService return [ 'code' => ResponseCode::SUCCESS, - 'data'=>$schedule, + 'data' => $list, 'msg' => 'success', ]; - }catch (Exception $e){ + } catch (Exception $e) { return [ 'code' => ResponseCode::FAIL, 'msg' => $e->getMessage()