params['source'] ?? 1; $type = $this->params['type'] ?? ''; $keyword = $this->params['keyword'] ?? ''; $channel = $this->params['channel'] ?? ''; $startTime = $this->params['start_time'] ?? ''; $endTime = $this->params['end_time'] ?? ''; $status = $this->params['status'] ?? ''; $where = []; $where[] = ['source','=',$source]; if($keyword){ if(1 == $source){ $ids = Coach::where('sn|name','like','%'.$keyword.'%')->field('id')->select()->toArray(); $ids = array_column($ids,'id'); }else{ $ids = Shop::where('sn|name','like','%'.$keyword.'%')->field('id')->select()->toArray(); $ids = array_column($ids,'id'); } $where[] = ['relation_id','in',$ids]; } if($channel){ //渠道 if(1 == $channel){ $where[] = ['apply_type','=',1]; }else{ $where[] = ['apply_type','=',2]; } } if($type){ $where[] = ['type','=',$type]; } if($startTime){ $where[] = ['create_time','>',$startTime]; } if($endTime){ $where[] = ['create_time','<',$endTime]; } switch ($status){ case 1: $where[] = ['status','=',1]; break; case 2: $where[] = ['status','=',4]; break; case 3: $where[] = ['status','in',[2,5]]; break; case 4: $where[] = ['status','in',[2,3,6]]; break; } return $where; } public function lists(): array { $lists = WithdrawApply::where($this->setWhere()) ->append(['status_desc','apply_type_desc','type_desc']) ->limit($this->limitOffset, $this->limitLength) ->withoutField('delete_time') ->order('id desc') ->select() ->toArray(); $source = $this->params['source'] ?? 1; $relationLists = []; $relationIds = array_column($lists,'relation_id'); if(1 == $source){ $relationLists = Coach::where(['id'=>$relationIds])->column('name,sn,work_photo','id'); }else{ $relationLists = Shop::where(['id'=>$relationIds])->column('name,sn,logo','id'); } foreach ($lists as $key => $value){ if(1 == $source){ $lists[$key]['relation_info'] = [ 'name' => $relationLists[$value['relation_id']]['name'] ?? '', 'sn' => $relationLists[$value['relation_id']]['sn'] ?? '', 'image' => FileService::getFileUrl($relationLists[$value['relation_id']]['work_photo'] ?? '') ]; }else{ $lists[$key]['relation_info'] = [ 'name' => $relationLists[$value['relation_id']]['name'] ?? '', 'sn' => $relationLists[$value['relation_id']]['sn'] ?? '', 'image' => FileService::getFileUrl($relationLists[$value['relation_id']]['logo'] ?? '') ]; } } return $lists; } public function count(): int { return WithdrawApply::where($this->setWhere())->count(); } public function extend() { $whereLists = $this->setWhere(); foreach ($whereLists as $key => $where){ if($where[0] == 'status'){ unset($whereLists[$key]); } } return [ 'all_count' => WithdrawApply::where($whereLists)->count(), 'wait_audit' => WithdrawApply::where($whereLists)->where('status','=',1)->count(), 'withdraw_ing' => WithdrawApply::where($whereLists)->where('status','=',4)->count(), 'withdraw_success' => WithdrawApply::where($whereLists)->where('status','in',[2,5])->count(), 'withdraw_failt' => WithdrawApply::where($whereLists)->where('status','in',[2,3,6])->count(), ]; } }