智慧教务系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

120 lines
3.8 KiB

<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址:https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\api\apiService;
use app\model\class_grade\ClassGrade;
use app\model\student\Student;
use core\base\BaseApiService;
/**
* 考勤管理服务层
* Class MemberService
* @package app\service\api\member
*/
class jlClassService extends BaseApiService
{
public function __construct()
{
parent::__construct();
$this->model = (new ClassGrade());
}
//列表
public function list($id,$data)
{
$order = 'id desc';
$where = [];
if ($data['name'] !== '') {
$where[] = ['name','like','%'.$data['name'].'%'];
}
$search_model = $this->model->where('head_coach', $id)->where($where)->order($order)
->with(['classPersonnelRel' => function($query) {
$query->with(['student' => function($query) {
$query->with(['customerResources' => function($query) {
$query->with(['member' => function($query) {
$query->select();
}]);
}]);
},'studentCourses']);
},'personnelAll']);
$list = $this->pageQuery($search_model);
foreach ($list['data'] as &$v){
if (count($v['classPersonnelRel']) > 0) {
$now = time();
$count = 0;
foreach ($v['classPersonnelRel'] as $item) {
if (isset($item['end_date'])) {
$endTime = strtotime($item['end_date']);
if ($endTime > $now && $endTime <= $now + 7 * 86400) {
$count++;
}
}
}
$v['end_count'] = $count;
} else {
$v['end_count'] = 0;
}
}
return $list;
}
public function info($data)
{
$search_model = $this->model->where('id', $data)
->with(['classPersonnelRel' => function($query) {
$query->with(['student' => function($query) {
$query->with(['customerResources' => function($query) {
$query->with(['member' => function($query) {
$query->select();
}]);
}]);
},'studentCourses','studentCoursesInfo']);
},'personnelAll', 'personnelName']);
$list = $search_model->find();
if (count($list['classPersonnelRel']) > 0) {
$now = time();
$count = 0;
foreach ($list['classPersonnelRel'] as $item) {
if (isset($item['end_date'])) {
$endTime = strtotime($item['end_date']);
if ($endTime > $now && $endTime <= $now + 7 * 86400) {
$count++;
}
}
}
$v['end_count'] = $count;
} else {
$v['end_count'] = 0;
}
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;
}
}