|
|
@ -12,12 +12,15 @@ |
|
|
namespace app\service\api\member; |
|
|
namespace app\service\api\member; |
|
|
|
|
|
|
|
|
use app\model\assignment\Assignment; |
|
|
use app\model\assignment\Assignment; |
|
|
|
|
|
use app\model\attendance\Attendance; |
|
|
use app\model\campus\Campus; |
|
|
use app\model\campus\Campus; |
|
|
|
|
|
use app\model\class_resources_rel\ClassResourcesRel; |
|
|
use app\model\communication_records\CommunicationRecords; |
|
|
use app\model\communication_records\CommunicationRecords; |
|
|
use app\model\course_schedule\CourseSchedule; |
|
|
use app\model\course_schedule\CourseSchedule; |
|
|
use app\model\member\Member; |
|
|
use app\model\member\Member; |
|
|
use app\model\person_course_schedule\PersonCourseSchedule; |
|
|
use app\model\person_course_schedule\PersonCourseSchedule; |
|
|
use app\model\service_logs\ServiceLogs; |
|
|
use app\model\service_logs\ServiceLogs; |
|
|
|
|
|
use app\model\student_courses\StudentCourses; |
|
|
use app\service\core\member\CoreMemberService; |
|
|
use app\service\core\member\CoreMemberService; |
|
|
use core\base\BaseApiService; |
|
|
use core\base\BaseApiService; |
|
|
use core\exception\ApiException; |
|
|
use core\exception\ApiException; |
|
|
@ -243,4 +246,155 @@ class MemberService extends BaseApiService |
|
|
|
|
|
|
|
|
return ['course_list' => $course_list,'task_list' => $task_list,'service_list' => $service_list]; |
|
|
return ['course_list' => $course_list,'task_list' => $task_list,'service_list' => $service_list]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function get_assignments_list(){ |
|
|
|
|
|
$Assignment = new Assignment(); |
|
|
|
|
|
$search_model = $Assignment |
|
|
|
|
|
->alias("a") |
|
|
|
|
|
->join(['school_class' => 'b'],"a.class_id = b.id","left") |
|
|
|
|
|
->join(['school_course' => 'c'],"a.course_id = c.id","left") |
|
|
|
|
|
->field("a.id,a.create_time,b.class_name,c.course_name,a.status") |
|
|
|
|
|
->where([ |
|
|
|
|
|
'a.personnel_id' => $this->member_id |
|
|
|
|
|
])->order("a.create_time desc"); |
|
|
|
|
|
|
|
|
|
|
|
$list = $this->pageQuery($search_model, function ($item){ |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return $list; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function assignments_info($data){ |
|
|
|
|
|
$Assignment = new Assignment(); |
|
|
|
|
|
|
|
|
|
|
|
$info = $Assignment |
|
|
|
|
|
->alias("a") |
|
|
|
|
|
->join(['school_personnel' => 'b'],'a.personnel_id = b.id','left') |
|
|
|
|
|
->where(['a.id' => $data['id']]) |
|
|
|
|
|
->field("a.*,b.name as coach_name,b.head_img as coach_pic") |
|
|
|
|
|
->find(); |
|
|
|
|
|
return $info ? $info->toArray() : []; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function service_detail($data){ |
|
|
|
|
|
$service_logs = new ServiceLogs(); |
|
|
|
|
|
$info = $service_logs->alias("a") |
|
|
|
|
|
->join(['school_customer_resources' => 'b'],'a.resource_id = b.id',"left") |
|
|
|
|
|
->join(['school_course' => 'c'],'a.course_id = c.id',"left") |
|
|
|
|
|
->join(['school_service' => 'd'],'a.service_id = d.id',"left") |
|
|
|
|
|
->join(['school_personnel' => 'e'],'a.staff_id = e.id',"left") |
|
|
|
|
|
->join(['school_campus' => 'f'],'b.campus = f.id',"left") |
|
|
|
|
|
->where(['a.id' => $data['id']]) |
|
|
|
|
|
->field(" |
|
|
|
|
|
a.id,b.name as resource_id,c.course_name as course_id,d.service_name as service_id,a.service_remark,a.status, |
|
|
|
|
|
e.name as staff_id,a.score,a.feedback,a.feedback_time,a.created_at,a.updated_at,f.campus_name as campus, |
|
|
|
|
|
b.source_channel,b.source |
|
|
|
|
|
") |
|
|
|
|
|
->find(); |
|
|
|
|
|
|
|
|
|
|
|
$info['source'] = get_dict_value('source',$info['source']); |
|
|
|
|
|
$info['channel'] = get_dict_value('SourceChannel',$info['source_channel']); |
|
|
|
|
|
|
|
|
|
|
|
return $info ? $info->toArray() : []; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function service_list(){ |
|
|
|
|
|
$service_logs = new ServiceLogs(); |
|
|
|
|
|
$search_model = $service_logs |
|
|
|
|
|
->alias("a") |
|
|
|
|
|
->join(['school_service' => 'd'],'a.service_id = d.id',"left") |
|
|
|
|
|
->where([ |
|
|
|
|
|
'a.staff_id' => $this->member_id |
|
|
|
|
|
]) |
|
|
|
|
|
->field("a.*,d.service_name,d.description") |
|
|
|
|
|
->order("a.created_at desc"); |
|
|
|
|
|
|
|
|
|
|
|
$list = $this->pageQuery($search_model, function ($item){ |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return $list; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//教练下全部学员 |
|
|
|
|
|
public function student_list($data) |
|
|
|
|
|
{ |
|
|
|
|
|
$where = []; |
|
|
|
|
|
if($data['type'] == "daoqi"){ |
|
|
|
|
|
$where[] = ['a.end_date', 'between', [date('Y-m-d', strtotime('-6 days')), date('Y-m-d')]]; |
|
|
|
|
|
} |
|
|
|
|
|
$student_courses = new StudentCourses(); |
|
|
|
|
|
$list = $student_courses |
|
|
|
|
|
->alias("a") |
|
|
|
|
|
->join(['school_student' => 'b'],"a.student_id = b.id","left") |
|
|
|
|
|
->join(['school_campus' => 'c'],'b.campus_id = c.id',"left") |
|
|
|
|
|
->join(['school_customer_resources' => 'e'],'e.id = b.user_id',"left") |
|
|
|
|
|
->join(['school_member' => 'f'],'f.member_id = e.member_id',"left") |
|
|
|
|
|
->join(['school_resource_sharing' => 'g'],'g.resource_id = e.id',"left") |
|
|
|
|
|
->where($where) |
|
|
|
|
|
->where("a.main_coach_id = {$this->member_id} OR a.education_id = {$this->member_id} OR find_in_set('{$this->member_id}', a.assistant_ids) ") |
|
|
|
|
|
->field(" |
|
|
|
|
|
b.id,b.name,c.campus_name as campus, |
|
|
|
|
|
a.total_hours,a.gift_hours,a.use_total_hours,a.use_gift_hours,a.end_date,f.headimg as avatar,g.id as resource_sharing_id |
|
|
|
|
|
") |
|
|
|
|
|
->select(); |
|
|
|
|
|
|
|
|
|
|
|
return $list ? $list->toArray() : []; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function sktj(){ |
|
|
|
|
|
$course_schedule = new CourseSchedule(); |
|
|
|
|
|
$student_courses = new StudentCourses(); |
|
|
|
|
|
$class_resources_rel = new ClassResourcesRel(); |
|
|
|
|
|
$attendance = new Attendance(); |
|
|
|
|
|
$year = date('Y'); |
|
|
|
|
|
$currentMonth = date('n'); |
|
|
|
|
|
$results = []; |
|
|
|
|
|
|
|
|
|
|
|
for ($m = $currentMonth; $m >= 1; $m--) { |
|
|
|
|
|
$start = date("Y-m-01", strtotime("$year-$m")); |
|
|
|
|
|
$end = date("Y-m-t", strtotime("$year-$m")); |
|
|
|
|
|
|
|
|
|
|
|
$count = $course_schedule |
|
|
|
|
|
->where("coach_id = {$this->member_id} OR education_id = {$this->member_id} OR find_in_set('{$this->member_id}', assistant_ids) ") |
|
|
|
|
|
->where('course_date', 'between', [$start, $end]) |
|
|
|
|
|
->count(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$list = $student_courses |
|
|
|
|
|
->where("main_coach_id = {$this->member_id} OR education_id = {$this->member_id} OR find_in_set('{$this->member_id}', assistant_ids) ") |
|
|
|
|
|
->where('start_date', 'between', [$start, $end]) |
|
|
|
|
|
->select(); |
|
|
|
|
|
|
|
|
|
|
|
$yfzxy = count($list); |
|
|
|
|
|
$class_id = []; |
|
|
|
|
|
foreach($list as $k=>$v){ |
|
|
|
|
|
$class_id[] = $class_resources_rel->where(['resource_id' => $v['resource_id']])->value("class_id"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$class_id = array_unique($class_id); |
|
|
|
|
|
|
|
|
|
|
|
$dk_count = $attendance->where(['staff_id' => $this->member_id])->where('attendance_date', 'between', [$start, $end])->count(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($count > 0) { |
|
|
|
|
|
$rate = round($dk_count / $count * 100, 2); // 保留两位小数 |
|
|
|
|
|
} else { |
|
|
|
|
|
$rate = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$results[] = ['month_date' => "$year-$m",'ysks' => $count,'yfzxy' => $yfzxy,'zsbj' => count($class_id),'ydkl' => $rate]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $results; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|