|
|
|
@ -12,6 +12,7 @@ |
|
|
|
namespace app\service\api\apiService; |
|
|
|
|
|
|
|
use app\model\class_grade\ClassGrade; |
|
|
|
use app\model\course_schedule\CourseSchedule; |
|
|
|
use app\model\student\Student; |
|
|
|
use app\model\assignment\Assignment; |
|
|
|
use app\model\course\Course; |
|
|
|
@ -148,9 +149,51 @@ class jlClassService extends BaseApiService |
|
|
|
public function addPublishJob($data) |
|
|
|
{ |
|
|
|
$Assignment = new Assignment(); |
|
|
|
$res = $Assignment->create($data); |
|
|
|
return $res; |
|
|
|
foreach ($data['student_id'] as $v) { |
|
|
|
$data['student_id'] = $v; |
|
|
|
$Assignment->create($data); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
public function getStatisticsInfo($id) |
|
|
|
{ |
|
|
|
$CourseSchedule = new CourseSchedule(); |
|
|
|
$courseNum = $CourseSchedule->where('coach_id', $id)->count(); |
|
|
|
$classNum = $this->model->where('head_coach', $id)->count(); |
|
|
|
$studentInfo = $this->model->where('head_coach', $id) |
|
|
|
->with(['classPersonnelRel' => function($query) { |
|
|
|
$query->select(); |
|
|
|
}]); |
|
|
|
$studentInfo = $studentInfo->select()->toArray(); |
|
|
|
$studentNum = 0; |
|
|
|
foreach ($studentInfo as $v){ |
|
|
|
$studentNum += count($v['classPersonnelRel']); |
|
|
|
} |
|
|
|
// 获取当前时间戳 |
|
|
|
$now = time(); |
|
|
|
$firstDayOfMonth = date('Y-m-01', $now); |
|
|
|
$lastDayOfMonth = date('Y-m-t', $now); |
|
|
|
$classMonthNum = $this->model->where('head_coach', $id)->whereBetween('created_at', [$firstDayOfMonth, $lastDayOfMonth])->count(); |
|
|
|
$courseMonthNum = $CourseSchedule->where('coach_id', $id)->whereBetween('course_date', [$firstDayOfMonth, $lastDayOfMonth])->count(); |
|
|
|
|
|
|
|
$studentMonthInfo = $this->model->where('head_coach', $id)->whereBetween('created_at', [$firstDayOfMonth, $lastDayOfMonth]) |
|
|
|
->with(['classPersonnelRel' => function($query) { |
|
|
|
$query->select(); |
|
|
|
}]); |
|
|
|
$studentMonthInfo = $studentMonthInfo->select()->toArray(); |
|
|
|
$studentMonthNum = 0; |
|
|
|
foreach ($studentMonthInfo as $v){ |
|
|
|
$studentMonthNum += count($v['classPersonnelRel']); |
|
|
|
} |
|
|
|
$arr = [ |
|
|
|
'courseNum' => $courseNum, |
|
|
|
'classNum' => $classNum, |
|
|
|
'studentNum' => $studentNum, |
|
|
|
'classMonthNum' => $classMonthNum, |
|
|
|
'courseMonthNum' => $courseMonthNum, |
|
|
|
'studentMonthNum' => $studentMonthNum, |
|
|
|
]; |
|
|
|
return $arr; |
|
|
|
} |
|
|
|
} |
|
|
|
|