初始版本
This commit is contained in:
113
server/app/adminapi/lists/coach/CoachApplyLists.php
Executable file
113
server/app/adminapi/lists/coach/CoachApplyLists.php
Executable file
@@ -0,0 +1,113 @@
|
||||
<?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\skill\Skill;
|
||||
|
||||
class CoachApplyLists 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']];
|
||||
}
|
||||
if(isset($this->params['type']) && '' != $this->params['type']){
|
||||
$where[] = ['audit_status','=',$this->params['type']];
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = Coach::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.work_photo,C.deposit,C.work_status,C.create_time,C.money')
|
||||
->append(['skill_desc','region_desc','audit_status_desc'])
|
||||
->where($this->setWhere())
|
||||
->order('C.id desc')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()->toArray();
|
||||
$goodsCountLists = CoachGoodsIndex::group('coach_id')->column('count(goods_id) as count','coach_id');
|
||||
foreach ($lists as $key => $list){
|
||||
$lists[$key]['goods_count'] = $goodsCountLists[$list['id']] ?? 0;
|
||||
}
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 统计人数
|
||||
* @return int
|
||||
* @author cjhao
|
||||
* @date 2024/8/21 17:53
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Coach::alias('C')
|
||||
->join('coach_user UC','UC.id = C.coach_user_id')
|
||||
->where($this->setWhere())
|
||||
->count();
|
||||
}
|
||||
|
||||
|
||||
public function extend()
|
||||
{
|
||||
$whereLists = $this->setWhere();
|
||||
foreach ($whereLists as $key => $where){
|
||||
if(isset($where['audit_status'])){
|
||||
unset($whereLists[$key]);
|
||||
}
|
||||
}
|
||||
$whereLists = array_values($whereLists);
|
||||
$allCount = Coach::alias('C')
|
||||
->join('coach_user UC','UC.id = C.coach_user_id')
|
||||
->where($whereLists)
|
||||
->count();
|
||||
$waitCount = Coach::alias('C')
|
||||
->join('coach_user UC','UC.id = C.coach_user_id')
|
||||
->where($whereLists)
|
||||
->where(['audit_status'=>CoachEnum::AUDIT_STATUS_WAIT])
|
||||
->count();
|
||||
$passCount = Coach::alias('C')
|
||||
->join('coach_user UC','UC.id = C.coach_user_id')
|
||||
->where($whereLists)
|
||||
->where(['audit_status'=>CoachEnum::AUDIT_STATUS_PASS])
|
||||
->count();
|
||||
$refuseCount = Coach::alias('C')
|
||||
->join('coach_user UC','UC.id = C.coach_user_id')
|
||||
->where($whereLists)
|
||||
->where(['audit_status'=>CoachEnum::AUDIT_STATUS_REFUSE])
|
||||
->count();
|
||||
return [
|
||||
'all_count' => $allCount,
|
||||
'wait_count' => $waitCount,
|
||||
'pass_count' => $passCount,
|
||||
'refuse_count' => $refuseCount,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user