diff --git a/niucloud/app/api/controller/apiController/ClassApi.php b/niucloud/app/api/controller/apiController/ClassApi.php index 0b12e697..93fd2c99 100644 --- a/niucloud/app/api/controller/apiController/ClassApi.php +++ b/niucloud/app/api/controller/apiController/ClassApi.php @@ -41,4 +41,13 @@ class ClassApi extends BaseApiService return success('获取成功',(new jlClassService())->info($data['class_id'])); } + //获取学员详情 + public function jlStudentsInfo(Request $request){ + $data = $this->request->params([ + ["students_id",0] + ]); + return success('获取成功',(new jlClassService())->jlStudentsInfo($data['students_id'])); + } + + } diff --git a/niucloud/app/api/controller/apiController/Course.php b/niucloud/app/api/controller/apiController/Course.php index a4b7a69d..597c7104 100644 --- a/niucloud/app/api/controller/apiController/Course.php +++ b/niucloud/app/api/controller/apiController/Course.php @@ -33,6 +33,12 @@ class Course extends BaseApiService return success((new CourseService())->list($id,$data)); } + //班级课程列表 + public function classCourseList(Request $request){ + $id = $this->member_id; + return success((new CourseService())->classList($id)); + } + //获取课程详情 public function courseInfo(Request $request){ $data = $this->request->params([ diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index 3b72577e..a9e7f6b0 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -286,8 +286,10 @@ Route::group(function () { - - + //获取学员详情 + Route::get('class/jlStudentsInfo', 'apiController.classApi/jlStudentsInfo'); + //班级课程列表 + Route::get('course/classCourseList', 'apiController.course/classCourseList'); //获取添加学员列表 Route::get('course/addStudentList', 'apiController.course/addStudentList'); Route::post('course/addStudent', 'apiController.course/addStudent'); diff --git a/niucloud/app/model/course/Course.php b/niucloud/app/model/course/Course.php index 2f9fc8d4..36992c8e 100644 --- a/niucloud/app/model/course/Course.php +++ b/niucloud/app/model/course/Course.php @@ -12,6 +12,7 @@ namespace app\model\course; use core\base\BaseModel; +use app\model\student_courses\StudentCourses; use think\model\concern\SoftDelete; use think\model\relation\HasMany; use think\model\relation\HasOne; @@ -85,7 +86,7 @@ class Course extends BaseModel $query->where("course_type", $value); } } - + /** * 搜索器:课程课程时长 * @param $value @@ -97,7 +98,7 @@ class Course extends BaseModel $query->where("duration", $value); } } - + /** * 搜索器:课程课时数量 * @param $value @@ -109,7 +110,7 @@ class Course extends BaseModel $query->where("session_count", $value); } } - + /** * 搜索器:课程单次逍客数量 * @param $value @@ -121,7 +122,7 @@ class Course extends BaseModel $query->where("single_session_count", $value); } } - + /** * 搜索器:课程课程价格 * @param $value @@ -133,7 +134,7 @@ class Course extends BaseModel $query->where("price", $value); } } - + /** * 搜索器:课程内部提醒课时 * @param $value @@ -145,7 +146,7 @@ class Course extends BaseModel $query->where("internal_reminder", $value); } } - + /** * 搜索器:课程客户提醒课时 * @param $value @@ -157,7 +158,7 @@ class Course extends BaseModel $query->where("customer_reminder", $value); } } - + /** * 搜索器:课程课程备注 * @param $value @@ -171,7 +172,10 @@ class Course extends BaseModel } - + public function studentCourses() + { + return $this->hasOne(StudentCourses::class, 'course_id', 'id'); + } diff --git a/niucloud/app/model/course_schedule/CourseSchedule.php b/niucloud/app/model/course_schedule/CourseSchedule.php index ec49b544..943e5c23 100644 --- a/niucloud/app/model/course_schedule/CourseSchedule.php +++ b/niucloud/app/model/course_schedule/CourseSchedule.php @@ -14,6 +14,8 @@ namespace app\model\course_schedule; use app\model\course\Course; use app\model\personnel\Personnel; use app\model\venue\Venue; +use app\model\campus\Campus; +use app\model\student_courses\StudentCourses; use core\base\BaseModel; use think\model\concern\SoftDelete; use think\model\relation\HasMany; @@ -102,4 +104,14 @@ class CourseSchedule extends BaseModel return $this->hasOne(Course::class, 'id', 'course_id'); } + public function campus() + { + return $this->hasOne(Campus::class, 'id', 'campus_id')->joinType('left')->withField('campus_name,id')->bind(['campus_name'=>'campus_name']); + } + + public function studentCourses() + { + return $this->hasOne(StudentCourses::class, 'course_id', 'course_id'); + } + } diff --git a/niucloud/app/model/student/Student.php b/niucloud/app/model/student/Student.php index e5d2e31b..4d8d0197 100644 --- a/niucloud/app/model/student/Student.php +++ b/niucloud/app/model/student/Student.php @@ -152,4 +152,5 @@ class Student extends BaseModel return $this->hasOne(ClassGrade::class, 'id', 'class_id'); } + } diff --git a/niucloud/app/service/api/apiService/CourseService.php b/niucloud/app/service/api/apiService/CourseService.php index ddefbf3b..1484cd5e 100644 --- a/niucloud/app/service/api/apiService/CourseService.php +++ b/niucloud/app/service/api/apiService/CourseService.php @@ -50,9 +50,8 @@ class CourseService extends BaseApiService $query->select(); },'venue' => function($query) { $query->select(); - }]); + },'campus','studentCourses']); $list = $this->pageQuery($search_model); - $PersonCourseSchedule = new PersonCourseSchedule(); foreach ($list['data'] as $k => $v) { $student = Db::name('person_course_schedule') ->alias('pcs') @@ -93,7 +92,7 @@ class CourseService extends BaseApiService ->alias('sc') ->where('sc.course_id', $list['id']) ->join('school_student_course_usage sscu', 'sc.id = sscu.student_course_id') - ->field('sc.student_id,sc.end_date') + ->field('sc.student_id,sc.end_date,sc.end_date,sc.start_date,sc.course_id') ->select()->toArray(); foreach ($student_courses as &$v){ $student = Db::name('student') @@ -138,6 +137,44 @@ class CourseService extends BaseApiService } + public function classList($data) + { + $CourseSchedule = new CourseSchedule(); + $search_model = $CourseSchedule + ->where('coach_id', $data) + ->with(['course' => function($query) { + $query->with(['studentCourses' => function($query) { + $query->select(); + }]); + },'venue' => function($query) { + $query->select(); + },'coach' => function($query) { + $query->select(); + },'campus']); + $list = $this->pageQuery($search_model); + foreach ($list['data'] as &$v){ + $student = Db::name('person_course_schedule') + ->alias('pcs') + ->where('pcs.schedule_id', $v['id']) + ->join('school_student st', 'pcs.student_id = st.id') + ->join('school_customer_resources cr', 'st.user_id = cr.id') + ->join('school_member sm', 'cr.member_id = sm.member_id') + ->field('st.name, sm.headimg as avatar') + ->select(); + $v['student'] = $student; + } + foreach ($list['data'] as &$v) { + $student_courses = Db::name('student_courses') + ->alias('sc') + ->where('sc.course_id', $v['id']) + ->join('school_student_course_usage sscu', 'sc.id = sscu.student_course_id') + ->field('sc.student_id,sc.end_date,sc.end_date,sc.start_date,sc.course_id') + ->select()->toArray(); + $v['student_courses'] = $student_courses; + } + return $list; + } + //获取添加学员列表 public function StudentList($id) { diff --git a/niucloud/app/service/api/apiService/jlClassService.php b/niucloud/app/service/api/apiService/jlClassService.php index d3628355..d02ff63f 100644 --- a/niucloud/app/service/api/apiService/jlClassService.php +++ b/niucloud/app/service/api/apiService/jlClassService.php @@ -12,6 +12,7 @@ namespace app\service\api\apiService; use app\model\class_grade\ClassGrade; +use app\model\student\Student; use core\base\BaseApiService; /** @@ -99,4 +100,21 @@ class jlClassService extends BaseApiService return $list; } + public function jlStudentsInfo($data) + { + $Student = new Student(); + $res = $Student->where('id',$data)->with(['customerResources' => function($query) { + $query->with(['member' => function($query) { + $query->select(); + }]); + }]); + $res = $res->find(); + + + + + + + return $res; + } }