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.
102 lines
3.5 KiB
102 lines
3.5 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\service\api\apiService;
|
|
|
|
use app\model\class_grade\ClassGrade;
|
|
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;
|
|
}
|
|
|
|
}
|
|
|