Compare commits
2 Commits
ca0f71588a
...
17632268db
| Author | SHA1 | Date |
|---|---|---|
|
|
17632268db | 10 months ago |
|
|
a8cbc26d23 | 10 months ago |
6 changed files with 188 additions and 9 deletions
@ -0,0 +1,57 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\model\class_personnel_rel; |
||||
|
|
||||
|
use core\base\BaseModel; |
||||
|
use think\model\concern\SoftDelete; |
||||
|
use think\model\relation\HasMany; |
||||
|
use think\model\relation\HasOne; |
||||
|
use app\model\student\Student; |
||||
|
use app\model\student_courses\StudentCourses; |
||||
|
use app\model\class_grade\ClassGrade; |
||||
|
|
||||
|
use app\model\customer_resources\CustomerResources; |
||||
|
|
||||
|
use app\model\campus\Campus; |
||||
|
|
||||
|
class ClassPersonnelRel extends BaseModel |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 数据表主键 |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $pk = 'id'; |
||||
|
|
||||
|
/** |
||||
|
* 模型名称 |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $name = 'class_personnel_rel'; |
||||
|
|
||||
|
|
||||
|
public function student(){ |
||||
|
return $this->hasOne(Student::class, 'id', 'source_id'); |
||||
|
} |
||||
|
|
||||
|
public function studentCourses(){ |
||||
|
return $this->hasOne(StudentCourses::class, 'student_id', 'source_id')->joinType('left')->withField('end_date,student_id')->bind(['end_date'=>'end_date']); |
||||
|
} |
||||
|
|
||||
|
public function studentCoursesInfo(){ |
||||
|
return $this->hasOne(StudentCourses::class, 'student_id', 'source_id'); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,102 @@ |
|||||
|
<?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; |
||||
|
} |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue