103 lines
3.8 KiB
PHP
Executable File
103 lines
3.8 KiB
PHP
Executable File
<?php
|
|
namespace app\adminapi\lists\coach;
|
|
use app\adminapi\lists\BaseAdminDataLists;
|
|
use app\common\enum\coach\CoachEnum;
|
|
use app\common\lists\ListsExtendInterface;
|
|
use app\common\model\coach\Coach;
|
|
use app\common\model\coach\CoachGoodsIndex;
|
|
use app\common\model\coach\CoachUpdate;
|
|
use app\common\model\skill\Skill;
|
|
|
|
class UpdateCoachLists extends BaseAdminDataLists implements ListsExtendInterface
|
|
{
|
|
|
|
public function setWhere()
|
|
{
|
|
$where = [];
|
|
if(isset($this->params['keyword']) && $this->params['keyword']){
|
|
$where[] = ['name|mobile','like',$this->params['keyword']];
|
|
}
|
|
if(isset($this->params['coach_keyword']) && $this->params['coach_keyword']){
|
|
$where[] = ['sn|account','like',$this->params['coach_keyword']];
|
|
}
|
|
if(isset($this->params['work_status']) && '' != $this->params['work_status']){
|
|
$where[] = ['work_status','=',$this->params['work_status']];
|
|
}
|
|
if(isset($this->params['server_status']) && '' != $this->params['server_status']){
|
|
$where[] = ['server_status','=',$this->params['server_status']];
|
|
}
|
|
if(isset($this->params['skill_id']) && '' != $this->params['skill_id']){
|
|
$skillIds = Skill::alias('S')
|
|
->join('coach_skill_index CSI','S.id = CSI.skill_id')
|
|
->column('CSI.coach_id');
|
|
$where[] = ['C.id','in',$skillIds];
|
|
}
|
|
if(isset($this->params['start_time']) && $this->params['start_time']){
|
|
$where[] = ['C.create_time','>=',$this->params['start_time']];
|
|
}
|
|
if(isset($this->params['end_time']) && $this->params['end_time']){
|
|
$where[] = ['C.create_time','<=',$this->params['end_time']];
|
|
}
|
|
return $where;
|
|
}
|
|
|
|
public function lists(): array
|
|
{
|
|
$lists = CoachUpdate::alias('C')
|
|
->join('coach_user UC','UC.id = C.coach_user_id')
|
|
->field('UC.sn,C.mobile,C.audit_status,C.skill_id,C.province_id,C.city_id,C.region_id,C.id,C.name,C.audit_remark,C.work_photo,C.goods_ids,C.create_time')
|
|
->append(['skill_desc','region_desc','audit_status_desc'])
|
|
->order('id desc')
|
|
->where($this->setWhere())
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
->select()->toArray();
|
|
foreach ($lists as $key => $list){
|
|
$lists[$key]['goods_count'] = count($list['goods_ids']);
|
|
}
|
|
return $lists;
|
|
}
|
|
|
|
/**
|
|
* @notes 统计人数
|
|
* @return int
|
|
* @author cjhao
|
|
* @date 2024/8/21 17:53
|
|
*/
|
|
public function count(): int
|
|
{
|
|
return CoachUpdate::alias('C')
|
|
->join('coach_user UC','UC.id = C.coach_user_id')
|
|
->where($this->setWhere())
|
|
->count();
|
|
}
|
|
|
|
|
|
public function extend()
|
|
{
|
|
$allCount = CoachUpdate::alias('C')
|
|
->join('coach_user UC','UC.id = C.coach_user_id')
|
|
->where($this->setWhere())
|
|
->count();
|
|
$waitCount = CoachUpdate::alias('C')
|
|
->join('coach_user UC','UC.id = C.coach_user_id')
|
|
->where($this->setWhere())
|
|
->where(['audit_status'=>CoachEnum::AUDIT_STATUS_WAIT])
|
|
->count();
|
|
$passCount = CoachUpdate::alias('C')
|
|
->join('coach_user UC','UC.id = C.coach_user_id')
|
|
->where($this->setWhere())
|
|
->where(['audit_status'=>CoachEnum::AUDIT_STATUS_PASS])
|
|
->count();
|
|
$refuseCount = CoachUpdate::alias('C')
|
|
->join('coach_user UC','UC.id = C.coach_user_id')
|
|
->where($this->setWhere())
|
|
->where(['audit_status'=>CoachEnum::AUDIT_STATUS_REFUSE])
|
|
->count();
|
|
return [
|
|
'all_count' => $allCount,
|
|
'wait_count' => $waitCount,
|
|
'pass_count' => $passCount,
|
|
'refuse_count' => $refuseCount,
|
|
];
|
|
}
|
|
} |